### Question:
GridDef { public int wrapX(int x) { if (x < 0) { return width - 1 + ((1 + x) % width); } if (x >= width) { return x % width; } return x; } 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 testWrapX() throws Exception { final GridDef gridDef = GridDef.createGlobal(8, 4); assertEquals(0, gridDef.wrapX(0)); assertEquals(7, gridDef.wrapX(7)); assertEquals(7, gridDef.wrapX(-1)); assertEquals(6, gridDef.wrapX(-2)); assertEquals(5, gridDef.wrapX(-3)); assertEquals(4, gridDef.wrapX(-4)); assertEquals(3, gridDef.wrapX(-5)); assertEquals(2, gridDef.wrapX(-6)); assertEquals(1, gridDef.wrapX(-7)); assertEquals(0, gridDef.wrapX(-8)); assertEquals(7, gridDef.wrapX(-9)); assertEquals(0, gridDef.wrapX(8)); assertEquals(1, gridDef.wrapX(9)); assertEquals(2, gridDef.wrapX(10)); assertEquals(3, gridDef.wrapX(11)); assertEquals(4, gridDef.wrapX(12)); assertEquals(5, gridDef.wrapX(13)); assertEquals(6, gridDef.wrapX(14)); assertEquals(7, gridDef.wrapX(15)); assertEquals(0, gridDef.wrapX(16)); }