Reads BoatDataSource into StreamedCourseXMLReader so the latter can function as a single source of static information for the race.
- Mock.StreamedCourseXMLReader populates participant and mark list from BoatDataSource - Added CompoundMarker class to accommodate Mark data from Boat XML - Had to check for Yacht type in Visualiser.BoatXMLReader - Added a missing coordinate value to raceTest.xml - Marker class still exists due to large number of tests, which should be transitioned to CompoundMark - IMPORTANT: race is no longer functional #story[881]
This commit is contained in:
@@ -8,6 +8,7 @@ import seng302.Model.Mark;
|
||||
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.testng.Assert.*;
|
||||
@@ -24,8 +25,8 @@ public class BoatXMLReaderTest {
|
||||
public void setUp() {
|
||||
try {
|
||||
boatData = new BoatXMLReader("mockXML/boatTest.xml");
|
||||
boats = boatData.getBoats();
|
||||
marks = boatData.getMarkerBoats();
|
||||
boats = new ArrayList<>(boatData.getBoats().values());
|
||||
marks = new ArrayList<>(boatData.getMarkerBoats().values());
|
||||
} catch (ParserConfigurationException e) {
|
||||
e.printStackTrace();
|
||||
} catch (SAXException e) {
|
||||
|
||||
@@ -18,18 +18,18 @@ public class BoatTest {
|
||||
@Test
|
||||
public void calculateDueNorthAzimuthReturns0() {
|
||||
|
||||
CompoundMarker startCompoundMarker = new CompoundMarker(ORIGIN_COORDS);
|
||||
CompoundMarker endCompoundMarker = new CompoundMarker(new GPSCoordinate(50, 0));
|
||||
Leg start = new Leg("Start", startCompoundMarker, endCompoundMarker, 0);
|
||||
Marker startMarker = new Marker(ORIGIN_COORDS);
|
||||
Marker endMarker = new Marker(new GPSCoordinate(50, 0));
|
||||
Leg start = new Leg("Start", startMarker, endMarker, 0);
|
||||
TEST_BOAT.setCurrentLeg(start);
|
||||
assertEquals(TEST_BOAT.calculateAzimuth(), 0, 1e-8);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void calculateDueSouthAzimuthReturns180() {
|
||||
CompoundMarker startCompoundMarker = new CompoundMarker(ORIGIN_COORDS);
|
||||
CompoundMarker endCompoundMarker = new CompoundMarker(new GPSCoordinate(-50, 0));
|
||||
Leg start = new Leg("Start", startCompoundMarker, endCompoundMarker, 0);
|
||||
Marker startMarker = new Marker(ORIGIN_COORDS);
|
||||
Marker endMarker = new Marker(new GPSCoordinate(-50, 0));
|
||||
Leg start = new Leg("Start", startMarker, endMarker, 0);
|
||||
TEST_BOAT.setCurrentLeg(start);
|
||||
assertEquals(TEST_BOAT.calculateAzimuth(), 180, 1e-8);
|
||||
}
|
||||
@@ -38,9 +38,9 @@ public class BoatTest {
|
||||
@Test
|
||||
public void calculateDueEastAzimuthReturns90() {
|
||||
|
||||
CompoundMarker startCompoundMarker = new CompoundMarker(ORIGIN_COORDS);
|
||||
CompoundMarker endCompoundMarker = new CompoundMarker(new GPSCoordinate(0, 50));
|
||||
Leg start = new Leg("Start", startCompoundMarker, endCompoundMarker, 0);
|
||||
Marker startMarker = new Marker(ORIGIN_COORDS);
|
||||
Marker endMarker = new Marker(new GPSCoordinate(0, 50));
|
||||
Leg start = new Leg("Start", startMarker, endMarker, 0);
|
||||
TEST_BOAT.setCurrentLeg(start);
|
||||
assertEquals(TEST_BOAT.calculateAzimuth(), 90, 1e-8);
|
||||
}
|
||||
@@ -48,9 +48,9 @@ public class BoatTest {
|
||||
|
||||
@Test
|
||||
public void calculateDueWestAzimuthReturnsNegative90() {
|
||||
CompoundMarker startCompoundMarker = new CompoundMarker(ORIGIN_COORDS);
|
||||
CompoundMarker endCompoundMarker = new CompoundMarker(new GPSCoordinate(0, -50));
|
||||
Leg start = new Leg("Start", startCompoundMarker, endCompoundMarker, 0);
|
||||
Marker startMarker = new Marker(ORIGIN_COORDS);
|
||||
Marker endMarker = new Marker(new GPSCoordinate(0, -50));
|
||||
Leg start = new Leg("Start", startMarker, endMarker, 0);
|
||||
TEST_BOAT.setCurrentLeg(start);
|
||||
assertEquals(TEST_BOAT.calculateAzimuth(), -90, 1e-8);
|
||||
|
||||
@@ -59,9 +59,9 @@ public class BoatTest {
|
||||
@Test
|
||||
public void calculateDueNorthHeadingReturns0() {
|
||||
|
||||
CompoundMarker startCompoundMarker = new CompoundMarker(ORIGIN_COORDS);
|
||||
CompoundMarker endCompoundMarker = new CompoundMarker(new GPSCoordinate(50, 0));
|
||||
Leg start = new Leg("Start", startCompoundMarker, endCompoundMarker, 0);
|
||||
Marker startMarker = new Marker(ORIGIN_COORDS);
|
||||
Marker endMarker = new Marker(new GPSCoordinate(50, 0));
|
||||
Leg start = new Leg("Start", startMarker, endMarker, 0);
|
||||
TEST_BOAT.setCurrentLeg(start);
|
||||
assertEquals(TEST_BOAT.calculateHeading(), 0, 1e-8);
|
||||
}
|
||||
@@ -69,27 +69,27 @@ public class BoatTest {
|
||||
|
||||
@Test
|
||||
public void calculateDueEastHeadingReturns90() {
|
||||
CompoundMarker startCompoundMarker = new CompoundMarker(ORIGIN_COORDS);
|
||||
CompoundMarker endCompoundMarker = new CompoundMarker(new GPSCoordinate(0, 50));
|
||||
Leg start = new Leg("Start", startCompoundMarker, endCompoundMarker, 0);
|
||||
Marker startMarker = new Marker(ORIGIN_COORDS);
|
||||
Marker endMarker = new Marker(new GPSCoordinate(0, 50));
|
||||
Leg start = new Leg("Start", startMarker, endMarker, 0);
|
||||
TEST_BOAT.setCurrentLeg(start);
|
||||
assertEquals(TEST_BOAT.calculateHeading(), 90, 1e-8);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void calculateDueSouthHeadingReturns180() {
|
||||
CompoundMarker startCompoundMarker = new CompoundMarker(ORIGIN_COORDS);
|
||||
CompoundMarker endCompoundMarker = new CompoundMarker(new GPSCoordinate(-50, 0));
|
||||
Leg start = new Leg("Start", startCompoundMarker, endCompoundMarker, 0);
|
||||
Marker startMarker = new Marker(ORIGIN_COORDS);
|
||||
Marker endMarker = new Marker(new GPSCoordinate(-50, 0));
|
||||
Leg start = new Leg("Start", startMarker, endMarker, 0);
|
||||
TEST_BOAT.setCurrentLeg(start);
|
||||
assertEquals(TEST_BOAT.calculateHeading(), 180, 1e-8);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void calculateDueWestHeadingReturns270() {
|
||||
CompoundMarker startCompoundMarker = new CompoundMarker(ORIGIN_COORDS);
|
||||
CompoundMarker endCompoundMarker = new CompoundMarker(new GPSCoordinate(0, -50));
|
||||
Leg start = new Leg("Start", startCompoundMarker, endCompoundMarker, 0);
|
||||
Marker startMarker = new Marker(ORIGIN_COORDS);
|
||||
Marker endMarker = new Marker(new GPSCoordinate(0, -50));
|
||||
Leg start = new Leg("Start", startMarker, endMarker, 0);
|
||||
TEST_BOAT.setCurrentLeg(start);
|
||||
assertEquals(TEST_BOAT.calculateHeading(), 270, 1e-8);
|
||||
}
|
||||
|
||||
+6
-6
@@ -8,14 +8,14 @@ import static org.junit.Assert.assertTrue;
|
||||
/**
|
||||
* Created by esa46 on 29/03/17.
|
||||
*/
|
||||
public class CompoundMarkerTest {
|
||||
public class CompoundMarkTest {
|
||||
|
||||
GPSCoordinate ORIGIN_COORD = new GPSCoordinate(0, 0);
|
||||
|
||||
@Test
|
||||
public void averageOfSingleMarkAtOriginIsSingleMark() {
|
||||
|
||||
CompoundMarker testMark = new CompoundMarker(ORIGIN_COORD);
|
||||
Marker testMark = new Marker(ORIGIN_COORD);
|
||||
assertTrue(testMark.getAverageGPSCoordinate().equals(ORIGIN_COORD));
|
||||
|
||||
}
|
||||
@@ -24,7 +24,7 @@ public class CompoundMarkerTest {
|
||||
public void averageOfSingleMarkIsSingleMark() {
|
||||
|
||||
GPSCoordinate testCoord = new GPSCoordinate(20, 25);
|
||||
CompoundMarker testMark = new CompoundMarker(testCoord);
|
||||
Marker testMark = new Marker(testCoord);
|
||||
assertTrue(testMark.getAverageGPSCoordinate().equals(testCoord));
|
||||
|
||||
}
|
||||
@@ -34,7 +34,7 @@ public class CompoundMarkerTest {
|
||||
public void averageLatOfTwoMarksIsAccurate() {
|
||||
|
||||
GPSCoordinate testCoord = new GPSCoordinate(10, 0);
|
||||
CompoundMarker testMark = new CompoundMarker(ORIGIN_COORD, testCoord);
|
||||
Marker testMark = new Marker(ORIGIN_COORD, testCoord);
|
||||
assertTrue(testMark.getAverageGPSCoordinate().equals(new GPSCoordinate(5, 0)));
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ public class CompoundMarkerTest {
|
||||
public void averageLongOfTwoMarksIsAccurate() {
|
||||
|
||||
GPSCoordinate testCoord = new GPSCoordinate(0, 10);
|
||||
CompoundMarker testMark = new CompoundMarker(ORIGIN_COORD, testCoord);
|
||||
Marker testMark = new Marker(ORIGIN_COORD, testCoord);
|
||||
assertTrue(testMark.getAverageGPSCoordinate().equals(new GPSCoordinate(0, 5)));
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ public class CompoundMarkerTest {
|
||||
|
||||
GPSCoordinate testCoord1 = new GPSCoordinate(10, 30);
|
||||
GPSCoordinate testCoord2 = new GPSCoordinate(30, 60);
|
||||
CompoundMarker testMark = new CompoundMarker(testCoord1, testCoord2);
|
||||
Marker testMark = new Marker(testCoord1, testCoord2);
|
||||
assertTrue(testMark.getAverageGPSCoordinate().equals(new GPSCoordinate(020.644102, 44.014817)));
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ import static junit.framework.TestCase.assertEquals;
|
||||
*/
|
||||
public class LegTest {
|
||||
|
||||
private CompoundMarker ORIGIN_Compound_MARKER = new CompoundMarker(new GPSCoordinate(0, 0));
|
||||
private Marker ORIGIN_Compound_MARKER = new Marker(new GPSCoordinate(0, 0));
|
||||
|
||||
@Test
|
||||
public void calculateDistanceHandles5nmNorth() {
|
||||
@@ -22,8 +22,8 @@ public class LegTest {
|
||||
calc.setStartingGeographicPoint(0, 0);
|
||||
calc.setDirection(0, 5 * Constants.NMToMetersConversion);
|
||||
|
||||
CompoundMarker endCompoundMarker = getEndMarker(calc.getDestinationGeographicPoint());
|
||||
Leg test = new Leg("Test", ORIGIN_Compound_MARKER, endCompoundMarker, 0);
|
||||
Marker endMarker = getEndMarker(calc.getDestinationGeographicPoint());
|
||||
Leg test = new Leg("Test", ORIGIN_Compound_MARKER, endMarker, 0);
|
||||
assertEquals(test.getDistance(), 5, 1e-8);
|
||||
}
|
||||
|
||||
@@ -33,8 +33,8 @@ public class LegTest {
|
||||
calc.setStartingGeographicPoint(0, 0);
|
||||
calc.setDirection(90, 12 * Constants.NMToMetersConversion);
|
||||
|
||||
CompoundMarker endCompoundMarker = getEndMarker(calc.getDestinationGeographicPoint());
|
||||
Leg test = new Leg("Test", ORIGIN_Compound_MARKER, endCompoundMarker, 0);
|
||||
Marker endMarker = getEndMarker(calc.getDestinationGeographicPoint());
|
||||
Leg test = new Leg("Test", ORIGIN_Compound_MARKER, endMarker, 0);
|
||||
assertEquals(test.getDistance(), 12, 1e-8);
|
||||
}
|
||||
|
||||
@@ -44,8 +44,8 @@ public class LegTest {
|
||||
calc.setStartingGeographicPoint(0, 0);
|
||||
calc.setDirection(180, 0.5 * Constants.NMToMetersConversion);
|
||||
|
||||
CompoundMarker endCompoundMarker = getEndMarker(calc.getDestinationGeographicPoint());
|
||||
Leg test = new Leg("Test", ORIGIN_Compound_MARKER, endCompoundMarker, 0);
|
||||
Marker endMarker = getEndMarker(calc.getDestinationGeographicPoint());
|
||||
Leg test = new Leg("Test", ORIGIN_Compound_MARKER, endMarker, 0);
|
||||
assertEquals(test.getDistance(), 0.5, 1e-8);
|
||||
}
|
||||
|
||||
@@ -55,8 +55,8 @@ public class LegTest {
|
||||
calc.setStartingGeographicPoint(0, 0);
|
||||
calc.setDirection(-90, 0.1 * Constants.NMToMetersConversion);
|
||||
|
||||
CompoundMarker endCompoundMarker = getEndMarker(calc.getDestinationGeographicPoint());
|
||||
Leg test = new Leg("Test", ORIGIN_Compound_MARKER, endCompoundMarker, 0);
|
||||
Marker endMarker = getEndMarker(calc.getDestinationGeographicPoint());
|
||||
Leg test = new Leg("Test", ORIGIN_Compound_MARKER, endMarker, 0);
|
||||
assertEquals(test.getDistance(), 0.1, 1e-8);
|
||||
}
|
||||
|
||||
@@ -67,11 +67,11 @@ public class LegTest {
|
||||
assertEquals(test.getDistance(), 0, 1e-8);
|
||||
}
|
||||
|
||||
private CompoundMarker getEndMarker(Point2D point) {
|
||||
private Marker getEndMarker(Point2D point) {
|
||||
|
||||
GPSCoordinate coords = new GPSCoordinate(point.getY(), point.getX());
|
||||
|
||||
return new CompoundMarker(coords);
|
||||
return new Marker(coords);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,8 +28,8 @@
|
||||
//public class RaceTest{
|
||||
//
|
||||
// private static MockOutput mockOutput;
|
||||
// SharedModel.Leg START_LEG = new SharedModel.Leg("Start", new SharedModel.CompoundMarker(new SharedModel.GPSCoordinate(0, 0)), new SharedModel.CompoundMarker(new SharedModel.GPSCoordinate(1, 1)), 0);
|
||||
// SharedModel.Leg FINISH_LEG = new SharedModel.Leg("Finish", new SharedModel.CompoundMarker(new SharedModel.GPSCoordinate(1, 1)), new SharedModel.CompoundMarker(new SharedModel.GPSCoordinate(2, 2)), 0);
|
||||
// SharedModel.Leg START_LEG = new SharedModel.Leg("Start", new SharedModel.Marker(new SharedModel.GPSCoordinate(0, 0)), new SharedModel.Marker(new SharedModel.GPSCoordinate(1, 1)), 0);
|
||||
// SharedModel.Leg FINISH_LEG = new SharedModel.Leg("Finish", new SharedModel.Marker(new SharedModel.GPSCoordinate(1, 1)), new SharedModel.Marker(new SharedModel.GPSCoordinate(2, 2)), 0);
|
||||
//
|
||||
//// @Override
|
||||
//// public void start(Stage primaryStage) throws Exception{}
|
||||
|
||||
Reference in New Issue
Block a user