]> git.gag.com Git - debian/openrocket/blobdiff - core/test/net/sf/openrocket/preset/EngineBlockPresetTests.java
Change the InvalidComponentPresetException so it reports all errors found in a preset...
[debian/openrocket] / core / test / net / sf / openrocket / preset / EngineBlockPresetTests.java
index 67971bc7f8915b6c6691c4eecac1e1c3c469d525..0c6ebf01fea8eb31338f2fc1aed9cd5593da1ea9 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 EngineBlockPresetTests {
                        presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.ENGINE_BLOCK);
                        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"
+                       }
+                                       );
                }
        }
 
@@ -37,7 +48,17 @@ public class EngineBlockPresetTests {
                        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"
+                       }
+                                       );
                }
        }
 
@@ -50,7 +71,15 @@ public class EngineBlockPresetTests {
                        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"
+                       }
+                                       );
                }
        }
 
@@ -65,7 +94,12 @@ public class EngineBlockPresetTests {
                        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"
+                       }
+                                       );
                }
        }
 
@@ -80,7 +114,12 @@ public class EngineBlockPresetTests {
                        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"
+                       }
+                                       );
                }
        }
 
@@ -95,7 +134,12 @@ public class EngineBlockPresetTests {
                        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"
+                       }
+                                       );
                }
        }