De-localize Material and FlightDataType objects when persisting in ork files. Added...
[debian/openrocket] / core / test / net / sf / openrocket / preset / NoseConePresetTests.java
index f36d026efe08e771cd358ce7f029ee1e210eec01..36743672ed4b24423e681ccc0c5d1bf05afe8f96 100644 (file)
@@ -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"));
+                       PresetAssertHelper.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"));
+                       PresetAssertHelper.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"));
+                       PresetAssertHelper.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"));
+                       PresetAssertHelper.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"));
+                       PresetAssertHelper.assertInvalidPresetException( ex,
+                                       new TypedKey<?>[] {
+                                       ComponentPreset.AFT_OUTER_DIAMETER
+                       },
+                       new String[] {
+                                       "No AftOuterDiameter specified"
+                       }
+                                       );
                }
        }
 
@@ -118,7 +172,7 @@ public class NoseConePresetTests extends BaseTestCase {
                presetspec.put( ComponentPreset.LENGTH, 2.0);
                presetspec.put( ComponentPreset.SHAPE, Transition.Shape.CONICAL);
                presetspec.put( ComponentPreset.AFT_OUTER_DIAMETER, 2.0);
-               presetspec.put( ComponentPreset.MATERIAL, new Material.Bulk("test", 2.0, true));
+               presetspec.put( ComponentPreset.MATERIAL, Material.newUserMaterial(Material.Type.BULK,"test", 2.0));
                ComponentPreset preset = ComponentPresetFactory.create(presetspec);
 
                assertEquals("test",preset.get(ComponentPreset.MATERIAL).getName());
@@ -137,7 +191,7 @@ public class NoseConePresetTests extends BaseTestCase {
                presetspec.put( ComponentPreset.AFT_OUTER_DIAMETER, 2.0);
                presetspec.put( ComponentPreset.FILLED, true);
                presetspec.put( ComponentPreset.MASS, 100.0);
-               presetspec.put( ComponentPreset.MATERIAL, new Material.Bulk("test", 2.0, true));
+               presetspec.put( ComponentPreset.MATERIAL, Material.newUserMaterial(Material.Type.BULK,"test", 2.0));
                ComponentPreset preset = ComponentPresetFactory.create(presetspec);
 
                // constants put into the presetspec above.