Upload project.

This commit is contained in:
StevenJW
2020-06-07 22:14:52 +01:00
parent 600a4b1b40
commit a7e61735b8
104 changed files with 33974 additions and 0 deletions

View File

@@ -0,0 +1,160 @@
package decorator_pattern_tests.submersible;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import seabedexplorer.data.Data;
import seabedexplorer.data.LaserReading;
import seabedexplorer.submersible.AUV;
import seabedexplorer.submersible.Submersible;
import seabedexplorer.submersible.equipment.locationtracking.Location;
import seabedexplorer.submersible.state.SubmersibleState;
import seabedexplorer.submersible.state.states.DeployState;
import seabedexplorer.submersible.state.states.IdleState;
/**
* AUVTest
*
* @author JLScott1999
*/
public class AUVTest
{
public AUVTest()
{
}
/**
* Test of getSubmersible method, of class AUV.
*/
@Test
public void testGetSubmersible()
{
System.out.println("getSubmersible");
Submersible instance = new AUV();
Submersible expResult = instance;
Submersible result = instance.getSubmersible();
assertEquals(expResult, result);
}
/**
* Test of collectData method, of class AUV.
*/
@Test
public void testCollectData()
{
System.out.println("collectData");
Submersible instance = new AUV();
instance.collectData();
assertTrue(instance.getData().isEmpty());
}
/**
* Test of addData method, of class AUV.
*/
@Test
public void testAddData()
{
System.out.println("addData");
Submersible instance = new AUV();
Data data = new LaserReading(30, 1);
instance.addData(data);
assertTrue(instance.getData().contains(data));
}
/**
* Test of changeState method, of class AUV.
*/
@Test
public void testChangeState()
{
System.out.println("changeState");
SubmersibleState state = new IdleState();
Submersible instance = new AUV();
instance.changeState(state);
SubmersibleState result = instance.getState();
assertEquals(state, result);
}
/**
* Test of getState method, of class AUV.
*/
@Test
public void testGetState()
{
System.out.println("getState");
Submersible instance = new AUV();
SubmersibleState expResult = new DeployState();
instance.changeState(expResult);
SubmersibleState result = instance.getState();
assertEquals(expResult, result);
}
/**
* Test of move method, of class AUV.
*/
@Test
public void testMove()
{
System.out.println("move");
Submersible instance = new AUV();
Location expResult = new Location(1, 2, 1);
instance.move(expResult);
Location result = instance.getGPS().getCurrentLocation();
assertEquals(expResult.toString(), result.toString());
}
/**
* Test of stopMove method, of class AUV.
*/
@Test
public void testStopMove()
{
System.out.println("stopMove");
Submersible instance = new AUV();
Location expResult = new Location();
instance.stopMove();
Location result = instance.getGPS().getCurrentLocation();
assertEquals(expResult.toString(), result.toString());
}
/**
* Test of canMove method, of class AUV.
*/
@Test
public void testCanMove()
{
System.out.println("canMove");
Submersible instance = new AUV();
boolean expResult = true;
boolean result = instance.canMove();
assertEquals(expResult, result);
}
/**
* Test of getSubmersibleType method, of class AUV.
*/
@Test
public void testGetSubmersibleType()
{
System.out.println("getSubmersibleType");
Submersible instance = new AUV();
String expResult = "AUV (Automated Underwater Vehicle)";
String result = instance.getSubmersibleType();
assertEquals(expResult, result);
}
/**
* Test of toString method, of class AUV.
*/
@Test
public void testToString()
{
System.out.println("toString");
Submersible instance = new AUV();
String expResult = "Type: AUV (Automated Underwater Vehicle)\nState: Docked\nData:\nEquipment:";
String result = instance.toString();
assertEquals(expResult, result);
}
}

View File

@@ -0,0 +1,160 @@
package decorator_pattern_tests.submersible;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import seabedexplorer.data.Data;
import seabedexplorer.data.LaserReading;
import seabedexplorer.submersible.MS;
import seabedexplorer.submersible.Submersible;
import seabedexplorer.submersible.equipment.locationtracking.Location;
import seabedexplorer.submersible.state.SubmersibleState;
import seabedexplorer.submersible.state.states.DeployState;
import seabedexplorer.submersible.state.states.IdleState;
/**
* MSTest
*
* @author JLScott1999
*/
public class MSTest
{
public MSTest()
{
}
/**
* Test of getSubmersible method, of class MS.
*/
@Test
public void testGetSubmersible()
{
System.out.println("getSubmersible");
Submersible instance = new MS();
Submersible expResult = instance;
Submersible result = instance.getSubmersible();
assertEquals(expResult, result);
}
/**
* Test of collectData method, of class MS.
*/
@Test
public void testCollectData()
{
System.out.println("collectData");
Submersible instance = new MS();
instance.collectData();
assertTrue(instance.getData().isEmpty());
}
/**
* Test of addData method, of class MS.
*/
@Test
public void testAddData()
{
System.out.println("addData");
Submersible instance = new MS();
Data data = new LaserReading(30, 1);
instance.addData(data);
assertTrue(instance.getData().contains(data));
}
/**
* Test of changeState method, of class MS.
*/
@Test
public void testChangeState()
{
System.out.println("changeState");
SubmersibleState state = new IdleState();
Submersible instance = new MS();
instance.changeState(state);
SubmersibleState result = instance.getState();
assertEquals(state, result);
}
/**
* Test of getState method, of class MS.
*/
@Test
public void testGetState()
{
System.out.println("getState");
Submersible instance = new MS();
SubmersibleState expResult = new DeployState();
instance.changeState(expResult);
SubmersibleState result = instance.getState();
assertEquals(expResult, result);
}
/**
* Test of move method, of class MS.
*/
@Test
public void testMove()
{
System.out.println("move");
Submersible instance = new MS();
Location expResult = new Location(1, 2, 1);
instance.move(expResult);
Location result = instance.getGPS().getCurrentLocation();
assertEquals(expResult.toString(), result.toString());
}
/**
* Test of stopMove method, of class MS.
*/
@Test
public void testStopMove()
{
System.out.println("stopMove");
Submersible instance = new MS();
Location expResult = new Location();
instance.stopMove();
Location result = instance.getGPS().getCurrentLocation();
assertEquals(expResult.toString(), result.toString());
}
/**
* Test of canMove method, of class MS.
*/
@Test
public void testCanMove()
{
System.out.println("canMove");
Submersible instance = new MS();
boolean expResult = true;
boolean result = instance.canMove();
assertEquals(expResult, result);
}
/**
* Test of getSubmersibleType method, of class MS.
*/
@Test
public void testGetSubmersibleType()
{
System.out.println("getSubmersibleType");
Submersible instance = new MS();
String expResult = "MS (Manned Submersible)";
String result = instance.getSubmersibleType();
assertEquals(expResult, result);
}
/**
* Test of toString method, of class MS.
*/
@Test
public void testToString()
{
System.out.println("toString");
Submersible instance = new MS();
String expResult = "Type: MS (Manned Submersible)\nState: Docked\nData:\nEquipment:";
String result = instance.toString();
assertEquals(expResult, result);
}
}

View File

@@ -0,0 +1,160 @@
package decorator_pattern_tests.submersible;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import seabedexplorer.data.Data;
import seabedexplorer.data.LaserReading;
import seabedexplorer.submersible.ROV;
import seabedexplorer.submersible.Submersible;
import seabedexplorer.submersible.equipment.locationtracking.Location;
import seabedexplorer.submersible.state.SubmersibleState;
import seabedexplorer.submersible.state.states.DeployState;
import seabedexplorer.submersible.state.states.IdleState;
/**
* ROVTest
*
* @author JLScott1999
*/
public class ROVTest
{
public ROVTest()
{
}
/**
* Test of getSubmersible method, of class ROV.
*/
@Test
public void testGetSubmersible()
{
System.out.println("getSubmersible");
Submersible instance = new ROV();
Submersible expResult = instance;
Submersible result = instance.getSubmersible();
assertEquals(expResult, result);
}
/**
* Test of collectData method, of class ROV.
*/
@Test
public void testCollectData()
{
System.out.println("collectData");
Submersible instance = new ROV();
instance.collectData();
assertTrue(instance.getData().isEmpty());
}
/**
* Test of addData method, of class ROV.
*/
@Test
public void testAddData()
{
System.out.println("addData");
Submersible instance = new ROV();
Data data = new LaserReading(30, 1);
instance.addData(data);
assertTrue(instance.getData().contains(data));
}
/**
* Test of changeState method, of class ROV.
*/
@Test
public void testChangeState()
{
System.out.println("changeState");
SubmersibleState state = new IdleState();
Submersible instance = new ROV();
instance.changeState(state);
SubmersibleState result = instance.getState();
assertEquals(state, result);
}
/**
* Test of getState method, of class ROV.
*/
@Test
public void testGetState()
{
System.out.println("getState");
Submersible instance = new ROV();
SubmersibleState expResult = new DeployState();
instance.changeState(expResult);
SubmersibleState result = instance.getState();
assertEquals(expResult, result);
}
/**
* Test of move method, of class ROV.
*/
@Test
public void testMove()
{
System.out.println("move");
Submersible instance = new ROV();
Location expResult = new Location(1, 2, 1);
instance.move(expResult);
Location result = instance.getGPS().getCurrentLocation();
assertEquals(expResult.toString(), result.toString());
}
/**
* Test of stopMove method, of class ROV.
*/
@Test
public void testStopMove()
{
System.out.println("stopMove");
Submersible instance = new ROV();
Location expResult = new Location();
instance.stopMove();
Location result = instance.getGPS().getCurrentLocation();
assertEquals(expResult.toString(), result.toString());
}
/**
* Test of canMove method, of class ROV.
*/
@Test
public void testCanMove()
{
System.out.println("canMove");
Submersible instance = new ROV();
boolean expResult = true;
boolean result = instance.canMove();
assertEquals(expResult, result);
}
/**
* Test of getSubmersibleType method, of class ROV.
*/
@Test
public void testGetSubmersibleType()
{
System.out.println("getSubmersibleType");
Submersible instance = new ROV();
String expResult = "ROV (Remote Operated Vehicle)";
String result = instance.getSubmersibleType();
assertEquals(expResult, result);
}
/**
* Test of toString method, of class ROV.
*/
@Test
public void testToString()
{
System.out.println("toString");
Submersible instance = new ROV();
String expResult = "Type: ROV (Remote Operated Vehicle)\nState: Docked\nData:\nEquipment:";
String result = instance.toString();
assertEquals(expResult, result);
}
}

