### Question:
MapUnitToPixelTransform { public Pixel toPixel(C2D point) { if (point.equals(this.extent.upperRight())) { return toPixel(point, true, false); } if (point.equals(this.extent.upperLeft())) { return toPixel(point, false, false); } if (point.equals(this.extent.lowerLeft())) { return toPixel(point, false, true); } if (point.equals(this.extent.lowerRight())) { return toPixel(point, true, true); } return toPixel(point, false, false); } MapUnitToPixelTransform(Envelope<C2D> extent, PixelRange pixelRange);  MapUnitToPixelTransform(Envelope<C2D> extent, int minPixelX, int minPixelY, double mapUnitsPerPixel);  MapUnitToPixelTransform(Envelope<C2D> extent, double mapUnitsPerPixel); PixelRange getRange(); Envelope<C2D> getDomain(); Point<C2D> toPoint(Pixel pixel); Pixel toPixel(C2D point); Pixel toPixel(C2D point, boolean leftBorderInclusive, boolean lowerBorderInclusive); PixelRange toPixelRange(Envelope<C2D> bbox);  }### Answer:
@Test public void test_point_outside_extent_is_allowed() { Pixel received = pixRangeBasedTransform.toPixel(new C2D(0, 2)); Pixel expected = Pixel.valueOf(90, 295); assertEquals(expected, received); }
@Test public void test_point_to_pixel_on_pixrange_based_transform() { Pixel pixel = pixRangeBasedTransform.toPixel( new C2D(10, 20)); assertEquals(Pixel.valueOf(100, 249), pixel); pixel = pixRangeBasedTransform.toPixel(new C2D(10, 100)); assertEquals(Pixel.valueOf(100, 50), pixel); pixel = pixRangeBasedTransform.toPixel(new C2D(110, 100)); assertEquals(Pixel.valueOf(199, 50), pixel); pixel = pixRangeBasedTransform.toPixel(new C2D(110, 20)); assertEquals(Pixel.valueOf(199, 249), pixel); pixel = pixRangeBasedTransform.toPixel(new C2D(60, 60)); assertEquals(Pixel.valueOf(150, 150), pixel); }
@Test public void test_point_pixel_on_upp_based_transform() { Pixel pixel = uppBasedTransform.toPixel(new C2D(10, 100)); assertEquals(Pixel.valueOf(100, 200), pixel); pixel = uppBasedTransform.toPixel(new C2D(10, 20)); assertEquals(Pixel.valueOf(100, 999), pixel); pixel = uppBasedTransform.toPixel(new C2D(110, 20)); assertEquals(Pixel.valueOf(1099, 999), pixel); pixel = uppBasedTransform.toPixel(new C2D(110, 100)); assertEquals(Pixel.valueOf(1099, 200), pixel); pixel = uppBasedTransform.toPixel(new C2D(60, 60)); assertEquals(Pixel.valueOf(600, 600), pixel); pixel = uppBasedTransform.toPixel(new C2D(60.1, 60)); assertEquals(Pixel.valueOf(601, 600), pixel); pixel = uppBasedTransform.toPixel(new C2D(60.05, 60)); assertEquals(Pixel.valueOf(600, 600), pixel); pixel = uppBasedTransform.toPixel(new C2D(60, 60.1)); assertEquals(Pixel.valueOf(600, 599), pixel); pixel = uppBasedTransform.toPixel(new C2D(60, 60.05)); assertEquals(Pixel.valueOf(600, 599), pixel); }