Node2MapUtil.map2node(subnode, (Map<String, Object>) value); } else {
@Test public void testExceptionOnNonPrimitive() throws Exception { // GIVEN map.put("failureExpected", new StringBuilder()); exception.expect(IllegalArgumentException.class); // WHEN node = Node2MapUtil.map2node(node, map); // THEN fail("No IllegalArgumentException thrown."); }
@Test public void testStorePrimitives() throws Exception { // GIVEN map.put(STRING, STRING_VALUE); map.put(LONG, LONG_VALUE); map.put(DOUBLE, DOUBLE_VALUE); map.put(BOOLEAN, BOOLEAN_VALUE); map.put(DATE, DATE_VALUE); // WHEN node = Node2MapUtil.map2node(node, map); // THEN assertTrue(node.hasProperty(STRING)); assertTrue(node.hasProperty(LONG)); assertTrue(node.hasProperty(DOUBLE)); assertTrue(node.hasProperty(BOOLEAN)); assertTrue(node.hasProperty(DATE)); assertEquals(STRING_VALUE, node.getProperty(STRING).getString()); assertEquals(LONG_VALUE, node.getProperty(LONG).getLong()); assertEquals(DOUBLE_VALUE, node.getProperty(DOUBLE).getDouble(), 0.0001); assertEquals(BOOLEAN_VALUE, node.getProperty(BOOLEAN).getBoolean()); assertEquals(DATE_VALUE, node.getProperty(DATE).getDate()); }
@Test public void testStoreSubnode() throws Exception { // GIVEN Map<String, Object> nested = new HashMap<String, Object>(); nested.put(STRING, STRING_VALUE); nested.put(LONG, LONG_VALUE); nested.put(DOUBLE, DOUBLE_VALUE); nested.put(BOOLEAN, BOOLEAN_VALUE); nested.put(DATE, DATE_VALUE); map.put(MAP, nested); // WHEN node = Node2MapUtil.map2node(node, map); // THEN assertTrue(node.hasNode(MAP)); Node nestedNode = node.getNode(MAP); assertTrue(nestedNode.hasProperty(STRING)); assertTrue(nestedNode.hasProperty(LONG)); assertTrue(nestedNode.hasProperty(DOUBLE)); assertTrue(nestedNode.hasProperty(BOOLEAN)); assertTrue(nestedNode.hasProperty(DATE)); assertEquals(STRING_VALUE, nestedNode.getProperty(STRING).getString()); assertEquals(LONG_VALUE, nestedNode.getProperty(LONG).getLong()); assertEquals(DOUBLE_VALUE, nestedNode.getProperty(DOUBLE).getDouble(), 0.0001); assertEquals(BOOLEAN_VALUE, nestedNode.getProperty(BOOLEAN).getBoolean()); assertEquals(DATE_VALUE, nestedNode.getProperty(DATE).getDate()); }