View File

@@ -0,0 +1,161 @@
package decorator_pattern_tests.submersible.equipment;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import seabedexplorer.data.Data;
import seabedexplorer.data.LaserReading;
import seabedexplorer.submersible.AUV;
import seabedexplorer.submersible.Submersible;
import seabedexplorer.submersible.equipment.PhotoSensor;
import seabedexplorer.submersible.equipment.locationtracking.Location;
import seabedexplorer.submersible.state.SubmersibleState;
import seabedexplorer.submersible.state.states.DeployState;
import seabedexplorer.submersible.state.states.IdleState;
/**
* PhotoSensor
*
* @author JLScott1999
*/
public class PhotoSensorTest
{
public PhotoSensorTest()
{
}
/**
* Test of getSubmersible method, of class PhotoSensor.
*/
@Test
public void testGetSubmersible()
{
System.out.println("getSubmersible");
Submersible expResult = new AUV();
Submersible instance = new PhotoSensor(expResult);
Submersible result = instance.getSubmersible();
assertEquals(expResult, result);
}
/**
* Test of collectData method, of class PhotoSensor.
*/
@Test
public void testCollectData()
{
System.out.println("collectData");
Submersible instance = new PhotoSensor(new AUV());
instance.collectData();
assertTrue(instance.getData().size() > 0 && instance.getData().size() < 2);
}
/**
* Test of addData method, of class PhotoSensor.
*/
@Test
public void testAddData()
{
System.out.println("addData");
Submersible instance = new PhotoSensor(new AUV());
Data data = new LaserReading(30, 1);
instance.addData(data);
assertTrue(instance.getData().contains(data));
}
/**
* Test of changeState method, of class PhotoSensor.
*/
@Test
public void testChangeState()
{
System.out.println("changeState");
SubmersibleState state = new IdleState();
Submersible instance = new PhotoSensor(new AUV());
instance.changeState(state);
SubmersibleState result = instance.getState();
assertEquals(state, result);
}
/**
* Test of getState method, of class PhotoSensor.
*/
@Test
public void testGetState()
{
System.out.println("getState");
Submersible instance = new PhotoSensor(new AUV());
SubmersibleState expResult = new DeployState();
instance.changeState(expResult);
SubmersibleState result = instance.getState();
assertEquals(expResult, result);
}
/**
* Test of move method, of class PhotoSensor.
*/
@Test
public void testMove()
{
System.out.println("move");
Submersible instance = new PhotoSensor(new AUV());
Location expResult = new Location(1, 2, 1);
instance.move(expResult);
Location result = instance.getGPS().getCurrentLocation();
assertEquals(expResult.toString(), result.toString());
}
/**
* Test of stopMove method, of class PhotoSensor.
*/
@Test
public void testStopMove()
{
System.out.println("stopMove");
Submersible instance = new PhotoSensor(new AUV());
Location expResult = new Location();
instance.stopMove();
Location result = instance.getGPS().getCurrentLocation();
assertEquals(expResult.toString(), result.toString());
}
/**
* Test of canMove method, of class PhotoSensor.
*/
@Test
public void testCanMove()
{
System.out.println("canMove");
Submersible instance = new PhotoSensor(new AUV());
boolean expResult = true;
boolean result = instance.canMove();
assertEquals(expResult, result);
}
/**
* Test of getSubmersibleType method, of class PhotoSensor.
*/
@Test
public void testGetSubmersibleType()
{
System.out.println("getSubmersibleType");
Submersible instance = new PhotoSensor(new AUV());
String expResult = "AUV (Automated Underwater Vehicle)";
String result = instance.getSubmersibleType();
assertEquals(expResult, result);
}
/**
* Test of toString method, of class PhotoSensor.
*/
@Test
public void testToString()
{
System.out.println("toString");
Submersible instance = new PhotoSensor(new AUV());
String expResult = "Type: AUV (Automated Underwater Vehicle)\nState: Docked\nData:\nEquipment:\n Photo Sensor";
String result = instance.toString();
assertEquals(expResult, result);
}
}

View File

@@ -0,0 +1,160 @@
package decorator_pattern_tests.submersible.equipment.materialsampler;
import static org.junit.Assert.*;
import org.junit.Test;
import seabedexplorer.data.Data;
import seabedexplorer.data.LaserReading;
import seabedexplorer.submersible.AUV;
import seabedexplorer.submersible.Submersible;
import seabedexplorer.submersible.equipment.locationtracking.Location;
import seabedexplorer.submersible.equipment.materialsampler.ChemicalScanner;
import seabedexplorer.submersible.state.SubmersibleState;
import seabedexplorer.submersible.state.states.DeployState;
import seabedexplorer.submersible.state.states.IdleState;
/**
* ChemicalScannerTest
*
* @author JLScott1999
*/
public class ChemicalScannerTest
{
public ChemicalScannerTest()
{
}
/**
* Test of getSubmersible method, of class ChemicalScanner.
*/
@Test
public void testGetSubmersible()
{
System.out.println("getSubmersible");
Submersible expResult = new AUV();
Submersible instance = new ChemicalScanner(expResult, 100);
Submersible result = instance.getSubmersible();
assertEquals(expResult, result);
}
/**
* Test of collectData method, of class ChemicalScanner.
*/
@Test
public void testCollectData()
{
System.out.println("collectData");
Submersible instance = new ChemicalScanner(new AUV(), 100);
instance.collectData();
assertTrue(instance.getData().size() > 0 && instance.getData().size() < 2);
}
/**
* Test of addData method, of class ChemicalScanner.
*/
@Test
public void testAddData()
{
System.out.println("addData");
Submersible instance = new ChemicalScanner(new AUV(), 100);
Data data = new LaserReading(30, 1);
instance.addData(data);
assertTrue(instance.getData().contains(data));
}
/**
* Test of changeState method, of class ChemicalScanner.
*/
@Test
public void testChangeState()
{
System.out.println("changeState");
SubmersibleState state = new IdleState();
Submersible instance = new ChemicalScanner(new AUV(), 100);
instance.changeState(state);
SubmersibleState result = instance.getState();
assertEquals(state, result);
}
/**
* Test of getState method, of class ChemicalScanner.
*/
@Test
public void testGetState()
{
System.out.println("getState");
Submersible instance = new ChemicalScanner(new AUV(), 100);
SubmersibleState expResult = new DeployState();
instance.changeState(expResult);
SubmersibleState result = instance.getState();
assertEquals(expResult, result);
}
/**
* Test of move method, of class ChemicalScanner.
*/
@Test
public void testMove()
{
System.out.println("move");
Submersible instance = new ChemicalScanner(new AUV(), 100);
Location expResult = new Location(1, 2, 1);
instance.move(expResult);
Location result = instance.getGPS().getCurrentLocation();
assertEquals(expResult.toString(), result.toString());
}
/**
* Test of stopMove method, of class ChemicalScanner.
*/
@Test
public void testStopMove()
{
System.out.println("stopMove");
Submersible instance = new ChemicalScanner(new AUV(), 100);
Location expResult = new Location();
instance.stopMove();
Location result = instance.getGPS().getCurrentLocation();
assertEquals(expResult.toString(), result.toString());
}
/**
* Test of canMove method, of class ChemicalScanner.
*/
@Test
public void testCanMove()
{
System.out.println("canMove");
Submersible instance = new ChemicalScanner(new AUV(), 100);
boolean expResult = true;
boolean result = instance.canMove();
assertEquals(expResult, result);
}
/**
* Test of getSubmersibleType method, of class ChemicalScanner.
*/
@Test
public void testGetSubmersibleType()
{
System.out.println("getSubmersibleType");
Submersible instance = new ChemicalScanner(new AUV(), 100);
String expResult = "AUV (Automated Underwater Vehicle)";
String result = instance.getSubmersibleType();
assertEquals(expResult, result);
}
/**
* Test of toString method, of class ChemicalScanner.
*/
@Test
public void testToString()
{
System.out.println("toString");
Submersible instance = new ChemicalScanner(new AUV(), 100);
String expResult = "Type: AUV (Automated Underwater Vehicle)\nState: Docked\nData:\nEquipment:\n Material Sampler - Chemical Scanner";
String result = instance.toString();
assertEquals(expResult, result);
}
}

View File

