De-localize Material and FlightDataType objects when persisting in ork files. Added...
[debian/openrocket] / core / test / net / sf / openrocket / preset / BulkHeadPresetTests.java
index 047fe1395742dc51a4e4f767a1bc0f9230a6a806..9f54ae953fff41549ef5f51ec73c695732800dad 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;
 
@@ -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"));
+                       PresetAssertHelper.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"));
+                       PresetAssertHelper.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"));
+                       PresetAssertHelper.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"));
+                       PresetAssertHelper.assertInvalidPresetException( ex,
+                                       new TypedKey<?>[] {
+                                       ComponentPreset.OUTER_DIAMETER
+                       },
+                       new String[] {
+                                       "No OuterDiameter specified"
+                       }
+                                       );
                }
        }
 
@@ -99,7 +138,7 @@ public class BulkHeadPresetTests {
                presetspec.put( ComponentPreset.PARTNO, "partno");
                presetspec.put( ComponentPreset.LENGTH, 2.0);
                presetspec.put( ComponentPreset.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());
@@ -116,7 +155,7 @@ public class BulkHeadPresetTests {
                presetspec.put( ComponentPreset.LENGTH, 2.0);
                presetspec.put( ComponentPreset.OUTER_DIAMETER, 2.0);
                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);
 
                // Compute the volume by hand here using a slightly different formula from