@Test @Category(UnitTest.class) public void testGetColorScaleSwatchMissingColorScale() throws Exception { Mockito.when( service.createColorScaleSwatch(Mockito.anyString(), Mockito.anyString(), Mockito.anyInt(), Mockito.anyInt())) .thenAnswer(new Answer() { public Object answer(InvocationOnMock invocation) throws MrsPyramidServiceException { throw new MrsPyramidServiceException("Base path \"" + invocation.getArguments()[0] + "\" does not exist."); } }); ImageResponseWriter writer = new PngImageResponseWriter(); Mockito.when(service.getImageResponseWriter(Mockito.anyString())).thenReturn(writer); String path = "/mrgeo/test-files/output/org.mrgeo.resources.raster.mrspyramid/ColorScaleResourceTest/missing.xml"; Response response = target("colorscales/" + path) .queryParam("width", "100") .queryParam("height", "10") .request().get(); Assert.assertNotSame("image/png", response.getHeaderString("Content-Type")); Assert.assertEquals(400, response.getStatus()); Assert.assertEquals("Color scale file not found: " + path, response.readEntity(String.class)); }
@GET @Produces(MediaType.APPLICATION_JSON) public ColorScaleList get() throws MrsPyramidServiceException { log.info("Retrieving color scales file list..."); getService(); List<String> files = service.getColorScales(); log.info("Color scales file list retrieved."); return new ColorScaleList(files); }
ColorScaleResource { @GET @Produces(MediaType.APPLICATION_JSON) public ColorScaleList get() throws MrsPyramidServiceException { log.info("Retrieving color scales file list..."); getService(); List<String> files = service.getColorScales(); log.info("Color scales file list retrieved."); return new ColorScaleList(files); } }
ColorScaleResource { @GET @Produces(MediaType.APPLICATION_JSON) public ColorScaleList get() throws MrsPyramidServiceException { log.info("Retrieving color scales file list..."); getService(); List<String> files = service.getColorScales(); log.info("Color scales file list retrieved."); return new ColorScaleList(files); }  }
ColorScaleResource { @GET @Produces(MediaType.APPLICATION_JSON) public ColorScaleList get() throws MrsPyramidServiceException { log.info("Retrieving color scales file list..."); getService(); List<String> files = service.getColorScales(); log.info("Color scales file list retrieved."); return new ColorScaleList(files); }  @GET @Produces(MediaType.APPLICATION_JSON) ColorScaleList get(); @SuppressFBWarnings(value = "JAXRS_ENDPOINT", justification = "verified") @GET @Produces("image/png") @Path("/{path: .*+}") Response getColorScaleSwatch(@PathParam("path") String colorScalePath,
    @DefaultValue("200") @QueryParam("width") int width,
    @DefaultValue("20") @QueryParam("height") int height
); @SuppressFBWarnings(value = "JAXRS_ENDPOINT", justification = "verified") @GET @Produces("text/html") @Path("/legend/{name: .*+}") Response getColorScaleLegend(@PathParam("name") String name,
    @DefaultValue("20") @QueryParam("width") int width,
    @DefaultValue("200") @QueryParam("height") int height,
    @DefaultValue("0") @QueryParam("min") Double min,
    @QueryParam("max") Double max,
    @DefaultValue("") @QueryParam("units") String units
); }
ColorScaleResource { @GET @Produces(MediaType.APPLICATION_JSON) public ColorScaleList get() throws MrsPyramidServiceException { log.info("Retrieving color scales file list..."); getService(); List<String> files = service.getColorScales(); log.info("Color scales file list retrieved."); return new ColorScaleList(files); }  @GET @Produces(MediaType.APPLICATION_JSON) ColorScaleList get(); @SuppressFBWarnings(value = "JAXRS_ENDPOINT", justification = "verified") @GET @Produces("image/png") @Path("/{path: .*+}") Response getColorScaleSwatch(@PathParam("path") String colorScalePath,
    @DefaultValue("200") @QueryParam("width") int width,
    @DefaultValue("20") @QueryParam("height") int height
); @SuppressFBWarnings(value = "JAXRS_ENDPOINT", justification = "verified") @GET @Produces("text/html") @Path("/legend/{name: .*+}") Response getColorScaleLegend(@PathParam("name") String name,
    @DefaultValue("20") @QueryParam("width") int width,
    @DefaultValue("200") @QueryParam("height") int height,
    @DefaultValue("0") @QueryParam("min") Double min,
    @QueryParam("max") Double max,
    @DefaultValue("") @QueryParam("units") String units
);  }