@@ -0,0 +1,160 @@
package decorator_pattern_tests.submersible.equipment.materialsampler;
import static org.junit.Assert.*;
import org.junit.Test;
import seabedexplorer.data.Data;
import seabedexplorer.data.LaserReading;
import seabedexplorer.submersible.AUV;
import seabedexplorer.submersible.Submersible;
import seabedexplorer.submersible.equipment.locationtracking.Location;
import seabedexplorer.submersible.equipment.materialsampler.HotFluidSampler;
import seabedexplorer.submersible.state.SubmersibleState;
import seabedexplorer.submersible.state.states.DeployState;
import seabedexplorer.submersible.state.states.IdleState;
/**
* HotFluidSamplerTest
*
* @author JLScott1999
*/
public class HotFluidSamplerTest
{
public HotFluidSamplerTest()
{
}
/**
* Test of getSubmersible method, of class HotFluidSampler.
*/
@Test
public void testGetSubmersible()
{
System.out.println("getSubmersible");
Submersible expResult = new AUV();
Submersible instance = new HotFluidSampler(expResult, 100);
Submersible result = instance.getSubmersible();
assertEquals(expResult, result);
}
/**
* Test of collectData method, of class HotFluidSampler.
*/
@Test
public void testCollectData()
{
System.out.println("collectData");
Submersible instance = new HotFluidSampler(new AUV(), 100);
instance.collectData();
assertTrue(instance.getData().size() > 0 && instance.getData().size() < 2);
}
/**
* Test of addData method, of class HotFluidSampler.
*/
@Test
public void testAddData()
{
System.out.println("addData");
Submersible instance = new HotFluidSampler(new AUV(), 100);
Data data = new LaserReading(30, 1);
instance.addData(data);
assertTrue(instance.getData().contains(data));
}
/**
* Test of changeState method, of class HotFluidSampler.
*/
@Test
public void testChangeState()
{
System.out.println("changeState");
SubmersibleState state = new IdleState();
Submersible instance = new HotFluidSampler(new AUV(), 100);
instance.changeState(state);
SubmersibleState result = instance.getState();
assertEquals(state, result);
}
/**
* Test of getState method, of class HotFluidSampler.
*/
@Test
public void testGetState()
{
System.out.println("getState");
Submersible instance = new HotFluidSampler(new AUV(), 100);
SubmersibleState expResult = new DeployState();
instance.changeState(expResult);
SubmersibleState result = instance.getState();
assertEquals(expResult, result);
}
/**
* Test of move method, of class HotFluidSampler.
*/
@Test
public void testMove()
{
System.out.println("move");
Submersible instance = new HotFluidSampler(new AUV(), 100);
Location expResult = new Location(1, 2, 1);
instance.move(expResult);
Location result = instance.getGPS().getCurrentLocation();
assertEquals(expResult.toString(), result.toString());
}
/**
* Test of stopMove method, of class HotFluidSampler.
*/
@Test
public void testStopMove()
{
System.out.println("stopMove");
Submersible instance = new HotFluidSampler(new AUV(), 100);
Location expResult = new Location();
instance.stopMove();
Location result = instance.getGPS().getCurrentLocation();
assertEquals(expResult.toString(), result.toString());
}
/**
* Test of canMove method, of class HotFluidSampler.
*/
@Test
public void testCanMove()
{
System.out.println("canMove");
Submersible instance = new HotFluidSampler(new AUV(), 100);
boolean expResult = true;
boolean result = instance.canMove();
assertEquals(expResult, result);
}
/**
* Test of getSubmersibleType method, of class HotFluidSampler.
*/
@Test
public void testGetSubmersibleType()
{
System.out.println("getSubmersibleType");
Submersible instance = new HotFluidSampler(new AUV(), 100);
String expResult = "AUV (Automated Underwater Vehicle)";
String result = instance.getSubmersibleType();
assertEquals(expResult, result);
}
/**
* Test of toString method, of class HotFluidSampler.
*/
@Test
public void testToString()
{
System.out.println("toString");
Submersible instance = new HotFluidSampler(new AUV(), 100);
String expResult = "Type: AUV (Automated Underwater Vehicle)\nState: Docked\nData:\nEquipment:\n Material Sampler - Hot Fluid Sampler";
String result = instance.toString();
assertEquals(expResult, result);
}
}

View File

@@ -0,0 +1,160 @@
package decorator_pattern_tests.submersible.equipment.materialsampler;
import static org.junit.Assert.*;
import org.junit.Test;
import seabedexplorer.data.Data;
import seabedexplorer.data.LaserReading;
import seabedexplorer.submersible.AUV;
import seabedexplorer.submersible.Submersible;
import seabedexplorer.submersible.equipment.locationtracking.Location;
import seabedexplorer.submersible.equipment.materialsampler.RockCoringDrill;
import seabedexplorer.submersible.state.SubmersibleState;
import seabedexplorer.submersible.state.states.DeployState;
import seabedexplorer.submersible.state.states.IdleState;
/**
* RockCoringDrillTest
*
* @author JLScott1999
*/
public class RockCoringDrillTest
{
public RockCoringDrillTest()
{
}
/**
* Test of getSubmersible method, of class RockCoringDrill.
*/
@Test
public void testGetSubmersible()
{
System.out.println("getSubmersible");
Submersible expResult = new AUV();
Submersible instance = new RockCoringDrill(expResult, 100);
Submersible result = instance.getSubmersible();
assertEquals(expResult, result);
}
/**
* Test of collectData method, of class RockCoringDrill.
*/
@Test
public void testCollectData()
{
System.out.println("collectData");
Submersible instance = new RockCoringDrill(new AUV(), 100);
instance.collectData();
assertTrue(instance.getData().size() > 0 && instance.getData().size() < 2);
}
/**
* Test of addData method, of class RockCoringDrill.
*/
@Test
public void testAddData()
{
System.out.println("addData");
Submersible instance = new RockCoringDrill(new AUV(), 100);
Data data = new LaserReading(30, 1);
instance.addData(data);
assertTrue(instance.getData().contains(data));
}
/**
* Test of changeState method, of class RockCoringDrill.
*/
@Test
public void testChangeState()
{
System.out.println("changeState");
SubmersibleState state = new IdleState();
Submersible instance = new RockCoringDrill(new AUV(), 100);
instance.changeState(state);
SubmersibleState result = instance.getState();
assertEquals(state, result);
}
/**
* Test of getState method, of class RockCoringDrill.
*/
@Test
public void testGetState()
{
System.out.println("getState");
Submersible instance = new RockCoringDrill(new AUV(), 100);
SubmersibleState expResult = new DeployState();
instance.changeState(expResult);
SubmersibleState result = instance.getState();
assertEquals(expResult, result);
}
/**
* Test of move method, of class RockCoringDrill.
*/
@Test
public void testMove()
{
System.out.println("move");
Submersible instance = new RockCoringDrill(new AUV(), 100);
Location expResult = new Location(1, 2, 1);
instance.move(expResult);
Location result = instance.getGPS().getCurrentLocation();
assertEquals(expResult.toString(), result.toString());
}
/**
* Test of stopMove method, of class RockCoringDrill.
*/
@Test
public void testStopMove()
{
System.out.println("stopMove");
Submersible instance = new RockCoringDrill(new AUV(), 100);
Location expResult = new Location();
instance.stopMove();
Location result = instance.getGPS().getCurrentLocation();
assertEquals(expResult.toString(), result.toString());
}
/**
* Test of canMove method, of class RockCoringDrill.
*/
@Test
public void testCanMove()
{
System.out.println("canMove");
Submersible instance = new RockCoringDrill(new AUV(), 100);
boolean expResult = true;
boolean result = instance.canMove();
assertEquals(expResult, result);
}
/**
* Test of getSubmersibleType method, of class RockCoringDrill.
*/
@Test
public void testGetSubmersibleType()
{
System.out.println("getSubmersibleType");
Submersible instance = new RockCoringDrill(new AUV(), 100);
String expResult = "AUV (Automated Underwater Vehicle)";
String result = instance.getSubmersibleType();
assertEquals(expResult, result);
}
/**
* Test of toString method, of class RockCoringDrill.
*/
@Test
public void testToString()
{
System.out.println("toString");
Submersible instance = new RockCoringDrill(new AUV(), 100);
String expResult = "Type: AUV (Automated Underwater Vehicle)\nState: Docked\nData:\nEquipment:\n Material Sampler - Rock-Coring Drill";
String result = instance.toString();
assertEquals(expResult, result);
}
}

View File

