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;
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"
+ }
+ );
}
}
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"
+ }
+ );
}
}
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"
+ }
+ );
}
}
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"
+ }
+ );
}
}
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"
+ }
+ );
}
}
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"
+ }
+ );
}
}
// constants put into the presetspec above.
double volume = /*outer area*/ (Math.PI * 1.0) - /* inner area */ (Math.PI * .25);
volume *= 2.0; /* times length */
-
+
double density = 100.0 / volume;
-
+
assertEquals("TubeCustom",preset.get(ComponentPreset.MATERIAL).getName());
assertEquals(density,preset.get(ComponentPreset.MATERIAL).getDensity(),0.0005);
}
assertEquals("test",preset.get(ComponentPreset.MATERIAL).getName());
assertEquals(2.0,preset.get(ComponentPreset.MATERIAL).getDensity(),0.0005);
-
+
}
@Test
// constants put into the presetspec above.
double volume = /*outer area*/ (Math.PI * 1.0) - /* inner area */ (Math.PI * .25);
volume *= 2.0; /* times length */
-
+
double density = 100.0 / volume;
-
+
assertEquals("test",preset.get(ComponentPreset.MATERIAL).getName());
assertEquals(density,preset.get(ComponentPreset.MATERIAL).getDensity(),0.0005);
}