ServerPortRegistry { public static void removePort( ServerPort serverPort ) { Service service = services.get( serverPort.getServiceName() ); service.getServerPorts().remove( serverPort ); serverPorts.remove( serverPort.getId() ); } private  ServerPortRegistry(); static void addPort( ServerPort serverPort ); static void addService( Service service ); static void removePort( ServerPort serverPort ); static void clear(); static Service getService( String serviceName ); static ServerPort getPort( String portId ); static Set<Service> getServices(); static Set<ServerPort> getPorts();  }
@Test public void removePortTest() { ServerPortRegistry.clear(); Service service = new Service( "foo", "foo description" ); ServerPortRegistry.addService( service ); ServerPort serverPort1 = new ServerPort( "id1", "description", 60001, "foo" ); ServerPort serverPort2 = new ServerPort( "id2", "description", 60101, "foo" ); ServerPortRegistry.addPort( serverPort1 ); ServerPortRegistry.addPort( serverPort2 ); assertEquals( 2, ServerPortRegistry.getService( "foo" ).getServerPorts().size() ); ServerPortRegistry.removePort( serverPort1 ); assertEquals( 1, ServerPortRegistry.getService( "foo" ).getServerPorts().size() ); assertEquals( null, ServerPortRegistry.getPort( "id1" ) ); }