EndlessGridHandler implements GridHandler<T> { @Override public void setCurrent(Grid<T> grid) { if (grid instanceof EndlessGrid) { currentGrid = grid; } else { currentGrid = new EndlessGrid<T>(grid, cellFactory); } } EndlessGridHandler(int x, int y, CellFactory<T> cellFactory); @Override Grid<T> getCurrent(); @Override Grid<T> createNew(); @Override void setCurrent(Grid<T> grid);  }
@Test public void testSetCurrent() { Grid newGrid = gridHandler.createNew(); newGrid.getCell(1, 1).setState(Cell.STATE_ALIVE); gridHandler.setCurrent(newGrid); assertThat(gridHandler.getCurrent()).isEqualTo(newGrid); }