### Question:
ArrayGrid implements Grid { @Override public int getSampleInt(int x, int y) { checkBounds(x, y); final int index = y * width + x; return array.getInt(index); } ArrayGrid(GridDef gridDef, Array array, final Number fillValue, double scaling, double offset); static Grid create(GridDef gridDef, float[] data); static ArrayGrid create(GridDef gridDef, double[] data); int getWidth(); int getHeight(); double getScaling(); double getOffset(); @Override GridDef getGridDef(); @Override boolean getSampleBoolean(int x, int y); @Override int getSampleInt(int x, int y); @Override double getSampleDouble(int x, int y); void setSample(int x, int y, double sample);  }### Answer:
@Test public void testGetSampleInt() throws Exception { final int[] data = {0, 1, 2, 3, 4, 5, 6, 7}; final Array array = Array.factory(data); final Grid grid = new ArrayGrid(GridDef.createGlobal(90), array, 19, 1.0, 0.0); assertEquals(1, grid.getSampleInt(1, 0)); assertEquals(5, grid.getSampleInt(1, 1)); }
@Test public void testGetSampleInt_outOfBounds() throws Exception { final int[] data = {0, 1, 2, 3, 4, 5, 6, 7}; final Array array = Array.factory(data); final Grid grid = new ArrayGrid(GridDef.createGlobal(90), array, 19, 1.0, 0.0); try { grid.getSampleInt(-1, 1); fail("ArrayIndexOutOfBoundsException expected"); } catch (Exception e) { } try { grid.getSampleInt(0, 3); fail("ArrayIndexOutOfBoundsException expected"); } catch (Exception e) { } }