@Test public void shouldOverwriteExistingProperties() throws PropertyValueException, NodeNotFoundException { long nodeId; Transaction tx = database.getGraph().beginTx(); try { Node node = database.getGraph().createNode(); node.setProperty("remove me", "trash"); nodeId = node.getId(); tx.success(); } finally { tx.finish(); } Map<String, Object> properties = new HashMap<String, Object>(); properties.put("foo", "bar"); properties.put("baz", 17); actions.setAllNodeProperties(nodeId, properties); tx = database.getGraph().beginTx(); try { Node node = database.getGraph().getNodeById(nodeId); assertHasProperties(node, properties); assertNull(node.getProperty("remove me", null)); } finally { tx.finish(); } }
@Test(expected = PropertyValueException.class) public void shouldFailOnTryingToStoreMixedArraysAsAProperty() throws Exception { long nodeId = graphdbHelper.createNode(); Map<String, Object> properties = new HashMap<String, Object>(); Object[] dodgyArray = new Object[3]; dodgyArray[0] = 0; dodgyArray[1] = 1; dodgyArray[2] = "two"; properties.put("foo", dodgyArray); actions.setAllNodeProperties(nodeId, properties); }
@Test public void shouldBeAbleToStorePropertiesInAnExistingNode() throws PropertyValueException, NodeNotFoundException { long nodeId = graphdbHelper.createNode(); Map<String, Object> properties = new HashMap<String, Object>(); properties.put("foo", "bar"); properties.put("baz", 17); actions.setAllNodeProperties(nodeId, properties); Transaction tx = database.getGraph().beginTx(); try { Node node = database.getGraph().getNodeById(nodeId); assertHasProperties(node, properties); } finally { tx.finish(); } }