use of javax.json.JsonArray in project visualee by Thomas-S-B.
the class GraphCreatorTest method testBuildJSONNodes.
@Test
public void testBuildJSONNodes() {
JavaSourceContainer.getInstance().clear();
int count = 10;
String namePrefix = "Testclass ";
for (int i = 0; i < count; i++) {
String name = namePrefix + i;
JavaSource javaSource = JavaSourceFactory.getInstance().newJavaSource(name);
JavaSourceContainer.getInstance().add(javaSource);
}
JsonArray nodes = GraphCreator.buildJSONNodes(null).build();
assertEquals(count, nodes.size());
}
use of javax.json.JsonArray in project visualee by Thomas-S-B.
the class GraphCreatorTest method testBuildJSONLinks.
@Test
public void testBuildJSONLinks() {
TestDataProvider.createSampleDependencies();
JsonArray links = GraphCreator.buildJSONLinks(null).build();
assertEquals(12, links.size());
DependencyFilter filter = new DependencyFilter().addType(DependencyType.PRODUCES).addType(DependencyType.INSTANCE).setDirectlyConnected(true);
links = GraphCreator.buildJSONLinks(filter).build();
assertEquals(8, links.size());
}
use of javax.json.JsonArray in project javaee7-samples by javaee-samples.
the class MyResourceTest method test5ClientSideNegotiation.
@Test
public void test5ClientSideNegotiation() {
String json = target.request().accept(MediaType.APPLICATION_JSON).get(String.class);
JsonReader reader = Json.createReader(new StringReader(json));
JsonArray jsonArray = reader.readArray();
assertEquals(1, jsonArray.getJsonObject(0).getInt("age"));
assertEquals("Penny", jsonArray.getJsonObject(0).getString("name"));
assertEquals(2, jsonArray.getJsonObject(1).getInt("age"));
assertEquals("Leonard", jsonArray.getJsonObject(1).getString("name"));
assertEquals(3, jsonArray.getJsonObject(2).getInt("age"));
assertEquals("Sheldon", jsonArray.getJsonObject(2).getString("name"));
}
use of javax.json.JsonArray in project javaee7-samples by javaee-samples.
the class MyResourceTest method testEchoArray.
@Test
public void testEchoArray() {
JsonArray jsonArray = Json.createArrayBuilder().add(Json.createObjectBuilder().add("apple", "red")).add(Json.createObjectBuilder().add("banana", "yellow")).build();
JsonArray json = targetArray.request().post(Entity.entity(jsonArray, MediaType.APPLICATION_JSON), JsonArray.class);
assertNotNull(json);
assertEquals(2, json.size());
assertTrue(json.getJsonObject(0).containsKey("apple"));
assertEquals("red", json.getJsonObject(0).getString("apple"));
assertTrue(json.getJsonObject(1).containsKey("banana"));
assertEquals("yellow", json.getJsonObject(1).getString("banana"));
}
use of javax.json.JsonArray in project jersey by jersey.
the class JsonProcessingTest method testJsonArray.
@Test
public void testJsonArray() throws Exception {
final Response response = target("jsonArray").request(MediaType.APPLICATION_JSON).post(Entity.json(JSON_ARRAY));
assertEquals(JSON_ARRAY, response.readEntity(JsonArray.class));
}
Aggregations