@@ -0,0 +1,160 @@
package decorator_pattern_tests.submersible.equipment.topographicalmapper;
import static org.junit.Assert.*;
import org.junit.Test;
import seabedexplorer.data.Data;
import seabedexplorer.data.LaserReading;
import seabedexplorer.submersible.AUV;
import seabedexplorer.submersible.Submersible;
import seabedexplorer.submersible.equipment.locationtracking.Location;
import seabedexplorer.submersible.equipment.topographicalmapper.Laser;
import seabedexplorer.submersible.state.SubmersibleState;
import seabedexplorer.submersible.state.states.DeployState;
import seabedexplorer.submersible.state.states.IdleState;
/**
* LaserTest
*
* @author JLScott1999
*/
public class LaserTest
{
public LaserTest()
{
}
/**
* Test of getSubmersible method, of class Laser.
*/
@Test
public void testGetSubmersible()
{
System.out.println("getSubmersible");
Submersible expResult = new AUV();
Submersible instance = new Laser(expResult, 0.3);
Submersible result = instance.getSubmersible();
assertEquals(expResult, result);
}
/**
* Test of collectData method, of class Laser.
*/
@Test
public void testCollectData()
{
System.out.println("collectData");
Submersible instance = new Laser(new AUV(), 0.3);
instance.collectData();
assertTrue(instance.getData().size() > 0 && instance.getData().size() < 2);
}
/**
* Test of addData method, of class Laser.
*/
@Test
public void testAddData()
{
System.out.println("addData");
Submersible instance = new Laser(new AUV(), 0.3);
Data data = new LaserReading(30, 1);
instance.addData(data);
assertTrue(instance.getData().contains(data));
}
/**
* Test of changeState method, of class Laser.
*/
@Test
public void testChangeState()
{
System.out.println("changeState");
SubmersibleState state = new IdleState();
Submersible instance = new Laser(new AUV(), 0.3);
instance.changeState(state);
SubmersibleState result = instance.getState();
assertEquals(state, result);
}
/**
* Test of getState method, of class Laser.
*/
@Test
public void testGetState()
{
System.out.println("getState");
Submersible instance = new Laser(new AUV(), 0.3);
SubmersibleState expResult = new DeployState();
instance.changeState(expResult);
SubmersibleState result = instance.getState();
assertEquals(expResult, result);
}
/**
* Test of move method, of class Laser.
*/
@Test
public void testMove()
{
System.out.println("move");
Submersible instance = new Laser(new AUV(), 0.3);
Location expResult = new Location(1, 2, 1);
instance.move(expResult);
Location result = instance.getGPS().getCurrentLocation();
assertEquals(expResult.toString(), result.toString());
}
/**
* Test of stopMove method, of class Laser.
*/
@Test
public void testStopMove()
{
System.out.println("stopMove");
Submersible instance = new Laser(new AUV(), 0.3);
Location expResult = new Location();
instance.stopMove();
Location result = instance.getGPS().getCurrentLocation();
assertEquals(expResult.toString(), result.toString());
}
/**
* Test of canMove method, of class Laser.
*/
@Test
public void testCanMove()
{
System.out.println("canMove");
Submersible instance = new Laser(new AUV(), 0.3);
boolean expResult = true;
boolean result = instance.canMove();
assertEquals(expResult, result);
}
/**
* Test of getSubmersibleType method, of class Laser.
*/
@Test
public void testGetSubmersibleType()
{
System.out.println("getSubmersibleType");
Submersible instance = new Laser(new AUV(), 0.3);
String expResult = "AUV (Automated Underwater Vehicle)";
String result = instance.getSubmersibleType();
assertEquals(expResult, result);
}
/**
* Test of toString method, of class Laser.
*/
@Test
public void testToString()
{
System.out.println("toString");
Submersible instance = new Laser(new AUV(), 0.3);
String expResult = "Type: AUV (Automated Underwater Vehicle)\nState: Docked\nData:\nEquipment:\n Topographical Mapper - Laser";
String result = instance.toString();
assertEquals(expResult, result);
}
}

View File

@@ -0,0 +1,160 @@
package decorator_pattern_tests.submersible.equipment.topographicalmapper;
import static org.junit.Assert.*;
import org.junit.Test;
import seabedexplorer.data.Data;
import seabedexplorer.data.LaserReading;
import seabedexplorer.submersible.AUV;
import seabedexplorer.submersible.Submersible;
import seabedexplorer.submersible.equipment.locationtracking.Location;
import seabedexplorer.submersible.equipment.topographicalmapper.Sonar;
import seabedexplorer.submersible.state.SubmersibleState;
import seabedexplorer.submersible.state.states.DeployState;
import seabedexplorer.submersible.state.states.IdleState;
/**
* SonarTest
*
* @author JLScott1999
*/
public class SonarTest
{
public SonarTest()
{
}
/**
* Test of getSubmersible method, of class Sonar.
*/
@Test
public void testGetSubmersible()
{
System.out.println("getSubmersible");
Submersible expResult = new AUV();
Submersible instance = new Sonar(expResult);
Submersible result = instance.getSubmersible();
assertEquals(expResult, result);
}
/**
* Test of collectData method, of class Sonar.
*/
@Test
public void testCollectData()
{
System.out.println("collectData");
Submersible instance = new Sonar(new AUV());
instance.collectData();
assertTrue(instance.getData().size() > 0 && instance.getData().size() < 2);
}
/**
* Test of addData method, of class Sonar.
*/
@Test
public void testAddData()
{
System.out.println("addData");
Submersible instance = new Sonar(new AUV());
Data data = new LaserReading(30, 1);
instance.addData(data);
assertTrue(instance.getData().contains(data));
}
/**
* Test of changeState method, of class Sonar.
*/
@Test
public void testChangeState()
{
System.out.println("changeState");
SubmersibleState state = new IdleState();
Submersible instance = new Sonar(new AUV());
instance.changeState(state);
SubmersibleState result = instance.getState();
assertEquals(state, result);
}
/**
* Test of getState method, of class Sonar.
*/
@Test
public void testGetState()
{
System.out.println("getState");
Submersible instance = new Sonar(new AUV());
SubmersibleState expResult = new DeployState();
instance.changeState(expResult);
SubmersibleState result = instance.getState();
assertEquals(expResult, result);
}
/**
* Test of move method, of class Sonar.
*/
@Test
public void testMove()
{
System.out.println("move");
Submersible instance = new Sonar(new AUV());
Location expResult = new Location(1, 2, 1);
instance.move(expResult);
Location result = instance.getGPS().getCurrentLocation();
assertEquals(expResult.toString(), result.toString());
}
/**
* Test of stopMove method, of class Sonar.
*/
@Test
public void testStopMove()
{
System.out.println("stopMove");
Submersible instance = new Sonar(new AUV());
Location expResult = new Location();
instance.stopMove();
Location result = instance.getGPS().getCurrentLocation();
assertEquals(expResult.toString(), result.toString());
}
/**
* Test of canMove method, of class Sonar.
*/
@Test
public void testCanMove()
{
System.out.println("canMove");
Submersible instance = new Sonar(new AUV());
boolean expResult = true;
boolean result = instance.canMove();
assertEquals(expResult, result);
}
/**
* Test of getSubmersibleType method, of class Sonar.
*/
@Test
public void testGetSubmersibleType()
{
System.out.println("getSubmersibleType");
Submersible instance = new Sonar(new AUV());
String expResult = "AUV (Automated Underwater Vehicle)";
String result = instance.getSubmersibleType();
assertEquals(expResult, result);
}
/**
* Test of toString method, of class Sonar.
*/
@Test
public void testToString()
{
System.out.println("toString");
Submersible instance = new Sonar(new AUV());
String expResult = "Type: AUV (Automated Underwater Vehicle)\nState: Docked\nData:\nEquipment:\n Topographical Mapper - Sonar";
String result = instance.toString();
assertEquals(expResult, result);
}
}

View File

@@ -0,0 +1,159 @@
package decorator_pattern_tests.submersible.equipment.waterreadings;
import static org.junit.Assert.*;
import org.junit.Test;
import seabedexplorer.data.Data;
import seabedexplorer.data.LaserReading;
import seabedexplorer.submersible.AUV;
import seabedexplorer.submersible.Submersible;
import seabedexplorer.submersible.equipment.locationtracking.Location;
import seabedexplorer.submersible.equipment.waterreadings.IndexOfRefraction;
import seabedexplorer.submersible.state.SubmersibleState;
import seabedexplorer.submersible.state.states.DeployState;
import seabedexplorer.submersible.state.states.IdleState;
/**
*
* @author JLScott1999
*/
public class IndexOfRefractionTest
{
public IndexOfRefractionTest()
{
}
/**
* Test of getSubmersible method, of class IndexOfRefraction.
*/
@Test
public void testGetSubmersible()
{
System.out.println("getSubmersible");
Submersible expResult = new AUV();
Submersible instance = new IndexOfRefraction(expResult, 30);
Submersible result = instance.getSubmersible();
assertEquals(expResult, result);
}
/**
* Test of collectData method, of class IndexOfRefraction.
*/
@Test
public void testCollectData()
{
System.out.println("collectData");
Submersible instance = new IndexOfRefraction(new AUV(), 30);
instance.collectData();
assertTrue(instance.getData().size() > 0 && instance.getData().size() < 2);
}
/**
* Test of addData method, of class IndexOfRefraction.
*/
@Test
public void testAddData()
{
System.out.println("addData");
Submersible instance = new IndexOfRefraction(new AUV(), 30);
Data data = new LaserReading(30, 1);
instance.addData(data);
assertTrue(instance.getData().contains(data));
}
/**
* Test of changeState method, of class IndexOfRefraction.
*/
@Test
public void testChangeState()
{
System.out.println("changeState");
SubmersibleState state = new IdleState();
Submersible instance = new IndexOfRefraction(new AUV(), 30);
instance.changeState(state);
SubmersibleState result = instance.getState();
assertEquals(state, result);
}
/**
* Test of getState method, of class IndexOfRefraction.
*/
@Test
public void testGetState()
{
System.out.println("getState");
Submersible instance = new IndexOfRefraction(new AUV(), 30);
SubmersibleState expResult = new DeployState();
instance.changeState(expResult);
SubmersibleState result = instance.getState();
assertEquals(expResult, result);
}
/**
* Test of move method, of class IndexOfRefraction.
*/
@Test
public void testMove()
{
System.out.println("move");
Submersible instance = new IndexOfRefraction(new AUV(), 30);
Location expResult = new Location(1, 2, 1);
instance.move(expResult);
Location result = instance.getGPS().getCurrentLocation();
assertEquals(expResult.toString(), result.toString());
}
/**
* Test of stopMove method, of class IndexOfRefraction.
*/
@Test
public void testStopMove()
{
System.out.println("stopMove");
Submersible instance = new IndexOfRefraction(new AUV(), 30);
Location expResult = new Location();
instance.stopMove();
Location result = instance.getGPS().getCurrentLocation();
assertEquals(expResult.toString(), result.toString());
}
/**
* Test of canMove method, of class IndexOfRefraction.
*/
@Test
public void testCanMove()
{
System.out.println("canMove");
Submersible instance = new IndexOfRefraction(new AUV(), 30);
boolean expResult = true;
boolean result = instance.canMove();
assertEquals(expResult, result);
}
/**
* Test of getSubmersibleType method, of class IndexOfRefraction.
*/
@Test
public void testGetSubmersibleType()
{
System.out.println("getSubmersibleType");
Submersible instance = new IndexOfRefraction(new AUV(), 30);
String expResult = "AUV (Automated Underwater Vehicle)";
String result = instance.getSubmersibleType();
assertEquals(expResult, result);
}
/**
* Test of toString method, of class IndexOfRefraction.
*/
@Test
public void testToString()
{
System.out.println("toString");
Submersible instance = new IndexOfRefraction(new AUV(), 30);
String expResult = "Type: AUV (Automated Underwater Vehicle)\nState: Docked\nData:\nEquipment:\n Water Readings - Index Of Refraction";
String result = instance.toString();
assertEquals(expResult, result);
}
}

