@Test @Category(UnitTest.class) public void testGetColorScaleSwatch() throws Exception { Mockito.when(service.createColorScaleSwatch(Mockito.anyString(), Mockito.anyString(), Mockito.anyInt(), Mockito.anyInt())).thenReturn(getRaster(input, "colorswatch.png")); ImageResponseWriter writer = new PngImageResponseWriter(); Mockito.when(service.getImageResponseWriter(Mockito.anyString())).thenReturn(writer); Response response = target("colorscales/mrgeo/test-files/output/org.mrgeo.resources.raster.mrspyramid/ColorScaleResourceTest/rainbow.xml") .queryParam("width", "100") .queryParam("height", "10") .request().get(); Assert.assertEquals("image/png", response.getHeaderString("Content-Type")); MrGeoRaster raster = MrGeoRaster.fromDataset(GDALUtils.open(response.readEntity(InputStream.class))); MrGeoRaster golden = getRaster(input, "colorswatch.png"); TestUtils.compareRasters(golden, raster); Assert.assertEquals(100, raster.width()); Assert.assertEquals(10, raster.height()); }
@SuppressFBWarnings(value = "JAXRS_ENDPOINT", justification = "verified") @GET @Produces("image/png") @Path("/{path: .*+}") public Response getColorScaleSwatch(@PathParam("path") String colorScalePath, @DefaultValue("200") @QueryParam("width") int width, @DefaultValue("20") @QueryParam("height") int height ) { try { getService(); String format = "png"; MrGeoRaster ri = service.createColorScaleSwatch(colorScalePath, format, width, height); return service.getImageResponseWriter(format).write(ri).build(); } catch (MrsPyramidServiceException e) { log.error("Exception thrown", e); return Response.status(Status.BAD_REQUEST).entity("Color scale file not found: " + colorScalePath).build(); } }
ColorScaleResource { @SuppressFBWarnings(value = "JAXRS_ENDPOINT", justification = "verified") @GET @Produces("image/png") @Path("/{path: .*+}") public Response getColorScaleSwatch(@PathParam("path") String colorScalePath, @DefaultValue("200") @QueryParam("width") int width, @DefaultValue("20") @QueryParam("height") int height ) { try { getService(); String format = "png"; MrGeoRaster ri = service.createColorScaleSwatch(colorScalePath, format, width, height); return service.getImageResponseWriter(format).write(ri).build(); } catch (MrsPyramidServiceException e) { log.error("Exception thrown", e); return Response.status(Status.BAD_REQUEST).entity("Color scale file not found: " + colorScalePath).build(); } } }
ColorScaleResource { @SuppressFBWarnings(value = "JAXRS_ENDPOINT", justification = "verified") @GET @Produces("image/png") @Path("/{path: .*+}") public Response getColorScaleSwatch(@PathParam("path") String colorScalePath, @DefaultValue("200") @QueryParam("width") int width, @DefaultValue("20") @QueryParam("height") int height ) { try { getService(); String format = "png"; MrGeoRaster ri = service.createColorScaleSwatch(colorScalePath, format, width, height); return service.getImageResponseWriter(format).write(ri).build(); } catch (MrsPyramidServiceException e) { log.error("Exception thrown", e); return Response.status(Status.BAD_REQUEST).entity("Color scale file not found: " + colorScalePath).build(); } }  }
ColorScaleResource { @SuppressFBWarnings(value = "JAXRS_ENDPOINT", justification = "verified") @GET @Produces("image/png") @Path("/{path: .*+}") public Response getColorScaleSwatch(@PathParam("path") String colorScalePath, @DefaultValue("200") @QueryParam("width") int width, @DefaultValue("20") @QueryParam("height") int height ) { try { getService(); String format = "png"; MrGeoRaster ri = service.createColorScaleSwatch(colorScalePath, format, width, height); return service.getImageResponseWriter(format).write(ri).build(); } catch (MrsPyramidServiceException e) { log.error("Exception thrown", e); return Response.status(Status.BAD_REQUEST).entity("Color scale file not found: " + colorScalePath).build(); } }  @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 { @SuppressFBWarnings(value = "JAXRS_ENDPOINT", justification = "verified") @GET @Produces("image/png") @Path("/{path: .*+}") public Response getColorScaleSwatch(@PathParam("path") String colorScalePath, @DefaultValue("200") @QueryParam("width") int width, @DefaultValue("20") @QueryParam("height") int height ) { try { getService(); String format = "png"; MrGeoRaster ri = service.createColorScaleSwatch(colorScalePath, format, width, height); return service.getImageResponseWriter(format).write(ri).build(); } catch (MrsPyramidServiceException e) { log.error("Exception thrown", e); return Response.status(Status.BAD_REQUEST).entity("Color scale file not found: " + colorScalePath).build(); } }  @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
);  }