update unit test to distinguish between motors based on descriptor.

This commit is contained in:
JoePfeiffer 2022-12-19 15:27:23 -07:00
parent 9145511f46
commit d8e9257623

View File

@ -23,7 +23,7 @@ public class ThrustCurveMotorSetTest {
private static final ThrustCurveMotor motor1 = new ThrustCurveMotor.Builder()
.setManufacturer(Manufacturer.getManufacturer("A"))
.setCommonName("F12")
.setDesignation("F12X")
.setDesignation("F12")
.setDescription("Desc")
.setMotorType(Motor.Type.UNKNOWN)
.setStandardDelays(new double[] {})
@ -38,7 +38,7 @@ public class ThrustCurveMotorSetTest {
private static final ThrustCurveMotor motor2 = new ThrustCurveMotor.Builder()
.setManufacturer(Manufacturer.getManufacturer("A"))
.setCommonName("F12")
.setDesignation("F12H")
.setDesignation("F12")
.setDescription("Desc")
.setMotorType(Motor.Type.SINGLE)
.setStandardDelays(new double[] { 5 })
@ -51,20 +51,6 @@ public class ThrustCurveMotorSetTest {
.build();
private static final ThrustCurveMotor motor3 = new ThrustCurveMotor.Builder()
.setManufacturer(Manufacturer.getManufacturer("A"))
.setCode("F12")
.setDescription("Desc")
.setMotorType(Motor.Type.UNKNOWN)
.setStandardDelays(new double[] { 0, Motor.PLUGGED_DELAY })
.setDiameter(0.024)
.setLength(0.07)
.setTimePoints(new double[] { 0, 1, 2 })
.setThrustPoints(new double[] { 0, 2, 0 })
.setCGPoints(new Coordinate[] { Coordinate.NUL, Coordinate.NUL, Coordinate.NUL })
.setDigest("digestC")
.build();
private static final ThrustCurveMotor motor4 = new ThrustCurveMotor.Builder()
.setManufacturer(Manufacturer.getManufacturer("A"))
.setDesignation("F12")
.setDescription("Desc")
@ -113,39 +99,20 @@ public class ThrustCurveMotorSetTest {
// Add motor2
assertTrue(set.matches(motor2));
set.addMotor(motor2);
assertEquals(motor1.getManufacturer(), set.getManufacturer());
assertEquals(motor3.getCommonName(), set.getCommonName());
assertEquals(motor2.getManufacturer(), set.getManufacturer());
assertEquals(motor2.getCommonName(), set.getCommonName());
assertEquals(Motor.Type.SINGLE, set.getType());
assertEquals(motor1.getDiameter(), set.getDiameter(), 0.00001);
assertEquals(motor1.getLength(), set.getLength(), 0.00001);
assertEquals(motor2.getDiameter(), set.getDiameter(), 0.00001);
assertEquals(motor2.getLength(), set.getLength(), 0.00001);
assertEquals(2, set.getMotors().size());
assertEquals(motor2, set.getMotors().get(0));
assertEquals(motor1, set.getMotors().get(1));
assertEquals(motor1, set.getMotors().get(0));
assertEquals(motor2, set.getMotors().get(1));
assertEquals(Arrays.asList(5.0), set.getDelays());
// Add motor3
assertTrue(set.matches(motor3));
set.addMotor(motor3);
assertEquals(motor1.getManufacturer(), set.getManufacturer());
assertEquals(motor3.getCommonName(), set.getCommonName());
assertEquals(Motor.Type.SINGLE, set.getType());
assertEquals(motor1.getDiameter(), set.getDiameter(), 0.00001);
assertEquals(motor1.getLength(), set.getLength(), 0.00001);
assertEquals(3, set.getMotors().size());
System.out.println("motor set");
System.out.println(set.getMotors());
System.out.println(motor3);
System.out.println(motor2);
System.out.println(motor1);
assertEquals(motor3, set.getMotors().get(0));
assertEquals(motor2, set.getMotors().get(1));
assertEquals(motor1, set.getMotors().get(2));
assertEquals(Arrays.asList(0.0, 5.0, Motor.PLUGGED_DELAY), set.getDelays());
// Test that adding motor4 fails
assertFalse(set.matches(motor4));
// Test that adding motor3 fails
assertFalse(set.matches(motor3));
try {
set.addMotor(motor4);
set.addMotor(motor3);
fail("Did not throw exception");
} catch (IllegalArgumentException e) {
}