EndlessGrid implements Grid<T>, Overseer { @Override public void putCell(T cell) { int y = normalizeY(cell.getY()); int x = normalizeX(cell.getX()); maintainIds(cell, x, y); cell.setOverseer(this); if (cells[y][x] != null) { cells[y][x].setOverseer(null); } cells[y][x] = cell; } EndlessGrid(int sizeX, int sizeY, CellFactory<T> cellFactory);  EndlessGrid(Grid<T> other, CellFactory<T> cellFactory); protected  EndlessGrid(Parcel in); @Override void putCell(T cell); @Override void onCellStateChanged(CellStateChange cellStateChange); @Override int getSizeX(); @Override int getSizeY(); @Override T getCell(int x, int y); @Override boolean equals(Object o); @Override int hashCode(); @Override int describeContents(); @Override void writeToParcel(Parcel dest, int flags); static final Creator<EndlessGrid> CREATOR; }
@Test public void testPutCell() { SimpleCell cell = cellFactory.create(1, 1); cell.setState(Cell.STATE_ALIVE); grid.putCell(cell); assertThat(grid.getCell(1, 1).isAlive()).isTrue(); }