AdminResources { @GET @Path("/nsqlookup/{topic : .+}") public String lookupTopic(@PathParam("topic") String topic) throws IOException, URISyntaxException { LoggerFactory.getLogger(AdminResources.class).debug("lookup for topic {}", topic); return nsqLookup.lookup(topic).stream().map(ServerAddress::toString).reduce((s, s2) -> s + "<br>" + s2).orElse("can't find topic on nsq lookups"); } AdminResources(NSQLookup nsqLookup); @GET @Path("/version") String version(); @GET @Path("/nsqlookup/{topic : .+}") String lookupTopic(@PathParam("topic") String topic); @POST @Path("/version") void lookupTopic(@QueryParam("host") String host, @QueryParam("port") int port);  }
@Test public void should_return_list_of_nsqlookup() throws IOException, URISyntaxException { NSQLookup nsqLookup = mock(NSQLookup.class); HashSet<ServerAddress> serverAddresses = new HashSet<>(); serverAddresses.add(new ServerAddress("localhost", 1234)); serverAddresses.add(new ServerAddress("1.2.3.4", 1111)); when(nsqLookup.lookup("mytopic")).thenReturn(serverAddresses); String resultAddresses = new AdminResources(nsqLookup).lookupTopic("mytopic"); Assert.assertEquals("localhost:1234<br>1.2.3.4:1111", resultAddresses); }