### Question:
SwitchManager implements AutoCloseable { synchronized void updateSwitch(NodeId nodeId, @Nullable FlowCapableNode fcNode) { SwitchState state = getSwitchState(checkNotNull(nodeId)); SwitchStatus oldStatus = state.status; state.setFlowCapableNode(fcNode); handleSwitchState(state, oldStatus); } 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 updateSwitchTestStateNull() { NodeId nodeId = mock(NodeId.class); FlowCapableNode fcNode = mock(FlowCapableNode.class); switchManager.updateSwitch(nodeId, fcNode); verifyZeroInteractions(listener); }
@Test public void updateSwitchTestReadyReady() { switchState.status = SwitchStatus.READY; switchState.setHasEndpoints(true); switchManager.updateSwitch(nodeId, fcNode); verify(listener).switchUpdated(nodeId); }
@Test public void updateSwitchTestReadyDisconnected() { switchState.status = SwitchStatus.DISCONNECTED; switchState.setHasEndpoints(true); switchManager.updateSwitch(nodeId, fcNode); verify(listener).switchReady(nodeId); }
@Test public void updateSwitchTestPreparingReady() { switchState.status = SwitchStatus.READY; switchState.setHasEndpoints(false); switchManager.updateSwitch(nodeId, fcNode); verify(listener).switchRemoved(nodeId); }
@Test public void updateSwitchTestDisconnectedReady() { switchState.status = SwitchStatus.READY; switchState.setHasEndpoints(true); switchManager.updateSwitch(nodeId, null); Assert.assertFalse(SwitchManager.switches.containsKey(nodeId)); }