]> git.gag.com Git - debian/openrocket/blobdiff - core/test/net/sf/openrocket/preset/BulkHeadPresetTests.java
Change the InvalidComponentPresetException so it reports all errors found in a preset...
[debian/openrocket] / core / test / net / sf / openrocket / preset / BulkHeadPresetTests.java
index 047fe1395742dc51a4e4f767a1bc0f9230a6a806..0cbfd28c18edffc0c403ba93c499a8034d18b39b 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"));
+                       PresetTest.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"));
+                       PresetTest.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"));
+                       PresetTest.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"));
+                       PresetTest.assertInvalidPresetException( ex,
+                                       new TypedKey<?>[] {
+                                       ComponentPreset.OUTER_DIAMETER
+                       },
+                       new String[] {
+                                       "No OuterDiameter specified"
+                       }
+                                       );
                }
        }