### Question:
SwitchManager implements AutoCloseable { public static void activatingSwitch(NodeId nodeId) { SwitchState state = switches.get(nodeId); if (state == null) { state = new SwitchState(nodeId); switches.put(nodeId, state); } state.setHasEndpoints(true); state.updateStatus(); } SwitchManager(DataBroker dataProvider); static void activatingSwitch(NodeId nodeId); static void deactivatingSwitch(NodeId nodeId); synchronized InstanceIdentifier<NodeConnector> getNodeConnectorIidForPortName(Name portName); synchronized Collection<NodeId> getReadySwitches(); synchronized Set<NodeConnectorId> getExternalPorts(NodeId nodeId); Set<Long> getExternalPortNumbers(NodeId nodeId); synchronized Collection<NodeConnectorId> getTunnelPorts(NodeId nodeId); synchronized NodeConnectorId getTunnelPort(NodeId nodeId, Class<? extends TunnelTypeBase> tunnelType); synchronized IpAddress getTunnelIP(NodeId nodeId, Class<? extends TunnelTypeBase> tunnelType); void registerListener(SwitchListener listener); void setEncapsulationFormat(EncapsulationFormat format); @Override void close();  }### Answer:
@Test public void activatingSwitchTest() { NodeId nodeId = mock(NodeId.class); SwitchState switchState; switchState = SwitchManager.switches.get(nodeId); Assert.assertNull(switchState); SwitchManager.activatingSwitch(nodeId); switchState = SwitchManager.switches.get(nodeId); Assert.assertNotNull(switchState); Assert.assertTrue(switchState.isHasEndpoints()); SwitchManager.activatingSwitch(nodeId); Assert.assertEquals(switchState, SwitchManager.switches.get(nodeId)); Assert.assertTrue(switchState.isHasEndpoints()); SwitchManager.deactivatingSwitch(nodeId); Assert.assertFalse(switchState.isHasEndpoints()); }