[Bugfix] moved ConfigurationTest to FlightConfigurationTest
- in FlightConfiguration: -- adjusted functions to consistently refer to <x>ActiveMotors() -- corresponding functions now act the same way - removed '.release()' calls from FlightConfiguration
This commit is contained in:
parent
af56da4162
commit
bc906c6652
@ -97,7 +97,7 @@ public class RocksimSaver extends RocketSaver {
|
|||||||
final FlightConfiguration configuration = rocket.getDefaultConfiguration();
|
final FlightConfiguration configuration = rocket.getDefaultConfiguration();
|
||||||
final double cg = massCalc.getCG(configuration, MassCalculator.MassCalcType.NO_MOTORS).x *
|
final double cg = massCalc.getCG(configuration, MassCalculator.MassCalcType.NO_MOTORS).x *
|
||||||
RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_LENGTH;
|
RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_LENGTH;
|
||||||
configuration.release();
|
|
||||||
int stageCount = rocket.getStageCount();
|
int stageCount = rocket.getStageCount();
|
||||||
if (stageCount == 3) {
|
if (stageCount == 3) {
|
||||||
result.setStage321CG(cg);
|
result.setStage321CG(cg);
|
||||||
|
@ -21,8 +21,8 @@ import net.sf.openrocket.util.StateChangeListener;
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A class defining a rocket configuration, including which stages are active.
|
* A class defining a rocket configuration.
|
||||||
*
|
* Describes active stages, and active motors.
|
||||||
*
|
*
|
||||||
* @author Sampo Niskanen <sampo.niskanen@iki.fi>
|
* @author Sampo Niskanen <sampo.niskanen@iki.fi>
|
||||||
* @author Daniel Williams <equipoise@gmail.com>
|
* @author Daniel Williams <equipoise@gmail.com>
|
||||||
@ -268,13 +268,6 @@ public class FlightConfiguration implements FlightConfigurableParameter<FlightCo
|
|||||||
return getFlightConfigurationID();
|
return getFlightConfigurationID();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes the listener connection to the rocket and listeners of this object.
|
|
||||||
* This configuration may not be used after a call to this method!
|
|
||||||
*/
|
|
||||||
public void release() {
|
|
||||||
}
|
|
||||||
|
|
||||||
//////////////// Listeners ////////////////
|
//////////////// Listeners ////////////////
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -295,7 +288,7 @@ public class FlightConfiguration implements FlightConfigurableParameter<FlightCo
|
|||||||
updateMotors();
|
updateMotors();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateStages() {
|
protected void updateStages() {
|
||||||
if (this.rocket.getStageCount() == this.stages.size()) {
|
if (this.rocket.getStageCount() == this.stages.size()) {
|
||||||
// no changes needed
|
// no changes needed
|
||||||
return;
|
return;
|
||||||
@ -418,18 +411,6 @@ public class FlightConfiguration implements FlightConfigurableParameter<FlightCo
|
|||||||
modID++;
|
modID++;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Collection<MotorConfiguration> getAllMotors() {
|
|
||||||
return motors.values();
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getMotorCount() {
|
|
||||||
return getAllMotorCount();
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getAllMotorCount(){
|
|
||||||
return motors.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set<MotorInstanceId> getMotorIDs() {
|
public Set<MotorInstanceId> getMotorIDs() {
|
||||||
return motors.keySet();
|
return motors.keySet();
|
||||||
}
|
}
|
||||||
@ -443,29 +424,21 @@ public class FlightConfiguration implements FlightConfigurableParameter<FlightCo
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Collection<MotorConfiguration> getActiveMotors() {
|
public Collection<MotorConfiguration> getActiveMotors() {
|
||||||
List<MotorConfiguration> activeList = new ArrayList<MotorConfiguration>();
|
return motors.values();
|
||||||
for( MotorConfiguration inst : this.motors.values() ){
|
|
||||||
if( inst.isActive() ){
|
|
||||||
activeList.add( inst );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return activeList;
|
protected void updateMotors() {
|
||||||
}
|
|
||||||
|
|
||||||
public void updateMotors() {
|
|
||||||
this.motors.clear();
|
this.motors.clear();
|
||||||
|
|
||||||
for ( RocketComponent compMount : getActiveComponents() ){
|
for ( RocketComponent compMount : getActiveComponents() ){
|
||||||
if (( compMount instanceof MotorMount )&&( ((MotorMount)compMount).isMotorMount())){
|
if (( compMount instanceof MotorMount )&&( ((MotorMount)compMount).isMotorMount())){
|
||||||
MotorMount mount = (MotorMount)compMount;
|
MotorMount mount = (MotorMount)compMount;
|
||||||
MotorConfiguration sourceInstance = mount.getMotorInstance( fcid);
|
MotorConfiguration sourceConfig = mount.getMotorInstance( fcid);
|
||||||
if( sourceInstance.isEmpty()){
|
if( sourceConfig.isEmpty()){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.motors.put( sourceInstance.getID(), sourceInstance);
|
this.motors.put( sourceConfig.getID(), sourceConfig);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -457,6 +457,11 @@ public class Rocket extends RocketComponent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(){
|
||||||
|
this.configSet.update();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Freezes the rocket structure from firing any events. This may be performed to
|
* Freezes the rocket structure from firing any events. This may be performed to
|
||||||
* combine several actions on the structure into a single large action.
|
* combine several actions on the structure into a single large action.
|
||||||
|
@ -105,7 +105,7 @@ public class BasicEventSimulationEngine implements SimulationEngine {
|
|||||||
if (!flightData.getWarningSet().isEmpty()) {
|
if (!flightData.getWarningSet().isEmpty()) {
|
||||||
log.info("Warnings at the end of simulation: " + flightData.getWarningSet());
|
log.info("Warnings at the end of simulation: " + flightData.getWarningSet());
|
||||||
}
|
}
|
||||||
simulationConfig.release();
|
|
||||||
return flightData;
|
return flightData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,12 +1,10 @@
|
|||||||
package net.sf.openrocket.rocketcomponent;
|
package net.sf.openrocket.rocketcomponent;
|
||||||
|
|
||||||
import static org.hamcrest.CoreMatchers.equalTo;
|
import static org.hamcrest.CoreMatchers.equalTo;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertThat;
|
import static org.junit.Assert.assertThat;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import java.util.EventObject;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import net.sf.openrocket.motor.Manufacturer;
|
import net.sf.openrocket.motor.Manufacturer;
|
||||||
@ -15,56 +13,12 @@ import net.sf.openrocket.motor.MotorConfiguration;
|
|||||||
import net.sf.openrocket.motor.ThrustCurveMotor;
|
import net.sf.openrocket.motor.ThrustCurveMotor;
|
||||||
import net.sf.openrocket.rocketcomponent.RocketComponent.Position;
|
import net.sf.openrocket.rocketcomponent.RocketComponent.Position;
|
||||||
import net.sf.openrocket.util.Coordinate;
|
import net.sf.openrocket.util.Coordinate;
|
||||||
import net.sf.openrocket.util.StateChangeListener;
|
import net.sf.openrocket.util.MathUtil;
|
||||||
import net.sf.openrocket.util.BaseTestCase.BaseTestCase;
|
import net.sf.openrocket.util.BaseTestCase.BaseTestCase;
|
||||||
|
|
||||||
public class ConfigurationTest extends BaseTestCase {
|
public class FlightConfigurationTest extends BaseTestCase {
|
||||||
|
|
||||||
/**
|
|
||||||
* Test change events and modIDs
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
public void testChangeEvent() {
|
|
||||||
|
|
||||||
/* Setup */
|
|
||||||
Rocket r1 = makeEmptyRocket();
|
|
||||||
FlightConfiguration config = r1.getDefaultConfiguration();
|
|
||||||
|
|
||||||
StateChangeListener listener1 = new StateChangeListener() {
|
|
||||||
@Override
|
|
||||||
public void stateChanged(EventObject e) {
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
StateChangeListener listener2 = new StateChangeListener() {
|
|
||||||
@Override
|
|
||||||
public void stateChanged(EventObject e) {
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
config.addChangeListener(listener1);
|
|
||||||
config.addChangeListener(listener2);
|
|
||||||
|
|
||||||
/* Test */
|
|
||||||
|
|
||||||
// ModID should not change if nothing changed
|
|
||||||
int origModID = config.getModID();
|
|
||||||
int noChangeModID = config.getModID();
|
|
||||||
assertTrue(origModID == noChangeModID);
|
|
||||||
|
|
||||||
|
|
||||||
// After a change event, modID should change
|
|
||||||
config.fireChangeEvent();
|
|
||||||
int changeModID = config.getModID();
|
|
||||||
assertTrue(origModID < changeModID);
|
|
||||||
|
|
||||||
/* Cleanup */
|
|
||||||
config.removeChangeListener(listener1);
|
|
||||||
config.removeChangeListener(listener2);
|
|
||||||
config.release();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
private final static double EPSILON = MathUtil.EPSILON*1E3;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Empty rocket (no components) specific configuration tests
|
* Empty rocket (no components) specific configuration tests
|
||||||
@ -77,42 +31,90 @@ public class ConfigurationTest extends BaseTestCase {
|
|||||||
FlightConfiguration configClone = config.clone();
|
FlightConfiguration configClone = config.clone();
|
||||||
|
|
||||||
assertTrue(config.getRocket() == configClone.getRocket());
|
assertTrue(config.getRocket() == configClone.getRocket());
|
||||||
|
|
||||||
config.release();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test flight configuration ID methods
|
* Test flight configuration ID methods
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testGeneralMethods() {
|
public void testCloneBasic() {
|
||||||
|
Rocket rkt1 = makeTwoStageMotorRocket();
|
||||||
|
FlightConfiguration config1 = rkt1.getDefaultConfiguration();
|
||||||
|
|
||||||
/* Setup */
|
// preconditions
|
||||||
Rocket r1 = makeSingleStageTestRocket();
|
config1.setAllStages();
|
||||||
FlightConfiguration config = r1.getDefaultConfiguration();
|
int expectedStageCount = 2;
|
||||||
|
int actualStageCount = config1.getActiveStageCount();
|
||||||
|
assertThat("active stage count doesn't match", actualStageCount, equalTo(expectedStageCount));
|
||||||
|
int expectedMotorCount = 2;
|
||||||
|
int actualMotorCount = config1.getActiveMotors().size();
|
||||||
|
assertThat("active motor count doesn't match", actualMotorCount, equalTo(expectedMotorCount));
|
||||||
|
double expectedLength = 176.8698848;
|
||||||
|
double actualLength = config1.getLength();
|
||||||
|
assertEquals("source config length doesn't match: ", expectedLength, actualLength, EPSILON);
|
||||||
|
double expectedReferenceLength = 2.5;
|
||||||
|
double actualReferenceLength = config1.getReferenceLength();
|
||||||
|
assertEquals("source config reference length doesn't match: ", expectedReferenceLength, actualReferenceLength, EPSILON);
|
||||||
|
double expectedReferenceArea = 4.9087385212;
|
||||||
|
double actualReferenceArea = config1.getReferenceArea();
|
||||||
|
assertEquals("source config reference area doesn't match: ", expectedReferenceArea, actualReferenceArea, EPSILON);
|
||||||
|
|
||||||
/* Test */
|
// vvvv test target vvvv
|
||||||
|
FlightConfiguration config2= config1.clone();
|
||||||
|
// ^^^^ test target ^^^^
|
||||||
|
|
||||||
// general method tests
|
// postconditions
|
||||||
FlightConfiguration configClone = config.clone(); // TODO validate clone worked
|
expectedStageCount = 2;
|
||||||
|
actualStageCount = config2.getActiveStageCount();
|
||||||
|
assertThat("active stage count doesn't match", actualStageCount, equalTo(expectedStageCount));
|
||||||
|
expectedMotorCount = 2;
|
||||||
|
actualMotorCount = config2.getActiveMotors().size();
|
||||||
|
assertThat("active motor count doesn't match", actualMotorCount, equalTo(expectedMotorCount));
|
||||||
|
actualLength = config2.getLength();
|
||||||
|
assertEquals("source config length doesn't match: ", expectedLength, actualLength, EPSILON);
|
||||||
|
actualReferenceLength = config2.getReferenceLength();
|
||||||
|
assertEquals("source config reference length doesn't match: ", expectedReferenceLength, actualReferenceLength, EPSILON);
|
||||||
|
actualReferenceArea = config2.getReferenceArea();
|
||||||
|
assertEquals("source config reference area doesn't match: ", expectedReferenceArea, actualReferenceArea, EPSILON);
|
||||||
|
|
||||||
assertFalse(config.getRocket() == null);
|
}
|
||||||
|
|
||||||
// TODO rocket has no motors! assertTrue(config.hasMotors());
|
/**
|
||||||
|
* Test flight configuration ID methods
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testCloneIndependence() {
|
||||||
|
Rocket rkt1 = makeTwoStageMotorRocket();
|
||||||
|
FlightConfiguration config1 = rkt1.getDefaultConfiguration();
|
||||||
|
int expectedStageCount;
|
||||||
|
int actualStageCount;
|
||||||
|
int expectedMotorCount;
|
||||||
|
int actualMotorCount;
|
||||||
|
|
||||||
// rocket info tests
|
// test that cloned configurations operate independently:
|
||||||
double length = config.getLength();
|
// change #1, test clone #2 -- verify that cloned configurations change independent.
|
||||||
double refLength = config.getReferenceLength();
|
config1.setAllStages();
|
||||||
double refArea = config.getReferenceArea();
|
// vvvv test target vvvv
|
||||||
|
FlightConfiguration config2 = config1.clone();
|
||||||
|
// ^^^^ test target ^^^^
|
||||||
|
config1.clearAllStages();
|
||||||
|
|
||||||
// TODO validate that the values are correct
|
|
||||||
//log.debug("ConfigurationTest, length: " + String.valueOf(length));
|
|
||||||
//log.debug("ConfigurationTest, refLength: " + String.valueOf(refLength));
|
|
||||||
//log.debug("ConfigurationTest, refArea: " + String.valueOf(refArea));
|
|
||||||
|
|
||||||
/* Cleanup */
|
// postcondition: config #1
|
||||||
config.release();
|
expectedStageCount = 0;
|
||||||
|
actualStageCount = config1.getActiveStageCount();
|
||||||
|
assertThat("active stage count doesn't match", actualStageCount, equalTo(expectedStageCount));
|
||||||
|
expectedMotorCount = 0;
|
||||||
|
actualMotorCount = config1.getActiveMotors().size();
|
||||||
|
assertThat("active motor count doesn't match", actualMotorCount, equalTo(expectedMotorCount));
|
||||||
|
|
||||||
|
// postcondition: config #2
|
||||||
|
expectedStageCount = 2;
|
||||||
|
actualStageCount = config2.getActiveStageCount();
|
||||||
|
assertThat("active stage count doesn't match", actualStageCount, equalTo(expectedStageCount));
|
||||||
|
expectedMotorCount = 2;
|
||||||
|
actualMotorCount = config2.getActiveMotors().size();
|
||||||
|
assertThat("active motor count doesn't match", actualMotorCount, equalTo(expectedMotorCount));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -125,17 +127,10 @@ public class ConfigurationTest extends BaseTestCase {
|
|||||||
Rocket r1 = makeSingleStageTestRocket();
|
Rocket r1 = makeSingleStageTestRocket();
|
||||||
FlightConfiguration config = r1.getDefaultConfiguration();
|
FlightConfiguration config = r1.getDefaultConfiguration();
|
||||||
|
|
||||||
/* Test */
|
|
||||||
|
|
||||||
// test cloning of single stage rocket
|
|
||||||
FlightConfiguration configClone = config.clone(); // TODO validate clone worked
|
|
||||||
configClone.release();
|
|
||||||
|
|
||||||
// test explicitly setting only first stage active
|
// test explicitly setting only first stage active
|
||||||
config.clearAllStages();
|
config.clearAllStages();
|
||||||
config.setOnlyStage(0);
|
config.setOnlyStage(0);
|
||||||
|
|
||||||
|
|
||||||
//config.dumpConfig();
|
//config.dumpConfig();
|
||||||
//System.err.println("treedump: \n" + treedump);
|
//System.err.println("treedump: \n" + treedump);
|
||||||
|
|
||||||
@ -154,9 +149,6 @@ public class ConfigurationTest extends BaseTestCase {
|
|||||||
// test explicitly setting all stages active
|
// test explicitly setting all stages active
|
||||||
config.setAllStages();
|
config.setAllStages();
|
||||||
|
|
||||||
// Cleanup
|
|
||||||
config.release();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -169,10 +161,6 @@ public class ConfigurationTest extends BaseTestCase {
|
|||||||
Rocket r1 = makeTwoStageTestRocket();
|
Rocket r1 = makeTwoStageTestRocket();
|
||||||
FlightConfiguration config = r1.getDefaultConfiguration();
|
FlightConfiguration config = r1.getDefaultConfiguration();
|
||||||
|
|
||||||
// test cloning of two stage rocket
|
|
||||||
FlightConfiguration configClone = config.clone(); // TODO validate clone worked
|
|
||||||
configClone.release();
|
|
||||||
|
|
||||||
int expectedStageCount;
|
int expectedStageCount;
|
||||||
int stageCount;
|
int stageCount;
|
||||||
|
|
||||||
@ -218,9 +206,6 @@ public class ConfigurationTest extends BaseTestCase {
|
|||||||
config.toggleStage(0);
|
config.toggleStage(0);
|
||||||
assertThat(" toggle stage #0: ", config.isStageActive(0), equalTo(false));
|
assertThat(" toggle stage #0: ", config.isStageActive(0), equalTo(false));
|
||||||
|
|
||||||
// Cleanup
|
|
||||||
config.release();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -237,93 +222,29 @@ public class ConfigurationTest extends BaseTestCase {
|
|||||||
config.clearAllStages();
|
config.clearAllStages();
|
||||||
int expectedMotorCount = 0;
|
int expectedMotorCount = 0;
|
||||||
int actualMotorCount = config.getActiveMotors().size();
|
int actualMotorCount = config.getActiveMotors().size();
|
||||||
assertThat("motor count doesn't match", actualMotorCount, equalTo(expectedMotorCount));
|
assertThat("active motor count doesn't match", actualMotorCount, equalTo(expectedMotorCount));
|
||||||
|
|
||||||
config.setOnlyStage(0);
|
config.setOnlyStage(0);
|
||||||
expectedMotorCount = 1;
|
expectedMotorCount = 1;
|
||||||
actualMotorCount = config.getActiveMotors().size();
|
actualMotorCount = config.getActiveMotors().size();
|
||||||
assertThat("motor count doesn't match: ", actualMotorCount, equalTo(expectedMotorCount));
|
assertThat("active motor count doesn't match: ", actualMotorCount, equalTo(expectedMotorCount));
|
||||||
|
|
||||||
config.setOnlyStage(1);
|
config.setOnlyStage(1);
|
||||||
expectedMotorCount = 2;
|
expectedMotorCount = 1;
|
||||||
actualMotorCount = config.getActiveMotors().size();
|
actualMotorCount = config.getActiveMotors().size();
|
||||||
assertThat("motor count doesn't match: ", actualMotorCount, equalTo(expectedMotorCount));
|
assertThat("active motor count doesn't match: ", actualMotorCount, equalTo(expectedMotorCount));
|
||||||
|
|
||||||
config.setAllStages();
|
config.setAllStages();
|
||||||
expectedMotorCount = 3;
|
expectedMotorCount = 2;
|
||||||
// {
|
|
||||||
// System.err.println("Booster Stage only: config set detail: "+rkt.getConfigSet().toDebug());
|
|
||||||
// System.err.println("Booster Stage only: config stage detail: "+config.toStageListDetail());
|
|
||||||
// System.err.println("Booster Stage only: config motor detail: "+config.toMotorDetail());
|
|
||||||
// config.enableDebugging();
|
|
||||||
// config.updateMotors();
|
|
||||||
// config.getActiveMotors();
|
|
||||||
// }
|
|
||||||
actualMotorCount = config.getActiveMotors().size();
|
actualMotorCount = config.getActiveMotors().size();
|
||||||
assertThat("motor count doesn't match: ", actualMotorCount, equalTo(expectedMotorCount));
|
assertThat("active motor count doesn't match: ", actualMotorCount, equalTo(expectedMotorCount));
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////// Helper Methods ////////////////////////////
|
|
||||||
//
|
|
||||||
// public void validateStages(Configuration config, int expectedStageCount, BitSet activeStageFlags) {
|
|
||||||
//
|
|
||||||
// // test that getStageCount() returns correct value
|
|
||||||
// int stageCount = config.getStageCount();
|
|
||||||
// assertTrue(stageCount == expectedStageCount);
|
|
||||||
//
|
|
||||||
// // test that getActiveStageCount() and getActiveStages() returns correct values
|
|
||||||
// int expectedActiveStageCount = 0;
|
|
||||||
// for (int i = 0; i < expectedStageCount; i++) {
|
|
||||||
// if (activeStageFlags.get(i)) {
|
|
||||||
// expectedActiveStageCount++;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// assertTrue(config.getActiveStageCount() == expectedActiveStageCount);
|
|
||||||
//
|
|
||||||
// assertTrue("this test is not yet written.", false);
|
|
||||||
// // int[] stages = config.getActiveStages();
|
|
||||||
// //
|
|
||||||
// // assertTrue(stages.length == expectedActiveStageCount);
|
|
||||||
// //
|
|
||||||
// // // test if isHead() detects first stage being active or inactive
|
|
||||||
// // if (activeStageFlags.get(0)) {
|
|
||||||
// // assertTrue(config.isHead());
|
|
||||||
// // } else {
|
|
||||||
// // assertFalse(config.isHead());
|
|
||||||
// // }
|
|
||||||
// //
|
|
||||||
// // // test if isStageActive() detects stage x being active or inactive
|
|
||||||
// // for (int i = 0; i < expectedStageCount; i++) {
|
|
||||||
// // if (activeStageFlags.get(i)) {
|
|
||||||
// // assertTrue(config.isStageActive(i));
|
|
||||||
// // } else {
|
|
||||||
// // assertFalse(config.isStageActive(i));
|
|
||||||
// // }
|
|
||||||
// // }
|
|
||||||
// //
|
|
||||||
// // // test boundary conditions
|
|
||||||
// //
|
|
||||||
// // // stage -1 should not exist, and isStageActive() should throw exception
|
|
||||||
// // boolean IndexOutOfBoundsExceptionFlag = false;
|
|
||||||
// // try {
|
|
||||||
// // assertFalse(config.isStageActive(-1));
|
|
||||||
// // } catch (IndexOutOfBoundsException e) {
|
|
||||||
// // IndexOutOfBoundsExceptionFlag = true;
|
|
||||||
// // }
|
|
||||||
// // assertTrue(IndexOutOfBoundsExceptionFlag);
|
|
||||||
// //
|
|
||||||
// // // n+1 stage should not exist, isStageActive() should return false
|
|
||||||
// // // TODO: isStageActive(stageCount + 1) really should throw IndexOutOfBoundsException
|
|
||||||
// // assertFalse(config.isStageActive(stageCount + 1));
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
|
|
||||||
//////////////////// Test Rocket Creation Methods /////////////////////////
|
//////////////////// Test Rocket Creation Methods /////////////////////////
|
||||||
|
|
||||||
public static Rocket makeEmptyRocket() {
|
public static Rocket makeEmptyRocket() {
|
||||||
Rocket rocket = new Rocket();
|
Rocket rocket = new Rocket();
|
||||||
|
rocket.enableEvents();
|
||||||
return rocket;
|
return rocket;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -464,24 +385,7 @@ public class ConfigurationTest extends BaseTestCase {
|
|||||||
expectedConfigurationCount = 1;
|
expectedConfigurationCount = 1;
|
||||||
assertThat(" configuration list contains : ", rocket.getConfigSet().size(), equalTo(expectedConfigurationCount));
|
assertThat(" configuration list contains : ", rocket.getConfigSet().size(), equalTo(expectedConfigurationCount));
|
||||||
|
|
||||||
//FlightConfigurationID fcid = config.getFlightConfigurationID();
|
rocket.enableEvents();
|
||||||
// Motor m = Application.getMotorSetDatabase().findMotors(null, null, "L540", Double.NaN, Double.NaN).get(0);
|
|
||||||
// MotorInstance inst = m.getNewInstance();
|
|
||||||
// inner.setMotorInstance( fcid, inst);
|
|
||||||
// inner.setMotorOverhang(0.02);
|
|
||||||
//
|
|
||||||
// //inner.setMotorMount(true);
|
|
||||||
// assertThat(" configuration updates stage Count correctly: ", inner.hasMotor(), equalTo(true));
|
|
||||||
//
|
|
||||||
// final int expectedMotorCount = 1;
|
|
||||||
// assertThat(" configuration updates correctly: ", inner.getMotorCount(), equalTo(expectedMotorCount));
|
|
||||||
//
|
|
||||||
// // Flight configuration
|
|
||||||
// //FlightConfigurationID id = rocket.newFlightConfigurationID();
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// // tube3.setIgnitionEvent(MotorMount.IgnitionEvent.NEVER);
|
|
||||||
|
|
||||||
return rocket;
|
return rocket;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -538,6 +442,7 @@ public class ConfigurationTest extends BaseTestCase {
|
|||||||
// FlightConfiguration newConfig = new FlightConfiguration(rocket,null);
|
// FlightConfiguration newConfig = new FlightConfiguration(rocket,null);
|
||||||
// rocket.setFlightConfiguration( newConfig.getId(), newConfig);
|
// rocket.setFlightConfiguration( newConfig.getId(), newConfig);
|
||||||
|
|
||||||
|
rocket.enableEvents();
|
||||||
return rocket;
|
return rocket;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -580,6 +485,8 @@ public class ConfigurationTest extends BaseTestCase {
|
|||||||
boosterMount.setMotorInstance(fcid, new MotorConfiguration(boosterMotor));
|
boosterMount.setMotorInstance(fcid, new MotorConfiguration(boosterMotor));
|
||||||
boosterMount.setClusterConfiguration( ClusterConfiguration.CONFIGURATIONS[1]); // double-mount
|
boosterMount.setClusterConfiguration( ClusterConfiguration.CONFIGURATIONS[1]); // double-mount
|
||||||
}
|
}
|
||||||
|
rocket.getConfigSet().update();
|
||||||
|
rocket.enableEvents();
|
||||||
return rocket;
|
return rocket;
|
||||||
}
|
}
|
||||||
|
|
@ -430,7 +430,6 @@ public class DesignReport {
|
|||||||
c.setBorder(PdfPCell.LEFT);
|
c.setBorder(PdfPCell.LEFT);
|
||||||
c.setBorderWidthTop(0f);
|
c.setBorderWidthTop(0f);
|
||||||
parent.addCell(c);
|
parent.addCell(c);
|
||||||
config.release();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user