return this::execute;
}
+ @Override
+ public Executable<Optional<Peer>> byHostAndPort(String host, int port) {
+ nodeIdentifier.set(String.format("%s:%d", host, port));
+ return this::execute;
+ }
+
private ListenableFuture<Optional<Peer>> execute() {
return threadPool.submit(this::executeSequence);
}
assertThat(peer.get().get().getIdentity(), is("id1"));
}
+ @Test
+ public void defaultFcpClientCanEnablePeerByHostAndPort()
+ throws InterruptedException, ExecutionException, IOException {
+ Future<Optional<Peer>> peer = fcpClient.modifyPeer().enable().byHostAndPort("1.2.3.4", 5678).execute();
+ connectNode();
+ List<String> lines = fcpServer.collectUntil(is("EndMessage"));
+ String identifier = extractIdentifier(lines);
+ assertThat(lines, matchesFcpMessage(
+ "ModifyPeer",
+ "Identifier=" + identifier,
+ "NodeIdentifier=1.2.3.4:5678",
+ "IsDisabled=false",
+ "EndMessage"
+ ));
+ fcpServer.writeLine(
+ "Peer",
+ "Identifier=" + identifier,
+ "NodeIdentifier=Friend1",
+ "identity=id1",
+ "EndMessage"
+ );
+ assertThat(peer.get().get().getIdentity(), is("id1"));
+ }
+
}