Spun off Locatable interface to make collision code more reusable
#story[1100]
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
package mock.model;
|
||||
|
||||
import mock.model.collider.Collision;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import shared.model.Bearing;
|
||||
@@ -12,17 +11,17 @@ import static org.junit.Assert.*;
|
||||
|
||||
public class MockBoatTest {
|
||||
private MockBoat boat;
|
||||
private CompoundMark near;
|
||||
private CompoundMark far;
|
||||
private Mark near;
|
||||
private Mark far;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
boat = new MockBoat(0, "Bob", "NZ", null);
|
||||
boat.setCurrentPosition(new GPSCoordinate(0,0));
|
||||
boat.setPosition(new GPSCoordinate(0,0));
|
||||
boat.setBearing(Bearing.fromDegrees(180));
|
||||
|
||||
near = new CompoundMark(0, "Near", new Mark(0, "Near", new GPSCoordinate(-.0001, 0)));
|
||||
far = new CompoundMark(1, "Far", new Mark(0, "Far", new GPSCoordinate(.001, 0)));
|
||||
near = new Mark(0, "Near", new GPSCoordinate(-.0001, 0));
|
||||
far = new Mark(0, "Far", new GPSCoordinate(.001, 0));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -19,7 +19,7 @@ public class BoatTest {
|
||||
public void setUp() {
|
||||
ORIGIN_COORDS = new GPSCoordinate(0, 0);
|
||||
TEST_BOAT = new Boat(1, "Test", "tt");
|
||||
TEST_BOAT.setCurrentPosition(ORIGIN_COORDS);
|
||||
TEST_BOAT.setPosition(ORIGIN_COORDS);
|
||||
}
|
||||
|
||||
//TODO these bearing tests could be tidied up to reduce code repetition.
|
||||
@@ -113,7 +113,7 @@ public class BoatTest {
|
||||
|
||||
Leg start = new Leg("Start", startMarker, endMarker, 0);
|
||||
TEST_BOAT.setCurrentLeg(start);
|
||||
assertEquals(GPSCoordinate.calculateAzimuth(TEST_BOAT.getCurrentPosition(), endMarker.getAverageGPSCoordinate()).degrees(), 0, 1e-8);
|
||||
assertEquals(GPSCoordinate.calculateAzimuth(TEST_BOAT.getPosition(), endMarker.getAverageGPSCoordinate()).degrees(), 0, 1e-8);
|
||||
}
|
||||
|
||||
|
||||
@@ -131,7 +131,7 @@ public class BoatTest {
|
||||
|
||||
Leg start = new Leg("Start", startMarker, endMarker, 0);
|
||||
TEST_BOAT.setCurrentLeg(start);
|
||||
assertEquals(GPSCoordinate.calculateAzimuth(TEST_BOAT.getCurrentPosition(), endMarker.getAverageGPSCoordinate()).degrees(), 90, 1e-8);
|
||||
assertEquals(GPSCoordinate.calculateAzimuth(TEST_BOAT.getPosition(), endMarker.getAverageGPSCoordinate()).degrees(), 90, 1e-8);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -148,7 +148,7 @@ public class BoatTest {
|
||||
|
||||
Leg start = new Leg("Start", startMarker, endMarker, 0);
|
||||
TEST_BOAT.setCurrentLeg(start);
|
||||
assertEquals(GPSCoordinate.calculateAzimuth(TEST_BOAT.getCurrentPosition(), endMarker.getAverageGPSCoordinate()).degrees(), -180, 1e-8);
|
||||
assertEquals(GPSCoordinate.calculateAzimuth(TEST_BOAT.getPosition(), endMarker.getAverageGPSCoordinate()).degrees(), -180, 1e-8);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -165,7 +165,7 @@ public class BoatTest {
|
||||
|
||||
Leg start = new Leg("Start", startMarker, endMarker, 0);
|
||||
TEST_BOAT.setCurrentLeg(start);
|
||||
assertEquals(GPSCoordinate.calculateBearing(TEST_BOAT.getCurrentPosition(), endMarker.getAverageGPSCoordinate()).degrees(), 270, 1e-8);
|
||||
assertEquals(GPSCoordinate.calculateBearing(TEST_BOAT.getPosition(), endMarker.getAverageGPSCoordinate()).degrees(), 270, 1e-8);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user