diff --git a/Client/Client.iml b/Client/Client.iml
index c3ea736..b076a0f 100644
--- a/Client/Client.iml
+++ b/Client/Client.iml
@@ -1,18 +1,20 @@
-
+
-
-
-
-
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Client/pom.xml b/Client/pom.xml
index ff427b8..79ef95c 100644
--- a/Client/pom.xml
+++ b/Client/pom.xml
@@ -10,6 +10,19 @@
4.0.0
Client
+
+
+ junit
+ junit
+ 4.12
+ compile
+
+
+ org.json
+ json
+ 20190722
+
+
\ No newline at end of file
diff --git a/Client/src/main/java/controllers/IdController.java b/Client/src/main/java/controllers/IdController.java
index 15b8253..3495c0e 100644
--- a/Client/src/main/java/controllers/IdController.java
+++ b/Client/src/main/java/controllers/IdController.java
@@ -1,22 +1,50 @@
package controllers;
import java.util.ArrayList;
+import java.util.stream.Collectors;
import models.Id;
+import utils.JsonUtils;
public class IdController {
Id myId;
+ public void setMyId(Id myId) {
+ this.myId = myId;
+ }
+
+ public Id getMyId() {
+ return this.myId;
+ }
+
public ArrayList getIds() {
- return null;
+ ArrayList ids = new ArrayList();
+ String json = TransactionController.MakeURLCall("/ids", "GET", "");
+ for (String id : JsonUtils.jsonSplitter(json)) {
+ ids.add(JsonUtils.stringToId(id));
+ }
+ return ids;
}
public Id postId(Id id) {
- return null;
+ String[] labels = {"name", "github"};
+ String[] values = {id.getName(), id.getGithubId()};
+ String json = JsonUtils.jsonBuilder(labels, values);
+
+ String resp = TransactionController.MakeURLCall("/ids", "POST", json);
+ return JsonUtils.stringToId(resp);
}
public Id putId(Id id) {
- return null;
+ String[] labels = {"userid", "name", "github"};
+ String[] values = {id.getUserId(), id.getName(), id.getGithubId()};
+ String json = JsonUtils.jsonBuilder(labels, values);
+
+ String resp = TransactionController.MakeURLCall("/ids", "PUT", json);
+ return JsonUtils.stringToId(resp);
+ }
+
+ public Id getIdByGit(String githubId) {
+ return getIds().stream().filter(id -> id.getGithubId().equals(githubId)).collect(Collectors.toList()).get(0);
}
-
}
\ No newline at end of file
diff --git a/Client/src/main/java/controllers/MessageController.java b/Client/src/main/java/controllers/MessageController.java
index f9462ed..195fb5e 100644
--- a/Client/src/main/java/controllers/MessageController.java
+++ b/Client/src/main/java/controllers/MessageController.java
@@ -2,30 +2,54 @@
import java.util.ArrayList;
import java.util.HashSet;
+import java.util.stream.Collectors;
import models.Id;
import models.Message;
+import utils.JsonUtils;
public class MessageController {
private HashSet messagesSeen;
// why a HashSet??
-
public ArrayList getMessages() {
- return null;
+ ArrayList messages = new ArrayList();
+ String json = TransactionController.MakeURLCall("/messages", "GET", "");
+ for (String message : JsonUtils.jsonSplitter(json)) {
+ messages.add(JsonUtils.stringToMessage(message));
+ }
+ return messages;
}
- public ArrayList getMessagesForId(Id Id) {
- return null;
+ public ArrayList getMessagesForId(Id id) {
+ return (ArrayList) getMessages().stream()
+ .filter(m -> m.getFromId().equals(id.getGithubId()))
+ .collect(Collectors.toList());
}
public Message getMessageForSequence(String seq) {
- return null;
+ return getMessages().stream()
+ .filter(m -> m.getSequence().equals(seq))
+ .collect(Collectors.toList()).get(0);
}
public ArrayList getMessagesFromFriend(Id myId, Id friendId) {
- return null;
+ return (ArrayList) getMessages().stream()
+ .filter(m -> friendCondition(m, myId, friendId))
+ .collect(Collectors.toList());
+ }
+
+ public Message postMessage(String fromid, String toid, String message) {
+ String[] labels = {"sequence", "timestamp", "fromid", "toid", "message"};
+ String[] values = {"-", null, fromid, toid, message};
+ String json = JsonUtils.jsonBuilder(labels, values);
+
+ String mainurl = String.format("/ids/%s/messages", fromid);
+
+ String resp = TransactionController.MakeURLCall(mainurl,"POST", json);
+ return JsonUtils.stringToMessage(resp);
}
- public Message postMessage(Id myId, Id toId, Message msg) {
- return null;
+ public static Boolean friendCondition(Message m, Id myId, Id friendId) {
+ return ((m.getFromId().equals(myId.getGithubId())) && (m.getToId().equals(friendId.getGithubId()))); //||
+ //((m.getFromId().equals(friendId.getGithubId())) && (m.getToId().equals(myId.getGithubId())));
}
}
\ No newline at end of file
diff --git a/Client/src/main/java/controllers/TransactionController.java b/Client/src/main/java/controllers/TransactionController.java
index acacc62..f1a7208 100644
--- a/Client/src/main/java/controllers/TransactionController.java
+++ b/Client/src/main/java/controllers/TransactionController.java
@@ -1,7 +1,78 @@
package controllers;
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+import java.net.HttpURLConnection;
+import java.net.URL;
+
public class TransactionController {
- private String rootURL = "http://zipcode.rocks:8085";
+ private static final String rootURL = "http://zipcode.rocks:8085";
+
+ public TransactionController() {
+
+ }
+
+ public static String MakeURLCall(String mainurl, String method, String jpayload) {
+ String response = "";
+ try {
+ HttpURLConnection conn = initConnection(mainurl, method, jpayload);
+ response = readServerResponse(conn);
+ conn.disconnect();
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ return response;
+ }
+
+ public static HttpURLConnection writeJsonToConn(HttpURLConnection conn, String jpayload) {
+ conn.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
+ conn.setRequestProperty("Accept", "application/json");
+ try {
+ OutputStreamWriter os = new OutputStreamWriter(conn.getOutputStream());
+ os.write(jpayload);
+ os.flush();
+ os.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return conn;
+ }
+
+ public static String readServerResponse(HttpURLConnection conn) {
+ StringBuilder result = new StringBuilder();
+ try {
+ BufferedReader br = new BufferedReader(new InputStreamReader(
+ (conn.getInputStream())));
+
+ String output;
+ while ((output = br.readLine()) != null) {
+ result.append(output);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return result.toString();
+ }
+
+ public static HttpURLConnection initConnection(String mainurl, String method, String jpayload) {
+ try {
+ URL url = new URL(rootURL + mainurl);
+ HttpURLConnection conn = (HttpURLConnection) url.openConnection();
+
+ conn.setDoOutput(true);
+ conn.setRequestMethod(method);
+
+ if (method.equals("POST") || method.equals("PUT")) {
+ conn = writeJsonToConn(conn, jpayload);
+ }
+
+ return conn;
- public TransactionController() {}
+ } catch(Exception e) {
+ e.printStackTrace();
+ return null;
+ }
+ }
}
diff --git a/Client/src/main/java/models/Id.java b/Client/src/main/java/models/Id.java
index 71f2ebf..87d496e 100644
--- a/Client/src/main/java/models/Id.java
+++ b/Client/src/main/java/models/Id.java
@@ -1,10 +1,57 @@
package models;
-/*
+import com.fasterxml.jackson.databind.ObjectMapper;
+import utils.JsonUtils;
+
+/*
* POJO for an Id object
*/
public class Id {
+ String name;
+ String githubid;
+ String userid;
- public Id (String name, String githubId) {}
+ public Id (String name, String githubId) {
+ this.name = name;
+ this.githubid = githubId;
+ this.userid = null;
+ }
+ public Id (String name, String githubId, String userId) {
+ this.name = name;
+ this.githubid = githubId;
+ this.userid = userId;
+ }
+
+ public Id (Id id) {
+ this(id.getName(), id.getGithubId(), id.getUserId());
+ }
+
+ public Id (String json) {
+ this(JsonUtils.stringToId(json));
+ }
+
+ public String getName() {
+ return this.name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getGithubId() {
+ return this.githubid;
+ }
+
+ public void setGithubId(String githubId) {
+ this.githubid = githubId;
+ }
+
+ public String getUserId() {
+ return this.userid;
+ }
+
+ public void setUserId(String userId) {
+ this.userid = userId;
+ }
}
\ No newline at end of file
diff --git a/Client/src/main/java/models/Message.java b/Client/src/main/java/models/Message.java
index da313ae..94b4421 100644
--- a/Client/src/main/java/models/Message.java
+++ b/Client/src/main/java/models/Message.java
@@ -1,10 +1,75 @@
package models;
-/*
+import utils.JsonUtils;
+
+/*
* POJO for an Message object
*/
public class Message {
+ String message;
+ String fromId;
+ String toId;
+ String sequence;
+ String timestamp;
+
+ public Message (String message, String fromId, String toId, String sequence, String timestamp) {
+ this.message = message;
+ this.fromId = fromId;
+ this.toId = toId;
+ this.sequence = sequence;
+ this.timestamp = timestamp;
+ }
+
+ public Message (String message, String fromId, String toId) {
+ this(message, fromId, toId, "-", null);
+ }
+
+ public Message(Message message) {
+ this(message.getMessage(), message.getFromId(), message.getToId(), message.getSequence(), message.getTimestamp());
+ }
+
+ public Message (String json) {
+ this(JsonUtils.stringToMessage(json));
+ }
+
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public String getFromId() {
+ return fromId;
+ }
+
+ public void setFromId(String fromId) {
+ this.fromId = fromId;
+ }
+
+ public String getToId() {
+ return toId;
+ }
+
+ public void setToId(String toId) {
+ this.toId = toId;
+ }
+
+ public String getSequence() {
+ return sequence;
+ }
+
+ public void setSequence(String sequence) {
+ this.sequence = sequence;
+ }
- public Message (String message, String fromId, String toId) {}
+ public String getTimestamp() {
+ return timestamp;
+ }
+ public void setTimestamp(String timestamp) {
+ this.timestamp = timestamp;
+ }
}
\ No newline at end of file
diff --git a/Client/src/main/java/utils/JsonUtils.java b/Client/src/main/java/utils/JsonUtils.java
new file mode 100644
index 0000000..f20a2dd
--- /dev/null
+++ b/Client/src/main/java/utils/JsonUtils.java
@@ -0,0 +1,174 @@
+package utils;
+
+import models.Id;
+import models.Message;
+import org.json.JSONObject;
+import views.IdTextView;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.regex.Pattern;
+
+public class JsonUtils {
+ public static ArrayList buildBadChars() {
+ Character[] bois = {'{','}',',',':','\"'};
+ ArrayList list = new ArrayList();
+ for (Character c : bois) {
+ list.add(c);
+ }
+ return list;
+ }
+
+ public static ArrayList jsonStringParser(String json) {
+ ArrayList list = new ArrayList();
+ ArrayList bois = buildBadChars();
+ int lastI = 0;
+ boolean inTheWord = false;
+
+ for (int i = 0; i < json.length(); i++) {
+ if (!bois.contains(json.charAt(i))) inTheWord = true;
+ else {
+ if (inTheWord && Math.abs(lastI-i) > 1)
+ list.add(json.substring(lastI+1,i));
+ lastI = i;
+ inTheWord = false;
+ }
+ }
+ return list;
+ }
+
+ public static ArrayList jsonSplitter(String json) {
+ ArrayList split = new ArrayList();
+
+ if (json.charAt(0) == '[' && json.charAt(json.length()-1) == ']')
+ json = json.substring(1, json.length() - 1);
+
+ int countL = 0;
+ int countR = 0;
+ int lastI = 0;
+
+ for (int i = 0; i < json.length(); i++) {
+ Character chip = json.charAt(i);
+
+ if (chip.equals('{')) countL++;
+ else if (chip.equals('}')) countR++;
+
+ if (countL == countR && countL > 0 && Math.abs(lastI-i) > 1) {
+ split.add(json.substring(lastI, i+1));
+ lastI = i+2;
+ if (lastI >= json.length()-1) break;
+ }
+ }
+ return split;
+ }
+
+// public static String jsonToFormattedString(String json) {
+// StringBuilder out = new StringBuilder();
+// JSONObject jsonO = new JSONObject(json);
+//
+// for (String key : jsonO.keySet()) {
+// String tabs = (key.length() > 7) ? "\t" : "\t\t";
+// out.append("\n\t" + key + tabs + jsonO.get(key));
+// }
+//
+// return out.toString();
+// }
+
+// public static String fixJSON(String json) {
+// if (json.charAt(0) != '{')
+// json = '{' + json;
+// if (json.charAt(json.length()-1) != '}')
+// json = json + '}';
+// return json;
+// }
+
+ public static String buildMessage(String commandLine) {
+ return commandLine.split("'")[1];
+ }
+
+ public static String buildMessage(List list) {
+ StringBuilder sb = new StringBuilder();
+ Boolean inTheMix = false;
+ for (String item : list) {
+ if (item.charAt(0) == '\'') {
+ sb.append(item);
+ inTheMix = true;
+ }
+ else if (inTheMix) {
+ sb.append(" " + item);
+ }
+ else if (item.charAt(item.length()-1) == '\'') {
+ inTheMix = false;
+ sb.append(item);
+ break;
+ }
+ }
+ String out = sb.toString();
+ return out.substring(1, out.length()-1);
+ }
+
+ public static String getId(ArrayList ids, String github) {
+ String userId = "";
+
+ for (Id id : ids) {
+ if (id.getGithubId().equals(github)) {
+ userId = id.getUserId();
+ break;
+ }
+ }
+ return userId;
+ }
+
+// public static String filterByGithub(String input, String github) {
+// StringBuilder filtered = new StringBuilder();
+// String[] out = jsonSplitter(input).toArray(new String[0]);
+//// ArrayList messages = jsonSplitter(input);
+//// Arrays.stream(out).filter()
+// for (int i = 0; i < out.length; i++) {
+// JSONObject json = new JSONObject(out[i]);
+// if (json.get("fromid").equals(github)) {
+// filtered.append(out[i]);
+// if (i != out.length-1) filtered.append(",");
+// }
+// }
+//
+// return filtered.toString();
+// }
+
+
+
+ public static Id stringToId(String json) {
+ try {
+ JSONObject jsonO = new JSONObject(json);
+ return new Id(jsonO.get("name").toString(), jsonO.get("github").toString(), jsonO.get("userid").toString());
+ } catch (Exception e) {
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+ public static Message stringToMessage(String json) {
+ try {
+ JSONObject jsonO = new JSONObject(json);
+ return new Message(jsonO.get("message").toString(), jsonO.get("fromid").toString(), jsonO.get("toid").toString(), jsonO.get("sequence").toString(), jsonO.get("timestamp").toString());
+ } catch (Exception e) {
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+ public static String jsonBuilder(String[] labels, String[] values) {
+ StringBuilder json = new StringBuilder().append("{");
+
+ for (int i = 0; i < labels.length; i++) {
+ if (values[i] == null) json.append(String.format("\"%s\": %s", labels[i], values[i]));
+ else json.append(String.format("\"%s\": \"%s\"", labels[i], values[i]));
+
+ if (i != labels.length-1) json.append(",");
+ }
+ json.append("}");
+// String g = "{\"name\": \"Wes\",\"github\":\"wesjones15\"}";
+ return json.toString();
+ }
+}
diff --git a/Client/src/main/java/views/IdTextView.java b/Client/src/main/java/views/IdTextView.java
index e61c754..a3de18e 100644
--- a/Client/src/main/java/views/IdTextView.java
+++ b/Client/src/main/java/views/IdTextView.java
@@ -3,11 +3,17 @@
import models.Id;
public class IdTextView {
+ Id id;
public IdTextView(Id idToDisplay) {
-
+ this.id = idToDisplay;
}
- @Override public String toString() {
- return null;
+
+ @Override
+ public String toString() {
+ return String.format("User:\n" +
+ "\tname:\t\t%s\n" +
+ "\tgithub:\t\t%s\n" +
+ "\tuserid:\t\t%s\n", id.getName(), id.getGithubId(), id.getUserId());
}
}
\ No newline at end of file
diff --git a/Client/src/main/java/views/MessageTextView.java b/Client/src/main/java/views/MessageTextView.java
index fe96921..a822d57 100644
--- a/Client/src/main/java/views/MessageTextView.java
+++ b/Client/src/main/java/views/MessageTextView.java
@@ -3,11 +3,22 @@
import models.Message;
public class MessageTextView {
-
+ Message message;
public MessageTextView(Message msgToDisplay) {
-
+ this.message = msgToDisplay;
}
- @Override public String toString() {
- return null;
+
+ @Override
+ public String toString() {
+ StringBuilder out = new StringBuilder();
+ out.append(String.format("Message:\n" +
+ "\tfromid:\t\t%s\n" +
+ "\ttoid:\t\t%s\n" +
+ "\tmessage:\t%s\n" +
+ "\ttimestamp:\t%s\n" +
+ "\tsequence:\t%s\n",
+ message.getFromId(), message.getToId(), message.getMessage(),
+ message.getTimestamp(), message.getSequence()));
+ return out.toString();
}
}
\ No newline at end of file
diff --git a/Client/src/main/java/views/SimpleShell.java b/Client/src/main/java/views/SimpleShell.java
index 3865bb2..6517bc0 100644
--- a/Client/src/main/java/views/SimpleShell.java
+++ b/Client/src/main/java/views/SimpleShell.java
@@ -7,25 +7,37 @@
import java.util.ArrayList;
import java.util.List;
+
import controllers.IdController;
import controllers.MessageController;
+import models.Id;
+import models.Message;
import youareell.YouAreEll;
+//import utils.JsonUtils;
// Simple Shell is a Console view for youareell.YouAreEll.
public class SimpleShell {
+ public static void decentPrintId(ArrayList ids) {
+ for (Id id : ids) {
+ IdTextView itv = new IdTextView(id);
+ System.out.println(itv.toString());
+ }
+ }
- public static void prettyPrint(String output) {
- // yep, make an effort to format things nicely, eh?
- System.out.println(output);
+ public static void decentPrintMsg(ArrayList msgs) {
+ for (Message msg : msgs) {
+ MessageTextView mtv = new MessageTextView(msg);
+ System.out.println(mtv.toString());
+ }
}
+
public static void main(String[] args) throws java.io.IOException {
YouAreEll webber = new YouAreEll(new MessageController(), new IdController());
String commandLine;
- BufferedReader console = new BufferedReader
- (new InputStreamReader(System.in));
+ BufferedReader console = new BufferedReader(new InputStreamReader(System.in));
ProcessBuilder pb = new ProcessBuilder();
List history = new ArrayList();
@@ -50,11 +62,11 @@ public static void main(String[] args) throws java.io.IOException {
//loop through to see if parsing worked
for (int i = 0; i < commands.length; i++) {
- //System.out.println(commands[i]); //***check to see if parsing/split worked***
+ System.out.println(commands[i]); //***check to see if parsing/split worked***
list.add(commands[i]);
}
- System.out.print(list); //***check to see if list was added correctly***
+ System.out.println(list); //***check to see if list was added correctly***
history.addAll(list);
try {
//display history of shell with index
@@ -68,18 +80,35 @@ public static void main(String[] args) throws java.io.IOException {
// ids
if (list.contains("ids")) {
- String results = webber.get_ids();
- SimpleShell.prettyPrint(results);
+ ArrayList ids = webber.interpretIds(list);
+ decentPrintId(ids);
continue;
}
// messages
if (list.contains("messages")) {
- String results = webber.get_messages();
- SimpleShell.prettyPrint(results);
+ ArrayList messages = webber.interpretMessages(list);
+ decentPrintMsg(messages);
continue;
}
- // you need to add a bunch more.
+
+ if (list.contains("send")) {
+ ArrayList messages = webber.interpretSendMessage(list, commandLine);
+ decentPrintMsg(messages);
+ continue;
+ }
+
+ if (list.size() == 1 && list.get(0).equals("help")) {
+ System.out.println("\nValid Commands\n" +
+ "\tids -\tlist all user ids\n" +
+ "\tids -\tPOST new user id or update existing\n" +
+ "\tmessages -\tlist all messages on server\n" +
+ "\tmessages -\tview messages involving \n" +
+ "\tsend to -\tsend message to x from y\n" +
+ "\tsend -\tsend message to specific user\n");
+ continue;
+ }
+ // you need to add a bunch more.
//!! command returns the last command in history
if (list.get(list.size() - 1).equals("!!")) {
@@ -107,8 +136,6 @@ else if (list.get(list.size() - 1).charAt(0) == '!') {
while ((line = br.readLine()) != null)
System.out.println(line);
br.close();
-
-
}
//catch ioexception, output appropriate message, resume waiting for input
@@ -123,10 +150,6 @@ else if (list.get(list.size() - 1).charAt(0) == '!') {
* 4. obtain the output stream
* 5. output the contents returned by the command
*/
-
}
-
-
}
-
}
\ No newline at end of file
diff --git a/Client/src/main/java/youareell/YouAreEll.java b/Client/src/main/java/youareell/YouAreEll.java
index acfe78a..b94abdd 100644
--- a/Client/src/main/java/youareell/YouAreEll.java
+++ b/Client/src/main/java/youareell/YouAreEll.java
@@ -1,6 +1,18 @@
package youareell;
+import com.fasterxml.jackson.databind.ObjectMapper;
import controllers.*;
+import models.Id;
+import models.Message;
+import utils.JsonUtils;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.util.*;
public class YouAreEll {
@@ -20,15 +32,55 @@ public static void main(String[] args) {
System.out.println(urlhandler.MakeURLCall("/messages", "GET", ""));
}
- public String get_ids() {
- return MakeURLCall("/ids", "GET", "");
+ public ArrayList interpretIds(List list) {
+ ArrayList idsList = idCtrl.getIds();
+
+ if (list.get(0).equals("ids") && list.size() == 3) {
+ String userId = JsonUtils.getId(idsList, list.get(2));
+ idsList = new ArrayList();
+
+ if (!userId.equals(""))
+ idsList.add(idCtrl.putId(new Id(list.get(1), list.get(2), userId)));
+ else
+ idsList.add(idCtrl.postId(new Id(list.get(1), list.get(2))));
+ }
+ return idsList;
+ }
+
+ public ArrayList interpretMessages(List list) {
+ ArrayList messages = msgCtrl.getMessages();
+
+ if (list.size() == 3 && list.get(1).equals("seq")){
+ messages = new ArrayList<>();
+ messages.add(msgCtrl.getMessageForSequence(list.get(2)));
+ }
+ else if (list.size() == 2) {
+ Id myId = idCtrl.getIdByGit(list.get(1));
+ messages = msgCtrl.getMessagesForId(myId);
+ }
+ else if (list.size() == 3) {
+ Id myId = idCtrl.getIdByGit(list.get(1));
+ Id friendId = idCtrl.getIdByGit(list.get(2));
+ messages = msgCtrl.getMessagesFromFriend(myId, friendId);
+ }
+
+ return messages;
}
- public String get_messages() {
- return MakeURLCall("/messages", "GET", "");
+ public ArrayList interpretSendMessage(List list, String commandLine) {
+ ArrayList messages = new ArrayList<>();
+ String message = JsonUtils.buildMessage(commandLine);
+
+ if (commandLine.matches("send [A-Za-z0-9]+ '[A-Za-z0-9,. ]+'"))
+ messages.add(msgCtrl.postMessage(list.get(1), "", message));
+
+ else if (commandLine.matches("send [A-Za-z0-9]+ '[A-Za-z0-9., ]+' to [A-Za-z0-9]+"))
+ messages.add(msgCtrl.postMessage(list.get(1), list.get(list.size()-1), message));
+
+ return messages;
}
public String MakeURLCall(String mainurl, String method, String jpayload) {
- return "nada";
+ return TransactionController.MakeURLCall(mainurl, method, jpayload);
}
}
diff --git a/Client/src/test/java/views/testSimpleShell.java b/Client/src/test/java/views/testSimpleShell.java
new file mode 100644
index 0000000..9861adf
--- /dev/null
+++ b/Client/src/test/java/views/testSimpleShell.java
@@ -0,0 +1,39 @@
+package views;
+
+import org.junit.Test;
+import utils.JsonUtils;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+
+public class testSimpleShell {
+ @Test
+ public void testJsonSplitter() {
+ String json = "{\"name\":\"wes\",\"id\":\"345\",\"color\":\"blue\"}," +
+ "{\"name\":\"kai\",\"id\":\"342\",\"color\":\"glellow\"}," +
+ "{\"name\":\"ryan\",\"id\":\"241\",\"color\":\"blorange\"}," +
+ "{\"name\":\"kendra\",\"id\":\"13\",\"color\":\"grurple\"}," +
+ "{\"name\":\"val\",\"id\":\"133\",\"color\":\"tangergreen\"}";
+ ArrayList list = JsonUtils.jsonSplitter(json);
+ for (String item : list) {
+ System.out.println(item);
+ }
+ }
+
+ @Test
+ public void testJsonStringParser() {
+ String json = "{\"name\":\"wes\",\"id\":\"345\",\"color\":\"blue\"}";
+ ArrayList list = JsonUtils.jsonStringParser(json);
+ for (String item : list) {
+ System.out.println(item);
+ }
+ }
+
+ @Test
+ public void testBuildMessage() {
+ String commandLine = "send wesjones15 'Hello there bud, abcde' to kaiiscool";
+ String a1 = JsonUtils.buildMessage(Arrays.asList(commandLine.split(" ")));
+ String a2 = JsonUtils.buildMessage(commandLine);
+ System.out.println(a1 + "\n\n" + a2);
+ }
+}
diff --git a/Client/src/test/java/youareell/testYouAreEll.java b/Client/src/test/java/youareell/testYouAreEll.java
new file mode 100644
index 0000000..dbc80f7
--- /dev/null
+++ b/Client/src/test/java/youareell/testYouAreEll.java
@@ -0,0 +1,21 @@
+package youareell;
+
+import org.junit.Test;
+import utils.JsonUtils;
+
+public class testYouAreEll {
+ @Test
+ public void testJsonBuilder() {
+// YouAreEll url = new YouAreEll(null,null);
+ String[] labels = {"name","github","favorite singer"};
+ String[] values = {"wes", "wesjones15", "blink182"};
+ String json = JsonUtils.jsonBuilder(labels, values);
+ System.out.println(json);
+ }
+
+ @Test
+ public void testBuildMessage() {
+ YouAreEll url = new YouAreEll(null, null);
+
+ }
+}
diff --git a/YouAreEll.iml b/YouAreEll.iml
index 5f1ec7b..084de76 100644
--- a/YouAreEll.iml
+++ b/YouAreEll.iml
@@ -8,8 +8,8 @@
-
-
-
+
+
+
\ No newline at end of file