DefaultServer implements Server { @Override public Sentence find(ServerSocketPredicate predicate) { return new Sentence(this, predicate); } if(state.get() == State.OPENED); @Override void on(ServerTransport transport); @Override Sentence find(ServerSocketPredicate predicate); @Override Server find(ServerSocketPredicate predicate, SerializableAction<ServerSocket> action); @Override Server onsocket(Action<ServerSocket> action); void setHeartbeat(int heartbeat); void set_heartbeat(int _heartbeat);  }
@Test public void find() { DefaultServer server = new DefaultServer(); DefaultServerSocket socketA = mock(DefaultServerSocket.class); DefaultServerSocket socketB = mock(DefaultServerSocket.class); DefaultServerSocket socketC = mock(DefaultServerSocket.class); when(socketA.id()).thenReturn("A"); when(socketB.id()).thenReturn("B"); when(socketC.id()).thenReturn("C"); server.sockets.put(socketA.id(), socketA); server.sockets.put(socketB.id(), socketB); server.sockets.put(socketC.id(), socketC); List<ServerSocket> result = new ArrayList<>(); server.find(ServerSocketPredicates.all(), result::add); assertEquals(Arrays.asList(socketA, socketB, socketC), result); result.clear(); server.find(ServerSocketPredicates.id("A"), result::add); assertEquals(Arrays.asList(socketA), result); result.clear(); server.find(ServerSocketPredicates.id("A").negate(), result::add); assertEquals(Arrays.asList(socketB, socketC), result); }