create changelog entry
[debian/openrocket] / core / test / net / sf / openrocket / preset / StreamerPresetTests.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 STREAMER 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 StreamerPresetTests {
17
18         @Test
19         public void testManufacturerRequired() {
20                 try {
21                         TypedPropertyMap presetspec = new TypedPropertyMap();
22                         presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.STREAMER);
23                         ComponentPresetFactory.create(presetspec);
24                 } catch ( InvalidComponentPresetException ex ) {
25                         PresetAssertHelper.assertInvalidPresetException( ex,
26                                         new TypedKey<?>[] {
27                                         ComponentPreset.MANUFACTURER, 
28                                         ComponentPreset.PARTNO, 
29                                         ComponentPreset.LENGTH,
30                                         ComponentPreset.WIDTH
31                         },
32                         new String[] {
33                                         "No Manufacturer specified",
34                                         "No PartNo specified",
35                                         "No Length specified",
36                                         "No Width specified"
37                         }
38                                         );
39                 }
40         }
41
42         @Test
43         public void testPartNoRequired() {
44                 try {
45                         TypedPropertyMap presetspec = new TypedPropertyMap();
46                         presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.STREAMER);
47                         presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
48                         ComponentPresetFactory.create(presetspec);
49                 } catch ( InvalidComponentPresetException ex ) {
50                         PresetAssertHelper.assertInvalidPresetException( ex,
51                                         new TypedKey<?>[] {
52                                         ComponentPreset.PARTNO, 
53                                         ComponentPreset.LENGTH,
54                                         ComponentPreset.WIDTH
55                         },
56                         new String[] {
57                                         "No PartNo specified",
58                                         "No Length specified",
59                                         "No Width specified"
60                         }
61                                         );
62                 }
63         }
64
65         @Test
66         public void testLengthRequired() {
67                 try {
68                         TypedPropertyMap presetspec = new TypedPropertyMap();
69                         presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.STREAMER);
70                         presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
71                         presetspec.put( ComponentPreset.PARTNO, "partno");
72                         ComponentPresetFactory.create(presetspec);
73                 } catch ( InvalidComponentPresetException ex ) {
74                         PresetAssertHelper.assertInvalidPresetException( ex,
75                                         new TypedKey<?>[] {
76                                         ComponentPreset.LENGTH,
77                                         ComponentPreset.WIDTH
78                         },
79                         new String[] {
80                                         "No Length specified",
81                                         "No Width specified"
82                         }
83                                         );
84                 }
85         }
86
87         @Test
88         public void testWidthRequired() {
89                 try {
90                         TypedPropertyMap presetspec = new TypedPropertyMap();
91                         presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.STREAMER);
92                         presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
93                         presetspec.put( ComponentPreset.PARTNO, "partno");
94                         presetspec.put( ComponentPreset.LENGTH, 2.0);
95                         ComponentPresetFactory.create(presetspec);
96                 } catch ( InvalidComponentPresetException ex ) {
97                         PresetAssertHelper.assertInvalidPresetException( ex,
98                                         new TypedKey<?>[] {
99                                         ComponentPreset.WIDTH
100                         },
101                         new String[] {
102                                         "No Width specified"
103                         }
104                                         );
105                 }
106         }
107
108 }