diff --git a/src/arcade/potts/agent/cell/PottsCell.java b/src/arcade/potts/agent/cell/PottsCell.java index 52623085..5fb7c31e 100644 --- a/src/arcade/potts/agent/cell/PottsCell.java +++ b/src/arcade/potts/agent/cell/PottsCell.java @@ -308,7 +308,7 @@ public void setState(CellState newState) { * @param newState the cell state */ abstract void setStateModule(CellState newState); - + @Override public void schedule(Schedule schedule) { stopper = schedule.scheduleRepeating(this, Ordering.CELLS.ordinal(), 1); diff --git a/src/arcade/potts/agent/cell/PottsCellStem.java b/src/arcade/potts/agent/cell/PottsCellStem.java index 0aac21f0..e93d8f11 100644 --- a/src/arcade/potts/agent/cell/PottsCellStem.java +++ b/src/arcade/potts/agent/cell/PottsCellStem.java @@ -38,25 +38,25 @@ public final class PottsCellStem extends PottsCell { * @param criticalRegionHeights the map of critical heights for regions */ public PottsCellStem(int id, int parent, int pop, CellState state, int age, int divisions, - Location location, boolean hasRegions, MiniBox parameters, - double criticalVolume, double criticalHeight, - EnumMap criticalRegionVolumes, - EnumMap criticalRegionHeights) { + Location location, boolean hasRegions, MiniBox parameters, + double criticalVolume, double criticalHeight, + EnumMap criticalRegionVolumes, + EnumMap criticalRegionHeights) { super(id, parent, pop, state, age, divisions, location, hasRegions, parameters, criticalVolume, criticalHeight, criticalRegionVolumes, criticalRegionHeights); } @Override public PottsCell make(int newID, CellState newState, Location newLocation, - MersenneTwisterFast random) { + MersenneTwisterFast random) { divisions++; return new PottsCellStem(newID, id, pop, newState, age, divisions, newLocation, - hasRegions, parameters, criticalVolume, criticalHeight, - criticalRegionVolumes, criticalRegionHeights); + hasRegions, parameters, criticalVolume, criticalHeight, + criticalRegionVolumes, criticalRegionHeights); } - + @Override - public void setStateModule(CellState newState) { + void setStateModule(CellState newState) { switch ((State) newState) { case QUIESCENT: module = new PottsModuleQuiescence(this); diff --git a/src/arcade/potts/sim/PottsSeries.java b/src/arcade/potts/sim/PottsSeries.java index 850cc333..f479b1dd 100644 --- a/src/arcade/potts/sim/PottsSeries.java +++ b/src/arcade/potts/sim/PottsSeries.java @@ -19,7 +19,7 @@ public final class PottsSeries extends Series { /** Default cell class. */ public static final String DEFAULT_CELL_CLASS = "stem"; - + /** Map of potts settings. */ public MiniBox potts; @@ -190,8 +190,9 @@ protected void updatePopulations(ArrayList populationsBox, MiniBox populati if (populationClass == null) { populationClass = DEFAULT_CELL_CLASS; } - //TODO: Use logger to print message when default class is used. - + + // TODO: Use logger to print message when default class is used. + // Create new population and update code. MiniBox population = new MiniBox(); population.put("CODE", code++); diff --git a/test/arcade/potts/agent/cell/PottsCellStemTest.java b/test/arcade/potts/agent/cell/PottsCellStemTest.java index 1cc59a86..783d67e2 100644 --- a/test/arcade/potts/agent/cell/PottsCellStemTest.java +++ b/test/arcade/potts/agent/cell/PottsCellStemTest.java @@ -56,12 +56,6 @@ public class PottsCellStemTest { static State cellState = State.QUIESCENT; - static PottsCell cellDefault; - - static PottsCell cellWithRegions; - - static PottsCell cellWithoutRegions; - static EnumSet regionList; static MiniBox parametersMock; @@ -176,6 +170,32 @@ public void setState_invalidState_setsNull() { assertNull(cell.getModule()); } + @Test + public void make_noRegions_setsFields() { + double criticalVolume = randomDoubleBetween(10, 100); + double criticalHeight = randomDoubleBetween(10, 100); + MiniBox parameters = mock(MiniBox.class); + Location location1 = mock(PottsLocation.class); + Location location2 = mock(PottsLocation.class); + + PottsCellStem cell1 = new PottsCellStem(cellID, cellParent, cellPop, cellState, cellAge, cellDivisions, + location1, false, parameters, criticalVolume, criticalHeight, + null, null); + PottsCellStem cell2 = (PottsCellStem) cell1.make(cellID + 1, State.QUIESCENT, location2, null); + + assertEquals(cellID + 1, cell2.id); + assertEquals(cellID, cell2.parent); + assertEquals(cellPop, cell2.pop); + assertEquals(cellAge, cell2.getAge()); + assertEquals(cellDivisions + 1, cell1.getDivisions()); + assertEquals(cellDivisions + 1, cell2.getDivisions()); + assertFalse(cell2.hasRegions()); + assertEquals(location2, cell2.getLocation()); + assertEquals(cell2.parameters, parameters); + assertEquals(criticalVolume, cell2.getCriticalVolume(), EPSILON); + assertEquals(criticalHeight, cell2.getCriticalHeight(), EPSILON); + } + @Test public void make_hasRegions_setsFields() { double criticalVolume = randomDoubleBetween(10, 100); diff --git a/test/arcade/potts/agent/cell/PottsCellTest.java b/test/arcade/potts/agent/cell/PottsCellTest.java index cc36b30e..3b504fc8 100644 --- a/test/arcade/potts/agent/cell/PottsCellTest.java +++ b/test/arcade/potts/agent/cell/PottsCellTest.java @@ -75,7 +75,7 @@ public class PottsCellTest { static EnumSet regionList; static MiniBox parametersMock; - + static class PottsCellMock extends PottsCell { PottsCellMock(int id, int parent, int pop, CellState state, int age, int divisions, Location location, boolean hasRegions, MiniBox parameters, @@ -83,20 +83,19 @@ static class PottsCellMock extends PottsCell { EnumMap criticalRegionVolumes, EnumMap criticalRegionHeights) { super(id, parent, pop, state, age, divisions, location, hasRegions, parameters, - criticalVolume, criticalHeight, criticalRegionVolumes, criticalRegionHeights); - + criticalVolume, criticalHeight, criticalRegionVolumes, criticalRegionHeights); } @Override public PottsCellMock make(int newID, CellState newState, Location newLocation, - MersenneTwisterFast random) { + MersenneTwisterFast random) { return new PottsCellMock(newID, id, pop, newState, age, divisions, newLocation, - hasRegions, parameters, criticalVolume, criticalHeight, - criticalRegionVolumes, criticalRegionHeights); + hasRegions, parameters, criticalVolume, criticalHeight, + criticalRegionVolumes, criticalRegionHeights); } @Override - public void setStateModule(CellState newState) { + void setStateModule(CellState newState) { module = mock(PottsModule.class); } } @@ -162,7 +161,7 @@ static PottsCell make(boolean regions) { return make(locationMock, regions); } - static PottsCellMock make(Location location, boolean regions) { + static PottsCell make(Location location, boolean regions) { if (!regions) { return new PottsCellMock(cellID, cellParent, cellPop, cellState, cellAge, cellDivisions, location, false, parametersMock, cellCriticalVolume, cellCriticalHeight, @@ -587,32 +586,6 @@ public void stop_called_callsMethod() { verify(cell.stopper).stop(); } - @Test - public void make_noRegions_setsFields() { - double criticalVolume = randomDoubleBetween(10, 100); - double criticalHeight = randomDoubleBetween(10, 100); - MiniBox parameters = mock(MiniBox.class); - Location location1 = mock(PottsLocation.class); - Location location2 = mock(PottsLocation.class); - - PottsCell cell1 = new PottsCellStem(cellID, cellParent, cellPop, cellState, cellAge, cellDivisions, - location1, false, parameters, criticalVolume, criticalHeight, - null, null); - PottsCell cell2 = (PottsCellStem) cell1.make(cellID + 1, State.QUIESCENT, location2, null); - - assertEquals(cellID + 1, cell2.id); - assertEquals(cellID, cell2.parent); - assertEquals(cellPop, cell2.pop); - assertEquals(cellAge, cell2.getAge()); - assertEquals(cellDivisions + 1, cell1.getDivisions()); - assertEquals(cellDivisions + 1, cell2.getDivisions()); - assertFalse(cell2.hasRegions()); - assertEquals(location2, cell2.getLocation()); - assertEquals(cell2.parameters, parameters); - assertEquals(criticalVolume, cell2.getCriticalVolume(), EPSILON); - assertEquals(criticalHeight, cell2.getCriticalHeight(), EPSILON); - } - @Test public void schedule_validInput_callsMethod() { Schedule schedule = spy(mock(Schedule.class)); @@ -1047,9 +1020,8 @@ public void convert_noRegions_createsContainer() { PottsCell cell = new PottsCellMock(id, parent, pop, state, age, divisions, location, false, parameters, criticalVolume, criticalHeight, null, null); - doReturn(phase).when((PottsModule) cell.getModule()).getPhase(); - + int voxels = randomIntBetween(1, 100); doReturn((double) voxels).when(location).getVolume(); @@ -1094,7 +1066,6 @@ public void convert_withRegions_createsContainer() { PottsCell cell = new PottsCellMock(id, parent, pop, state, age, divisions, location, true, parameters, criticalVolume, criticalHeight, criticalRegionVolumes, criticalRegionHeights); - doReturn(phase).when((PottsModule) cell.getModule()).getPhase(); int voxels = randomIntBetween(1, 100); diff --git a/test/arcade/potts/sim/PottsSeriesTest.java b/test/arcade/potts/sim/PottsSeriesTest.java index 56b364ff..c9c2d2b4 100644 --- a/test/arcade/potts/sim/PottsSeriesTest.java +++ b/test/arcade/potts/sim/PottsSeriesTest.java @@ -12,7 +12,6 @@ import arcade.core.util.MiniBox; import arcade.potts.vis.PottsVisualization; import static org.junit.Assert.*; -import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.*; import static arcade.core.ARCADETestUtilities.*; import static arcade.core.util.MiniBox.TAG_SEPARATOR;