View File

@@ -0,0 +1,160 @@
package decorator_pattern_tests.submersible.equipment.waterreadings;
import static org.junit.Assert.*;
import org.junit.Test;
import seabedexplorer.data.Data;
import seabedexplorer.data.LaserReading;
import seabedexplorer.submersible.AUV;
import seabedexplorer.submersible.Submersible;
import seabedexplorer.submersible.equipment.locationtracking.Location;
import seabedexplorer.submersible.equipment.waterreadings.PH;
import seabedexplorer.submersible.state.SubmersibleState;
import seabedexplorer.submersible.state.states.DeployState;
import seabedexplorer.submersible.state.states.IdleState;
/**
* PHTest
*
* @author JLScott1999
*/
public class PHTest
{
public PHTest()
{
}
/**
* Test of getSubmersible method, of class PH.
*/
@Test
public void testGetSubmersible()
{
System.out.println("getSubmersible");
Submersible expResult = new AUV();
Submersible instance = new PH(expResult);
Submersible result = instance.getSubmersible();
assertEquals(expResult, result);
}
/**
* Test of collectData method, of class PH.
*/
@Test
public void testCollectData()
{
System.out.println("collectData");
Submersible instance = new PH(new AUV());
instance.collectData();
assertTrue(instance.getData().size() > 0 && instance.getData().size() < 2);
}
/**
* Test of addData method, of class PH.
*/
@Test
public void testAddData()
{
System.out.println("addData");
Submersible instance = new PH(new AUV());
Data data = new LaserReading(30, 1);
instance.addData(data);
assertTrue(instance.getData().contains(data));
}
/**
* Test of changeState method, of class PH.
*/
@Test
public void testChangeState()
{
System.out.println("changeState");
SubmersibleState state = new IdleState();
Submersible instance = new PH(new AUV());
instance.changeState(state);
SubmersibleState result = instance.getState();
assertEquals(state, result);
}
/**
* Test of getState method, of class PH.
*/
@Test
public void testGetState()
{
System.out.println("getState");
Submersible instance = new PH(new AUV());
SubmersibleState expResult = new DeployState();
instance.changeState(expResult);
SubmersibleState result = instance.getState();
assertEquals(expResult, result);
}
/**
* Test of move method, of class PH.
*/
@Test
public void testMove()
{
System.out.println("move");
Submersible instance = new PH(new AUV());
Location expResult = new Location(1, 2, 1);
instance.move(expResult);
Location result = instance.getGPS().getCurrentLocation();
assertEquals(expResult.toString(), result.toString());
}
/**
* Test of stopMove method, of class PH.
*/
@Test
public void testStopMove()
{
System.out.println("stopMove");
Submersible instance = new PH(new AUV());
Location expResult = new Location();
instance.stopMove();
Location result = instance.getGPS().getCurrentLocation();
assertEquals(expResult.toString(), result.toString());
}
/**
* Test of canMove method, of class PH.
*/
@Test
public void testCanMove()
{
System.out.println("canMove");
Submersible instance = new PH(new AUV());
boolean expResult = true;
boolean result = instance.canMove();
assertEquals(expResult, result);
}
/**
* Test of getSubmersibleType method, of class PH.
*/
@Test
public void testGetSubmersibleType()
{
System.out.println("getSubmersibleType");
Submersible instance = new PH(new AUV());
String expResult = "AUV (Automated Underwater Vehicle)";
String result = instance.getSubmersibleType();
assertEquals(expResult, result);
}
/**
* Test of toString method, of class PH.
*/
@Test
public void testToString()
{
System.out.println("toString");
Submersible instance = new PH(new AUV());
String expResult = "Type: AUV (Automated Underwater Vehicle)\nState: Docked\nData:\nEquipment:\n Water Readings - pH Reader";
String result = instance.toString();
assertEquals(expResult, result);
}
}

View File

@@ -0,0 +1,161 @@
package decorator_pattern_tests.submersible.equipment.waterreadings;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import seabedexplorer.data.Data;
import seabedexplorer.data.LaserReading;
import seabedexplorer.submersible.AUV;
import seabedexplorer.submersible.Submersible;
import seabedexplorer.submersible.equipment.locationtracking.Location;
import seabedexplorer.submersible.equipment.waterreadings.Salinity;
import seabedexplorer.submersible.state.SubmersibleState;
import seabedexplorer.submersible.state.states.DeployState;
import seabedexplorer.submersible.state.states.IdleState;
/**
* SalinityTest
*
* @author JLScott1999
*/
public class SalinityTest
{
public SalinityTest()
{
}
/**
* Test of getSubmersible method, of class Salinity.
*/
@Test
public void testGetSubmersible()
{
System.out.println("getSubmersible");
Submersible expResult = new AUV();
Submersible instance = new Salinity(expResult);
Submersible result = instance.getSubmersible();
assertEquals(expResult, result);
}
/**
* Test of collectData method, of class Salinity.
*/
@Test
public void testCollectData()
{
System.out.println("collectData");
Submersible instance = new Salinity(new AUV());
instance.collectData();
assertTrue(instance.getData().size() > 0 && instance.getData().size() < 2);
}
/**
* Test of addData method, of class Salinity.
*/
@Test
public void testAddData()
{
System.out.println("addData");
Submersible instance = new Salinity(new AUV());
Data data = new LaserReading(30, 1);
instance.addData(data);
assertTrue(instance.getData().contains(data));
}
/**
* Test of changeState method, of class Salinity.
*/
@Test
public void testChangeState()
{
System.out.println("changeState");
SubmersibleState state = new IdleState();
Submersible instance = new Salinity(new AUV());
instance.changeState(state);
SubmersibleState result = instance.getState();
assertEquals(state, result);
}
/**
* Test of getState method, of class Salinity.
*/
@Test
public void testGetState()
{
System.out.println("getState");
Submersible instance = new Salinity(new AUV());
SubmersibleState expResult = new DeployState();
instance.changeState(expResult);
SubmersibleState result = instance.getState();
assertEquals(expResult, result);
}
/**
* Test of move method, of class Salinity.
*/
@Test
public void testMove()
{
System.out.println("move");
Submersible instance = new Salinity(new AUV());
Location expResult = new Location(1, 2, 1);
instance.move(expResult);
Location result = instance.getGPS().getCurrentLocation();
assertEquals(expResult.toString(), result.toString());
}
/**
* Test of stopMove method, of class Salinity.
*/
@Test
public void testStopMove()
{
System.out.println("stopMove");
Submersible instance = new Salinity(new AUV());
Location expResult = new Location();
instance.stopMove();
Location result = instance.getGPS().getCurrentLocation();
assertEquals(expResult.toString(), result.toString());
}
/**
* Test of canMove method, of class Salinity.
*/
@Test
public void testCanMove()
{
System.out.println("canMove");
Submersible instance = new Salinity(new AUV());
boolean expResult = true;
boolean result = instance.canMove();
assertEquals(expResult, result);
}
/**
* Test of getSubmersibleType method, of class Salinity.
*/
@Test
public void testGetSubmersibleType()
{
System.out.println("getSubmersibleType");
Submersible instance = new Salinity(new AUV());
String expResult = "AUV (Automated Underwater Vehicle)";
String result = instance.getSubmersibleType();
assertEquals(expResult, result);
}
/**
* Test of toString method, of class Salinity.
*/
@Test
public void testToString()
{
System.out.println("toString");
Submersible instance = new Salinity(new AUV());
String expResult = "Type: AUV (Automated Underwater Vehicle)\nState: Docked\nData:\nEquipment:\n Water Readings - Salinity Reader";
String result = instance.toString();
assertEquals(expResult, result);
}
}

View File

@@ -0,0 +1,33 @@
package observer_pattern_tests.submersible.equipment;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
import org.junit.Test;
import static org.junit.Assert.*;
import seabedexplorer.submersible.ROV;
import seabedexplorer.submersible.equipment.PhotoSensor;
/**
*
* @author Dylan Currey
*/
public class PhotoSensorTest {
public PhotoSensorTest() {
}
/**
* Test of update method, of class PhotoSensor.
*/
@Test
public void testUpdate() {
System.out.println("update");
PhotoSensor s = new PhotoSensor(new ROV());
String before = s.toString();
s.update("photosensor");
String after = s.toString();
assertThat(after, is(not(equalTo(before))));
}
}

View File

@@ -0,0 +1,33 @@
package observer_pattern_tests.submersible.equipment.materialsampler;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
import org.junit.Test;
import static org.junit.Assert.*;
import seabedexplorer.submersible.ROV;
import seabedexplorer.submersible.equipment.materialsampler.ChemicalScanner;
/**
*
* @author Dylan Currey
*/
public class ChemicalScannerTest {
public ChemicalScannerTest() {
}
/**
* Test of update method, of class ChemicalScanner.
*/
@Test
public void testUpdate() {
System.out.println("update");
ChemicalScanner s = new ChemicalScanner(new ROV(), 1);
String before = s.toString();
s.update("scan");
String after = s.toString();
assertThat(after, is(not(equalTo(before))));
}
}

View File

