public void testNodeObjectsRememberedByAddress() throws Exception {
final AddressNodeId addressNodeId = AddressNodeId.create("http://localhost:65535", UUID.randomUUID().toString());
setupNodes(addressNodeId);
api.setHttpClient(client);
final Node firstNode = serverNodes.any();
Throwable t = null;
try {
api.put().path("/").node(firstNode).execute();
} catch (Graylog2ServerUnavailableException e) {
t = e;
}
assertNotNull("Should have thrown an Graylog2ServerUnavailableException", t);
assertEquals("First node failure count should be 1", 1, firstNode.getFailureCount());
final Node.Factory nodeFactory = injector.getInstance(Node.Factory.class);
final NodeSummaryResponse r1 = new NodeSummaryResponse();
r1.transportAddress = "http://localhost:65534";
r1.id = UUID.randomUUID().toString();
final Node newNode = nodeFactory.fromSummaryResponse(r1);
newNode.touch();
final NodeSummaryResponse r2 = new NodeSummaryResponse();
r2.transportAddress = firstNode.getTransportAddress();
r2.id = firstNode.getNodeId();
final Node sameAsInitialNode = nodeFactory.fromSummaryResponse(r2);
sameAsInitialNode.touch();
serverNodes.put(ImmutableList.of(newNode, sameAsInitialNode));
final Map<Node, EmptyResponse> responses = api.put().nodes(serverNodes.all().toArray(new Node[0])).path("/").executeOnAll();
assertTrue(responses.isEmpty());