presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.BODY_TUBE);
ComponentPresetFactory.create(presetspec);
} catch ( InvalidComponentPresetException ex ) {
- PresetTest.assertInvalidPresetException( ex,
+ PresetAssertHelper.assertInvalidPresetException( ex,
new TypedKey<?>[] {
ComponentPreset.MANUFACTURER,
ComponentPreset.PARTNO,
presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
ComponentPresetFactory.create(presetspec);
} catch ( InvalidComponentPresetException ex ) {
- PresetTest.assertInvalidPresetException( ex,
+ PresetAssertHelper.assertInvalidPresetException( ex,
new TypedKey<?>[] {
ComponentPreset.PARTNO,
ComponentPreset.LENGTH
presetspec.put( ComponentPreset.PARTNO, "partno");
ComponentPresetFactory.create(presetspec);
} catch ( InvalidComponentPresetException ex ) {
- PresetTest.assertInvalidPresetException( ex,
+ PresetAssertHelper.assertInvalidPresetException( ex,
new TypedKey<?>[] {
ComponentPreset.LENGTH
},
presetspec.put( ComponentPreset.OUTER_DIAMETER, 2.0);
ComponentPresetFactory.create(presetspec);
} catch ( InvalidComponentPresetException ex ) {
- PresetTest.assertInvalidPresetException( ex,
+ PresetAssertHelper.assertInvalidPresetException( ex,
null,
new String[] {
"Preset dimensions underspecified"
presetspec.put( ComponentPreset.INNER_DIAMETER, 2.0);
ComponentPresetFactory.create(presetspec);
} catch ( InvalidComponentPresetException ex ) {
- PresetTest.assertInvalidPresetException( ex,
+ PresetAssertHelper.assertInvalidPresetException( ex,
null,
new String[] {
"Preset dimensions underspecified"
presetspec.put( ComponentPreset.THICKNESS, 2.0);
ComponentPresetFactory.create(presetspec);
} catch ( InvalidComponentPresetException ex ) {
- PresetTest.assertInvalidPresetException( ex,
+ PresetAssertHelper.assertInvalidPresetException( ex,
null,
new String[] {
"Preset dimensions underspecified"
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.BULK_HEAD);
ComponentPresetFactory.create(presetspec);
} catch ( InvalidComponentPresetException ex ) {
- PresetTest.assertInvalidPresetException( ex,
+ PresetAssertHelper.assertInvalidPresetException( ex,
new TypedKey<?>[] {
ComponentPreset.MANUFACTURER,
ComponentPreset.PARTNO,
presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
ComponentPresetFactory.create(presetspec);
} catch ( InvalidComponentPresetException ex ) {
- PresetTest.assertInvalidPresetException( ex,
+ PresetAssertHelper.assertInvalidPresetException( ex,
new TypedKey<?>[] {
ComponentPreset.PARTNO,
ComponentPreset.LENGTH,
presetspec.put( ComponentPreset.PARTNO, "partno");
ComponentPresetFactory.create(presetspec);
} catch ( InvalidComponentPresetException ex ) {
- PresetTest.assertInvalidPresetException( ex,
+ PresetAssertHelper.assertInvalidPresetException( ex,
new TypedKey<?>[] {
ComponentPreset.LENGTH,
ComponentPreset.OUTER_DIAMETER
presetspec.put( ComponentPreset.LENGTH, 2.0);
ComponentPresetFactory.create(presetspec);
} catch ( InvalidComponentPresetException ex ) {
- PresetTest.assertInvalidPresetException( ex,
+ PresetAssertHelper.assertInvalidPresetException( ex,
new TypedKey<?>[] {
ComponentPreset.OUTER_DIAMETER
},
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.CENTERING_RING);
ComponentPresetFactory.create(presetspec);
} catch ( InvalidComponentPresetException ex ) {
- PresetTest.assertInvalidPresetException( ex,
+ PresetAssertHelper.assertInvalidPresetException( ex,
new TypedKey<?>[] {
ComponentPreset.MANUFACTURER,
ComponentPreset.PARTNO,
presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
ComponentPresetFactory.create(presetspec);
} catch ( InvalidComponentPresetException ex ) {
- PresetTest.assertInvalidPresetException( ex,
+ PresetAssertHelper.assertInvalidPresetException( ex,
new TypedKey<?>[] {
ComponentPreset.PARTNO,
ComponentPreset.LENGTH
presetspec.put( ComponentPreset.PARTNO, "partno");
ComponentPresetFactory.create(presetspec);
} catch ( InvalidComponentPresetException ex ) {
- PresetTest.assertInvalidPresetException( ex,
+ PresetAssertHelper.assertInvalidPresetException( ex,
new TypedKey<?>[] {
ComponentPreset.LENGTH
},
presetspec.put( ComponentPreset.OUTER_DIAMETER, 2.0);
ComponentPresetFactory.create(presetspec);
} catch ( InvalidComponentPresetException ex ) {
- PresetTest.assertInvalidPresetException( ex,
+ PresetAssertHelper.assertInvalidPresetException( ex,
null,
new String[] {
"Preset dimensions underspecified"
presetspec.put( ComponentPreset.INNER_DIAMETER, 2.0);
ComponentPresetFactory.create(presetspec);
} catch ( InvalidComponentPresetException ex ) {
- PresetTest.assertInvalidPresetException( ex,
+ PresetAssertHelper.assertInvalidPresetException( ex,
null,
new String[] {
"Preset dimensions underspecified"
presetspec.put( ComponentPreset.THICKNESS, 2.0);
ComponentPresetFactory.create(presetspec);
} catch ( InvalidComponentPresetException ex ) {
- PresetTest.assertInvalidPresetException( ex,
+ PresetAssertHelper.assertInvalidPresetException( ex,
null,
new String[] {
"Preset dimensions underspecified"
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.ENGINE_BLOCK);
ComponentPresetFactory.create(presetspec);
} catch ( InvalidComponentPresetException ex ) {
- PresetTest.assertInvalidPresetException( ex,
+ PresetAssertHelper.assertInvalidPresetException( ex,
new TypedKey<?>[] {
ComponentPreset.MANUFACTURER,
ComponentPreset.PARTNO,
presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
ComponentPresetFactory.create(presetspec);
} catch ( InvalidComponentPresetException ex ) {
- PresetTest.assertInvalidPresetException( ex,
+ PresetAssertHelper.assertInvalidPresetException( ex,
new TypedKey<?>[] {
ComponentPreset.PARTNO,
ComponentPreset.LENGTH
presetspec.put( ComponentPreset.PARTNO, "partno");
ComponentPresetFactory.create(presetspec);
} catch ( InvalidComponentPresetException ex ) {
- PresetTest.assertInvalidPresetException( ex,
+ PresetAssertHelper.assertInvalidPresetException( ex,
new TypedKey<?>[] {
ComponentPreset.LENGTH
},
presetspec.put( ComponentPreset.OUTER_DIAMETER, 2.0);
ComponentPresetFactory.create(presetspec);
} catch ( InvalidComponentPresetException ex ) {
- PresetTest.assertInvalidPresetException( ex,
+ PresetAssertHelper.assertInvalidPresetException( ex,
null,
new String[] {
"Preset dimensions underspecified"
presetspec.put( ComponentPreset.INNER_DIAMETER, 2.0);
ComponentPresetFactory.create(presetspec);
} catch ( InvalidComponentPresetException ex ) {
- PresetTest.assertInvalidPresetException( ex,
+ PresetAssertHelper.assertInvalidPresetException( ex,
null,
new String[] {
"Preset dimensions underspecified"
presetspec.put( ComponentPreset.THICKNESS, 2.0);
ComponentPresetFactory.create(presetspec);
} catch ( InvalidComponentPresetException ex ) {
- PresetTest.assertInvalidPresetException( ex,
+ PresetAssertHelper.assertInvalidPresetException( ex,
null,
new String[] {
"Preset dimensions underspecified"
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.LAUNCH_LUG);
ComponentPresetFactory.create(presetspec);
} catch ( InvalidComponentPresetException ex ) {
- PresetTest.assertInvalidPresetException( ex,
+ PresetAssertHelper.assertInvalidPresetException( ex,
new TypedKey<?>[] {
ComponentPreset.MANUFACTURER,
ComponentPreset.PARTNO,
presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
ComponentPresetFactory.create(presetspec);
} catch ( InvalidComponentPresetException ex ) {
- PresetTest.assertInvalidPresetException( ex,
+ PresetAssertHelper.assertInvalidPresetException( ex,
new TypedKey<?>[] {
ComponentPreset.PARTNO,
ComponentPreset.LENGTH
presetspec.put( ComponentPreset.PARTNO, "partno");
ComponentPresetFactory.create(presetspec);
} catch ( InvalidComponentPresetException ex ) {
- PresetTest.assertInvalidPresetException( ex,
+ PresetAssertHelper.assertInvalidPresetException( ex,
new TypedKey<?>[] {
ComponentPreset.LENGTH
},
presetspec.put( ComponentPreset.OUTER_DIAMETER, 2.0);
ComponentPresetFactory.create(presetspec);
} catch ( InvalidComponentPresetException ex ) {
- PresetTest.assertInvalidPresetException( ex,
+ PresetAssertHelper.assertInvalidPresetException( ex,
null,
new String[] {
"Preset dimensions underspecified"
presetspec.put( ComponentPreset.INNER_DIAMETER, 2.0);
ComponentPresetFactory.create(presetspec);
} catch ( InvalidComponentPresetException ex ) {
- PresetTest.assertInvalidPresetException( ex,
+ PresetAssertHelper.assertInvalidPresetException( ex,
null,
new String[] {
"Preset dimensions underspecified"
presetspec.put( ComponentPreset.THICKNESS, 2.0);
ComponentPresetFactory.create(presetspec);
} catch ( InvalidComponentPresetException ex ) {
- PresetTest.assertInvalidPresetException( ex,
+ PresetAssertHelper.assertInvalidPresetException( ex,
null,
new String[] {
"Preset dimensions underspecified"
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.NOSE_CONE);
ComponentPresetFactory.create(presetspec);
} catch ( InvalidComponentPresetException ex ) {
- PresetTest.assertInvalidPresetException( ex,
+ PresetAssertHelper.assertInvalidPresetException( ex,
new TypedKey<?>[] {
ComponentPreset.MANUFACTURER,
ComponentPreset.PARTNO,
presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
ComponentPresetFactory.create(presetspec);
} catch ( InvalidComponentPresetException ex ) {
- PresetTest.assertInvalidPresetException( ex,
+ PresetAssertHelper.assertInvalidPresetException( ex,
new TypedKey<?>[] {
ComponentPreset.PARTNO,
ComponentPreset.LENGTH,
presetspec.put( ComponentPreset.PARTNO, "partno");
ComponentPresetFactory.create(presetspec);
} catch ( InvalidComponentPresetException ex ) {
- PresetTest.assertInvalidPresetException( ex,
+ PresetAssertHelper.assertInvalidPresetException( ex,
new TypedKey<?>[] {
ComponentPreset.LENGTH,
ComponentPreset.AFT_OUTER_DIAMETER,
presetspec.put( ComponentPreset.LENGTH, 2.0);
ComponentPresetFactory.create(presetspec);
} catch ( InvalidComponentPresetException ex ) {
- PresetTest.assertInvalidPresetException( ex,
+ PresetAssertHelper.assertInvalidPresetException( ex,
new TypedKey<?>[] {
ComponentPreset.AFT_OUTER_DIAMETER,
ComponentPreset.SHAPE
presetspec.put( ComponentPreset.SHAPE, Transition.Shape.CONICAL);
ComponentPresetFactory.create(presetspec);
} catch ( InvalidComponentPresetException ex ) {
- PresetTest.assertInvalidPresetException( ex,
+ PresetAssertHelper.assertInvalidPresetException( ex,
new TypedKey<?>[] {
ComponentPreset.AFT_OUTER_DIAMETER
},
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.PARACHUTE);
ComponentPresetFactory.create(presetspec);
} catch ( InvalidComponentPresetException ex ) {
- PresetTest.assertInvalidPresetException( ex,
+ PresetAssertHelper.assertInvalidPresetException( ex,
new TypedKey<?>[] {
ComponentPreset.MANUFACTURER,
ComponentPreset.PARTNO,
presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
ComponentPresetFactory.create(presetspec);
} catch ( InvalidComponentPresetException ex ) {
- PresetTest.assertInvalidPresetException( ex,
+ PresetAssertHelper.assertInvalidPresetException( ex,
new TypedKey<?>[] {
ComponentPreset.PARTNO,
ComponentPreset.DIAMETER,
presetspec.put( ComponentPreset.PARTNO, "partno");
ComponentPresetFactory.create(presetspec);
} catch ( InvalidComponentPresetException ex ) {
- PresetTest.assertInvalidPresetException( ex,
+ PresetAssertHelper.assertInvalidPresetException( ex,
new TypedKey<?>[] {
ComponentPreset.DIAMETER,
ComponentPreset.LINE_COUNT,
presetspec.put( ComponentPreset.DIAMETER, 2.0);
ComponentPresetFactory.create(presetspec);
} catch ( InvalidComponentPresetException ex ) {
- PresetTest.assertInvalidPresetException( ex,
+ PresetAssertHelper.assertInvalidPresetException( ex,
new TypedKey<?>[] {
ComponentPreset.LINE_COUNT,
ComponentPreset.LINE_LENGTH
presetspec.put( ComponentPreset.LINE_COUNT, 6);
ComponentPresetFactory.create(presetspec);
} catch ( InvalidComponentPresetException ex ) {
- PresetTest.assertInvalidPresetException( ex,
+ PresetAssertHelper.assertInvalidPresetException( ex,
new TypedKey<?>[] {
ComponentPreset.LINE_LENGTH
},
--- /dev/null
+package net.sf.openrocket.preset;
+
+import static org.junit.Assert.*;
+
+public abstract class PresetAssertHelper {
+
+ 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() );
+ }
+ }
+}
+++ /dev/null
-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() );
- }
- }
-}
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.STREAMER);
ComponentPresetFactory.create(presetspec);
} catch ( InvalidComponentPresetException ex ) {
- PresetTest.assertInvalidPresetException( ex,
+ PresetAssertHelper.assertInvalidPresetException( ex,
new TypedKey<?>[] {
ComponentPreset.MANUFACTURER,
ComponentPreset.PARTNO,
presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
ComponentPresetFactory.create(presetspec);
} catch ( InvalidComponentPresetException ex ) {
- PresetTest.assertInvalidPresetException( ex,
+ PresetAssertHelper.assertInvalidPresetException( ex,
new TypedKey<?>[] {
ComponentPreset.PARTNO,
ComponentPreset.LENGTH,
presetspec.put( ComponentPreset.PARTNO, "partno");
ComponentPresetFactory.create(presetspec);
} catch ( InvalidComponentPresetException ex ) {
- PresetTest.assertInvalidPresetException( ex,
+ PresetAssertHelper.assertInvalidPresetException( ex,
new TypedKey<?>[] {
ComponentPreset.LENGTH,
ComponentPreset.WIDTH
presetspec.put( ComponentPreset.LENGTH, 2.0);
ComponentPresetFactory.create(presetspec);
} catch ( InvalidComponentPresetException ex ) {
- PresetTest.assertInvalidPresetException( ex,
+ PresetAssertHelper.assertInvalidPresetException( ex,
new TypedKey<?>[] {
ComponentPreset.WIDTH
},
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.TRANSITION);
ComponentPresetFactory.create(presetspec);
} catch ( InvalidComponentPresetException ex ) {
- PresetTest.assertInvalidPresetException( ex,
+ PresetAssertHelper.assertInvalidPresetException( ex,
new TypedKey<?>[] {
ComponentPreset.MANUFACTURER,
ComponentPreset.PARTNO,
presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
ComponentPresetFactory.create(presetspec);
} catch ( InvalidComponentPresetException ex ) {
- PresetTest.assertInvalidPresetException( ex,
+ PresetAssertHelper.assertInvalidPresetException( ex,
new TypedKey<?>[] {
ComponentPreset.PARTNO,
ComponentPreset.LENGTH,
presetspec.put( ComponentPreset.PARTNO, "partno");
ComponentPresetFactory.create(presetspec);
} catch ( InvalidComponentPresetException ex ) {
- PresetTest.assertInvalidPresetException( ex,
+ PresetAssertHelper.assertInvalidPresetException( ex,
new TypedKey<?>[] {
ComponentPreset.LENGTH,
ComponentPreset.AFT_OUTER_DIAMETER,
presetspec.put( ComponentPreset.SHAPE, Transition.Shape.CONICAL);
ComponentPresetFactory.create(presetspec);
} catch ( InvalidComponentPresetException ex ) {
- PresetTest.assertInvalidPresetException( ex,
+ PresetAssertHelper.assertInvalidPresetException( ex,
new TypedKey<?>[] {
ComponentPreset.AFT_OUTER_DIAMETER,
ComponentPreset.FORE_OUTER_DIAMETER
presetspec.put( ComponentPreset.AFT_OUTER_DIAMETER, 2.0);
ComponentPresetFactory.create(presetspec);
} catch ( InvalidComponentPresetException ex ) {
- PresetTest.assertInvalidPresetException( ex,
+ PresetAssertHelper.assertInvalidPresetException( ex,
new TypedKey<?>[] {
ComponentPreset.FORE_OUTER_DIAMETER
},
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.TUBE_COUPLER);
ComponentPresetFactory.create(presetspec);
} catch ( InvalidComponentPresetException ex ) {
- PresetTest.assertInvalidPresetException( ex,
+ PresetAssertHelper.assertInvalidPresetException( ex,
new TypedKey<?>[] {
ComponentPreset.MANUFACTURER,
ComponentPreset.PARTNO,
presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
ComponentPresetFactory.create(presetspec);
} catch ( InvalidComponentPresetException ex ) {
- PresetTest.assertInvalidPresetException( ex,
+ PresetAssertHelper.assertInvalidPresetException( ex,
new TypedKey<?>[] {
ComponentPreset.PARTNO,
ComponentPreset.LENGTH
presetspec.put( ComponentPreset.PARTNO, "partno");
ComponentPresetFactory.create(presetspec);
} catch ( InvalidComponentPresetException ex ) {
- PresetTest.assertInvalidPresetException( ex,
+ PresetAssertHelper.assertInvalidPresetException( ex,
new TypedKey<?>[] {
ComponentPreset.LENGTH
},
presetspec.put( ComponentPreset.OUTER_DIAMETER, 2.0);
ComponentPresetFactory.create(presetspec);
} catch ( InvalidComponentPresetException ex ) {
- PresetTest.assertInvalidPresetException( ex,
+ PresetAssertHelper.assertInvalidPresetException( ex,
null,
new String[] {
"Preset dimensions underspecified"
presetspec.put( ComponentPreset.INNER_DIAMETER, 2.0);
ComponentPresetFactory.create(presetspec);
} catch ( InvalidComponentPresetException ex ) {
- PresetTest.assertInvalidPresetException( ex,
+ PresetAssertHelper.assertInvalidPresetException( ex,
null,
new String[] {
"Preset dimensions underspecified"
presetspec.put( ComponentPreset.THICKNESS, 2.0);
ComponentPresetFactory.create(presetspec);
} catch ( InvalidComponentPresetException ex ) {
- PresetTest.assertInvalidPresetException( ex,
+ PresetAssertHelper.assertInvalidPresetException( ex,
null,
new String[] {
"Preset dimensions underspecified"