@@ -0,0 +1,33 @@
package observer_pattern_tests.submersible.equipment.materialsampler;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
import org.junit.Test;
import static org.junit.Assert.*;
import seabedexplorer.submersible.ROV;
import seabedexplorer.submersible.equipment.materialsampler.HotFluidSampler;
/**
*
* @author Dylan Currey
*/
public class HotFluidSamplerTest {
public HotFluidSamplerTest() {
}
/**
* Test of update method, of class HotFluidSampler.
*/
@Test
public void testUpdate() {
System.out.println("update");
HotFluidSampler s = new HotFluidSampler(new ROV(),1);
String before = s.toString();
s.update("fluid");
String after = s.toString();
assertThat(after, is(not(equalTo(before))));
}
}

View File

@@ -0,0 +1,33 @@
package observer_pattern_tests.submersible.equipment.materialsampler;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
import org.junit.Test;
import static org.junit.Assert.*;
import seabedexplorer.submersible.ROV;
import seabedexplorer.submersible.equipment.materialsampler.RockCoringDrill;
/**
*
* @author Dylan Currey
*/
public class RockCoringDrillTest {
public RockCoringDrillTest() {
}
/**
* Test of update method, of class RockCoringDrill.
*/
@Test
public void testUpdate() {
System.out.println("update");
RockCoringDrill s = new RockCoringDrill(new ROV(),1);
String before = s.toString();
s.update("drill");
String after = s.toString();
assertThat(after, is(not(equalTo(before))));
}
}

View File

@@ -0,0 +1,33 @@
package observer_pattern_tests.submersible.equipment.topographicalmapper;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
import org.junit.Test;
import static org.junit.Assert.*;
import seabedexplorer.submersible.ROV;
import seabedexplorer.submersible.equipment.topographicalmapper.Laser;
/**
*
* @author Dylan Currey
*/
public class LaserTest {
public LaserTest() {
}
/**
* Test of update method, of class Laser.
*/
@Test
public void testUpdate() {
System.out.println("update");
Laser s = new Laser(new ROV(),1);
String before = s.toString();
s.update("laser");
String after = s.toString();
assertThat(after, is(not(equalTo(before))));
}
}

View File

@@ -0,0 +1,33 @@
package observer_pattern_tests.submersible.equipment.topographicalmapper;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
import org.junit.Test;
import static org.junit.Assert.*;
import seabedexplorer.submersible.ROV;
import seabedexplorer.submersible.equipment.topographicalmapper.Sonar;
/**
*
* @author Dylan Currey
*/
public class SonarTest {
public SonarTest() {
}
/**
* Test of update method, of class Sonar.
*/
@Test
public void testUpdate() {
System.out.println("update");
Sonar s = new Sonar(new ROV());
String before = s.toString();
s.update("sonar");
String after = s.toString();
assertThat(after, is(not(equalTo(before))));
}
}

View File

@@ -0,0 +1,33 @@
package observer_pattern_tests.submersible.equipment.waterreadings;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
import org.junit.Test;
import static org.junit.Assert.*;
import seabedexplorer.submersible.ROV;
import seabedexplorer.submersible.equipment.waterreadings.IndexOfRefraction;
/**
*
* @author Dylan Currey
*/
public class IndexOfRefractionTest {
public IndexOfRefractionTest() {
}
/**
* Test of update method, of class IndexOfRefraction.
*/
@Test
public void testUpdate() {
System.out.println("update");
IndexOfRefraction s = new IndexOfRefraction(new ROV(),1);
String before = s.toString();
s.update("refraction");
String after = s.toString();
assertThat(after, is(not(equalTo(before))));
}
}

View File

@@ -0,0 +1,31 @@
package observer_pattern_tests.submersible.equipment.waterreadings;
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;
import org.junit.Test;
import seabedexplorer.submersible.ROV;
import seabedexplorer.submersible.equipment.waterreadings.PH;
/**
*
* @author Dylan Currey
*/
public class PHTest {
public PHTest() {
}
/**
* Test of update method, of class PH.
*/
@Test
public void testUpdate() {
System.out.println("update");
PH s = new PH(new ROV());
String before = s.toString();
s.update("PH");
String after = s.toString();
assertThat(after, is(not(equalTo(before))));
}
}

View File

@@ -0,0 +1,33 @@
package observer_pattern_tests.submersible.equipment.waterreadings;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
import org.junit.Test;
import static org.junit.Assert.*;
import seabedexplorer.submersible.ROV;
import seabedexplorer.submersible.equipment.waterreadings.Salinity;
/**
*
* @author Dylan Currey
*/
public class SalinityTest {
public SalinityTest() {
}
/**
* Test of update method, of class Salinity.
*/
@Test
public void testUpdate() {
System.out.println("update");
Salinity s = new Salinity(new ROV());
String before = s.toString();
s.update("salinity");
String after = s.toString();
assertThat(after, is(not(equalTo(before))));
}
}

View File

@@ -0,0 +1,76 @@
package observer_pattern_tests.vessel;
import static org.junit.Assert.*;
import org.junit.Test;
import seabedexplorer.observer.Observer;
import seabedexplorer.submersible.AUV;
import seabedexplorer.submersible.MS;
import seabedexplorer.submersible.ROV;
import seabedexplorer.submersible.Submersible;
import seabedexplorer.util.submersible.SubmersibleUtil;
import seabedexplorer.vessel.Vessel;
/**
*
* @author cdrbv
*/
public class VesselTest {
public VesselTest() {
}
/**
* Test of attach method, of class Vessel.
*/
@Test
public void testAttach() {
System.out.println("attach");
Observer AUV = new AUV();
Observer ROV = new ROV();
Observer MS = new MS();
Vessel v = new Vessel();
v.attach(AUV);
v.attach(ROV);
v.attach(MS);
final int expectedValue = 3;
assertEquals(expectedValue, v.getNoSubmersibles());
}
/**
* Test of detach method, of class Vessel.
*/
@Test
public void testDetach() {
System.out.println("detach");
Vessel v = new Vessel();
Observer AUV = new AUV();
Observer ROV = new ROV();
Observer MS = new MS();
v.attach(AUV);
v.attach(ROV);
v.attach(MS);
v.detach(AUV);
v.detach(ROV);
v.detach(MS);
final int expectedValue = 0;
assertEquals(expectedValue, v.getNoSubmersibles());
}
/**
* Test of updateObservers method, of class Vessel.
*/
@Test
public void testUpdateObservers() {
System.out.println("updateObservers");
Vessel v = new Vessel();
for(Submersible s: SubmersibleUtil.GenerateRandomSubmersibles(3))
{
v.attach(s);
}
boolean result = v.updateObservers("info");
assertTrue(result);
}
}

View File

@@ -0,0 +1,19 @@
package state_pattern_tests;
import org.junit.Test;
import static org.junit.Assert.*;
import seabedexplorer.submersible.ROV;
import seabedexplorer.submersible.equipment.locationtracking.Location;
public class StateTransitionTest {
@Test
public void StateTransitionTest()
{
ROV rov = new ROV();
rov.move(new Location(5, 5, 5));
assertEquals(rov.getStateName(), "Idle");
}
}

View File

@@ -0,0 +1,71 @@
package state_pattern_tests.states;
import org.junit.Test;
import static org.junit.Assert.*;
import seabedexplorer.submersible.ROV;
import seabedexplorer.submersible.equipment.locationtracking.Location;
import seabedexplorer.submersible.state.states.BusyActionState;
import seabedexplorer.submersible.state.states.IdleState;
public class BusyActionStateTest {
public BusyActionStateTest() {
}
@Test
public void BusyActionStateTestCanMove()
{
BusyActionState is = new BusyActionState();
assertFalse(is.canMove());
}
@Test
public void BusyActionStateTestMove()
{
BusyActionState is = new BusyActionState();
is.submersibleInstance(new ROV());
assertFalse(is.move(new Location(5, 5, 5)));
}
@Test
public void BusyActionStatesTestStopMove()
{
BusyActionState is = new BusyActionState();
assertFalse(is.stopMove());
}
@Test
public void BusyActionStateString()
{
BusyActionState is = new BusyActionState();
assertEquals(is.toString(), "Busy (Action in progress)");
}
@Test
public void BusyActionStateReturnToVesel()
{
BusyActionState is = new BusyActionState();
assertFalse(is.returnToVessel());
}
@Test
public void BusyActionStateCollectWater()
{
BusyActionState is = new BusyActionState();
assertFalse(is.collectWater());
}
@Test
public void BusyActionStateCollectMaterial()
{
BusyActionState is = new BusyActionState();
assertFalse(is.collectMaterial());
}
@Test
public void BusyActionStateCollectMapping()
{
BusyActionState is = new BusyActionState();
assertFalse(is.collectMappingData());
}
}

View File

