### Question:
SwitchManager implements AutoCloseable { public synchronized Set<NodeConnectorId> getExternalPorts(NodeId nodeId) { SwitchState state = switches.get(nodeId); if (state == null) { return Collections.emptySet(); } return ImmutableSet.copyOf(state.externalPorts); } 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 getExternalPortsTest() { NodeId nodeId = mock(NodeId.class); SwitchState switchState = new SwitchState(nodeId); Set<NodeConnectorId> externalPorts = Collections.emptySet(); switchState.externalPorts = externalPorts; SwitchManager.switches.put(nodeId, null); Assert.assertTrue(switchManager.getExternalPorts(nodeId).isEmpty()); SwitchManager.switches.put(nodeId, switchState); Assert.assertEquals(externalPorts, switchManager.getExternalPorts(nodeId)); }