Change the InvalidComponentPresetException so it reports all errors found in a preset instead of just the first. Changed all the test cases to ensure the proper errors are reported.
This commit is contained in:
parent
a32bfe7366
commit
370dfd0e18
@ -10,19 +10,22 @@ public abstract class ComponentPresetFactory {
|
||||
|
||||
public static ComponentPreset create( TypedPropertyMap props ) throws InvalidComponentPresetException {
|
||||
|
||||
InvalidComponentPresetException exceptions = new InvalidComponentPresetException("Invalid preset specification.");
|
||||
|
||||
ComponentPreset preset = new ComponentPreset();
|
||||
// First do validation.
|
||||
if ( !props.containsKey(TYPE)) {
|
||||
throw new InvalidComponentPresetException("No Type specified " + props.toString() );
|
||||
}
|
||||
|
||||
if (!props.containsKey(MANUFACTURER)) {
|
||||
throw new InvalidComponentPresetException("No Manufacturer specified " + props.toString() );
|
||||
exceptions.addInvalidParameter(MANUFACTURER, "No Manufacturer specified");
|
||||
}
|
||||
if (!props.containsKey(PARTNO)) {
|
||||
exceptions.addInvalidParameter(PARTNO,"No PartNo specified");
|
||||
}
|
||||
if ( !props.containsKey(TYPE)) {
|
||||
exceptions.addInvalidParameter(TYPE, "No Type specified" );
|
||||
// We can't do anything else without TYPE so throw immediately.
|
||||
throw exceptions;
|
||||
}
|
||||
|
||||
if (!props.containsKey(PARTNO)) {
|
||||
throw new InvalidComponentPresetException("No PartNo specified " + props.toString() );
|
||||
}
|
||||
|
||||
preset.putAll(props);
|
||||
|
||||
@ -30,60 +33,64 @@ public abstract class ComponentPresetFactory {
|
||||
Type t = props.get(TYPE);
|
||||
switch ( t ) {
|
||||
case BODY_TUBE: {
|
||||
makeBodyTube(preset);
|
||||
makeBodyTube(exceptions,preset);
|
||||
break;
|
||||
}
|
||||
case NOSE_CONE: {
|
||||
makeNoseCone(preset);
|
||||
makeNoseCone(exceptions,preset);
|
||||
break;
|
||||
}
|
||||
case TRANSITION: {
|
||||
makeTransition(preset);
|
||||
makeTransition(exceptions,preset);
|
||||
break;
|
||||
}
|
||||
case BULK_HEAD: {
|
||||
makeBulkHead(preset);
|
||||
makeBulkHead(exceptions,preset);
|
||||
break;
|
||||
}
|
||||
case TUBE_COUPLER: {
|
||||
// For now TUBE_COUPLER is the same as BODY_TUBE
|
||||
makeBodyTube(preset);
|
||||
makeBodyTube(exceptions,preset);
|
||||
break;
|
||||
}
|
||||
case CENTERING_RING: {
|
||||
makeCenteringRing(preset);
|
||||
makeCenteringRing(exceptions,preset);
|
||||
break;
|
||||
}
|
||||
case ENGINE_BLOCK: {
|
||||
makeEngineBlock(preset);
|
||||
makeEngineBlock(exceptions,preset);
|
||||
break;
|
||||
}
|
||||
case LAUNCH_LUG: {
|
||||
// Same processing as BODY_TUBE
|
||||
makeBodyTube(preset);
|
||||
makeBodyTube(exceptions,preset);
|
||||
break;
|
||||
}
|
||||
case STREAMER: {
|
||||
makeStreamer(preset);
|
||||
makeStreamer(exceptions,preset);
|
||||
break;
|
||||
}
|
||||
case PARACHUTE: {
|
||||
makeParachute(preset);
|
||||
makeParachute(exceptions,preset);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( exceptions.hasProblems() ) {
|
||||
throw exceptions;
|
||||
}
|
||||
|
||||
preset.computeDigest();
|
||||
|
||||
return preset;
|
||||
|
||||
}
|
||||
|
||||
private static void makeBodyTube( ComponentPreset preset ) throws InvalidComponentPresetException {
|
||||
private static void makeBodyTube( InvalidComponentPresetException exceptions, ComponentPreset preset ) throws InvalidComponentPresetException {
|
||||
|
||||
checkRequiredFields( preset, LENGTH );
|
||||
checkRequiredFields( exceptions, preset, LENGTH );
|
||||
|
||||
checkDiametersAndThickness(preset);
|
||||
checkDiametersAndThickness(exceptions, preset);
|
||||
|
||||
double volume = computeVolumeOfTube( preset );
|
||||
|
||||
@ -100,9 +107,9 @@ public abstract class ComponentPresetFactory {
|
||||
|
||||
}
|
||||
|
||||
private static void makeNoseCone( ComponentPreset preset ) throws InvalidComponentPresetException {
|
||||
private static void makeNoseCone( InvalidComponentPresetException exceptions, ComponentPreset preset ) {
|
||||
|
||||
checkRequiredFields( preset, LENGTH, SHAPE, AFT_OUTER_DIAMETER );
|
||||
checkRequiredFields( exceptions, preset, LENGTH, SHAPE, AFT_OUTER_DIAMETER );
|
||||
|
||||
if ( preset.has(MASS) ) {
|
||||
// compute a density for this component
|
||||
@ -123,8 +130,8 @@ public abstract class ComponentPresetFactory {
|
||||
|
||||
}
|
||||
|
||||
private static void makeTransition( ComponentPreset preset ) throws InvalidComponentPresetException {
|
||||
checkRequiredFields(preset, LENGTH, AFT_OUTER_DIAMETER, FORE_OUTER_DIAMETER);
|
||||
private static void makeTransition( InvalidComponentPresetException exceptions, ComponentPreset preset ) {
|
||||
checkRequiredFields(exceptions, preset, LENGTH, AFT_OUTER_DIAMETER, FORE_OUTER_DIAMETER);
|
||||
|
||||
if ( preset.has(MASS) ) {
|
||||
// compute a density for this component
|
||||
@ -145,8 +152,8 @@ public abstract class ComponentPresetFactory {
|
||||
|
||||
}
|
||||
|
||||
private static void makeBulkHead( ComponentPreset preset ) throws InvalidComponentPresetException {
|
||||
checkRequiredFields(preset, LENGTH, OUTER_DIAMETER );
|
||||
private static void makeBulkHead( InvalidComponentPresetException exceptions, ComponentPreset preset ) {
|
||||
checkRequiredFields(exceptions, preset, LENGTH, OUTER_DIAMETER );
|
||||
|
||||
if ( preset.has(MASS) ) {
|
||||
// compute a density for this component
|
||||
@ -167,10 +174,10 @@ public abstract class ComponentPresetFactory {
|
||||
|
||||
}
|
||||
|
||||
private static void makeCenteringRing( ComponentPreset preset ) throws InvalidComponentPresetException {
|
||||
checkRequiredFields( preset, LENGTH );
|
||||
private static void makeCenteringRing( InvalidComponentPresetException exceptions, ComponentPreset preset ) throws InvalidComponentPresetException {
|
||||
checkRequiredFields( exceptions, preset, LENGTH );
|
||||
|
||||
checkDiametersAndThickness( preset );
|
||||
checkDiametersAndThickness( exceptions, preset );
|
||||
|
||||
double volume = computeVolumeOfTube( preset );
|
||||
|
||||
@ -186,10 +193,10 @@ public abstract class ComponentPresetFactory {
|
||||
|
||||
}
|
||||
|
||||
private static void makeEngineBlock( ComponentPreset preset ) throws InvalidComponentPresetException {
|
||||
checkRequiredFields( preset, LENGTH );
|
||||
private static void makeEngineBlock( InvalidComponentPresetException exceptions, ComponentPreset preset ) throws InvalidComponentPresetException {
|
||||
checkRequiredFields( exceptions, preset, LENGTH );
|
||||
|
||||
checkDiametersAndThickness( preset );
|
||||
checkDiametersAndThickness( exceptions, preset );
|
||||
|
||||
double volume = computeVolumeOfTube( preset );
|
||||
|
||||
@ -205,24 +212,24 @@ public abstract class ComponentPresetFactory {
|
||||
|
||||
}
|
||||
|
||||
private static void makeStreamer( ComponentPreset preset ) throws InvalidComponentPresetException {
|
||||
checkRequiredFields( preset, LENGTH, WIDTH );
|
||||
private static void makeStreamer( InvalidComponentPresetException exceptions, ComponentPreset preset ) {
|
||||
checkRequiredFields( exceptions, preset, LENGTH, WIDTH );
|
||||
}
|
||||
|
||||
private static void makeParachute( ComponentPreset preset ) throws InvalidComponentPresetException {
|
||||
checkRequiredFields( preset, DIAMETER, LINE_COUNT, LINE_LENGTH );
|
||||
private static void makeParachute( InvalidComponentPresetException exceptions, ComponentPreset preset ) {
|
||||
checkRequiredFields( exceptions, preset, DIAMETER, LINE_COUNT, LINE_LENGTH );
|
||||
}
|
||||
|
||||
|
||||
private static void checkRequiredFields( ComponentPreset preset, TypedKey<?> ... keys ) throws InvalidComponentPresetException {
|
||||
private static void checkRequiredFields( InvalidComponentPresetException exceptions, ComponentPreset preset, TypedKey<?> ... keys ) {
|
||||
for( TypedKey<?> key: keys ) {
|
||||
if (! preset.has(key) ) {
|
||||
throw new InvalidComponentPresetException( "No " + key.getName() + " specified for " + preset.getType().name() + " preset " + preset.toString());
|
||||
exceptions.addInvalidParameter(key, "No " + key.getName() + " specified");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void checkDiametersAndThickness( ComponentPreset preset ) throws InvalidComponentPresetException {
|
||||
private static void checkDiametersAndThickness( InvalidComponentPresetException exceptions, ComponentPreset preset ) throws InvalidComponentPresetException {
|
||||
// Need to verify contains 2 of OD, thickness, ID. Compute the third.
|
||||
boolean hasOd = preset.has(OUTER_DIAMETER);
|
||||
boolean hasId = preset.has(INNER_DIAMETER);
|
||||
@ -242,11 +249,13 @@ public abstract class ComponentPresetFactory {
|
||||
thickness = preset.get(THICKNESS);
|
||||
innerRadius = outerRadius - thickness;
|
||||
} else {
|
||||
throw new InvalidComponentPresetException("Preset underspecified " + preset.toString());
|
||||
exceptions.addMessage("Preset dimensions underspecified");
|
||||
throw exceptions;
|
||||
}
|
||||
} else {
|
||||
if ( ! hasId || ! hasThickness ) {
|
||||
throw new InvalidComponentPresetException("Preset underspecified " + preset.toString());
|
||||
exceptions.addMessage("Preset dimensions underspecified");
|
||||
throw exceptions;
|
||||
}
|
||||
innerRadius = preset.get(INNER_DIAMETER)/2.0;
|
||||
thickness = preset.get(THICKNESS);
|
||||
|
@ -1,25 +1,56 @@
|
||||
package net.sf.openrocket.preset;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class InvalidComponentPresetException extends Exception {
|
||||
|
||||
private List<String> errors = new ArrayList<String>();
|
||||
private List<TypedKey<?>> invalidParameters = new ArrayList<TypedKey<?>>();
|
||||
|
||||
public InvalidComponentPresetException() {
|
||||
super();
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
public InvalidComponentPresetException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
public InvalidComponentPresetException(String message) {
|
||||
super(message);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
public InvalidComponentPresetException(Throwable cause) {
|
||||
super(cause);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
void addInvalidParameter(TypedKey<?> key ) {
|
||||
invalidParameters.add(key);
|
||||
}
|
||||
|
||||
void addInvalidParameter(TypedKey<?> key, String message ) {
|
||||
invalidParameters.add(key);
|
||||
errors.add(message);
|
||||
}
|
||||
|
||||
void addMessage( String message ) {
|
||||
errors.add(message);
|
||||
}
|
||||
|
||||
boolean hasProblems() {
|
||||
return (invalidParameters.size() + errors.size()) > 0;
|
||||
}
|
||||
|
||||
public int problemCount() {
|
||||
return Math.max( invalidParameters.size(), errors.size() );
|
||||
}
|
||||
|
||||
public List<String> getErrors() {
|
||||
return errors;
|
||||
}
|
||||
|
||||
public List<TypedKey<?>> getInvalidParameters() {
|
||||
return invalidParameters;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package net.sf.openrocket.preset;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import net.sf.openrocket.material.Material;
|
||||
import net.sf.openrocket.motor.Manufacturer;
|
||||
|
||||
@ -25,7 +24,19 @@ public class BodyTubePresetTests {
|
||||
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.BODY_TUBE);
|
||||
ComponentPresetFactory.create(presetspec);
|
||||
} catch ( InvalidComponentPresetException ex ) {
|
||||
assertTrue("Wrong Exception Thrown", ex.getMessage().contains("No Manufacturer specified"));
|
||||
PresetTest.assertInvalidPresetException( ex,
|
||||
new TypedKey<?>[] {
|
||||
ComponentPreset.MANUFACTURER,
|
||||
ComponentPreset.PARTNO,
|
||||
ComponentPreset.LENGTH
|
||||
},
|
||||
new String[] {
|
||||
"No Manufacturer specified",
|
||||
"No PartNo specified",
|
||||
"No Length specified",
|
||||
"Preset dimensions underspecified"
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -37,7 +48,17 @@ public class BodyTubePresetTests {
|
||||
presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
|
||||
ComponentPresetFactory.create(presetspec);
|
||||
} catch ( InvalidComponentPresetException ex ) {
|
||||
assertTrue("Wrong Exception Thrown", ex.getMessage().contains("No PartNo specified"));
|
||||
PresetTest.assertInvalidPresetException( ex,
|
||||
new TypedKey<?>[] {
|
||||
ComponentPreset.PARTNO,
|
||||
ComponentPreset.LENGTH
|
||||
},
|
||||
new String[] {
|
||||
"No PartNo specified",
|
||||
"No Length specified",
|
||||
"Preset dimensions underspecified"
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -50,7 +71,15 @@ public class BodyTubePresetTests {
|
||||
presetspec.put( ComponentPreset.PARTNO, "partno");
|
||||
ComponentPresetFactory.create(presetspec);
|
||||
} catch ( InvalidComponentPresetException ex ) {
|
||||
assertTrue("Wrong Exception Thrown", ex.getMessage().contains("No Length specified"));
|
||||
PresetTest.assertInvalidPresetException( ex,
|
||||
new TypedKey<?>[] {
|
||||
ComponentPreset.LENGTH
|
||||
},
|
||||
new String[] {
|
||||
"No Length specified",
|
||||
"Preset dimensions underspecified"
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -65,7 +94,12 @@ public class BodyTubePresetTests {
|
||||
presetspec.put( ComponentPreset.OUTER_DIAMETER, 2.0);
|
||||
ComponentPresetFactory.create(presetspec);
|
||||
} catch ( InvalidComponentPresetException ex ) {
|
||||
assertTrue("Wrong Exception Thrown", ex.getMessage().contains("Preset underspecified"));
|
||||
PresetTest.assertInvalidPresetException( ex,
|
||||
null,
|
||||
new String[] {
|
||||
"Preset dimensions underspecified"
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -80,7 +114,12 @@ public class BodyTubePresetTests {
|
||||
presetspec.put( ComponentPreset.INNER_DIAMETER, 2.0);
|
||||
ComponentPresetFactory.create(presetspec);
|
||||
} catch ( InvalidComponentPresetException ex ) {
|
||||
assertTrue("Wrong Exception Thrown", ex.getMessage().contains("Preset underspecified"));
|
||||
PresetTest.assertInvalidPresetException( ex,
|
||||
null,
|
||||
new String[] {
|
||||
"Preset dimensions underspecified"
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -95,7 +134,12 @@ public class BodyTubePresetTests {
|
||||
presetspec.put( ComponentPreset.THICKNESS, 2.0);
|
||||
ComponentPresetFactory.create(presetspec);
|
||||
} catch ( InvalidComponentPresetException ex ) {
|
||||
assertTrue("Wrong Exception Thrown", ex.getMessage().contains("Preset underspecified"));
|
||||
PresetTest.assertInvalidPresetException( ex,
|
||||
null,
|
||||
new String[] {
|
||||
"Preset dimensions underspecified"
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
package net.sf.openrocket.preset;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import net.sf.openrocket.material.Material;
|
||||
import net.sf.openrocket.motor.Manufacturer;
|
||||
|
||||
@ -25,7 +24,20 @@ public class BulkHeadPresetTests {
|
||||
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.BULK_HEAD);
|
||||
ComponentPresetFactory.create(presetspec);
|
||||
} catch ( InvalidComponentPresetException ex ) {
|
||||
assertTrue("Wrong Exception Thrown", ex.getMessage().contains("No Manufacturer specified"));
|
||||
PresetTest.assertInvalidPresetException( ex,
|
||||
new TypedKey<?>[] {
|
||||
ComponentPreset.MANUFACTURER,
|
||||
ComponentPreset.PARTNO,
|
||||
ComponentPreset.LENGTH,
|
||||
ComponentPreset.OUTER_DIAMETER
|
||||
},
|
||||
new String[] {
|
||||
"No Manufacturer specified",
|
||||
"No PartNo specified",
|
||||
"No Length specified",
|
||||
"No OuterDiameter specified"
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -37,7 +49,18 @@ public class BulkHeadPresetTests {
|
||||
presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
|
||||
ComponentPresetFactory.create(presetspec);
|
||||
} catch ( InvalidComponentPresetException ex ) {
|
||||
assertTrue("Wrong Exception Thrown", ex.getMessage().contains("No PartNo specified"));
|
||||
PresetTest.assertInvalidPresetException( ex,
|
||||
new TypedKey<?>[] {
|
||||
ComponentPreset.PARTNO,
|
||||
ComponentPreset.LENGTH,
|
||||
ComponentPreset.OUTER_DIAMETER
|
||||
},
|
||||
new String[] {
|
||||
"No PartNo specified",
|
||||
"No Length specified",
|
||||
"No OuterDiameter specified"
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -50,7 +73,16 @@ public class BulkHeadPresetTests {
|
||||
presetspec.put( ComponentPreset.PARTNO, "partno");
|
||||
ComponentPresetFactory.create(presetspec);
|
||||
} catch ( InvalidComponentPresetException ex ) {
|
||||
assertTrue("Wrong Exception Thrown", ex.getMessage().contains("No Length specified"));
|
||||
PresetTest.assertInvalidPresetException( ex,
|
||||
new TypedKey<?>[] {
|
||||
ComponentPreset.LENGTH,
|
||||
ComponentPreset.OUTER_DIAMETER
|
||||
},
|
||||
new String[] {
|
||||
"No Length specified",
|
||||
"No OuterDiameter specified"
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -64,7 +96,14 @@ public class BulkHeadPresetTests {
|
||||
presetspec.put( ComponentPreset.LENGTH, 2.0);
|
||||
ComponentPresetFactory.create(presetspec);
|
||||
} catch ( InvalidComponentPresetException ex ) {
|
||||
assertTrue("Wrong Exception Thrown", ex.getMessage().contains("No OuterDiameter specified"));
|
||||
PresetTest.assertInvalidPresetException( ex,
|
||||
new TypedKey<?>[] {
|
||||
ComponentPreset.OUTER_DIAMETER
|
||||
},
|
||||
new String[] {
|
||||
"No OuterDiameter specified"
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
package net.sf.openrocket.preset;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import net.sf.openrocket.material.Material;
|
||||
import net.sf.openrocket.motor.Manufacturer;
|
||||
|
||||
@ -25,7 +24,19 @@ public class CenteringRingPresetTests {
|
||||
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.CENTERING_RING);
|
||||
ComponentPresetFactory.create(presetspec);
|
||||
} catch ( InvalidComponentPresetException ex ) {
|
||||
assertTrue("Wrong Exception Thrown", ex.getMessage().contains("No Manufacturer specified"));
|
||||
PresetTest.assertInvalidPresetException( ex,
|
||||
new TypedKey<?>[] {
|
||||
ComponentPreset.MANUFACTURER,
|
||||
ComponentPreset.PARTNO,
|
||||
ComponentPreset.LENGTH
|
||||
},
|
||||
new String[] {
|
||||
"No Manufacturer specified",
|
||||
"No PartNo specified",
|
||||
"No Length specified",
|
||||
"Preset dimensions underspecified"
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -37,7 +48,17 @@ public class CenteringRingPresetTests {
|
||||
presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
|
||||
ComponentPresetFactory.create(presetspec);
|
||||
} catch ( InvalidComponentPresetException ex ) {
|
||||
assertTrue("Wrong Exception Thrown", ex.getMessage().contains("No PartNo specified"));
|
||||
PresetTest.assertInvalidPresetException( ex,
|
||||
new TypedKey<?>[] {
|
||||
ComponentPreset.PARTNO,
|
||||
ComponentPreset.LENGTH
|
||||
},
|
||||
new String[] {
|
||||
"No PartNo specified",
|
||||
"No Length specified",
|
||||
"Preset dimensions underspecified"
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -50,7 +71,15 @@ public class CenteringRingPresetTests {
|
||||
presetspec.put( ComponentPreset.PARTNO, "partno");
|
||||
ComponentPresetFactory.create(presetspec);
|
||||
} catch ( InvalidComponentPresetException ex ) {
|
||||
assertTrue("Wrong Exception Thrown", ex.getMessage().contains("No Length specified"));
|
||||
PresetTest.assertInvalidPresetException( ex,
|
||||
new TypedKey<?>[] {
|
||||
ComponentPreset.LENGTH
|
||||
},
|
||||
new String[] {
|
||||
"No Length specified",
|
||||
"Preset dimensions underspecified"
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -65,7 +94,12 @@ public class CenteringRingPresetTests {
|
||||
presetspec.put( ComponentPreset.OUTER_DIAMETER, 2.0);
|
||||
ComponentPresetFactory.create(presetspec);
|
||||
} catch ( InvalidComponentPresetException ex ) {
|
||||
assertTrue("Wrong Exception Thrown", ex.getMessage().contains("Preset underspecified"));
|
||||
PresetTest.assertInvalidPresetException( ex,
|
||||
null,
|
||||
new String[] {
|
||||
"Preset dimensions underspecified"
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -80,7 +114,12 @@ public class CenteringRingPresetTests {
|
||||
presetspec.put( ComponentPreset.INNER_DIAMETER, 2.0);
|
||||
ComponentPresetFactory.create(presetspec);
|
||||
} catch ( InvalidComponentPresetException ex ) {
|
||||
assertTrue("Wrong Exception Thrown", ex.getMessage().contains("Preset underspecified"));
|
||||
PresetTest.assertInvalidPresetException( ex,
|
||||
null,
|
||||
new String[] {
|
||||
"Preset dimensions underspecified"
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -95,7 +134,12 @@ public class CenteringRingPresetTests {
|
||||
presetspec.put( ComponentPreset.THICKNESS, 2.0);
|
||||
ComponentPresetFactory.create(presetspec);
|
||||
} catch ( InvalidComponentPresetException ex ) {
|
||||
assertTrue("Wrong Exception Thrown", ex.getMessage().contains("Preset underspecified"));
|
||||
PresetTest.assertInvalidPresetException( ex,
|
||||
null,
|
||||
new String[] {
|
||||
"Preset dimensions underspecified"
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
package net.sf.openrocket.preset;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import net.sf.openrocket.material.Material;
|
||||
import net.sf.openrocket.motor.Manufacturer;
|
||||
|
||||
@ -25,7 +24,19 @@ public class EngineBlockPresetTests {
|
||||
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.ENGINE_BLOCK);
|
||||
ComponentPresetFactory.create(presetspec);
|
||||
} catch ( InvalidComponentPresetException ex ) {
|
||||
assertTrue("Wrong Exception Thrown", ex.getMessage().contains("No Manufacturer specified"));
|
||||
PresetTest.assertInvalidPresetException( ex,
|
||||
new TypedKey<?>[] {
|
||||
ComponentPreset.MANUFACTURER,
|
||||
ComponentPreset.PARTNO,
|
||||
ComponentPreset.LENGTH
|
||||
},
|
||||
new String[] {
|
||||
"No Manufacturer specified",
|
||||
"No PartNo specified",
|
||||
"No Length specified",
|
||||
"Preset dimensions underspecified"
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -37,7 +48,17 @@ public class EngineBlockPresetTests {
|
||||
presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
|
||||
ComponentPresetFactory.create(presetspec);
|
||||
} catch ( InvalidComponentPresetException ex ) {
|
||||
assertTrue("Wrong Exception Thrown", ex.getMessage().contains("No PartNo specified"));
|
||||
PresetTest.assertInvalidPresetException( ex,
|
||||
new TypedKey<?>[] {
|
||||
ComponentPreset.PARTNO,
|
||||
ComponentPreset.LENGTH
|
||||
},
|
||||
new String[] {
|
||||
"No PartNo specified",
|
||||
"No Length specified",
|
||||
"Preset dimensions underspecified"
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -50,7 +71,15 @@ public class EngineBlockPresetTests {
|
||||
presetspec.put( ComponentPreset.PARTNO, "partno");
|
||||
ComponentPresetFactory.create(presetspec);
|
||||
} catch ( InvalidComponentPresetException ex ) {
|
||||
assertTrue("Wrong Exception Thrown", ex.getMessage().contains("No Length specified"));
|
||||
PresetTest.assertInvalidPresetException( ex,
|
||||
new TypedKey<?>[] {
|
||||
ComponentPreset.LENGTH
|
||||
},
|
||||
new String[] {
|
||||
"No Length specified",
|
||||
"Preset dimensions underspecified"
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -65,7 +94,12 @@ public class EngineBlockPresetTests {
|
||||
presetspec.put( ComponentPreset.OUTER_DIAMETER, 2.0);
|
||||
ComponentPresetFactory.create(presetspec);
|
||||
} catch ( InvalidComponentPresetException ex ) {
|
||||
assertTrue("Wrong Exception Thrown", ex.getMessage().contains("Preset underspecified"));
|
||||
PresetTest.assertInvalidPresetException( ex,
|
||||
null,
|
||||
new String[] {
|
||||
"Preset dimensions underspecified"
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -80,7 +114,12 @@ public class EngineBlockPresetTests {
|
||||
presetspec.put( ComponentPreset.INNER_DIAMETER, 2.0);
|
||||
ComponentPresetFactory.create(presetspec);
|
||||
} catch ( InvalidComponentPresetException ex ) {
|
||||
assertTrue("Wrong Exception Thrown", ex.getMessage().contains("Preset underspecified"));
|
||||
PresetTest.assertInvalidPresetException( ex,
|
||||
null,
|
||||
new String[] {
|
||||
"Preset dimensions underspecified"
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -95,7 +134,12 @@ public class EngineBlockPresetTests {
|
||||
presetspec.put( ComponentPreset.THICKNESS, 2.0);
|
||||
ComponentPresetFactory.create(presetspec);
|
||||
} catch ( InvalidComponentPresetException ex ) {
|
||||
assertTrue("Wrong Exception Thrown", ex.getMessage().contains("Preset underspecified"));
|
||||
PresetTest.assertInvalidPresetException( ex,
|
||||
null,
|
||||
new String[] {
|
||||
"Preset dimensions underspecified"
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
package net.sf.openrocket.preset;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import net.sf.openrocket.material.Material;
|
||||
import net.sf.openrocket.motor.Manufacturer;
|
||||
|
||||
@ -25,7 +24,19 @@ public class LaunchLugPresetTests {
|
||||
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.LAUNCH_LUG);
|
||||
ComponentPresetFactory.create(presetspec);
|
||||
} catch ( InvalidComponentPresetException ex ) {
|
||||
assertTrue("Wrong Exception Thrown", ex.getMessage().contains("No Manufacturer specified"));
|
||||
PresetTest.assertInvalidPresetException( ex,
|
||||
new TypedKey<?>[] {
|
||||
ComponentPreset.MANUFACTURER,
|
||||
ComponentPreset.PARTNO,
|
||||
ComponentPreset.LENGTH
|
||||
},
|
||||
new String[] {
|
||||
"No Manufacturer specified",
|
||||
"No PartNo specified",
|
||||
"No Length specified",
|
||||
"Preset dimensions underspecified"
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -37,7 +48,17 @@ public class LaunchLugPresetTests {
|
||||
presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
|
||||
ComponentPresetFactory.create(presetspec);
|
||||
} catch ( InvalidComponentPresetException ex ) {
|
||||
assertTrue("Wrong Exception Thrown", ex.getMessage().contains("No PartNo specified"));
|
||||
PresetTest.assertInvalidPresetException( ex,
|
||||
new TypedKey<?>[] {
|
||||
ComponentPreset.PARTNO,
|
||||
ComponentPreset.LENGTH
|
||||
},
|
||||
new String[] {
|
||||
"No PartNo specified",
|
||||
"No Length specified",
|
||||
"Preset dimensions underspecified"
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -50,7 +71,15 @@ public class LaunchLugPresetTests {
|
||||
presetspec.put( ComponentPreset.PARTNO, "partno");
|
||||
ComponentPresetFactory.create(presetspec);
|
||||
} catch ( InvalidComponentPresetException ex ) {
|
||||
assertTrue("Wrong Exception Thrown", ex.getMessage().contains("No Length specified"));
|
||||
PresetTest.assertInvalidPresetException( ex,
|
||||
new TypedKey<?>[] {
|
||||
ComponentPreset.LENGTH
|
||||
},
|
||||
new String[] {
|
||||
"No Length specified",
|
||||
"Preset dimensions underspecified"
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -65,7 +94,12 @@ public class LaunchLugPresetTests {
|
||||
presetspec.put( ComponentPreset.OUTER_DIAMETER, 2.0);
|
||||
ComponentPresetFactory.create(presetspec);
|
||||
} catch ( InvalidComponentPresetException ex ) {
|
||||
assertTrue("Wrong Exception Thrown", ex.getMessage().contains("Preset underspecified"));
|
||||
PresetTest.assertInvalidPresetException( ex,
|
||||
null,
|
||||
new String[] {
|
||||
"Preset dimensions underspecified"
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -80,7 +114,12 @@ public class LaunchLugPresetTests {
|
||||
presetspec.put( ComponentPreset.INNER_DIAMETER, 2.0);
|
||||
ComponentPresetFactory.create(presetspec);
|
||||
} catch ( InvalidComponentPresetException ex ) {
|
||||
assertTrue("Wrong Exception Thrown", ex.getMessage().contains("Preset underspecified"));
|
||||
PresetTest.assertInvalidPresetException( ex,
|
||||
null,
|
||||
new String[] {
|
||||
"Preset dimensions underspecified"
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -95,7 +134,12 @@ public class LaunchLugPresetTests {
|
||||
presetspec.put( ComponentPreset.THICKNESS, 2.0);
|
||||
ComponentPresetFactory.create(presetspec);
|
||||
} catch ( InvalidComponentPresetException ex ) {
|
||||
assertTrue("Wrong Exception Thrown", ex.getMessage().contains("Preset underspecified"));
|
||||
PresetTest.assertInvalidPresetException( ex,
|
||||
null,
|
||||
new String[] {
|
||||
"Preset dimensions underspecified"
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
package net.sf.openrocket.preset;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import net.sf.openrocket.material.Material;
|
||||
import net.sf.openrocket.motor.Manufacturer;
|
||||
import net.sf.openrocket.rocketcomponent.Transition;
|
||||
@ -27,7 +26,22 @@ public class NoseConePresetTests extends BaseTestCase {
|
||||
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.NOSE_CONE);
|
||||
ComponentPresetFactory.create(presetspec);
|
||||
} catch ( InvalidComponentPresetException ex ) {
|
||||
assertTrue("Wrong Exception Thrown", ex.getMessage().contains("No Manufacturer specified"));
|
||||
PresetTest.assertInvalidPresetException( ex,
|
||||
new TypedKey<?>[] {
|
||||
ComponentPreset.MANUFACTURER,
|
||||
ComponentPreset.PARTNO,
|
||||
ComponentPreset.LENGTH,
|
||||
ComponentPreset.AFT_OUTER_DIAMETER,
|
||||
ComponentPreset.SHAPE
|
||||
},
|
||||
new String[] {
|
||||
"No Manufacturer specified",
|
||||
"No PartNo specified",
|
||||
"No Length specified",
|
||||
"No AftOuterDiameter specified",
|
||||
"No Shape specified"
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -39,7 +53,20 @@ public class NoseConePresetTests extends BaseTestCase {
|
||||
presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
|
||||
ComponentPresetFactory.create(presetspec);
|
||||
} catch ( InvalidComponentPresetException ex ) {
|
||||
assertTrue("Wrong Exception Thrown", ex.getMessage().contains("No PartNo specified"));
|
||||
PresetTest.assertInvalidPresetException( ex,
|
||||
new TypedKey<?>[] {
|
||||
ComponentPreset.PARTNO,
|
||||
ComponentPreset.LENGTH,
|
||||
ComponentPreset.AFT_OUTER_DIAMETER,
|
||||
ComponentPreset.SHAPE
|
||||
},
|
||||
new String[] {
|
||||
"No PartNo specified",
|
||||
"No Length specified",
|
||||
"No AftOuterDiameter specified",
|
||||
"No Shape specified"
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -52,7 +79,18 @@ public class NoseConePresetTests extends BaseTestCase {
|
||||
presetspec.put( ComponentPreset.PARTNO, "partno");
|
||||
ComponentPresetFactory.create(presetspec);
|
||||
} catch ( InvalidComponentPresetException ex ) {
|
||||
assertTrue("Wrong Exception Thrown", ex.getMessage().contains("No Length specified"));
|
||||
PresetTest.assertInvalidPresetException( ex,
|
||||
new TypedKey<?>[] {
|
||||
ComponentPreset.LENGTH,
|
||||
ComponentPreset.AFT_OUTER_DIAMETER,
|
||||
ComponentPreset.SHAPE
|
||||
},
|
||||
new String[] {
|
||||
"No Length specified",
|
||||
"No AftOuterDiameter specified",
|
||||
"No Shape specified"
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -66,7 +104,16 @@ public class NoseConePresetTests extends BaseTestCase {
|
||||
presetspec.put( ComponentPreset.LENGTH, 2.0);
|
||||
ComponentPresetFactory.create(presetspec);
|
||||
} catch ( InvalidComponentPresetException ex ) {
|
||||
assertTrue("Wrong Exception Thrown", ex.getMessage().contains("No Shape"));
|
||||
PresetTest.assertInvalidPresetException( ex,
|
||||
new TypedKey<?>[] {
|
||||
ComponentPreset.AFT_OUTER_DIAMETER,
|
||||
ComponentPreset.SHAPE
|
||||
},
|
||||
new String[] {
|
||||
"No AftOuterDiameter specified",
|
||||
"No Shape specified"
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -81,7 +128,14 @@ public class NoseConePresetTests extends BaseTestCase {
|
||||
presetspec.put( ComponentPreset.SHAPE, Transition.Shape.CONICAL);
|
||||
ComponentPresetFactory.create(presetspec);
|
||||
} catch ( InvalidComponentPresetException ex ) {
|
||||
assertTrue("Wrong Exception Thrown", ex.getMessage().contains("No AftOuterDiameter"));
|
||||
PresetTest.assertInvalidPresetException( ex,
|
||||
new TypedKey<?>[] {
|
||||
ComponentPreset.AFT_OUTER_DIAMETER
|
||||
},
|
||||
new String[] {
|
||||
"No AftOuterDiameter specified"
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
package net.sf.openrocket.preset;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import net.sf.openrocket.motor.Manufacturer;
|
||||
|
||||
import org.junit.Test;
|
||||
@ -23,7 +22,22 @@ public class ParachutePresetTests {
|
||||
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.PARACHUTE);
|
||||
ComponentPresetFactory.create(presetspec);
|
||||
} catch ( InvalidComponentPresetException ex ) {
|
||||
assertTrue("Wrong Exception Thrown", ex.getMessage().contains("No Manufacturer specified"));
|
||||
PresetTest.assertInvalidPresetException( ex,
|
||||
new TypedKey<?>[] {
|
||||
ComponentPreset.MANUFACTURER,
|
||||
ComponentPreset.PARTNO,
|
||||
ComponentPreset.DIAMETER,
|
||||
ComponentPreset.LINE_COUNT,
|
||||
ComponentPreset.LINE_LENGTH
|
||||
},
|
||||
new String[] {
|
||||
"No Manufacturer specified",
|
||||
"No PartNo specified",
|
||||
"No Diameter specified",
|
||||
"No LineCount specified",
|
||||
"No LineLength specified"
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -35,7 +49,20 @@ public class ParachutePresetTests {
|
||||
presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
|
||||
ComponentPresetFactory.create(presetspec);
|
||||
} catch ( InvalidComponentPresetException ex ) {
|
||||
assertTrue("Wrong Exception Thrown", ex.getMessage().contains("No PartNo specified"));
|
||||
PresetTest.assertInvalidPresetException( ex,
|
||||
new TypedKey<?>[] {
|
||||
ComponentPreset.PARTNO,
|
||||
ComponentPreset.DIAMETER,
|
||||
ComponentPreset.LINE_COUNT,
|
||||
ComponentPreset.LINE_LENGTH
|
||||
},
|
||||
new String[] {
|
||||
"No PartNo specified",
|
||||
"No Diameter specified",
|
||||
"No LineCount specified",
|
||||
"No LineLength specified"
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -48,7 +75,18 @@ public class ParachutePresetTests {
|
||||
presetspec.put( ComponentPreset.PARTNO, "partno");
|
||||
ComponentPresetFactory.create(presetspec);
|
||||
} catch ( InvalidComponentPresetException ex ) {
|
||||
assertTrue("Wrong Exception Thrown", ex.getMessage().contains("No Diameter specified"));
|
||||
PresetTest.assertInvalidPresetException( ex,
|
||||
new TypedKey<?>[] {
|
||||
ComponentPreset.DIAMETER,
|
||||
ComponentPreset.LINE_COUNT,
|
||||
ComponentPreset.LINE_LENGTH
|
||||
},
|
||||
new String[] {
|
||||
"No Diameter specified",
|
||||
"No LineCount specified",
|
||||
"No LineLength specified"
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -62,7 +100,16 @@ public class ParachutePresetTests {
|
||||
presetspec.put( ComponentPreset.DIAMETER, 2.0);
|
||||
ComponentPresetFactory.create(presetspec);
|
||||
} catch ( InvalidComponentPresetException ex ) {
|
||||
assertTrue("Wrong Exception Thrown", ex.getMessage().contains("No LineCount specified"));
|
||||
PresetTest.assertInvalidPresetException( ex,
|
||||
new TypedKey<?>[] {
|
||||
ComponentPreset.LINE_COUNT,
|
||||
ComponentPreset.LINE_LENGTH
|
||||
},
|
||||
new String[] {
|
||||
"No LineCount specified",
|
||||
"No LineLength specified"
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -77,7 +124,14 @@ public class ParachutePresetTests {
|
||||
presetspec.put( ComponentPreset.LINE_COUNT, 6);
|
||||
ComponentPresetFactory.create(presetspec);
|
||||
} catch ( InvalidComponentPresetException ex ) {
|
||||
assertTrue("Wrong Exception Thrown", ex.getMessage().contains("No LineLength specified"));
|
||||
PresetTest.assertInvalidPresetException( ex,
|
||||
new TypedKey<?>[] {
|
||||
ComponentPreset.LINE_LENGTH
|
||||
},
|
||||
new String[] {
|
||||
"No LineLength specified"
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
43
core/test/net/sf/openrocket/preset/PresetTest.java
Normal file
43
core/test/net/sf/openrocket/preset/PresetTest.java
Normal file
@ -0,0 +1,43 @@
|
||||
package net.sf.openrocket.preset;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public abstract class PresetTest {
|
||||
|
||||
public static void assertInvalidPresetException( InvalidComponentPresetException exceptions, TypedKey<?>[] keys, String[] messages ) {
|
||||
if ( keys != null ) {
|
||||
assertEquals( keys.length, exceptions.getInvalidParameters().size() );
|
||||
for( TypedKey<?> expectedKey : keys ) {
|
||||
boolean keyFound = false;
|
||||
for( TypedKey<?> k : exceptions.getInvalidParameters() ) {
|
||||
if ( expectedKey == k ) {
|
||||
keyFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( ! keyFound ) {
|
||||
fail( "Expected key " + expectedKey + " not in exception");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
assertEquals(0, exceptions.getInvalidParameters().size() );
|
||||
}
|
||||
if ( messages != null ) {
|
||||
assertEquals( messages.length, exceptions.getErrors().size() );
|
||||
for( String expectedMessage : messages ) {
|
||||
boolean stringMatched = false;
|
||||
for ( String s : exceptions.getErrors() ) {
|
||||
if ( s.contains( expectedMessage ) ) {
|
||||
stringMatched = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if( !stringMatched ) {
|
||||
fail( "Expected string \"" + expectedMessage + "\" not reported in errors");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
assertEquals(0, exceptions.getErrors().size() );
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
package net.sf.openrocket.preset;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import net.sf.openrocket.motor.Manufacturer;
|
||||
|
||||
import org.junit.Test;
|
||||
@ -23,7 +22,20 @@ public class StreamerPresetTests {
|
||||
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.STREAMER);
|
||||
ComponentPresetFactory.create(presetspec);
|
||||
} catch ( InvalidComponentPresetException ex ) {
|
||||
assertTrue("Wrong Exception Thrown", ex.getMessage().contains("No Manufacturer specified"));
|
||||
PresetTest.assertInvalidPresetException( ex,
|
||||
new TypedKey<?>[] {
|
||||
ComponentPreset.MANUFACTURER,
|
||||
ComponentPreset.PARTNO,
|
||||
ComponentPreset.LENGTH,
|
||||
ComponentPreset.WIDTH
|
||||
},
|
||||
new String[] {
|
||||
"No Manufacturer specified",
|
||||
"No PartNo specified",
|
||||
"No Length specified",
|
||||
"No Width specified"
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -35,7 +47,18 @@ public class StreamerPresetTests {
|
||||
presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
|
||||
ComponentPresetFactory.create(presetspec);
|
||||
} catch ( InvalidComponentPresetException ex ) {
|
||||
assertTrue("Wrong Exception Thrown", ex.getMessage().contains("No PartNo specified"));
|
||||
PresetTest.assertInvalidPresetException( ex,
|
||||
new TypedKey<?>[] {
|
||||
ComponentPreset.PARTNO,
|
||||
ComponentPreset.LENGTH,
|
||||
ComponentPreset.WIDTH
|
||||
},
|
||||
new String[] {
|
||||
"No PartNo specified",
|
||||
"No Length specified",
|
||||
"No Width specified"
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -48,7 +71,16 @@ public class StreamerPresetTests {
|
||||
presetspec.put( ComponentPreset.PARTNO, "partno");
|
||||
ComponentPresetFactory.create(presetspec);
|
||||
} catch ( InvalidComponentPresetException ex ) {
|
||||
assertTrue("Wrong Exception Thrown", ex.getMessage().contains("No Length specified"));
|
||||
PresetTest.assertInvalidPresetException( ex,
|
||||
new TypedKey<?>[] {
|
||||
ComponentPreset.LENGTH,
|
||||
ComponentPreset.WIDTH
|
||||
},
|
||||
new String[] {
|
||||
"No Length specified",
|
||||
"No Width specified"
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -62,7 +94,14 @@ public class StreamerPresetTests {
|
||||
presetspec.put( ComponentPreset.LENGTH, 2.0);
|
||||
ComponentPresetFactory.create(presetspec);
|
||||
} catch ( InvalidComponentPresetException ex ) {
|
||||
assertTrue("Wrong Exception Thrown", ex.getMessage().contains("No Width specified"));
|
||||
PresetTest.assertInvalidPresetException( ex,
|
||||
new TypedKey<?>[] {
|
||||
ComponentPreset.WIDTH
|
||||
},
|
||||
new String[] {
|
||||
"No Width specified"
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
package net.sf.openrocket.preset;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import net.sf.openrocket.material.Material;
|
||||
import net.sf.openrocket.motor.Manufacturer;
|
||||
import net.sf.openrocket.rocketcomponent.Transition;
|
||||
@ -27,7 +26,22 @@ public class TransitionPresetTests extends BaseTestCase {
|
||||
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.TRANSITION);
|
||||
ComponentPresetFactory.create(presetspec);
|
||||
} catch ( InvalidComponentPresetException ex ) {
|
||||
assertTrue("Wrong Exception Thrown", ex.getMessage().contains("No Manufacturer specified"));
|
||||
PresetTest.assertInvalidPresetException( ex,
|
||||
new TypedKey<?>[] {
|
||||
ComponentPreset.MANUFACTURER,
|
||||
ComponentPreset.PARTNO,
|
||||
ComponentPreset.LENGTH,
|
||||
ComponentPreset.AFT_OUTER_DIAMETER,
|
||||
ComponentPreset.FORE_OUTER_DIAMETER
|
||||
},
|
||||
new String[] {
|
||||
"No Manufacturer specified",
|
||||
"No PartNo specified",
|
||||
"No Length specified",
|
||||
"No AftOuterDiameter specified",
|
||||
"No ForeOuterDiameter specified"
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -39,7 +53,20 @@ public class TransitionPresetTests extends BaseTestCase {
|
||||
presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
|
||||
ComponentPresetFactory.create(presetspec);
|
||||
} catch ( InvalidComponentPresetException ex ) {
|
||||
assertTrue("Wrong Exception Thrown", ex.getMessage().contains("No PartNo specified"));
|
||||
PresetTest.assertInvalidPresetException( ex,
|
||||
new TypedKey<?>[] {
|
||||
ComponentPreset.PARTNO,
|
||||
ComponentPreset.LENGTH,
|
||||
ComponentPreset.AFT_OUTER_DIAMETER,
|
||||
ComponentPreset.FORE_OUTER_DIAMETER
|
||||
},
|
||||
new String[] {
|
||||
"No PartNo specified",
|
||||
"No Length specified",
|
||||
"No AftOuterDiameter specified",
|
||||
"No ForeOuterDiameter specified"
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -52,7 +79,18 @@ public class TransitionPresetTests extends BaseTestCase {
|
||||
presetspec.put( ComponentPreset.PARTNO, "partno");
|
||||
ComponentPresetFactory.create(presetspec);
|
||||
} catch ( InvalidComponentPresetException ex ) {
|
||||
assertTrue("Wrong Exception Thrown", ex.getMessage().contains("No Length specified"));
|
||||
PresetTest.assertInvalidPresetException( ex,
|
||||
new TypedKey<?>[] {
|
||||
ComponentPreset.LENGTH,
|
||||
ComponentPreset.AFT_OUTER_DIAMETER,
|
||||
ComponentPreset.FORE_OUTER_DIAMETER
|
||||
},
|
||||
new String[] {
|
||||
"No Length specified",
|
||||
"No AftOuterDiameter specified",
|
||||
"No ForeOuterDiameter specified"
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -67,7 +105,16 @@ public class TransitionPresetTests extends BaseTestCase {
|
||||
presetspec.put( ComponentPreset.SHAPE, Transition.Shape.CONICAL);
|
||||
ComponentPresetFactory.create(presetspec);
|
||||
} catch ( InvalidComponentPresetException ex ) {
|
||||
assertTrue("Wrong Exception Thrown", ex.getMessage().contains("No AftOuterDiameter"));
|
||||
PresetTest.assertInvalidPresetException( ex,
|
||||
new TypedKey<?>[] {
|
||||
ComponentPreset.AFT_OUTER_DIAMETER,
|
||||
ComponentPreset.FORE_OUTER_DIAMETER
|
||||
},
|
||||
new String[] {
|
||||
"No AftOuterDiameter specified",
|
||||
"No ForeOuterDiameter specified"
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -84,7 +131,14 @@ public class TransitionPresetTests extends BaseTestCase {
|
||||
presetspec.put( ComponentPreset.AFT_OUTER_DIAMETER, 2.0);
|
||||
ComponentPresetFactory.create(presetspec);
|
||||
} catch ( InvalidComponentPresetException ex ) {
|
||||
assertTrue("Wrong Exception Thrown", ex.getMessage().contains("No ForeOuterDiameter"));
|
||||
PresetTest.assertInvalidPresetException( ex,
|
||||
new TypedKey<?>[] {
|
||||
ComponentPreset.FORE_OUTER_DIAMETER
|
||||
},
|
||||
new String[] {
|
||||
"No ForeOuterDiameter specified"
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
package net.sf.openrocket.preset;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import net.sf.openrocket.material.Material;
|
||||
import net.sf.openrocket.motor.Manufacturer;
|
||||
|
||||
@ -25,7 +24,19 @@ public class TubeCouplerPresetTests {
|
||||
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.TUBE_COUPLER);
|
||||
ComponentPresetFactory.create(presetspec);
|
||||
} catch ( InvalidComponentPresetException ex ) {
|
||||
assertTrue("Wrong Exception Thrown", ex.getMessage().contains("No Manufacturer specified"));
|
||||
PresetTest.assertInvalidPresetException( ex,
|
||||
new TypedKey<?>[] {
|
||||
ComponentPreset.MANUFACTURER,
|
||||
ComponentPreset.PARTNO,
|
||||
ComponentPreset.LENGTH
|
||||
},
|
||||
new String[] {
|
||||
"No Manufacturer specified",
|
||||
"No PartNo specified",
|
||||
"No Length specified",
|
||||
"Preset dimensions underspecified"
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -37,7 +48,17 @@ public class TubeCouplerPresetTests {
|
||||
presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
|
||||
ComponentPresetFactory.create(presetspec);
|
||||
} catch ( InvalidComponentPresetException ex ) {
|
||||
assertTrue("Wrong Exception Thrown", ex.getMessage().contains("No PartNo specified"));
|
||||
PresetTest.assertInvalidPresetException( ex,
|
||||
new TypedKey<?>[] {
|
||||
ComponentPreset.PARTNO,
|
||||
ComponentPreset.LENGTH
|
||||
},
|
||||
new String[] {
|
||||
"No PartNo specified",
|
||||
"No Length specified",
|
||||
"Preset dimensions underspecified"
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -50,7 +71,15 @@ public class TubeCouplerPresetTests {
|
||||
presetspec.put( ComponentPreset.PARTNO, "partno");
|
||||
ComponentPresetFactory.create(presetspec);
|
||||
} catch ( InvalidComponentPresetException ex ) {
|
||||
assertTrue("Wrong Exception Thrown", ex.getMessage().contains("No Length specified"));
|
||||
PresetTest.assertInvalidPresetException( ex,
|
||||
new TypedKey<?>[] {
|
||||
ComponentPreset.LENGTH
|
||||
},
|
||||
new String[] {
|
||||
"No Length specified",
|
||||
"Preset dimensions underspecified"
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -65,7 +94,12 @@ public class TubeCouplerPresetTests {
|
||||
presetspec.put( ComponentPreset.OUTER_DIAMETER, 2.0);
|
||||
ComponentPresetFactory.create(presetspec);
|
||||
} catch ( InvalidComponentPresetException ex ) {
|
||||
assertTrue("Wrong Exception Thrown", ex.getMessage().contains("Preset underspecified"));
|
||||
PresetTest.assertInvalidPresetException( ex,
|
||||
null,
|
||||
new String[] {
|
||||
"Preset dimensions underspecified"
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -80,7 +114,12 @@ public class TubeCouplerPresetTests {
|
||||
presetspec.put( ComponentPreset.INNER_DIAMETER, 2.0);
|
||||
ComponentPresetFactory.create(presetspec);
|
||||
} catch ( InvalidComponentPresetException ex ) {
|
||||
assertTrue("Wrong Exception Thrown", ex.getMessage().contains("Preset underspecified"));
|
||||
PresetTest.assertInvalidPresetException( ex,
|
||||
null,
|
||||
new String[] {
|
||||
"Preset dimensions underspecified"
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -95,7 +134,12 @@ public class TubeCouplerPresetTests {
|
||||
presetspec.put( ComponentPreset.THICKNESS, 2.0);
|
||||
ComponentPresetFactory.create(presetspec);
|
||||
} catch ( InvalidComponentPresetException ex ) {
|
||||
assertTrue("Wrong Exception Thrown", ex.getMessage().contains("Preset underspecified"));
|
||||
PresetTest.assertInvalidPresetException( ex,
|
||||
null,
|
||||
new String[] {
|
||||
"Preset dimensions underspecified"
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user