@@ -0,0 +1,65 @@
package state_pattern_tests.states;
import org.junit.Test;
import static org.junit.Assert.*;
import seabedexplorer.submersible.ROV;
import seabedexplorer.submersible.equipment.locationtracking.Location;
import seabedexplorer.submersible.state.states.BusyMoveState;
import seabedexplorer.util.movement.MovementEmulation;
public class BusyMoveStateTest {
public BusyMoveStateTest() {
}
@Test
public void BusyMoveStateTestCanMove()
{
BusyMoveState is = new BusyMoveState(new MovementEmulation(new ROV(), new Location(5, 5, 5)));
assertFalse(is.canMove());
}
@Test
public void BusyMoveStateTestMove()
{
BusyMoveState is = new BusyMoveState(new MovementEmulation(new ROV(), new Location(5, 5, 5)));
assertFalse(is.move(new Location(5, 5, 5)));
}
@Test
public void BusyMoveStateString()
{
BusyMoveState is = new BusyMoveState(new MovementEmulation(new ROV(), new Location(5, 5, 5)));
assertEquals(is.toString(), "Busy (Movement in progress)");
}
@Test
public void BusyMoveStateReturnToVesel()
{
BusyMoveState is = new BusyMoveState(new MovementEmulation(new ROV(), new Location(5, 5, 5)));
assertFalse(is.returnToVessel());
}
@Test
public void BusyMoveStateCollectWater()
{
BusyMoveState is = new BusyMoveState(new MovementEmulation(new ROV(), new Location(5, 5, 5)));
assertFalse(is.collectWater());
}
@Test
public void BusyMoveStateCollectMaterial()
{
BusyMoveState is = new BusyMoveState(new MovementEmulation(new ROV(), new Location(5, 5, 5)));
assertFalse(is.collectMaterial());
}
@Test
public void BusyMoveStateCollectMapping()
{
BusyMoveState is = new BusyMoveState(new MovementEmulation(new ROV(), new Location(5, 5, 5)));
assertFalse(is.collectMappingData());
}
}

View File

@@ -0,0 +1,71 @@
package state_pattern_tests.states;
import org.junit.Test;
import static org.junit.Assert.*;
import seabedexplorer.submersible.ROV;
import seabedexplorer.submersible.equipment.locationtracking.Location;
import seabedexplorer.submersible.state.states.DeployState;
import seabedexplorer.submersible.state.states.IdleState;
public class DeployStateTest {
public DeployStateTest() {
}
@Test
public void DeployStateTestCanMove()
{
DeployState is = new DeployState();
assertFalse(is.canMove());
}
@Test
public void DeployStateTestMove()
{
DeployState is = new DeployState();
is.submersibleInstance(new ROV());
assertFalse(is.move(new Location(5, 5, 5)));
}
@Test
public void DeployStatesTestStopMove()
{
DeployState is = new DeployState();
assertFalse(is.stopMove());
}
@Test
public void DeployStateString()
{
DeployState is = new DeployState();
assertEquals(is.toString(), "Deployed");
}
@Test
public void DeployStateReturnToVesel()
{
DeployState is = new DeployState();
assertFalse(is.returnToVessel());
}
@Test
public void DeployStateCollectWater()
{
DeployState is = new DeployState();
assertFalse(is.collectWater());
}
@Test
public void DeployStateCollectMaterial()
{
DeployState is = new DeployState();
assertFalse(is.collectMaterial());
}
@Test
public void DeployStateCollectMapping()
{
DeployState is = new DeployState();
assertFalse(is.collectMappingData());
}
}

View File

@@ -0,0 +1,71 @@
package state_pattern_tests.states;
import org.junit.Test;
import static org.junit.Assert.*;
import seabedexplorer.submersible.ROV;
import seabedexplorer.submersible.equipment.locationtracking.Location;
import seabedexplorer.submersible.state.states.DockedState;
import seabedexplorer.submersible.state.states.IdleState;
public class DockedStateTest {
public DockedStateTest() {
}
@Test
public void DockedStateTestCanMove()
{
DockedState is = new DockedState();
assertTrue(is.canMove());
}
@Test
public void DockedStateTestMove()
{
DockedState is = new DockedState();
is.submersibleInstance(new ROV());
assertTrue(is.move(new Location(5, 5, 5)));
}
@Test
public void DockedStatesTestStopMove()
{
DockedState is = new DockedState();
assertFalse(is.stopMove());
}
@Test
public void DockedStateString()
{
DockedState is = new DockedState();
assertEquals(is.toString(), "Docked");
}
@Test
public void DockedStateReturnToVesel()
{
DockedState is = new DockedState();
assertFalse(is.returnToVessel());
}
@Test
public void DockedStateCollectWater()
{
DockedState is = new DockedState();
assertFalse(is.collectWater());
}
@Test
public void DockedStateCollectMaterial()
{
DockedState is = new DockedState();
assertFalse(is.collectMaterial());
}
@Test
public void DockedStateCollectMapping()
{
DockedState is = new DockedState();
assertFalse(is.collectMappingData());
}
}

View File

@@ -0,0 +1,71 @@
package state_pattern_tests.states;
import org.junit.Test;
import static org.junit.Assert.*;
import seabedexplorer.submersible.ROV;
import seabedexplorer.submersible.equipment.locationtracking.Location;
import seabedexplorer.submersible.state.states.IdleState;
public class IdleStateTest {
@Test
public void IdleStateTestCanMove()
{
IdleState is = new IdleState();
assertTrue(is.canMove());
}
@Test
public void IdleStateTestMove()
{
IdleState is = new IdleState();
is.submersibleInstance(new ROV());
assertTrue(is.move(new Location(5, 5, 5)));
}
@Test
public void IdleStatesTestStopMove()
{
IdleState is = new IdleState();
assertFalse(is.stopMove());
}
@Test
public void IdleStateString()
{
IdleState is = new IdleState();
assertEquals(is.toString(), "Idle");
}
@Test
public void IdleStateReturnToVesel()
{
IdleState is = new IdleState();
is.submersibleInstance(new ROV());
assertTrue(is.returnToVessel());
}
@Test
public void IdleStateCollectWater()
{
IdleState is = new IdleState();
is.submersibleInstance(new ROV());
assertTrue(is.collectWater());
}
@Test
public void IdleStateCollectMaterial()
{
IdleState is = new IdleState();
is.submersibleInstance(new ROV());
assertTrue(is.collectMaterial());
}
@Test
public void IdleStateCollectMapping()
{
IdleState is = new IdleState();
is.submersibleInstance(new ROV());
assertTrue(is.collectMappingData());
}
}

View File

@@ -0,0 +1,74 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package strategy_pattern_tests;
import static org.junit.Assert.*;
import org.junit.Test;
import seabedexplorer.data.Data;
import seabedexplorer.data.MaterialSample;
import seabedexplorer.submersible.ROV;
import seabedexplorer.submersible.equipment.materialsampler.ChemicalScanner;
/**
*
* @author Super
*/
public class ChemicalScannerTest {
@Test
public void validMassTest() {
ROV submersible = new ROV();
ChemicalScanner equipment = new ChemicalScanner(submersible, 0.5);
for (int i = 0; i < 100; i++)
equipment.collectData();
Data[] data = equipment.getData().toArray(new Data[100]);
for (int i = 0; i < 100; i++) {
MaterialSample current = (MaterialSample) data[i];
System.out.println(current.getMass());
assertTrue(current.getMass() >= 0);
}
}
@Test
public void validDensityTest() {
ROV submersible = new ROV();
ChemicalScanner equipment = new ChemicalScanner(submersible, 0.5);
for (int i = 0; i < 100; i++)
equipment.collectData();
Data[] data = equipment.getData().toArray(new Data[100]);
for (int i = 0; i < 100; i++) {
MaterialSample current = (MaterialSample) data[i];
System.out.println(current.getDensity());
assertTrue(current.getDensity() >= 0);
}
}
@Test
public void correctDensityTest() {
ROV submersible = new ROV();
ChemicalScanner equipment = new ChemicalScanner(submersible, 0.5);
for (int i = 0; i < 100; i++)
equipment.collectData();
Data[] data = equipment.getData().toArray(new Data[100]);
for (int i = 0; i < 100; i++) {
MaterialSample current = (MaterialSample) data[i];
System.out.println(current.getMass() + " " + current.getDensity());
assertEquals(current.getMass(),current.getDensity() * 0.5, 0);
}
}
}

View File

@@ -0,0 +1,74 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package strategy_pattern_tests;
import static org.junit.Assert.*;
import org.junit.Test;
import seabedexplorer.data.Data;
import seabedexplorer.data.MaterialSample;
import seabedexplorer.submersible.ROV;
import seabedexplorer.submersible.equipment.materialsampler.HotFluidSampler;
/**
*
* @author Super
*/
public class HotFluidSamplerTest {
@Test
public void validMassTest() {
ROV submersible = new ROV();
HotFluidSampler equipment = new HotFluidSampler(submersible, 0.5);
for (int i = 0; i < 100; i++)
equipment.collectData();
Data[] data = equipment.getData().toArray(new Data[100]);
for (int i = 0; i < 100; i++) {
MaterialSample current = (MaterialSample) data[i];
System.out.println(current.getMass());
assertTrue(current.getMass() >= 0);
}
}
@Test
public void validDensityTest() {
ROV submersible = new ROV();
HotFluidSampler equipment = new HotFluidSampler(submersible, 0.5);
for (int i = 0; i < 100; i++)
equipment.collectData();
Data[] data = equipment.getData().toArray(new Data[100]);
for (int i = 0; i < 100; i++) {
MaterialSample current = (MaterialSample) data[i];
System.out.println(current.getDensity());
assertTrue(current.getDensity() >= 0);
}
}
@Test
public void correctDensityTest() {
ROV submersible = new ROV();
HotFluidSampler equipment = new HotFluidSampler(submersible, 0.5);
for (int i = 0; i < 100; i++)
equipment.collectData();
Data[] data = equipment.getData().toArray(new Data[100]);
for (int i = 0; i < 100; i++) {
MaterialSample current = (MaterialSample) data[i];
System.out.println(current.getMass() + " " + current.getDensity());
assertEquals(current.getMass(),current.getDensity() * 0.5, 0);
}
}
}

View File

