create changelog entry
[debian/openrocket] / core / test / net / sf / openrocket / preset / ParachutePresetTests.java
1 package net.sf.openrocket.preset;
2
3 import net.sf.openrocket.motor.Manufacturer;
4
5 import org.junit.Test;
6
7 /**
8  * Test construction of PARACHUTE type ComponentPresets based on TypedPropertyMap through the
9  * ComponentPresetFactory.create() method.
10  * 
11  * Ensure required properties are populated
12  * 
13  * Ensure any computed values are correctly computed.
14  * 
15  */
16 public class ParachutePresetTests {
17
18         @Test
19         public void testManufacturerRequired() {
20                 try {
21                         TypedPropertyMap presetspec = new TypedPropertyMap();
22                         presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.PARACHUTE);
23                         ComponentPresetFactory.create(presetspec);
24                 } catch ( InvalidComponentPresetException ex ) {
25                         PresetAssertHelper.assertInvalidPresetException( ex,
26                                         new TypedKey<?>[] {
27                                         ComponentPreset.MANUFACTURER, 
28                                         ComponentPreset.PARTNO, 
29                                         ComponentPreset.DIAMETER,
30                                         ComponentPreset.LINE_COUNT,
31                                         ComponentPreset.LINE_LENGTH
32                         },
33                         new String[] {
34                                         "No Manufacturer specified",
35                                         "No PartNo specified",
36                                         "No Diameter specified",
37                                         "No LineCount specified",
38                                         "No LineLength specified"
39                         }
40                                         );
41                 }
42         }
43
44         @Test
45         public void testPartNoRequired() {
46                 try {
47                         TypedPropertyMap presetspec = new TypedPropertyMap();
48                         presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.PARACHUTE);
49                         presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
50                         ComponentPresetFactory.create(presetspec);
51                 } catch ( InvalidComponentPresetException ex ) {
52                         PresetAssertHelper.assertInvalidPresetException( ex,
53                                         new TypedKey<?>[] {
54                                         ComponentPreset.PARTNO, 
55                                         ComponentPreset.DIAMETER,
56                                         ComponentPreset.LINE_COUNT,
57                                         ComponentPreset.LINE_LENGTH
58                         },
59                         new String[] {
60                                         "No PartNo specified",
61                                         "No Diameter specified",
62                                         "No LineCount specified",
63                                         "No LineLength specified"
64                         }
65                                         );
66                 }
67         }
68
69         @Test
70         public void testDiameterRequired() {
71                 try {
72                         TypedPropertyMap presetspec = new TypedPropertyMap();
73                         presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.PARACHUTE);
74                         presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
75                         presetspec.put( ComponentPreset.PARTNO, "partno");
76                         ComponentPresetFactory.create(presetspec);
77                 } catch ( InvalidComponentPresetException ex ) {
78                         PresetAssertHelper.assertInvalidPresetException( ex,
79                                         new TypedKey<?>[] {
80                                         ComponentPreset.DIAMETER,
81                                         ComponentPreset.LINE_COUNT,
82                                         ComponentPreset.LINE_LENGTH
83                         },
84                         new String[] {
85                                         "No Diameter specified",
86                                         "No LineCount specified",
87                                         "No LineLength specified"
88                         }
89                                         );
90                 }
91         }
92
93         @Test
94         public void testLineCountRequired() {
95                 try {
96                         TypedPropertyMap presetspec = new TypedPropertyMap();
97                         presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.PARACHUTE);
98                         presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
99                         presetspec.put( ComponentPreset.PARTNO, "partno");
100                         presetspec.put( ComponentPreset.DIAMETER, 2.0);
101                         ComponentPresetFactory.create(presetspec);
102                 } catch ( InvalidComponentPresetException ex ) {
103                         PresetAssertHelper.assertInvalidPresetException( ex,
104                                         new TypedKey<?>[] {
105                                         ComponentPreset.LINE_COUNT,
106                                         ComponentPreset.LINE_LENGTH
107                         },
108                         new String[] {
109                                         "No LineCount specified",
110                                         "No LineLength specified"
111                         }
112                                         );
113                 }
114         }
115
116         @Test
117         public void testLineLengthRequired() {
118                 try {
119                         TypedPropertyMap presetspec = new TypedPropertyMap();
120                         presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.PARACHUTE);
121                         presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
122                         presetspec.put( ComponentPreset.PARTNO, "partno");
123                         presetspec.put( ComponentPreset.DIAMETER, 2.0);
124                         presetspec.put( ComponentPreset.LINE_COUNT, 6);
125                         ComponentPresetFactory.create(presetspec);
126                 } catch ( InvalidComponentPresetException ex ) {
127                         PresetAssertHelper.assertInvalidPresetException( ex,
128                                         new TypedKey<?>[] {
129                                         ComponentPreset.LINE_LENGTH
130                         },
131                         new String[] {
132                                         "No LineLength specified"
133                         }
134                                         );
135                 }
136         }
137
138 }