Search in sources :

Example 51 with JsonValue

use of com.eclipsesource.json.JsonValue in project abstools by abstools.

the class ErlangModelApiTests method test_floatList.

@Test
public void test_floatList() throws IOException {
    JsonObject parameter = Json.object().add("p", Json.array(1.1, 2.2, 3.3));
    String response = sendPostRequest("/call/test/test_list_float", parameter.toString(), 200);
    JsonValue result = getValueFromResponse(response);
    JsonArray array = result.asArray();
    Assert.assertEquals(1.1, array.get(0).asFloat(), 0.001);
    Assert.assertEquals(2.2, array.get(1).asFloat(), 0.001);
    Assert.assertEquals(3.3, array.get(2).asFloat(), 0.001);
}
Also used : JsonArray(com.eclipsesource.json.JsonArray) JsonValue(com.eclipsesource.json.JsonValue) JsonObject(com.eclipsesource.json.JsonObject) Test(org.junit.Test)

Example 52 with JsonValue

use of com.eclipsesource.json.JsonValue in project abstools by abstools.

the class ErlangModelApiTests method test_intList.

@Test
public void test_intList() throws IOException {
    JsonObject parameter = Json.object().add("p", Json.array(1, 2, 3));
    String response = sendPostRequest("/call/test/test_list_int", parameter.toString(), 200);
    JsonValue result = getValueFromResponse(response);
    JsonArray array = result.asArray();
    Assert.assertEquals(1, array.get(0).asInt());
    Assert.assertEquals(2, array.get(1).asInt());
    Assert.assertEquals(3, array.get(2).asInt());
}
Also used : JsonArray(com.eclipsesource.json.JsonArray) JsonValue(com.eclipsesource.json.JsonValue) JsonObject(com.eclipsesource.json.JsonObject) Test(org.junit.Test)

Example 53 with JsonValue

use of com.eclipsesource.json.JsonValue in project abstools by abstools.

the class ErlangModelApiTests method test_boolByJson.

@Test
public void test_boolByJson() throws IOException {
    JsonObject parameter = Json.object().add("p", true);
    String response = sendPostRequest("/call/test/test_bool", parameter, 200);
    JsonValue result = getValueFromResponse(response);
    boolean value = result.asBoolean();
    Assert.assertTrue(value);
}
Also used : JsonValue(com.eclipsesource.json.JsonValue) JsonObject(com.eclipsesource.json.JsonObject) Test(org.junit.Test)

Example 54 with JsonValue

use of com.eclipsesource.json.JsonValue in project abstools by abstools.

the class ErlangModelApiTests method test_boolList.

@Test
public void test_boolList() throws IOException {
    JsonObject parameter = Json.object().add("p", Json.array(true, false));
    String response = sendPostRequest("/call/test/test_list_bool", parameter.toString(), 200);
    JsonValue result = getValueFromResponse(response);
    JsonArray array = result.asArray();
    Assert.assertTrue(array.get(0).asBoolean());
    Assert.assertFalse(array.get(1).asBoolean());
}
Also used : JsonArray(com.eclipsesource.json.JsonArray) JsonValue(com.eclipsesource.json.JsonValue) JsonObject(com.eclipsesource.json.JsonObject) Test(org.junit.Test)

Example 55 with JsonValue

use of com.eclipsesource.json.JsonValue in project abstools by abstools.

the class ErlangModelApiTests method test_boolMap.

@Test
public void test_boolMap() throws IOException {
    JsonObject parameter = Json.object().add("p", Json.object().add("a", true).add("b", false).add("c", true));
    String response = sendPostRequest("/call/test/test_map_bool", parameter.toString(), 200);
    JsonValue result = getValueFromResponse(response);
    JsonObject object = result.asObject();
    Assert.assertTrue(object.get("a").asBoolean());
    Assert.assertFalse(object.get("b").asBoolean());
    Assert.assertTrue(object.get("c").asBoolean());
}
Also used : JsonValue(com.eclipsesource.json.JsonValue) JsonObject(com.eclipsesource.json.JsonObject) Test(org.junit.Test)

Aggregations

JsonValue (com.eclipsesource.json.JsonValue)147 JsonObject (com.eclipsesource.json.JsonObject)74 JsonArray (com.eclipsesource.json.JsonArray)43 Test (org.junit.Test)38 ArrayList (java.util.ArrayList)26 URL (java.net.URL)21 HashMap (java.util.HashMap)10 IOException (java.io.IOException)9 Member (com.eclipsesource.json.JsonObject.Member)6 ParseException (com.eclipsesource.json.ParseException)4 File (java.io.File)4 MalformedURLException (java.net.MalformedURLException)4 InetSocketAddress (java.net.InetSocketAddress)3 Collection (java.util.Collection)3 Map (java.util.Map)3 WebTarget (javax.ws.rs.client.WebTarget)3 Matchers.containsString (org.hamcrest.Matchers.containsString)3 JsonUtil.getString (com.hazelcast.util.JsonUtil.getString)2 WalletCallException (com.vaklinov.zcashui.ZCashClientCaller.WalletCallException)2 FileInputStream (java.io.FileInputStream)2