List of usage examples for com.fasterxml.jackson.databind JsonNode equals
public abstract boolean equals(Object paramObject);
From source file:org.opendaylight.sfc.sbrest.provider.task.SbRestSfTaskTest.java
@Test public void testSbRestSfTask1() throws IOException { SbRestSfTask sbRestSfTask = new SbRestSfTask(RestOperation.DELETE, this.buildServiceFunction(), executorService);/* ww w . j av a 2s . c o m*/ JsonNode jsonObject = mapper.readTree(sbRestSfTask.jsonObject); assertTrue("Must be true", jsonObject.equals(buildServiceFunctionObjectNode1())); assertTrue("Must be true", sbRestSfTask.restUriList.get(0).contains(REST_URI)); }
From source file:org.opendaylight.sfc.sbrest.provider.task.SbRestSfTaskTest.java
@Test public void testSbRestSfTaskEmpty() throws IOException { SbRestSfTask sbRestSfTask = new SbRestSfTask(RestOperation.PUT, new ServiceFunctionBuilder().build(), executorService);//from w w w. j ava 2 s . c om JsonNode jsonObject = mapper.readTree(sbRestSfTask.jsonObject); assertTrue("Must be true", jsonObject.equals(this.buildServiceFunctionTopNode())); assertNull("Must be null", sbRestSfTask.restUriList); }
From source file:com.ikanow.aleph2.graph.titan.utils.TitanGraphBuildingUtils.java
/** Previously our edges were double-grouped by in and out keys - now we can group them by the (in/out) pair * @param key/*from w w w. j a va 2 s . c o m*/ * @param vertex_winner * @param mutable_edges * @return */ protected static Map<ObjectNode, List<ObjectNode>> finalEdgeGrouping(final ObjectNode key, final Vertex vertex_winner, final List<ObjectNode> mutable_edges) { final Map<ObjectNode, List<ObjectNode>> grouped_edges = mutable_edges.stream().filter(mutable_edge -> { final JsonNode in_key = mutable_edge.get(GraphAnnotationBean.inV); final JsonNode out_key = mutable_edge.get(GraphAnnotationBean.outV); final JsonNode matching_key = in_key.equals(key) // (has to be one of the 2 by construction) ? in_key : out_key; final JsonNode off_key = !in_key.equals(key) // (doesn't match this key) ? in_key : (!out_key.equals(key) ? out_key : null); // (a vertex can have an edge be to itself) if (null == off_key) { mutable_edge.put(GraphAnnotationBean.inV, (Long) vertex_winner.id()); mutable_edge.put(GraphAnnotationBean.outV, (Long) vertex_winner.id()); mutable_edge.set(GraphAnnotationBean.inVLabel, key); // (internal, see below) mutable_edge.set(GraphAnnotationBean.outVLabel, key); // (internal, see below) } else { mutable_edge.put((matching_key == in_key) ? GraphAnnotationBean.inV : GraphAnnotationBean.outV, (Long) vertex_winner.id()); mutable_edge.set( (matching_key == in_key) ? GraphAnnotationBean.inVLabel : GraphAnnotationBean.outVLabel, key); // (internal, see below) } return ((null == off_key) || off_key.isIntegralNumber()); }).collect(Collectors.groupingBy((ObjectNode mutable_edge) -> { // These edges are "promoted" - can call the user merge on them final ObjectNode edge_key = Optional.of(_mapper.createObjectNode()).map( o -> (ObjectNode) o.set(GraphAnnotationBean.label, mutable_edge.get(GraphAnnotationBean.label))) .map(o -> Optional.ofNullable(mutable_edge.remove(GraphAnnotationBean.inVLabel)) .map(k -> (ObjectNode) o.set(GraphAnnotationBean.inV, k)).orElse(o)) .map(o -> Optional.ofNullable(mutable_edge.remove(GraphAnnotationBean.outVLabel)) .map(k -> (ObjectNode) o.set(GraphAnnotationBean.outV, k)).orElse(o)) .get(); return edge_key; })); return grouped_edges; }
From source file:org.opendaylight.sfc.sbrest.provider.task.SbRestSffTaskTest.java
@Test public void testSbRestSffTask() throws IOException { SbRestSffTask sbRestSffTask = new SbRestSffTask(RestOperation.PUT, this.buildServiceFunctionForwarder(), executorService);//from w w w. ja v a 2s . co m JsonNode jsonObject = mapper.readTree(sbRestSffTask.jsonObject); assertTrue("Must be true", jsonObject.equals(this.buildServiceFunctionForwarderObjectNode())); assertTrue("Must be true", sbRestSffTask.restUriList.get(0).contains(REST_URI)); }
From source file:org.opendaylight.sfc.sbrest.provider.task.SbRestSffTaskTest.java
@Test public void testSbRestSffTask1() throws IOException { SbRestSffTask sbRestSffTask = new SbRestSffTask(RestOperation.DELETE, this.buildServiceFunctionForwarder(), executorService);/* w w w .ja v a2 s.c o m*/ JsonNode jsonObject = mapper.readTree(sbRestSffTask.jsonObject); assertTrue("Must be true", jsonObject.equals(this.buildServiceFunctionForwarderObjectNode1())); assertTrue("Must be true", sbRestSffTask.restUriList.get(0).contains(REST_URI)); }
From source file:org.opendaylight.sfc.sbrest.provider.task.SbRestSffTaskTest.java
@Test public void testSbRestSffTaskEmpty() throws IOException { SbRestSffTask sbRestSffTask = new SbRestSffTask(RestOperation.PUT, new ServiceFunctionForwarderBuilder().build(), executorService); JsonNode jsonObject = mapper.readTree(sbRestSffTask.jsonObject); assertTrue("Must be true", jsonObject.equals(this.buildServiceFunctionForwarderTopNode())); assertNull("Must be null", sbRestSffTask.restUriList); }
From source file:de.bytefish.elasticutils.elasticsearch2.mapping.LocalWeatherDataMapperTest.java
@Test public void valid_json_mapping_generated_when_calling_get_mapping() throws Exception { // Create the Mapper: LocalWeatherDataMapper mapper = new LocalWeatherDataMapper(); // Get the Mapping: XContentBuilder mapping = mapper.getMapping(); // Turn it into a String: String actualJsonContent = mapping.string(); // Expected Mapping: String expectedJsonContent = "{\"document\":{\"properties\":{\"dateTime\":{\"type\":\"date\",\"format\":\"strict_date_optional_time||epoch_millis\"},\"skyCondition\":{\"type\":\"string\"},\"station\":{\"type\":\"nested\",\"include_in_parent\":true,\"properties\":{\"coordinates\":{\"type\":\"geo_point\",\"lat_lon\":true},\"location\":{\"type\":\"string\"},\"name\":{\"type\":\"string\"},\"state\":{\"type\":\"string\"},\"wban\":{\"type\":\"string\"}}},\"stationPressure\":{\"type\":\"float\"},\"temperature\":{\"type\":\"float\"},\"windSpeed\":{\"type\":\"float\"}}}}"; final JsonNode tree1 = jacksonObjectMapper.readTree(expectedJsonContent); final JsonNode tree2 = jacksonObjectMapper.readTree(actualJsonContent); Assert.assertEquals(true, tree1.equals(tree2)); }
From source file:com.crushpaper.DbJsonBackupForUserTest.java
@Test public void test3() throws IOException { final TestEntrySet before = new TestEntrySet( new TestEntry[] { new TestEntry("1", 1), new TestEntry("2", 2) }); final ObjectMapper mapper = new ObjectMapper(); final JsonNode node1 = mapper.readTree("{\n" + "\"note\": \"1\",\n" + "\"modTime\": 1,\n" + "\"createTime\": 1,\n" + "\"id\": \"S3\",\n" + "\"type\": \"root\"\n" + "}"); final JsonNode node2 = mapper.readTree("{\n" + "\"note\": \"2\",\n" + "\"modTime\": 2,\n" + "\"createTime\": 2,\n" + "\"id\": \"S4\",\n" + "\"type\": \"root\"\n" + "}\n"); final Errors errors = new Errors(); try {//from w ww. j a v a 2 s .c o m final User user = dbLogic.getOrCreateUser("user"); assertTrue(dbLogic.addEntries(before, user, createTime, errors)); dbLogic.commit(); final StringBuilder result = new StringBuilder(); dbLogic.backupJsonForUser(user, result); final JsonNode resultNode = mapper.readTree(result.toString()); assertTrue(resultNode.isObject()); final JsonNode entriesNodes = resultNode.get("entries"); assertTrue(entriesNodes.isArray()); assertEquals(2, entriesNodes.size()); boolean matched1 = false, matched2 = false; for (int i = 0; i < 2; ++i) { final JsonNode obj = entriesNodes.get(i); if (obj.equals(node1)) { matched1 = true; } else if (obj.equals(node2)) { matched2 = true; } } assertTrue(matched1); assertTrue(matched2); } catch (final IOException e) { assertTrue(false); } }
From source file:org.opendaylight.sfc.sbrest.provider.task.SbRestSfstateTaskTest.java
@Test public void testSbRestSfstateTask() throws IOException { SbRestSfstateTask sbRestSfstateTask = new SbRestSfstateTask(RestOperation.PUT, this.buildServiceFunctionState(), executorService); JsonNode jsonObject = mapper.readTree(sbRestSfstateTask.jsonObject); assertTrue("Must be true", jsonObject.equals(this.buildServiceFunctionStateObjectNode())); assertTrue("Must be true", sbRestSfstateTask.restUriList.get(0).contains(REST_URI)); }
From source file:org.opendaylight.sfc.sbrest.provider.task.SbRestSfstateTaskTest.java
@Test public void testSbRestSfstateTask1() throws IOException { SbRestSfstateTask sbRestSfstateTask = new SbRestSfstateTask(RestOperation.DELETE, this.buildServiceFunctionState(), executorService); JsonNode jsonObject = mapper.readTree(sbRestSfstateTask.jsonObject); assertTrue("Must be true", jsonObject.equals(buildServiceFunctionStateObjectNode1())); assertTrue("Must be true", sbRestSfstateTask.restUriList.get(0).contains(REST_URI)); }