Skip to content

Commit

Permalink
adding metabolism tests for CART cells
Browse files Browse the repository at this point in the history
  • Loading branch information
allison-li-1016 committed Dec 26, 2024
1 parent b0b31d3 commit edd42cb
Showing 1 changed file with 317 additions and 0 deletions.
317 changes: 317 additions & 0 deletions test/arcade/patch/agent/process/PatchProcessMetabolismCARTTest.java
Original file line number Diff line number Diff line change
@@ -1,2 +1,319 @@
package arcade.patch.agent.process;

import java.lang.reflect.Field;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import ec.util.MersenneTwisterFast;
import arcade.core.sim.Simulation;
import arcade.core.util.Parameters;
import arcade.patch.agent.cell.PatchCellCART;
import arcade.patch.env.location.PatchLocation;
import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.*;
import static arcade.core.ARCADETestUtilities.randomDoubleBetween;

public class PatchProcessMetabolismCARTTest {

private PatchCellCART mockCell;
private Parameters mockParameters;

Check failure on line 18 in test/arcade/patch/agent/process/PatchProcessMetabolismCARTTest.java

View workflow job for this annotation

GitHub Actions / checkstyle

[checkstyle] test/arcade/patch/agent/process/PatchProcessMetabolismCARTTest.java#L18 <com.puppycrawl.tools.checkstyle.checks.whitespace.EmptyLineSeparatorCheck>

'VARIABLE_DEF' should be separated from previous line.
Raw output
/github/workspace/./test/arcade/patch/agent/process/PatchProcessMetabolismCARTTest.java:18:5: error: 'VARIABLE_DEF' should be separated from previous line. (com.puppycrawl.tools.checkstyle.checks.whitespace.EmptyLineSeparatorCheck)
private PatchProcessMetabolismCART metabolism;

Check failure on line 19 in test/arcade/patch/agent/process/PatchProcessMetabolismCARTTest.java

View workflow job for this annotation

GitHub Actions / checkstyle

[checkstyle] test/arcade/patch/agent/process/PatchProcessMetabolismCARTTest.java#L19 <com.puppycrawl.tools.checkstyle.checks.whitespace.EmptyLineSeparatorCheck>

'VARIABLE_DEF' should be separated from previous line.
Raw output
/github/workspace/./test/arcade/patch/agent/process/PatchProcessMetabolismCARTTest.java:19:5: error: 'VARIABLE_DEF' should be separated from previous line. (com.puppycrawl.tools.checkstyle.checks.whitespace.EmptyLineSeparatorCheck)
private PatchLocation mockLocation;

Check failure on line 20 in test/arcade/patch/agent/process/PatchProcessMetabolismCARTTest.java

View workflow job for this annotation

GitHub Actions / checkstyle

[checkstyle] test/arcade/patch/agent/process/PatchProcessMetabolismCARTTest.java#L20 <com.puppycrawl.tools.checkstyle.checks.whitespace.EmptyLineSeparatorCheck>

'VARIABLE_DEF' should be separated from previous line.
Raw output
/github/workspace/./test/arcade/patch/agent/process/PatchProcessMetabolismCARTTest.java:20:5: error: 'VARIABLE_DEF' should be separated from previous line. (com.puppycrawl.tools.checkstyle.checks.whitespace.EmptyLineSeparatorCheck)

@BeforeEach

Check failure on line 22 in test/arcade/patch/agent/process/PatchProcessMetabolismCARTTest.java

View workflow job for this annotation

GitHub Actions / checkstyle

[checkstyle] test/arcade/patch/agent/process/PatchProcessMetabolismCARTTest.java#L22 <com.puppycrawl.tools.checkstyle.checks.design.DesignForExtensionCheck>

Class 'PatchProcessMetabolismCARTTest' looks like designed for extension (can be subclassed), but the method 'setUp' does not have javadoc that explains how to do that safely. If class is not designed for extension consider making the class 'PatchProcessMetabolismCARTTest' final or making the method 'setUp' static/final/abstract/empty, or adding allowed annotation for the method.
Raw output
/github/workspace/./test/arcade/patch/agent/process/PatchProcessMetabolismCARTTest.java:22:5: error: Class 'PatchProcessMetabolismCARTTest' looks like designed for extension (can be subclassed), but the method 'setUp' does not have javadoc that explains how to do that safely. If class is not designed for extension consider making the class 'PatchProcessMetabolismCARTTest' final or making the method 'setUp' static/final/abstract/empty, or adding allowed annotation for the method. (com.puppycrawl.tools.checkstyle.checks.design.DesignForExtensionCheck)
public void setUp() {
mockCell = mock(PatchCellCART.class);
mockParameters = mock(Parameters.class);
mockLocation = mock(PatchLocation.class);

when(mockCell.getParameters()).thenReturn(mockParameters);
when(mockParameters.getDouble(anyString())).thenReturn(1.0);
when(mockCell.getLocation()).thenReturn(mockLocation);
when(mockCell.getVolume()).thenReturn(randomDoubleBetween(165, 180));
when(mockLocation.getPerimeter(anyDouble()))
.thenReturn(randomDoubleBetween(0, 1.0) * 6 * 30 / Math.sqrt(3));
when(mockLocation.getArea()).thenReturn(3.0 / 2.0 / Math.sqrt(3.0) * 30 * 30);
when(mockLocation.getVolume()).thenReturn(3.0 / 2.0 / Math.sqrt(3.0) * 30 * 30 * 8.7);
}

@Test
public void testConstructorInitializesFields()
throws NoSuchFieldException, IllegalAccessException {
metabolism = new PatchProcessMetabolismCART(mockCell);

assertNotNull(metabolism);

Field metaPrefField = PatchProcessMetabolismCART.class.getDeclaredField("metaPref");
metaPrefField.setAccessible(true);
assertEquals(1.0, metaPrefField.get(metabolism));

Field conversionFractionField =
PatchProcessMetabolismCART.class.getDeclaredField("conversionFraction");
conversionFractionField.setAccessible(true);
assertEquals(1.0, conversionFractionField.get(metabolism));

Field fracMassField = PatchProcessMetabolismCART.class.getDeclaredField("fracMass");
fracMassField.setAccessible(true);
assertEquals(1.0, fracMassField.get(metabolism));

Field ratioGlucosePyruvateField =
PatchProcessMetabolismCART.class.getDeclaredField("ratioGlucosePyruvate");
ratioGlucosePyruvateField.setAccessible(true);
assertEquals(1.0, ratioGlucosePyruvateField.get(metabolism));

Field lactateRateField = PatchProcessMetabolismCART.class.getDeclaredField("lactateRate");
lactateRateField.setAccessible(true);
assertEquals(1.0, lactateRateField.get(metabolism));

Field autophagyRateField =
PatchProcessMetabolismCART.class.getDeclaredField("autophagyRate");
autophagyRateField.setAccessible(true);
assertEquals(1.0, autophagyRateField.get(metabolism));

Field glucUptakeRateField =
PatchProcessMetabolismCART.class.getDeclaredField("glucUptakeRate");
glucUptakeRateField.setAccessible(true);
assertEquals(1.0, glucUptakeRateField.get(metabolism));

Field metabolicPreference_IL2Field =

Check failure on line 77 in test/arcade/patch/agent/process/PatchProcessMetabolismCARTTest.java

View workflow job for this annotation

GitHub Actions / checkstyle

[checkstyle] test/arcade/patch/agent/process/PatchProcessMetabolismCARTTest.java#L77 <com.puppycrawl.tools.checkstyle.checks.naming.LocalVariableNameCheck>

Name 'metabolicPreference_IL2Field' must match pattern '^[a-z][a-zA-Z0-9]*$'.
Raw output
/github/workspace/./test/arcade/patch/agent/process/PatchProcessMetabolismCARTTest.java:77:15: error: Name 'metabolicPreference_IL2Field' must match pattern '^[a-z][a-zA-Z0-9]*$'. (com.puppycrawl.tools.checkstyle.checks.naming.LocalVariableNameCheck)
PatchProcessMetabolismCART.class.getDeclaredField("metabolicPreference_IL2");
metabolicPreference_IL2Field.setAccessible(true);
assertEquals(1.0, metabolicPreference_IL2Field.get(metabolism));

Field metabolicPreference_activeField =

Check failure on line 82 in test/arcade/patch/agent/process/PatchProcessMetabolismCARTTest.java

View workflow job for this annotation

GitHub Actions / checkstyle

[checkstyle] test/arcade/patch/agent/process/PatchProcessMetabolismCARTTest.java#L82 <com.puppycrawl.tools.checkstyle.checks.naming.LocalVariableNameCheck>

Name 'metabolicPreference_activeField' must match pattern '^[a-z][a-zA-Z0-9]*$'.
Raw output
/github/workspace/./test/arcade/patch/agent/process/PatchProcessMetabolismCARTTest.java:82:15: error: Name 'metabolicPreference_activeField' must match pattern '^[a-z][a-zA-Z0-9]*$'. (com.puppycrawl.tools.checkstyle.checks.naming.LocalVariableNameCheck)
PatchProcessMetabolismCART.class.getDeclaredField("metabolicPreference_active");
metabolicPreference_activeField.setAccessible(true);
assertEquals(1.0, metabolicPreference_activeField.get(metabolism));

Field glucoseUptakeRate_IL2Field =

Check failure on line 87 in test/arcade/patch/agent/process/PatchProcessMetabolismCARTTest.java

View workflow job for this annotation

GitHub Actions / checkstyle

[checkstyle] test/arcade/patch/agent/process/PatchProcessMetabolismCARTTest.java#L87 <com.puppycrawl.tools.checkstyle.checks.naming.LocalVariableNameCheck>

Name 'glucoseUptakeRate_IL2Field' must match pattern '^[a-z][a-zA-Z0-9]*$'.
Raw output
/github/workspace/./test/arcade/patch/agent/process/PatchProcessMetabolismCARTTest.java:87:15: error: Name 'glucoseUptakeRate_IL2Field' must match pattern '^[a-z][a-zA-Z0-9]*$'. (com.puppycrawl.tools.checkstyle.checks.naming.LocalVariableNameCheck)
PatchProcessMetabolismCART.class.getDeclaredField("glucoseUptakeRate_IL2");
glucoseUptakeRate_IL2Field.setAccessible(true);
assertEquals(1.0, glucoseUptakeRate_IL2Field.get(metabolism));

Field glucoseUptakeRate_activeField =

Check failure on line 92 in test/arcade/patch/agent/process/PatchProcessMetabolismCARTTest.java

View workflow job for this annotation

GitHub Actions / checkstyle

[checkstyle] test/arcade/patch/agent/process/PatchProcessMetabolismCARTTest.java#L92 <com.puppycrawl.tools.checkstyle.checks.naming.LocalVariableNameCheck>

Name 'glucoseUptakeRate_activeField' must match pattern '^[a-z][a-zA-Z0-9]*$'.
Raw output
/github/workspace/./test/arcade/patch/agent/process/PatchProcessMetabolismCARTTest.java:92:15: error: Name 'glucoseUptakeRate_activeField' must match pattern '^[a-z][a-zA-Z0-9]*$'. (com.puppycrawl.tools.checkstyle.checks.naming.LocalVariableNameCheck)
PatchProcessMetabolismCART.class.getDeclaredField("glucoseUptakeRate_active");
glucoseUptakeRate_activeField.setAccessible(true);
assertEquals(1.0, glucoseUptakeRate_activeField.get(metabolism));

Field minimumMassFraction_activeField =

Check failure on line 97 in test/arcade/patch/agent/process/PatchProcessMetabolismCARTTest.java

View workflow job for this annotation

GitHub Actions / checkstyle

[checkstyle] test/arcade/patch/agent/process/PatchProcessMetabolismCARTTest.java#L97 <com.puppycrawl.tools.checkstyle.checks.naming.LocalVariableNameCheck>

Name 'minimumMassFraction_activeField' must match pattern '^[a-z][a-zA-Z0-9]*$'.
Raw output
/github/workspace/./test/arcade/patch/agent/process/PatchProcessMetabolismCARTTest.java:97:15: error: Name 'minimumMassFraction_activeField' must match pattern '^[a-z][a-zA-Z0-9]*$'. (com.puppycrawl.tools.checkstyle.checks.naming.LocalVariableNameCheck)
PatchProcessMetabolismCART.class.getDeclaredField("minimumMassFraction_active");
minimumMassFraction_activeField.setAccessible(true);
assertEquals(1.0, minimumMassFraction_activeField.get(metabolism));

Field timeDelayField = PatchProcessMetabolismCART.class.getDeclaredField("timeDelay");
timeDelayField.setAccessible(true);
assertEquals(1, timeDelayField.get(metabolism));
}

@Test
public void testStepProcess() throws NoSuchFieldException, IllegalAccessException {
// set up metabolism class
when(mockParameters.getDouble("metabolism/GLUCOSE_UPTAKE_RATE")).thenReturn(1.12);
when(mockParameters.getDouble("metabolism/INITIAL_GLUCOSE_CONCENTRATION")).thenReturn(0.05);
metabolism = new PatchProcessMetabolismCART(mockCell);
Field fraction = PatchProcessMetabolism.class.getDeclaredField("f");
fraction.setAccessible(true);
fraction.set(metabolism, 1.0);

// set up simulation
MersenneTwisterFast random = new MersenneTwisterFast();
Simulation sim = mock(Simulation.class);

// mock inflammation process
PatchProcessInflammation inflammation = spy(new PatchProcessInflammationCD4(mockCell));
when(mockCell.getProcess(any())).thenReturn(inflammation);
when(mockCell.getActivationStatus()).thenReturn(true);

metabolism.stepProcess(random, sim);

assertTrue(metabolism.intAmts[PatchProcessMetabolismCART.GLUCOSE] >= 0);
assertTrue(metabolism.intAmts[PatchProcessMetabolismCART.PYRUVATE] >= 0);
}

@Test
public void testStepProcessWithZeroInitialGlucose() {
// set up metabolism class
when(mockParameters.getDouble("metabolism/GLUCOSE_UPTAKE_RATE")).thenReturn(1.12);
when(mockParameters.getDouble("metabolism/INITIAL_GLUCOSE_CONCENTRATION")).thenReturn(0.0);
metabolism = new PatchProcessMetabolismCART(mockCell);

// set up simulation
MersenneTwisterFast random = new MersenneTwisterFast();
Simulation sim = mock(Simulation.class);

// mock inflammation process
PatchProcessInflammation inflammation = spy(new PatchProcessInflammationCD4(mockCell));
when(mockCell.getProcess(any())).thenReturn(inflammation);
when(mockCell.getActivationStatus()).thenReturn(true);

metabolism.stepProcess(random, sim);

assertEquals(0.0, metabolism.intAmts[PatchProcessMetabolismCART.GLUCOSE]);
}

@Test
public void testStepProcessWithMaxGlucoseConcentration() {
// set up metabolism class
when(mockParameters.getDouble("metabolism/GLUCOSE_UPTAKE_RATE")).thenReturn(1.12);
when(mockParameters.getDouble("metabolism/INITIAL_GLUCOSE_CONCENTRATION"))
.thenReturn(Double.MAX_VALUE);
metabolism = new PatchProcessMetabolismCART(mockCell);

// set up simulation
MersenneTwisterFast random = new MersenneTwisterFast();
Simulation sim = mock(Simulation.class);

// mock inflammation process
PatchProcessInflammation inflammation = spy(new PatchProcessInflammationCD4(mockCell));
when(mockCell.getProcess(any())).thenReturn(inflammation);
when(mockCell.getActivationStatus()).thenReturn(true);

metabolism.stepProcess(random, sim);

assertTrue(metabolism.intAmts[PatchProcessMetabolismCART.GLUCOSE] <= Double.MAX_VALUE);
}

@Test
public void testStepProcessWithNegativeGlucoseConcentration() {
// set up metabolism class
when(mockParameters.getDouble("metabolism/GLUCOSE_UPTAKE_RATE")).thenReturn(1.12);
when(mockParameters.getDouble("metabolism/INITIAL_GLUCOSE_CONCENTRATION")).thenReturn(-1.0);
metabolism = new PatchProcessMetabolismCART(mockCell);

// set up simulation
MersenneTwisterFast random = new MersenneTwisterFast();
Simulation sim = mock(Simulation.class);

// mock inflammation process
PatchProcessInflammation inflammation = spy(new PatchProcessInflammationCD4(mockCell));
when(mockCell.getProcess(any())).thenReturn(inflammation);
when(mockCell.getActivationStatus()).thenReturn(true);

metabolism.stepProcess(random, sim);

assertTrue(metabolism.intAmts[PatchProcessMetabolismCART.GLUCOSE] >= 0);
}

@Test
public void testStepProcessWithZeroOxygenConcentration() {
// set up metabolism class
when(mockParameters.getDouble("metabolism/GLUCOSE_UPTAKE_RATE")).thenReturn(1.12);
when(mockParameters.getDouble("metabolism/INITIAL_GLUCOSE_CONCENTRATION")).thenReturn(0.05);
metabolism = new PatchProcessMetabolismCART(mockCell);

// set up simulation
MersenneTwisterFast random = new MersenneTwisterFast();
Simulation sim = mock(Simulation.class);

// mock inflammation process
PatchProcessInflammation inflammation = spy(new PatchProcessInflammationCD4(mockCell));
when(mockCell.getProcess(any())).thenReturn(inflammation);
when(mockCell.getActivationStatus()).thenReturn(true);

metabolism.extAmts[PatchProcessMetabolismCART.OXYGEN] = 0.0;

metabolism.stepProcess(random, sim);

assertEquals(0.0, metabolism.extAmts[PatchProcessMetabolismCART.OXYGEN]);
}

@Test
public void testStepProcessWithMaxOxygenConcentration() {
// set up metabolism class
when(mockParameters.getDouble("metabolism/GLUCOSE_UPTAKE_RATE")).thenReturn(1.12);
when(mockParameters.getDouble("metabolism/INITIAL_GLUCOSE_CONCENTRATION")).thenReturn(0.05);
metabolism = new PatchProcessMetabolismCART(mockCell);

// set up simulation
MersenneTwisterFast random = new MersenneTwisterFast();
Simulation sim = mock(Simulation.class);

// mock inflammation process
PatchProcessInflammation inflammation = spy(new PatchProcessInflammationCD4(mockCell));
when(mockCell.getProcess(any())).thenReturn(inflammation);
when(mockCell.getActivationStatus()).thenReturn(true);

metabolism.extAmts[PatchProcessMetabolismCART.OXYGEN] = Double.MAX_VALUE;

metabolism.stepProcess(random, sim);

assertTrue(metabolism.extAmts[PatchProcessMetabolismCART.OXYGEN] <= Double.MAX_VALUE);
}

@Test
public void testActivatedMetabolicPreference()
throws IllegalAccessException, NoSuchFieldException {
// set up metabolism class
when(mockParameters.getDouble("metabolism/GLUCOSE_UPTAKE_RATE")).thenReturn(1.12);
when(mockParameters.getDouble("metabolism/INITIAL_GLUCOSE_CONCENTRATION")).thenReturn(0.05);
metabolism = new PatchProcessMetabolismCART(mockCell);

// set up simulation
MersenneTwisterFast random = new MersenneTwisterFast();
Simulation sim = mock(Simulation.class);

// mock inflammation process
PatchProcessInflammation inflammation = spy(new PatchProcessInflammationCD4(mockCell));
Field activeTicker = PatchProcessInflammation.class.getDeclaredField("activeTicker");
activeTicker.setAccessible(true);
activeTicker.set(inflammation, 1);
when(mockCell.getProcess(any())).thenReturn(inflammation);
when(mockCell.getActivationStatus()).thenReturn(true);

metabolism.stepProcess(random, sim);

double expectedMetabolicPreference = 1.0 + 1.0; // base + active
assertEquals(expectedMetabolicPreference, metabolism.getFinalMetabolicPreference());
}

@Test
public void testActivatedGlucoseUptakeRate()
throws IllegalAccessException, NoSuchFieldException {
// set up metabolism class
when(mockParameters.getDouble("metabolism/GLUCOSE_UPTAKE_RATE")).thenReturn(1.12);
when(mockParameters.getDouble("metabolism/INITIAL_GLUCOSE_CONCENTRATION")).thenReturn(0.05);
metabolism = new PatchProcessMetabolismCART(mockCell);

// set up simulation
MersenneTwisterFast random = new MersenneTwisterFast();
Simulation sim = mock(Simulation.class);

// mock inflammation process
PatchProcessInflammation inflammation = spy(new PatchProcessInflammationCD4(mockCell));
Field activeTicker = PatchProcessInflammation.class.getDeclaredField("activeTicker");
activeTicker.setAccessible(true);
activeTicker.set(inflammation, 1);
when(mockCell.getProcess(any())).thenReturn(inflammation);
when(mockCell.getActivationStatus()).thenReturn(true);

metabolism.stepProcess(random, sim);

double expectedGlucoseUptakeRate = 1.12 + 1.0; // base + active
assertEquals(expectedGlucoseUptakeRate, metabolism.getFinalGlucoseUptakeRate());
}

@Test
public void testActivatedMinimumMassFraction()
throws NoSuchFieldException, IllegalAccessException {
// set up metabolism class
when(mockParameters.getDouble("metabolism/GLUCOSE_UPTAKE_RATE")).thenReturn(1.12);
when(mockParameters.getDouble("metabolism/INITIAL_GLUCOSE_CONCENTRATION")).thenReturn(0.05);
metabolism = new PatchProcessMetabolismCART(mockCell);

// set up simulation
MersenneTwisterFast random = new MersenneTwisterFast();
Simulation sim = mock(Simulation.class);

// mock inflammation process
PatchProcessInflammation inflammation = spy(new PatchProcessInflammationCD4(mockCell));
Field activeTicker = PatchProcessInflammation.class.getDeclaredField("activeTicker");
activeTicker.setAccessible(true);
activeTicker.set(inflammation, 1);
when(mockCell.getProcess(any())).thenReturn(inflammation);
when(mockCell.getActivationStatus()).thenReturn(true);

metabolism.stepProcess(random, sim);

double expectedMinimumMassFraction = 1.0 + 1.0; // base + active
assertEquals(expectedMinimumMassFraction, metabolism.getFinalMinimumMassFraction());
}
}

0 comments on commit edd42cb

Please sign in to comment.