De-localize Material and FlightDataType objects when persisting in ork files. Added...
[debian/openrocket] / core / test / net / sf / openrocket / preset / LaunchLugPresetTests.java
index d37443b03584e618f8b2d7f077932121e4668cb3..2297e20c8aa94e70a660ed3e302ff0b2b1658f12 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,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"));
+                       PresetAssertHelper.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"));
+                       PresetAssertHelper.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"));
+                       PresetAssertHelper.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"));
+                       PresetAssertHelper.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"));
+                       PresetAssertHelper.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"));
+                       PresetAssertHelper.assertInvalidPresetException( ex,
+                                       null,
+                       new String[] {
+                                       "Preset dimensions underspecified"
+                       }
+                                       );
                }
        }
 
@@ -191,7 +235,7 @@ public class LaunchLugPresetTests {
                presetspec.put( ComponentPreset.LENGTH, 2.0);
                presetspec.put( ComponentPreset.OUTER_DIAMETER, 2.0);
                presetspec.put( ComponentPreset.INNER_DIAMETER, 1.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());
@@ -209,7 +253,7 @@ public class LaunchLugPresetTests {
                presetspec.put( ComponentPreset.OUTER_DIAMETER, 2.0);
                presetspec.put( ComponentPreset.INNER_DIAMETER, 1.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