Update unit tests

This commit is contained in:
SiboVG 2023-07-23 02:53:26 +02:00
parent b6235a1630
commit 84ff186d39

View File

@ -86,6 +86,7 @@ public class FlightEventsTest extends BaseTestCase {
public void testMultiStage() throws SimulationException {
final Rocket rocket = TestRockets.makeFalcon9Heavy();
TestRockets.addCoreFins(rocket);
TestRockets.dumpRocket(rocket, "/Users/SiboVanGool/Downloads/f9.ork");
final Simulation sim = new Simulation(rocket);
sim.getOptions().setISAAtmosphere(true);
@ -108,8 +109,8 @@ public class FlightEventsTest extends BaseTestCase {
// events whose time is too variable to check are given a time of 1200
for (int b = 0; b < 3; b++) {
FlightEvent[] expectedEvents;
final RocketComponent[] expectedSources;
switch (b) {
// Sustainer (payload fairing stage)
case 0:
expectedEvents = new FlightEvent[] {
new FlightEvent(FlightEvent.Type.LAUNCH, 0.0, rocket),
@ -129,15 +130,23 @@ public class FlightEventsTest extends BaseTestCase {
new FlightEvent(FlightEvent.Type.SIMULATION_END, 1200, null)
};
break;
// Core stage
case 1:
expectedEvents = new FlightEvent[] {
new FlightEvent(FlightEvent.Type.IGNITION, 0.0, coreBody),
new FlightEvent(FlightEvent.Type.BURNOUT, 2.0, coreBody),
new FlightEvent(FlightEvent.Type.EJECTION_CHARGE, 2.0, coreStage),
new FlightEvent(FlightEvent.Type.STAGE_SEPARATION, 2.0, coreStage),
new FlightEvent(FlightEvent.Type.GROUND_HIT, 1200, null),
new FlightEvent(FlightEvent.Type.SIMULATION_END, 1200, null)
};
break;
// Booster stage
case 2:
expectedEvents = new FlightEvent[] {
new FlightEvent(FlightEvent.Type.IGNITION, 0.0, boosterMotorTubes),
new FlightEvent(FlightEvent.Type.BURNOUT, 2.0, boosterMotorTubes),
new FlightEvent(FlightEvent.Type.EJECTION_CHARGE, 2.0, boosterStage),
new FlightEvent(FlightEvent.Type.STAGE_SEPARATION, 2.0, boosterStage),
new FlightEvent(FlightEvent.Type.TUMBLE, 3.551, null),
new FlightEvent(FlightEvent.Type.GROUND_HIT, 1200, null),
@ -150,10 +159,7 @@ public class FlightEventsTest extends BaseTestCase {
// Test event count
final FlightDataBranch branch = sim.getSimulatedData().getBranch(b);
final FlightEvent[] events = (FlightEvent[]) branch.getEvents().toArray(new FlightEvent[0]);
for (int i = 0; i < events.length; i++) {
System.out.println("branch " + b + " index " + i + " event " + events[i]);
}
final FlightEvent[] events = branch.getEvents().toArray(new FlightEvent[0]);
assertEquals(" Multi-stage simulation, branch " + b + " invalid number of events ", expectedEvents.length, events.length);
// Test that all expected events are present, in the right order, at the right time, from the right sources