@@ -0,0 +1,74 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package strategy_pattern_tests;
import static org.junit.Assert.*;
import org.junit.Test;
import seabedexplorer.data.Data;
import seabedexplorer.data.IndexOfRefractionReading;
import seabedexplorer.submersible.ROV;
import seabedexplorer.submersible.equipment.waterreadings.IndexOfRefraction;
/**
*
* @author Super
*/
public class IndexOfRefractionTest {
@Test
public void validAngleTest() {
ROV submersible = new ROV();
IndexOfRefraction equipment = new IndexOfRefraction(submersible, 30);
for (int i = 0; i < 100; i++)
equipment.collectData();
Data[] data = equipment.getData().toArray(new Data[100]);
for (int i = 0; i < 100; i++) {
IndexOfRefractionReading current = (IndexOfRefractionReading) data[i];
System.out.println(current.getAngleOfRefraction());
assertTrue(current.getAngleOfRefraction() >= 0 && current.getAngleOfRefraction() <= 90);
}
}
@Test
public void validIndexTest() {
ROV submersible = new ROV();
IndexOfRefraction equipment = new IndexOfRefraction(submersible,30);
for (int i = 0; i < 100; i++)
equipment.collectData();
Data[] data = equipment.getData().toArray(new Data[100]);
for (int i = 0; i < 100; i++) {
IndexOfRefractionReading current = (IndexOfRefractionReading) data[i];
System.out.println(current.getIndexOfRefraction());
assertTrue(current.getAngleOfRefraction() >= 0);
}
}
@Test
public void correctIndexTest() {
ROV submersible = new ROV();
IndexOfRefraction equipment = new IndexOfRefraction(submersible,30);
for (int i = 0; i < 100; i++)
equipment.collectData();
Data[] data = equipment.getData().toArray(new Data[100]);
for (int i = 0; i < 100; i++) {
IndexOfRefractionReading current = (IndexOfRefractionReading) data[i];
System.out.println(current.getAngleOfRefraction() + " " + current.getIndexOfRefraction());
assertEquals(current.getIndexOfRefraction(), 30 / current.getAngleOfRefraction(),0);
}
}
}

View File

@@ -0,0 +1,74 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package strategy_pattern_tests;
import static org.junit.Assert.*;
import org.junit.Test;
import seabedexplorer.data.Data;
import seabedexplorer.data.LaserReading;
import seabedexplorer.submersible.ROV;
import seabedexplorer.submersible.equipment.topographicalmapper.Laser;
/**
*
* @author Super
*/
public class LaserTest {
@Test
public void validAngleTest() {
ROV submersible = new ROV();
Laser equipment = new Laser(submersible, 0.5);
for (int i = 0; i < 100; i++)
equipment.collectData();
Data[] data = equipment.getData().toArray(new Data[100]);
for (int i = 0; i < 100; i++) {
LaserReading current = (LaserReading) data[i];
System.out.println(current.getAngle());
assertTrue(current.getAngle() >= 0 && current.getAngle() <= 90);
}
}
@Test
public void correctDepthTest() {
ROV submersible = new ROV();
Laser equipment = new Laser(submersible,0.5);
for (int i = 0; i < 100; i++)
equipment.collectData();
Data[] data = equipment.getData().toArray(new Data[100]);
for (int i = 0; i < 100; i++) {
LaserReading current = (LaserReading) data[i];
System.out.println(current.getAngle() + " " + current.getDepth());
assertEquals(current.getDepth(), 0.5 / Math.tan(current.getAngle() / (180/Math.PI)),0);
}
}
@Test
public void validDepthTest() {
ROV submersible = new ROV();
Laser equipment = new Laser(submersible, 0.5);
for (int i = 0; i < 100; i++)
equipment.collectData();
Data[] data = equipment.getData().toArray(new Data[100]);
for (int i = 0; i < 100; i++) {
LaserReading current = (LaserReading) data[i];
System.out.println(current.getDepth());
assertTrue(current.getDepth() >= 0);
}
}
}

View File

@@ -0,0 +1,38 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package strategy_pattern_tests;
import static org.junit.Assert.*;
import org.junit.Test;
import seabedexplorer.data.Data;
import seabedexplorer.data.PhotoSensorReading;
import seabedexplorer.submersible.ROV;
import seabedexplorer.submersible.equipment.PhotoSensor;
/**
*
* @author Super
*/
public class PhotosensorTest {
@Test
public void validPhotosensorTest() {
ROV submersible = new ROV();
PhotoSensor equipment = new PhotoSensor(submersible);
for (int i = 0; i < 100; i++)
equipment.collectData();
Data[] data = equipment.getData().toArray(new Data[100]);
for (int i = 0; i < 100; i++) {
PhotoSensorReading current = (PhotoSensorReading) data[i];
System.out.println(current.getReading());
assertTrue(current.getReading() >= 10 && current.getReading() <= 1000000);
}
}
}

View File

@@ -0,0 +1,74 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package strategy_pattern_tests;
import static org.junit.Assert.*;
import org.junit.Test;
import seabedexplorer.data.Data;
import seabedexplorer.data.MaterialSample;
import seabedexplorer.submersible.ROV;
import seabedexplorer.submersible.equipment.materialsampler.RockCoringDrill;
/**
*
* @author Super
*/
public class RockCoringDrillTest {
@Test
public void validMassTest() {
ROV submersible = new ROV();
RockCoringDrill equipment = new RockCoringDrill(submersible, 0.5);
for (int i = 0; i < 100; i++)
equipment.collectData();
Data[] data = equipment.getData().toArray(new Data[100]);
for (int i = 0; i < 100; i++) {
MaterialSample current = (MaterialSample) data[i];
System.out.println(current.getMass());
assertTrue(current.getMass() >= 0);
}
}
@Test
public void validDensityTest() {
ROV submersible = new ROV();
RockCoringDrill equipment = new RockCoringDrill(submersible, 0.5);
for (int i = 0; i < 100; i++)
equipment.collectData();
Data[] data = equipment.getData().toArray(new Data[100]);
for (int i = 0; i < 100; i++) {
MaterialSample current = (MaterialSample) data[i];
System.out.println(current.getDensity());
assertTrue(current.getDensity() >= 0);
}
}
@Test
public void correctDensityTest() {
ROV submersible = new ROV();
RockCoringDrill equipment = new RockCoringDrill(submersible, 0.5);
for (int i = 0; i < 100; i++)
equipment.collectData();
Data[] data = equipment.getData().toArray(new Data[100]);
for (int i = 0; i < 100; i++) {
MaterialSample current = (MaterialSample) data[i];
System.out.println(current.getMass() + " " + current.getDensity());
assertEquals(current.getMass(),current.getDensity() * 0.5, 0);
}
}
}

View File

@@ -0,0 +1,38 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package strategy_pattern_tests;
import static org.junit.Assert.*;
import org.junit.Test;
import seabedexplorer.data.Data;
import seabedexplorer.data.SalinityReading;
import seabedexplorer.submersible.ROV;
import seabedexplorer.submersible.equipment.waterreadings.Salinity;
/**
*
* @author Super
*/
public class SalinityTest {
@Test
public void validSalinityTest() {
ROV submersible = new ROV();
Salinity equipment = new Salinity(submersible);
for (int i = 0; i < 100; i++)
equipment.collectData();
Data[] data = equipment.getData().toArray(new Data[100]);
for (int i = 0; i < 100; i++) {
SalinityReading current = (SalinityReading) data[i];
System.out.println(current.getReading());
assertTrue(current.getReading() >= 0 && current.getReading() <= 1000);
}
}
}

View File

@@ -0,0 +1,75 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package strategy_pattern_tests;
import static org.junit.Assert.*;
import org.junit.Test;
import seabedexplorer.data.Data;
import seabedexplorer.data.SonarReading;
import seabedexplorer.submersible.ROV;
import seabedexplorer.submersible.equipment.topographicalmapper.Sonar;
/**
*
* @author Super
*/
public class SonarTest {
@Test
public void validSonarTest() {
ROV submersible = new ROV();
Sonar equipment = new Sonar(submersible);
for (int i = 0; i < 100; i++)
equipment.collectData();
Data[] data = equipment.getData().toArray(new Data[100]);
for (int i = 0; i < 100; i++) {
SonarReading current = (SonarReading) data[i];
System.out.println(current.getReading());
assertTrue(current.getReading() >= 0 && current.getReading() <= 10000);
}
}
@Test
public void correctDepthTest() {
ROV submersible = new ROV();
Sonar equipment = new Sonar(submersible);
for (int i = 0; i < 100; i++)
equipment.collectData();
Data[] data = equipment.getData().toArray(new Data[100]);
for (int i = 0; i < 100; i++) {
SonarReading current = (SonarReading) data[i];
System.out.println(current.getReading() + " " + current.getDepth());
assertEquals(current.getDepth(), current.getReading() * 1.5, 0);
}
}
@Test
public void validDepthTest() {
ROV submersible = new ROV();
Sonar equipment = new Sonar(submersible);
for (int i = 0; i < 100; i++)
equipment.collectData();
Data[] data = equipment.getData().toArray(new Data[100]);
for (int i = 0; i < 100; i++) {
SonarReading current = (SonarReading) data[i];
System.out.println(current.getDepth());
assertTrue(current.getDepth() >= 0);
}
}
}

View File

@@ -0,0 +1,38 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package strategy_pattern_tests;
import static org.junit.Assert.*;
import org.junit.Test;
import seabedexplorer.data.Data;
import seabedexplorer.data.pHReading;
import seabedexplorer.submersible.ROV;
import seabedexplorer.submersible.equipment.waterreadings.PH;
/**
*
* @author Super
*/
public class pHTest {
@Test
public void validpHTest() {
ROV submersible = new ROV();
PH equipment = new PH(submersible);
for (int i = 0; i < 100; i++)
equipment.collectData();
Data[] data = equipment.getData().toArray(new Data[100]);
for (int i = 0; i < 100; i++) {
pHReading current = (pHReading) data[i];
System.out.println(current.getReading());
assertTrue(current.getReading() >= 1 && current.getReading() <= 14);
}
}
}