### Question:
Node2ContainerMap extends Node2ObjectsMap<ContainerID> { @Override public void insertNewDatanode(UUID datanodeID, Set<ContainerID> containerIDs) throws SCMException { super.insertNewDatanode(datanodeID, containerIDs); } Node2ContainerMap(); Set<ContainerID> getContainers(UUID datanode); @Override void insertNewDatanode(UUID datanodeID, Set<ContainerID> containerIDs); void setContainersForDatanode(UUID datanodeID,
      Set<ContainerID> containers); @VisibleForTesting @Override int size();  }### Answer:
@Test public void testIsKnownDatanode() throws SCMException { Node2ContainerMap map = new Node2ContainerMap(); UUID knownNode = getFirstKey(); UUID unknownNode = UUID.randomUUID(); Set<ContainerID> containerIDs = testData.get(knownNode); map.insertNewDatanode(knownNode, containerIDs); Assert.assertTrue("Not able to detect a known node", map.isKnownDatanode(knownNode)); Assert.assertFalse("Unknown node detected", map.isKnownDatanode(unknownNode)); }
@Test public void testInsertNewDatanode() throws SCMException { Node2ContainerMap map = new Node2ContainerMap(); UUID knownNode = getFirstKey(); Set<ContainerID> containerIDs = testData.get(knownNode); map.insertNewDatanode(knownNode, containerIDs); Set<ContainerID> readSet = map.getContainers(knownNode); Set newSet = new TreeSet((readSet)); Assert.assertTrue(newSet.removeAll(containerIDs)); Assert.assertTrue(newSet.size() == 0); thrown.expect(SCMException.class); thrown.expectMessage("already exists"); map.insertNewDatanode(knownNode, containerIDs); map.removeDatanode(knownNode); map.insertNewDatanode(knownNode, containerIDs); }
@Test public void testProcessReportCheckOneNode() throws SCMException { UUID key = getFirstKey(); Set<ContainerID> values = testData.get(key); Node2ContainerMap map = new Node2ContainerMap(); map.insertNewDatanode(key, values); Assert.assertTrue(map.isKnownDatanode(key)); ReportResult result = map.processReport(key, values); Assert.assertEquals(ReportResult.ReportStatus.ALL_IS_WELL, result.getStatus()); }
@Test public void testProcessReportInsertAll() throws SCMException { Node2ContainerMap map = new Node2ContainerMap(); for (Map.Entry<UUID, TreeSet<ContainerID>> keyEntry : testData.entrySet()) { map.insertNewDatanode(keyEntry.getKey(), keyEntry.getValue()); } for (UUID key : testData.keySet()) { Assert.assertTrue(map.isKnownDatanode(key)); } }