Grid implements Serializable, Regionlike { public void moveBlock(int numRows, int numCols, int origY, int origX, int newY, int newX, DirtyGridCell<Z> resetCell) { this.copyFrom(this, numRows, numCols, origY, origX, newY, newX, resetCell); } Grid();   Grid(Map<String, Object> map);  Grid(Z empty, int numRows, int numCols);  Grid(Z empty, int numRows, int numCols, int y, int x);  Grid(Z empty, int numRows, int numCols, int y, int x, 
                boolean irregular); void box(int height, int width, int y1, int x1, 
                    Z left, Z right, Z top, Z bottom, 
                    Z topleft, Z topright, Z bottomleft, Z bottomright, 
                    Z inside); void box(Regionlike region, 
                    Z left, Z right, Z top, Z bottom, 
                    Z topleft, Z topright, Z bottomleft, Z bottomright, 
                    Z inside); void clear(); void clear(Z empty); @Override boolean contains(int y, int x); @Override boolean contains(int height, int width, int y1, int x1); @Override boolean contains(Positionable p); @Override boolean contains(Regionlike r); Z get(int y, int x); Z get(T pos); @Override Regionlike getBounds(); @Override RegionIterator getEdgeIterator(); Z getEmpty(); Z copyCell(Z cell); @Override int getHeight(); @Override RegionIterator getInsideIterator(); @Override RegionIterator getNotOutsideIterator(); @Override Sizable getSize(); @Override int getWidth(); @Override int getX(); @Override int getY(); @Override boolean intersects(int height, int width, int y1, int x1); @Override boolean intersects(Regionlike room); Grid<Z> like(); void line(int y0, int x0, int y1, int x1, Z cell); void line(Positionable start, Positionable end, Z cell); void makeIrregular(); void makeRegular(Z filler); void reset(int ysize, int xsize, Z empty); Z set(int y, int x, Z value); Z set(T pos, Z value); Z setCopy(int y, int x, Z value); Z setCopy(T pos, Z value); @Override void setHeight(int height); @Override void setPosition(int y, int x); @Override void setPosition(Positionable point); @Override void setSize(int ysize, int xsize); @Override void setSize(Sizable size); @Override void setBounds(Regionlike bounds); @Override void setWidth(int width); @Override void setX(int x); @Override void setY(int y); Grid<Z> subGrid(int numRows, int numCols, int y1, int x1); Grid<Z> subGrid(Regionlike r); Z unset(int y, int x); Z unset(Positionable pos); void wipe(int height, int width, int y1, int x1); void wipe(int height, int width, int y1, int x1, Z empty); void addGrid(Grid<Z> source); void moveBlock(int numRows, int numCols, int origY, int origX,
                          int newY, int newX, DirtyGridCell<Z> resetCell); void copyFrom(Grid<Z> source, int numRows, int numCols,
                         int startY, int startX, int destY, int destX, 
                         DirtyGridCell<Z> resetCell); @Override Positionable getPosition(); Grid<Z> copySubGrid(int numRows, int numCols, int startY, int startX); Grid<Z> cutSubGrid(int numRows, int numCols, int y1, int x1); @Override void setBounds(int height, int width, int y, int x); GridCellCopier<Z> getCellCopier(); void setCellCopier(GridCellCopier<Z> cellCopier); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString(); @Override boolean contains(int[] location);  }
@Test @Covers("public void moveBlock(int,int,int,int,int,int,DirtyGridCell<Z>)") public void moveBlock() { grid.clear(new Integer(0)); for (int row = 0; row < size_y; row++) { for (int col = 0; col < size_x; col++) { assertEquals(0, (int)grid.get(row+start_y, col+start_x)); } } for (int col = 0; col < size_x; col++) { grid.set(0+start_y, col+start_x, new Integer(100 + col)); assertEquals(100+col, (int)grid.get(0+start_y, col+start_x)); } grid.moveBlock(1, size_x, start_y, start_x, 2+start_y, start_x, null); for (int col = 0; col < size_x; col++) { assertEquals(String.format("(%s,%s)", start_y, col+start_x), (int)empty, (int)grid.get(start_y, col+start_x)); assertEquals(String.format("(%s,%s)", start_y, col+start_x), 100+col, (int)grid.get(2+start_y, col+start_x)); } grid.set(2+start_y, start_x, 0x30); grid.moveBlock(1, 1, 2+start_y, start_x, 2+start_y, 2+start_x, null); assertEquals(0, (int)grid.get(2+start_y, start_x)); assertEquals(0x30, (int)grid.get(2+start_y, 2+start_x)); }