package net.sf.openrocket.preset;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
+import static org.junit.Assert.*;
import net.sf.openrocket.material.Material;
import net.sf.openrocket.motor.Manufacturer;
import net.sf.openrocket.rocketcomponent.Bulkhead;
*
*/
public class BulkHeadComponentTests extends BaseTestCase {
-
+
ComponentPreset preset;
@Before
public void createPreset() throws Exception {
TypedPropertyMap presetspec = new TypedPropertyMap();
presetspec.put(ComponentPreset.TYPE, ComponentPreset.Type.BULK_HEAD);
- presetspec.put( ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
- presetspec.put( ComponentPreset.PARTNO, "partno");
- presetspec.put( ComponentPreset.LENGTH, 2.0);
- presetspec.put( ComponentPreset.OUTER_DIAMETER, 2.0);
- presetspec.put( ComponentPreset.MASS, 100.0);
+ presetspec.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer("manufacturer"));
+ presetspec.put(ComponentPreset.PARTNO, "partno");
+ presetspec.put(ComponentPreset.LENGTH, 2.0);
+ presetspec.put(ComponentPreset.OUTER_DIAMETER, 2.0);
+ presetspec.put(ComponentPreset.MASS, 100.0);
preset = ComponentPresetFactory.create(presetspec);
}
-
+
@Test
public void testComponentType() {
Bulkhead bt = new Bulkhead();
- assertSame( ComponentPreset.Type.BULK_HEAD, bt.getPresetType() );
+ assertSame(ComponentPreset.Type.BULK_HEAD, bt.getPresetType());
}
@Test
bt.loadPreset(preset);
- assertEquals( 2.0, bt.getLength(), 0.0 );
- assertEquals( 1.0, bt.getOuterRadius(), 0.0 );
+ assertEquals(2.0, bt.getLength(), 0.0);
+ assertEquals(1.0, bt.getOuterRadius(), 0.0);
- assertFalse( bt.isOuterRadiusAutomatic() );
+ assertFalse(bt.isOuterRadiusAutomatic());
- assertSame( preset.get( ComponentPreset.MATERIAL), bt.getMaterial() );
- assertEquals( 100.0, bt.getMass(), 0.05);
+ assertSame(preset.get(ComponentPreset.MATERIAL), bt.getMaterial());
+ assertEquals(100.0, bt.getMass(), 0.05);
}
@Test
Bulkhead bt = new Bulkhead();
bt.loadPreset(preset);
-
+
bt.setLength(1.0);
- assertSame( preset, bt.getPresetComponent() );
+ assertSame(preset, bt.getPresetComponent());
}
-
+
@Test
public void changeODClearsPreset() {
Bulkhead bt = new Bulkhead();
bt.loadPreset(preset);
-
+
bt.setOuterRadius(2.0);
- assertNull( bt.getPresetComponent() );
+ assertNull(bt.getPresetComponent());
}
-
+
@Test
public void changeODAutomaticClearsPreset() {
Bulkhead bt = new Bulkhead();
bt.loadPreset(preset);
bt.setOuterRadiusAutomatic(true);
-
- assertNull( bt.getPresetComponent() );
+
+ assertNull(bt.getPresetComponent());
}
-
+
@Test
public void changeMaterialClearsPreset() {
Bulkhead bt = new Bulkhead();
bt.loadPreset(preset);
-
- bt.setMaterial( Material.newUserMaterial(Material.Type.BULK,"new", 1.0));
- assertNull( bt.getPresetComponent() );
+ bt.setMaterial(Material.newMaterial(Material.Type.BULK, "new", 1.0, true));
+
+ assertNull(bt.getPresetComponent());
}
-
+
}