Skip to content

Commit

Permalink
Cleanup tests (#329)
Browse files Browse the repository at this point in the history
* chore: wrote assertEquals in the correct order
  • Loading branch information
asmfstatoil authored Feb 21, 2022
1 parent 26922fe commit b114abd
Show file tree
Hide file tree
Showing 11 changed files with 63 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public void testCompressorSchultzMethod() {
processOps.run();
// System.out.println("schultz compressor power " + compressor1.getPower() / 1e6
// + " MW");
assertEquals(compressor1.getPower() / 1e6, 4.668373797540108,
assertEquals(4.668373797540108, compressor1.getPower() / 1e6,
"Test case for compressor Schultz method polytropic calculation should return approximate 4.67 MW");
}

Expand All @@ -116,7 +116,7 @@ public void testCompressorRigorousMethod() {
processOps.run();
// System.out.println("rigorous compressor power " + compressor1.getPower() /
// 1e6 + " MW");
assertEquals(compressor1.getPower() / 1e6, 4.655081035416562,
assertEquals(4.655081035416562, compressor1.getPower() / 1e6,
"Test case for rigorous polytropic compressor calculation should return approximate 4.66 MW");
}

Expand All @@ -132,7 +132,7 @@ public void testIsentropicCalcMethod() {
processOps.run();
// System.out.println("compressor power " + compressor1.getPower() / 1e6 + "
// MW");
assertEquals(compressor1.getPower() / 1e6, 4.5621157449685);
assertEquals(4.5621157449685, compressor1.getPower() / 1e6);
}

/**
Expand All @@ -159,7 +159,7 @@ public void testCompressorWithSrk() {
// System.out.println("srk fluid head " + compressor1.getPolytropicFluidHead() +
// " kJ/kg");
// System.out.println("srk power " + compressor1.getPower() + " W");
assertEquals(compressor1.getPolytropicEfficiency() * 100, 88.94871563458828,
assertEquals(88.94871563458828, compressor1.getPolytropicEfficiency() * 100,
"Test case for rigorous polytropic efficiency with SRK calculation should return approximate 88.948715 ");
}

Expand Down Expand Up @@ -189,7 +189,7 @@ public void testCompressorWithGERG2008() {
// System.out.println("gerg fluid head " + compressor1.getPolytropicFluidHead()
// + " kJ/kg");
// System.out.println("gerg power " + compressor1.getPower() + " W");
assertEquals(compressor1.getPolytropicEfficiency() * 100, 89.99367027631443,
assertEquals(89.99367027631443, compressor1.getPolytropicEfficiency() * 100,
"Test case for rigorous polytropic efficiency with GER2008 calculation should return approximate 89.992296751");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public void setUp() {
public void testGetName() {
String name = "TestProsess";
p.setName(name);
Assertions.assertEquals(p.getName(), name);
Assertions.assertEquals(name, p.getName());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ void testGetName() {
@Test
public void testSetTimeStep() {
double timeStep = p.getTimeStep() * 2;
Assertions.assertEquals(p.getTimeStep(), timeStep / 2);
Assertions.assertNotEquals(p.getTimeStep(), timeStep);
Assertions.assertEquals(timeStep / 2, p.getTimeStep());
Assertions.assertNotEquals(timeStep, p.getTimeStep());

p.setTimeStep(timeStep);
Assertions.assertEquals(p.getTimeStep(), timeStep);
Assertions.assertNotEquals(p.getTimeStep(), timeStep / 2);
Assertions.assertEquals(timeStep, p.getTimeStep());
Assertions.assertNotEquals(timeStep / 2, p.getTimeStep());
}

@Test
Expand All @@ -55,47 +55,47 @@ void testAdd() {

Assertions.assertTrue(sep == p.getUnit(sepName));

Assertions.assertEquals(list.size(), 1);
Assertions.assertEquals(p.size(), 1);
Assertions.assertEquals(1, list.size());
Assertions.assertEquals(1, p.size());

Assertions.assertTrue((Separator) list.get(0) == sep);

p.removeUnit(sepName);
Assertions.assertNull(p.getUnit(sepName));
Assertions.assertEquals(p.size(), 0);
Assertions.assertEquals(0, p.size());

list = p.getUnitOperations();

Assertions.assertEquals(list.size(), 0);
Assertions.assertEquals(0, list.size());

p.add(sep);
Assertions.assertEquals(p.size(), 1);
Assertions.assertEquals(1, p.size());

p.clear();
Assertions.assertEquals(p.size(), 0);
Assertions.assertEquals(0, p.size());

p.add(sep);
Assertions.assertEquals(p.size(), 1);
Assertions.assertEquals(1, p.size());

p.clearAll();
Assertions.assertEquals(p.size(), 0);
Assertions.assertEquals(0, p.size());
}

@Test
public void testAddUnitTwice() {
Separator sep = new Separator();
p.add(sep);
p.add(sep); // Won't add the copy
Assertions.assertEquals(p.size(), 1);
Assertions.assertEquals(1, p.size());
}

@Test
public void testRemoveUnit() {
Separator sep = new Separator();
p.add(sep);
Assertions.assertEquals(p.size(), 1);
Assertions.assertEquals(1, p.size());
p.removeUnit("");
Assertions.assertEquals(p.size(), 0);
Assertions.assertEquals(0, p.size());
}


Expand All @@ -105,11 +105,11 @@ public void testAddUnitsWithNoName() {
p.add(sep);
sep = new Separator();
p.add(sep);
Assertions.assertEquals(p.size(), 2);
Assertions.assertEquals(2, p.size());
p.removeUnit("Separator2");
Assertions.assertEquals(p.size(), 1);
Assertions.assertEquals(1, p.size());
p.removeUnit("");
Assertions.assertEquals(p.size(), 0);
Assertions.assertEquals(0, p.size());
}

@Test
Expand All @@ -119,21 +119,21 @@ public void testGetUnitNumber() {
Separator sep2 = new Separator();
p.add(sep2);

Assertions.assertEquals(p.getUnitNumber(""), 0);
Assertions.assertEquals(p.getUnitNumber("Separator2"), 1);
Assertions.assertEquals(0, p.getUnitNumber(""));
Assertions.assertEquals(1, p.getUnitNumber("Separator2"));

p.removeUnit("");
p.add(sep);

Assertions.assertEquals(p.getUnitNumber("Separator2"), 0);
Assertions.assertEquals(p.getUnitNumber(""), 1);
Assertions.assertEquals(0, p.getUnitNumber("Separator2"));
Assertions.assertEquals(1, p.getUnitNumber(""));
}

@Test
public void testSetSurroundingTemperature() {
double temp = 200;
p.setSurroundingTemperature(temp);
Assertions.assertEquals(p.getSurroundingTemperature(), temp);
Assertions.assertEquals(temp, p.getSurroundingTemperature());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package neqsim.processSimulation.util.example;

import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;

import neqsim.processSimulation.processEquipment.stream.Stream;

class process1Test {
Expand Down Expand Up @@ -48,6 +48,5 @@ void tearDown() throws Exception {}
@Test
void runTest() {
operations.run();
assertEquals(2, 2);
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package neqsim.thermo.system;

import static org.junit.jupiter.api.Assertions.assertEquals;

import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

import neqsim.thermodynamicOperations.ThermodynamicOperations;

/**
Expand Down Expand Up @@ -55,7 +57,7 @@ public void testTPflash() {

thermoSystem.init();
testOps.TPflash();
assertEquals(thermoSystem.getNumberOfPhases(), 2);
assertEquals(2, thermoSystem.getNumberOfPhases());
}

/**
Expand Down
10 changes: 6 additions & 4 deletions src/test/java/neqsim/thermo/system/SystemPrEosTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

import neqsim.thermodynamicOperations.ThermodynamicOperations;

class SystemPrEoSTest {
Expand Down Expand Up @@ -39,7 +41,7 @@ public static void setUp() {
@Test
@DisplayName("test a TPflash2")
public void testTPflash2() {
assertEquals(testSystem.getNumberOfPhases(), 2);
assertEquals(2, testSystem.getNumberOfPhases());
}

/**
Expand All @@ -50,7 +52,7 @@ public void testTPflash2() {
@Test
@DisplayName("test a TPflash of the fluid (should return two phases)")
public void testTPflash() {
assertEquals(testSystem.getNumberOfPhases(), 2);
assertEquals(2, testSystem.getNumberOfPhases());
}

/**
Expand Down Expand Up @@ -116,7 +118,7 @@ public void checkFugacityCoefficientsDn2() {
@Test
@DisplayName("calculate compressibility of gas phase")
public void checkCompressibility() {
assertEquals(testSystem.getPhase("gas").getZ(), 0.9708455641951108, 1e-5);
assertEquals(0.9708455641951108, testSystem.getPhase("gas").getZ(), 1e-5);
}

/**
Expand All @@ -131,7 +133,7 @@ public void calcProperties() {
ThermodynamicOperations testOps = new ThermodynamicOperations(testSystem);
testOps.TPflash();
testSystem.initProperties();
assertEquals(testSystem.getEnthalpy("kJ/kg"), -165.60627184389855,
assertEquals(-165.60627184389855, testSystem.getEnthalpy("kJ/kg"),
Math.abs(-165.60627184389855 / 1000.0));
}
}
12 changes: 5 additions & 7 deletions src/test/java/neqsim/thermo/system/SystemSrkCPAstatoilTest.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package neqsim.thermo.system;

import static org.junit.jupiter.api.Assertions.assertEquals;

import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

import neqsim.thermodynamicOperations.ThermodynamicOperations;

/**
Expand Down Expand Up @@ -43,7 +45,7 @@ public static void setUp() {
public void testTPflash() {
ThermodynamicOperations testOps = new ThermodynamicOperations(thermoSystem);
testOps.TPflash();
assertEquals(thermoSystem.getNumberOfPhases(), 2);
assertEquals(2, thermoSystem.getNumberOfPhases());
}

/**
Expand Down Expand Up @@ -72,9 +74,7 @@ public void testPHflash() {
testOps.PHflash(enthalpy + 10.0);
thermoSystem.init(3);

double enthalpy2 = thermoSystem.getEnthalpy();

assertEquals(Math.round(enthalpy + 10.0), Math.round(enthalpy2));
assertEquals(Math.round(enthalpy + 10.0), Math.round(thermoSystem.getEnthalpy()));
}

/**
Expand All @@ -91,8 +91,6 @@ public void testPSflash() {
testOps.PSflash(entropy + 10.0);
thermoSystem.init(3);

double entropy2 = thermoSystem.getEntropy();

assertEquals(Math.round(entropy + 10.0), Math.round(entropy2));
assertEquals(Math.round(entropy + 10.0), Math.round(thermoSystem.getEntropy()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

import neqsim.thermodynamicOperations.ThermodynamicOperations;

@Disabled
Expand Down Expand Up @@ -44,7 +46,7 @@ public static void setUp() {
@Test
@DisplayName("test a TPflash2")
public void testTPflash2() {
assertEquals(testSystem.getNumberOfPhases(), 2);
assertEquals(2, testSystem.getNumberOfPhases());
}

/**
Expand All @@ -55,7 +57,7 @@ public void testTPflash2() {
@Test
@DisplayName("test a TPflash of the fluid (should return two phases)")
public void testTPflash() {
assertEquals(testSystem.getNumberOfPhases(), 2);
assertEquals(2, testSystem.getNumberOfPhases());
}

/**
Expand Down
14 changes: 6 additions & 8 deletions src/test/java/neqsim/thermo/util/example/SrkEoSTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

import neqsim.thermo.system.SystemInterface;
import neqsim.thermo.system.SystemSrkEos;
import neqsim.thermodynamicOperations.ThermodynamicOperations;
import org.junit.jupiter.api.Disabled;

/**
* <p>
Expand Down Expand Up @@ -47,7 +49,7 @@ public static void setUp() {
public void testTPflash() {
ThermodynamicOperations testOps = new ThermodynamicOperations(thermoSystem);
testOps.TPflash();
assertEquals(thermoSystem.getNumberOfPhases(), 2);
assertEquals(2, thermoSystem.getNumberOfPhases());
}

/**
Expand Down Expand Up @@ -89,9 +91,7 @@ public void testPHflash() {
testOps.PHflash(enthalpy + 10.0);
thermoSystem.init(3);

double enthalpy2 = thermoSystem.getEnthalpy();

assertEquals(Math.round(enthalpy + 10.0), Math.round(enthalpy2));
assertEquals(Math.round(enthalpy + 10.0), Math.round(thermoSystem.getEnthalpy()));
}

/**
Expand All @@ -108,8 +108,6 @@ public void testPSflash() {
testOps.PSflash(entropy + 10.0);
thermoSystem.init(3);

double entropy2 = thermoSystem.getEntropy();

assertEquals(Math.round(entropy + 10.0), Math.round(entropy2));
assertEquals(Math.round(entropy + 10.0), Math.round(thermoSystem.getEntropy()));
}
}
Loading

0 comments on commit b114abd

Please sign in to comment.