### Question:
NodeManager { public Node getOrCreateNode(Manager manager, String key, GraphDatabaseService db) { return manager.getOrCreateNode(key, db); } NodeManager(); static Map<String, Object> getNodeFromGlobalCache(Long id); Node getOrCreateNode(Manager manager, String key, GraphDatabaseService db); static Map<String, Object> getNodeAsMap(Long id, GraphDatabaseService graphDb); Object getNodeProperty(Long id, String key, GraphDatabaseService graphDb); boolean setNodeProperty(Long id, String key, Object value, GraphDatabaseService graphDb); static final Cache<Long, HashMap<String, Object>> globalNodeCache; }### Answer:
@Test public void testGetOrCreateNode() throws Exception { GraphDatabaseService db = setUpDb(); NodeManager nodeManager = new NodeManager(); NodeManager.globalNodeCache.invalidateAll(); DataNodeManager.dataCache.invalidateAll(); DataNodeManager dataNodeManager = new DataNodeManager(); Node a = nodeManager.getOrCreateNode(dataNodeManager, "a", db); Node b = nodeManager.getOrCreateNode(dataNodeManager, "b", db); Node c = nodeManager.getOrCreateNode(dataNodeManager, "c", db); Node d = nodeManager.getOrCreateNode(dataNodeManager, "d", db); Node e = nodeManager.getOrCreateNode(dataNodeManager, "e", db); Node f = nodeManager.getOrCreateNode(dataNodeManager, "f", db); Node g = nodeManager.getOrCreateNode(dataNodeManager, "g", db); Assert.assertNotNull(a); Assert.assertNotNull(b); Assert.assertNotNull(c); Assert.assertNotNull(d); Assert.assertNotNull(e); Assert.assertNotNull(f); Assert.assertNotNull(g); String expected = "a"; Transaction tx = db.beginTx(); String actual = (String)a.getProperty("value"); tx.success(); Assert.assertEquals(expected, actual); }