@Test public void shouldRetriveDifferentInstances() { NodeUpdater updater1 = NodeUpdaters.getUpdaterFor(node1); NodeUpdater updater2 = NodeUpdaters.getUpdaterFor(node2); assertTrue(updater1 != updater2); }
public static NodeUpdater getUpdaterFor(CloudNode node) { String nodeId = node.getId(); if (testing) { return updaterForTest; } else { synchronized (NodeUpdaters.class) { if (!updaters.containsKey(nodeId)) { NodeUpdater updater = new NodeUpdater(node); updaters.put(nodeId, updater); } } return updaters.get(nodeId); } }
NodeUpdaters { public static NodeUpdater getUpdaterFor(CloudNode node) { String nodeId = node.getId(); if (testing) { return updaterForTest; } else { synchronized (NodeUpdaters.class) { if (!updaters.containsKey(nodeId)) { NodeUpdater updater = new NodeUpdater(node); updaters.put(nodeId, updater); } } return updaters.get(nodeId); } } }
NodeUpdaters { public static NodeUpdater getUpdaterFor(CloudNode node) { String nodeId = node.getId(); if (testing) { return updaterForTest; } else { synchronized (NodeUpdaters.class) { if (!updaters.containsKey(nodeId)) { NodeUpdater updater = new NodeUpdater(node); updaters.put(nodeId, updater); } } return updaters.get(nodeId); } }  }
NodeUpdaters { public static NodeUpdater getUpdaterFor(CloudNode node) { String nodeId = node.getId(); if (testing) { return updaterForTest; } else { synchronized (NodeUpdaters.class) { if (!updaters.containsKey(nodeId)) { NodeUpdater updater = new NodeUpdater(node); updaters.put(nodeId, updater); } } return updaters.get(nodeId); } }  static NodeUpdater getUpdaterFor(CloudNode node); }
NodeUpdaters { public static NodeUpdater getUpdaterFor(CloudNode node) { String nodeId = node.getId(); if (testing) { return updaterForTest; } else { synchronized (NodeUpdaters.class) { if (!updaters.containsKey(nodeId)) { NodeUpdater updater = new NodeUpdater(node); updaters.put(nodeId, updater); } } return updaters.get(nodeId); } }  static NodeUpdater getUpdaterFor(CloudNode node); static NodeUpdater updaterForTest; static boolean testing; }