InstanceController implements RouterNanoHTTPD.UriResponder { @Override public Response get(RouterNanoHTTPD.UriResource uriResource, Map<String, String> map, NanoHTTPD.IHTTPSession ihttpSession) { return ResponseGenerator.generateMethodNotAllowedResponse(); }  @Override Response post(RouterNanoHTTPD.UriResource uriResource, Map<String, String> map, NanoHTTPD.IHTTPSession session); @Override Response get(RouterNanoHTTPD.UriResource uriResource, Map<String, String> map, NanoHTTPD.IHTTPSession ihttpSession); @Override Response put(RouterNanoHTTPD.UriResource uriResource, Map<String, String> map, NanoHTTPD.IHTTPSession ihttpSession); @Override Response delete(RouterNanoHTTPD.UriResource uriResource, Map<String, String> map, NanoHTTPD.IHTTPSession ihttpSession); @Override Response other(String s, RouterNanoHTTPD.UriResource uriResource, Map<String, String> map, NanoHTTPD.IHTTPSession ihttpSession);  }
@Test public void testLearnerError() throws Exception { TestCase testCase = new TestCase(); doThrow(new AnnotatorException("")).when(testCase.annotator).addView(any()); NanoHTTPD.Response response = testCase.execute(RequestResponseBuilder.getMultipleAnnotationRequestBody()); JsonArray instances = RequestResponseBuilder.getInstancesFromJson(response); assertEquals(2, instances.size()); JsonObject instance = instances.get(0).getAsJsonObject(); assertTrue(instance.has("error")); assertFalse(instance.has("textAnnotation")); String error = instance.get("error").getAsString(); assertTrue(error.startsWith("There was an error adding the view to the instance:")); assertEquals(NanoHTTPD.Response.Status.OK, response.getStatus()); }
@Test public void testGet() throws Exception { InstanceController instanceController = new InstanceController(); NanoHTTPD.Response response = instanceController.get(null,null,null); String body = IOUtils.toString(response.getData()); assertEquals("Error, method not allowed", body); assertEquals(NanoHTTPD.Response.Status.METHOD_NOT_ALLOWED, response.getStatus()); }