@Test @Category(UnitTest.class) public void testGetMetadataBadPath() throws Exception { Mockito.when(service.getMetadata(Mockito.anyString())).thenAnswer(new Answer() { public Object answer(InvocationOnMock invocation) { throw new NotFoundException("Path does not exist - " + invocation.getArguments()[0]); } }); String resultImg = "small-elevation-bad-path"; Response response = target("metadata/" + resultImg) .request().get(); Assert.assertEquals(404, response.getStatus()); Assert.assertEquals("Path does not exist - " + resultImg, response.readEntity(String.class)); }
@SuppressFBWarnings(value = "JAXRS_ENDPOINT", justification = "verified") @GET @Produces(MediaType.APPLICATION_JSON) @Path("/{output: .*+}") public Response getMetadata(@PathParam("output") String imgName) { try { getService(); return Response.status(Status.OK).entity(service.getMetadata(imgName)).build(); } catch (NotFoundException e) { log.error("Exception thrown", e); String error = e.getMessage() != null ? e.getMessage() : ""; return Response.status(Status.NOT_FOUND).entity(error).build(); } catch (Exception e1) { log.error("Exception thrown", e1); String error = e1.getMessage() != null ? e1.getMessage() : ""; return Response.serverError().entity(error).build(); } }
MetadataResource { @SuppressFBWarnings(value = "JAXRS_ENDPOINT", justification = "verified") @GET @Produces(MediaType.APPLICATION_JSON) @Path("/{output: .*+}") public Response getMetadata(@PathParam("output") String imgName) { try { getService(); return Response.status(Status.OK).entity(service.getMetadata(imgName)).build(); } catch (NotFoundException e) { log.error("Exception thrown", e); String error = e.getMessage() != null ? e.getMessage() : ""; return Response.status(Status.NOT_FOUND).entity(error).build(); } catch (Exception e1) { log.error("Exception thrown", e1); String error = e1.getMessage() != null ? e1.getMessage() : ""; return Response.serverError().entity(error).build(); } } }
MetadataResource { @SuppressFBWarnings(value = "JAXRS_ENDPOINT", justification = "verified") @GET @Produces(MediaType.APPLICATION_JSON) @Path("/{output: .*+}") public Response getMetadata(@PathParam("output") String imgName) { try { getService(); return Response.status(Status.OK).entity(service.getMetadata(imgName)).build(); } catch (NotFoundException e) { log.error("Exception thrown", e); String error = e.getMessage() != null ? e.getMessage() : ""; return Response.status(Status.NOT_FOUND).entity(error).build(); } catch (Exception e1) { log.error("Exception thrown", e1); String error = e1.getMessage() != null ? e1.getMessage() : ""; return Response.serverError().entity(error).build(); } }  }
MetadataResource { @SuppressFBWarnings(value = "JAXRS_ENDPOINT", justification = "verified") @GET @Produces(MediaType.APPLICATION_JSON) @Path("/{output: .*+}") public Response getMetadata(@PathParam("output") String imgName) { try { getService(); return Response.status(Status.OK).entity(service.getMetadata(imgName)).build(); } catch (NotFoundException e) { log.error("Exception thrown", e); String error = e.getMessage() != null ? e.getMessage() : ""; return Response.status(Status.NOT_FOUND).entity(error).build(); } catch (Exception e1) { log.error("Exception thrown", e1); String error = e1.getMessage() != null ? e1.getMessage() : ""; return Response.serverError().entity(error).build(); } }  @SuppressFBWarnings(value = "JAXRS_ENDPOINT", justification = "verified") @GET @Produces(MediaType.APPLICATION_JSON) @Path("/{output: .*+}") Response getMetadata(@PathParam("output") String imgName); }
MetadataResource { @SuppressFBWarnings(value = "JAXRS_ENDPOINT", justification = "verified") @GET @Produces(MediaType.APPLICATION_JSON) @Path("/{output: .*+}") public Response getMetadata(@PathParam("output") String imgName) { try { getService(); return Response.status(Status.OK).entity(service.getMetadata(imgName)).build(); } catch (NotFoundException e) { log.error("Exception thrown", e); String error = e.getMessage() != null ? e.getMessage() : ""; return Response.status(Status.NOT_FOUND).entity(error).build(); } catch (Exception e1) { log.error("Exception thrown", e1); String error = e1.getMessage() != null ? e1.getMessage() : ""; return Response.serverError().entity(error).build(); } }  @SuppressFBWarnings(value = "JAXRS_ENDPOINT", justification = "verified") @GET @Produces(MediaType.APPLICATION_JSON) @Path("/{output: .*+}") Response getMetadata(@PathParam("output") String imgName);  }