SPQRNodeManager { public NodeDeRegistrationResponse deregisterNode(final String nodeId) { if(StringUtils.isBlank(nodeId)) return new NodeDeRegistrationResponse("", NodeDeRegistrationState.MISSING_NODE_ID, ""); String id = StringUtils.lowerCase(StringUtils.trim(nodeId)); if(!this.processingNodes.containsKey(id)) return new NodeDeRegistrationResponse(nodeId, NodeDeRegistrationState.NO_SUCH_NODE_ID, "Unknown node id: " + nodeId); final SPQRNodeClient client = this.processingNodes.remove(id); if(client != null) client.shutdown(); return new NodeDeRegistrationResponse(nodeId, NodeDeRegistrationState.OK, ""); } SPQRNodeManager(final int numIdentifierComputationRetries, final JerseyClientBuilder httpClientBuilder); NodeRegistrationResponse registerNode(final String protocol, final String remoteHost, final int servicePort, final int adminPort); NodeDeRegistrationResponse deregisterNode(final String nodeId); boolean hasNode(final String nodeId);  }
@Test public void testDeRegisterNode_withEmptyInput() { Assert.assertEquals("Invalid input", NodeDeRegistrationState.MISSING_NODE_ID, new SPQRNodeManager(5, Mockito.mock(JerseyClientBuilder.class)).deregisterNode("").getState()); }
@Test public void testDeRegisterNode_withUnknownNodeId() { Assert.assertEquals("Invalid input", NodeDeRegistrationState.NO_SUCH_NODE_ID, new SPQRNodeManager(5, Mockito.mock(JerseyClientBuilder.class)).deregisterNode("unknown-id").getState()); }