@Test public void testGet() throws Exception { InfoController infoController = new InfoController(); Annotator annotator = mock(Annotator.class); String[] requiredViews = new String[]{"a", "b", "c"}; when(annotator.getRequiredViews()).thenReturn(requiredViews); when(annotator.getViewName()).thenReturn("view"); RouterNanoHTTPD.UriResource uriResource = mock(RouterNanoHTTPD.UriResource.class); when(uriResource.initParameter(Annotator.class)).thenReturn(annotator); ServerPreferences serverPreferences = new ServerPreferences(100, 10); when(uriResource.initParameter(1, ServerPreferences.class)).thenReturn(serverPreferences); NanoHTTPD.Response response = infoController.get(uriResource, null, null); String body = IOUtils.toString(response.getData()); JsonObject object = new JsonParser().parse(body).getAsJsonObject(); assertInfoEqual(object, requiredViews, "view", serverPreferences); assertEquals(NanoHTTPD.Response.Status.OK, response.getStatus()); }
@Override public NanoHTTPD.Response get(RouterNanoHTTPD.UriResource uriResource, Map<String, String> map, NanoHTTPD.IHTTPSession ihttpSession) { Annotator annotator = uriResource.initParameter(Annotator.class); ServerPreferences serverPreferences = uriResource.initParameter(1, ServerPreferences.class); JsonObject jObject = new JsonObject(); addAnnotatorDetails(jObject, annotator); addServerSettings(jObject, serverPreferences); String json = jObject.toString(); return NanoHTTPD.newFixedLengthResponse(json); }
InfoController implements RouterNanoHTTPD.UriResponder { @Override public NanoHTTPD.Response get(RouterNanoHTTPD.UriResource uriResource, Map<String, String> map, NanoHTTPD.IHTTPSession ihttpSession) { Annotator annotator = uriResource.initParameter(Annotator.class); ServerPreferences serverPreferences = uriResource.initParameter(1, ServerPreferences.class); JsonObject jObject = new JsonObject(); addAnnotatorDetails(jObject, annotator); addServerSettings(jObject, serverPreferences); String json = jObject.toString(); return NanoHTTPD.newFixedLengthResponse(json); } }
InfoController implements RouterNanoHTTPD.UriResponder { @Override public NanoHTTPD.Response get(RouterNanoHTTPD.UriResource uriResource, Map<String, String> map, NanoHTTPD.IHTTPSession ihttpSession) { Annotator annotator = uriResource.initParameter(Annotator.class); ServerPreferences serverPreferences = uriResource.initParameter(1, ServerPreferences.class); JsonObject jObject = new JsonObject(); addAnnotatorDetails(jObject, annotator); addServerSettings(jObject, serverPreferences); String json = jObject.toString(); return NanoHTTPD.newFixedLengthResponse(json); }  }
InfoController implements RouterNanoHTTPD.UriResponder { @Override public NanoHTTPD.Response get(RouterNanoHTTPD.UriResource uriResource, Map<String, String> map, NanoHTTPD.IHTTPSession ihttpSession) { Annotator annotator = uriResource.initParameter(Annotator.class); ServerPreferences serverPreferences = uriResource.initParameter(1, ServerPreferences.class); JsonObject jObject = new JsonObject(); addAnnotatorDetails(jObject, annotator); addServerSettings(jObject, serverPreferences); String json = jObject.toString(); return NanoHTTPD.newFixedLengthResponse(json); }  @Override NanoHTTPD.Response get(RouterNanoHTTPD.UriResource uriResource, Map<String, String> map, NanoHTTPD.IHTTPSession ihttpSession); @Override NanoHTTPD.Response put(RouterNanoHTTPD.UriResource uriResource, Map<String, String> map, NanoHTTPD.IHTTPSession ihttpSession); @Override NanoHTTPD.Response post(RouterNanoHTTPD.UriResource uriResource, Map<String, String> map, NanoHTTPD.IHTTPSession ihttpSession); @Override NanoHTTPD.Response delete(RouterNanoHTTPD.UriResource uriResource, Map<String, String> map, NanoHTTPD.IHTTPSession ihttpSession); @Override NanoHTTPD.Response other(String s, RouterNanoHTTPD.UriResource uriResource, Map<String, String> map, NanoHTTPD.IHTTPSession ihttpSession); }
InfoController implements RouterNanoHTTPD.UriResponder { @Override public NanoHTTPD.Response get(RouterNanoHTTPD.UriResource uriResource, Map<String, String> map, NanoHTTPD.IHTTPSession ihttpSession) { Annotator annotator = uriResource.initParameter(Annotator.class); ServerPreferences serverPreferences = uriResource.initParameter(1, ServerPreferences.class); JsonObject jObject = new JsonObject(); addAnnotatorDetails(jObject, annotator); addServerSettings(jObject, serverPreferences); String json = jObject.toString(); return NanoHTTPD.newFixedLengthResponse(json); }  @Override NanoHTTPD.Response get(RouterNanoHTTPD.UriResource uriResource, Map<String, String> map, NanoHTTPD.IHTTPSession ihttpSession); @Override NanoHTTPD.Response put(RouterNanoHTTPD.UriResource uriResource, Map<String, String> map, NanoHTTPD.IHTTPSession ihttpSession); @Override NanoHTTPD.Response post(RouterNanoHTTPD.UriResource uriResource, Map<String, String> map, NanoHTTPD.IHTTPSession ihttpSession); @Override NanoHTTPD.Response delete(RouterNanoHTTPD.UriResource uriResource, Map<String, String> map, NanoHTTPD.IHTTPSession ihttpSession); @Override NanoHTTPD.Response other(String s, RouterNanoHTTPD.UriResource uriResource, Map<String, String> map, NanoHTTPD.IHTTPSession ihttpSession);  }