### Question:
GridDef { public Rectangle getGridRectangle(Rectangle2D lonLatRectangle) { final double lon1 = lonLatRectangle.getX(); final double lat1 = lonLatRectangle.getY(); final double lon2 = lon1 + lonLatRectangle.getWidth(); final double lat2 = lat1 + lonLatRectangle.getHeight(); return getGridRectangle(lon1, lat1, lon2, lat2); } private  GridDef(int width, int height, double easting, double northing, double resolutionX, double resolutionY); static GridDef createGlobal(double resolution); static GridDef createGlobal(int width, int height); static GridDef createRaster(int width, int height); int getTime(); int getWidth(); int getHeight(); double getEasting(); double getNorthing(); double getResolutionX(); double getResolutionY(); double getResolution(); int wrapX(int x); double getCenterLon(int x); double getCenterLat(int y); final double getDiagonal(int x, int y); final int getGridX(double lon, boolean crop); final int getGridY(double lat, boolean crop); Rectangle2D getLonLatRectangle(int x, int y); Rectangle getGridRectangle(Rectangle2D lonLatRectangle); Rectangle getGridRectangle(double minLon, double minLat, double maxLon, double maxLat); Rectangle getGridRectangle(int x, int y, GridDef gridDef); @Override boolean equals(Object o); @Override int hashCode();  }### Answer:
@Test public void testGetGridRectangle3() throws Exception { assertEquals(new Rectangle(0, 0, 100, 100), gridDef05.getGridRectangle(0, 0, gridDef5)); assertEquals(new Rectangle(100, 0, 100, 100), gridDef05.getGridRectangle(1, 0, gridDef5)); assertEquals(new Rectangle(0, 100, 100, 100), gridDef05.getGridRectangle(0, 1, gridDef5)); assertEquals(new Rectangle(100, 100, 100, 100), gridDef05.getGridRectangle(1, 1, gridDef5)); }
@Test public void testGetGridRectangle_resolutionTooCoarse() { try { gridDef5.getGridRectangle(0, 0, gridDef05); fail("IllegalArgumentException expected"); } catch (IllegalArgumentException expected) { } }