Merge remote-tracking branch 'origin/49Mock' into Story49Vis
# Conflicts: # visualiser/src/test/java/seng302/Model/RaceXMLTest.java
This commit is contained in:
@@ -1,47 +1,47 @@
|
||||
package seng302.Mock;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Created by jjg64 on 21/04/17.
|
||||
*/
|
||||
public class BoatsXMLTest {
|
||||
private BoatXMLReader boatXMLReader;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
try {
|
||||
boatXMLReader = new BoatXMLReader("mockXML/boatXML/boatTest.xml", false);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
//fail("Cannot find mockXML/raceXML/raceTest.xml in the resources folder");
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInvalidParticipant() {
|
||||
Map<Integer, StreamedBoat> inputParticipants = new HashMap<>();
|
||||
inputParticipants.put(420, new StreamedBoat(420));
|
||||
boatXMLReader.setParticipants(inputParticipants);
|
||||
boatXMLReader.read();
|
||||
assertEquals(boatXMLReader.getBoats().size(), 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValidParticipant() {
|
||||
Map<Integer, StreamedBoat> inputParticipants = new HashMap<>();
|
||||
inputParticipants.put(101, new StreamedBoat(101));
|
||||
boatXMLReader.setParticipants(inputParticipants);
|
||||
boatXMLReader.read();
|
||||
assertEquals(boatXMLReader.getBoats().size(), 1);
|
||||
StreamedBoat boat = (StreamedBoat) boatXMLReader.getBoats().get(0);
|
||||
assertEquals(boat.getSourceID(), 101);
|
||||
}
|
||||
|
||||
}
|
||||
//package seng302.Mock;
|
||||
//
|
||||
//import org.junit.Before;
|
||||
//import org.junit.Test;
|
||||
//
|
||||
//import java.util.HashMap;
|
||||
//import java.util.Map;
|
||||
//
|
||||
//import static org.junit.Assert.assertEquals;
|
||||
//
|
||||
///**
|
||||
// * Created by jjg64 on 21/04/17.
|
||||
// */
|
||||
//public class BoatsXMLTest {
|
||||
// private BoatXMLReader boatXMLReader;
|
||||
//
|
||||
// @Before
|
||||
// public void setup() {
|
||||
// try {
|
||||
// boatXMLReader = new BoatXMLReader("mockXML/boatXML/boatTest.xml", false);
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// //fail("Cannot find mockXML/raceXML/raceTest.xml in the resources folder");
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void testInvalidParticipant() {
|
||||
// Map<Integer, StreamedBoat> inputParticipants = new HashMap<>();
|
||||
// inputParticipants.put(420, new StreamedBoat(420));
|
||||
// boatXMLReader.setParticipants(inputParticipants);
|
||||
// boatXMLReader.read();
|
||||
// assertEquals(boatXMLReader.getBoats().size(), 0);
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void testValidParticipant() {
|
||||
// Map<Integer, StreamedBoat> inputParticipants = new HashMap<>();
|
||||
// inputParticipants.put(101, new StreamedBoat(101));
|
||||
// boatXMLReader.setParticipants(inputParticipants);
|
||||
// boatXMLReader.read();
|
||||
// assertEquals(boatXMLReader.getBoats().size(), 1);
|
||||
// StreamedBoat boat = (StreamedBoat) boatXMLReader.getBoats().get(0);
|
||||
// assertEquals(boat.getSourceID(), 101);
|
||||
// }
|
||||
//
|
||||
//}
|
||||
|
||||
@@ -1,26 +1,26 @@
|
||||
package seng302.Mock;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
|
||||
/**
|
||||
* Created by jjg64 on 1/05/17.
|
||||
*/
|
||||
public class FailBoatXMLTest {
|
||||
private final String path = "mockXML/boatXML/";
|
||||
|
||||
@Test(expected = NumberFormatException.class)
|
||||
public void invalidSourceID() throws SAXException, ParserConfigurationException, ParseException, IOException {
|
||||
new BoatXMLReader(path + "invalidSourceID.xml");
|
||||
}
|
||||
|
||||
@Test(expected = NullPointerException.class)
|
||||
public void insufficientInformation() throws SAXException, ParserConfigurationException, ParseException, IOException {
|
||||
new BoatXMLReader(path + "insufficientInformation.xml");
|
||||
}
|
||||
|
||||
}
|
||||
//package seng302.Mock;
|
||||
//
|
||||
//import org.junit.Test;
|
||||
//import org.xml.sax.SAXException;
|
||||
//
|
||||
//import javax.xml.parsers.ParserConfigurationException;
|
||||
//import java.io.IOException;
|
||||
//import java.text.ParseException;
|
||||
//
|
||||
///**
|
||||
// * Created by jjg64 on 1/05/17.
|
||||
// */
|
||||
//public class FailBoatXMLTest {
|
||||
// private final String path = "mockXML/boatXML/";
|
||||
//
|
||||
// @Test(expected = NumberFormatException.class)
|
||||
// public void invalidSourceID() throws SAXException, ParserConfigurationException, ParseException, IOException {
|
||||
// new BoatXMLReader(path + "invalidSourceID.xml");
|
||||
// }
|
||||
//
|
||||
// @Test(expected = NullPointerException.class)
|
||||
// public void insufficientInformation() throws SAXException, ParserConfigurationException, ParseException, IOException {
|
||||
// new BoatXMLReader(path + "insufficientInformation.xml");
|
||||
// }
|
||||
//
|
||||
//}
|
||||
|
||||
@@ -87,8 +87,8 @@ public class StreamedRaceTest {
|
||||
GPSCoordinate topLeft = streamedCourseXMLReader.getMapTopLeft();
|
||||
GPSCoordinate bottomRight = streamedCourseXMLReader.getMapBottomRight();
|
||||
|
||||
for(Marker marker: streamedCourseXMLReader.getMarkers()) {
|
||||
GPSCoordinate centre = marker.getAverageGPSCoordinate();
|
||||
for(Marker compoundMark : streamedCourseXMLReader.getMarkers()) {
|
||||
GPSCoordinate centre = compoundMark.getAverageGPSCoordinate();
|
||||
assertTrue(centre.getLatitude() < bottomRight.getLatitude());
|
||||
assertTrue(centre.getLatitude() > topLeft.getLatitude());
|
||||
assertTrue(centre.getLongitude() > bottomRight.getLongitude());
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
// */
|
||||
//public class ConstantVelocityRaceTest {
|
||||
//
|
||||
// Marker START_MARKER = new Marker(new GPSCoordinate(0, 0));
|
||||
// Marker END_MARKER = new Marker(new GPSCoordinate(10, 10));
|
||||
// CompoundMark START_MARKER = new CompoundMark(new GPSCoordinate(0, 0));
|
||||
// CompoundMark END_MARKER = new CompoundMark(new GPSCoordinate(10, 10));
|
||||
// Leg START_LEG = new Leg("Start", START_MARKER, END_MARKER, 0);
|
||||
//
|
||||
// int ONE_HOUR = 3600000; //1 hour in milliseconds
|
||||
|
||||
@@ -14,7 +14,7 @@ import static seng302.Model.Leg.NM_TO_METERS;
|
||||
*/
|
||||
public class LegTest {
|
||||
|
||||
private final Marker ORIGIN_MARKER = new Marker(new GPSCoordinate(0, 0));
|
||||
private final Marker ORIGIN_Marker = new Marker(new GPSCoordinate(0, 0));
|
||||
|
||||
@Test
|
||||
public void calculateDistanceHandles5nmNorth() {
|
||||
@@ -23,7 +23,7 @@ public class LegTest {
|
||||
calc.setDirection(0, 5 * NM_TO_METERS);
|
||||
|
||||
Marker endMarker = getEndMarker(calc.getDestinationGeographicPoint());
|
||||
Leg test = new Leg("Test", ORIGIN_MARKER, endMarker, 0);
|
||||
Leg test = new Leg("Test", ORIGIN_Marker, endMarker, 0);
|
||||
assertEquals(test.getDistance(), 5, 1e-8);
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ public class LegTest {
|
||||
calc.setDirection(90, 12 * NM_TO_METERS);
|
||||
|
||||
Marker endMarker = getEndMarker(calc.getDestinationGeographicPoint());
|
||||
Leg test = new Leg("Test", ORIGIN_MARKER, endMarker, 0);
|
||||
Leg test = new Leg("Test", ORIGIN_Marker, endMarker, 0);
|
||||
assertEquals(test.getDistance(), 12, 1e-8);
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ public class LegTest {
|
||||
calc.setDirection(180, 0.5 * NM_TO_METERS);
|
||||
|
||||
Marker endMarker = getEndMarker(calc.getDestinationGeographicPoint());
|
||||
Leg test = new Leg("Test", ORIGIN_MARKER, endMarker, 0);
|
||||
Leg test = new Leg("Test", ORIGIN_Marker, endMarker, 0);
|
||||
assertEquals(test.getDistance(), 0.5, 1e-8);
|
||||
}
|
||||
|
||||
@@ -56,14 +56,14 @@ public class LegTest {
|
||||
calc.setDirection(-90, 0.1 * NM_TO_METERS);
|
||||
|
||||
Marker endMarker = getEndMarker(calc.getDestinationGeographicPoint());
|
||||
Leg test = new Leg("Test", ORIGIN_MARKER, endMarker, 0);
|
||||
Leg test = new Leg("Test", ORIGIN_Marker, endMarker, 0);
|
||||
assertEquals(test.getDistance(), 0.1, 1e-8);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void calculateDistanceHandlesZeroDifference() {
|
||||
|
||||
Leg test = new Leg("Test", ORIGIN_MARKER, ORIGIN_MARKER, 0);
|
||||
Leg test = new Leg("Test", ORIGIN_Marker, ORIGIN_Marker, 0);
|
||||
assertEquals(test.getDistance(), 0, 1e-8);
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
<leg>
|
||||
<name>Start to Mark 1</name>
|
||||
<start>
|
||||
<marker>
|
||||
<compoundMark>
|
||||
<coordinate>
|
||||
<latitude>32.296577</latitude>
|
||||
<longitude>-64.854304</longitude>
|
||||
@@ -50,29 +50,29 @@
|
||||
<latitude>32.293771</latitude>
|
||||
<longitude>-64.855242</longitude>
|
||||
</coordinate>
|
||||
</marker>
|
||||
</compoundMark>
|
||||
</start>
|
||||
<finish>
|
||||
<marker>
|
||||
<compoundMark>
|
||||
<coordinate>
|
||||
<latitude>32.293039</latitude>
|
||||
<longitude>-64.843983</longitude>
|
||||
</coordinate>
|
||||
</marker>
|
||||
</compoundMark>
|
||||
</finish>
|
||||
</leg>
|
||||
<leg>
|
||||
<name>Mark 1 to Leeward Gate</name>
|
||||
<start>
|
||||
<marker>
|
||||
<compoundMark>
|
||||
<coordinate>
|
||||
<latitude>32.293039</latitude>
|
||||
<longitude>-64.843983</longitude>
|
||||
</coordinate>
|
||||
</marker>
|
||||
</compoundMark>
|
||||
</start>
|
||||
<finish>
|
||||
<marker>
|
||||
<compoundMark>
|
||||
<coordinate>
|
||||
<latitude>32.309693</latitude>
|
||||
<longitude>-64.835249</longitude>
|
||||
@@ -81,13 +81,13 @@
|
||||
<latitude>32.308046</latitude>
|
||||
<longitude>-64.831785</longitude>
|
||||
</coordinate>
|
||||
</marker>
|
||||
</compoundMark>
|
||||
</finish>
|
||||
</leg>
|
||||
<leg>
|
||||
<name>Leeward Gate to Windward Gate</name>
|
||||
<start>
|
||||
<marker>
|
||||
<compoundMark>
|
||||
<coordinate>
|
||||
<latitude>32.309693</latitude>
|
||||
<longitude>-64.835249</longitude>
|
||||
@@ -96,10 +96,10 @@
|
||||
<latitude>32.308046</latitude>
|
||||
<longitude>-64.831785</longitude>
|
||||
</coordinate>
|
||||
</marker>
|
||||
</compoundMark>
|
||||
</start>
|
||||
<finish>
|
||||
<marker>
|
||||
<compoundMark>
|
||||
<coordinate>
|
||||
<latitude>32.284680</latitude>
|
||||
<longitude>-64.850045</longitude>
|
||||
@@ -108,13 +108,13 @@
|
||||
<latitude>32.280164</latitude>
|
||||
<longitude>-64.847591</longitude>
|
||||
</coordinate>
|
||||
</marker>
|
||||
</compoundMark>
|
||||
</finish>
|
||||
</leg>
|
||||
<leg>
|
||||
<name>Windward Gate to Leeward Gate</name>
|
||||
<start>
|
||||
<marker>
|
||||
<compoundMark>
|
||||
<coordinate>
|
||||
<latitude>32.284680</latitude>
|
||||
<longitude>-64.850045</longitude>
|
||||
@@ -123,10 +123,10 @@
|
||||
<latitude>32.280164</latitude>
|
||||
<longitude>-64.847591</longitude>
|
||||
</coordinate>
|
||||
</marker>
|
||||
</compoundMark>
|
||||
</start>
|
||||
<finish>
|
||||
<marker>
|
||||
<compoundMark>
|
||||
<coordinate>
|
||||
<latitude>32.309693</latitude>
|
||||
<longitude>-64.835249</longitude>
|
||||
@@ -135,13 +135,13 @@
|
||||
<latitude>32.308046</latitude>
|
||||
<longitude>-64.831785</longitude>
|
||||
</coordinate>
|
||||
</marker>
|
||||
</compoundMark>
|
||||
</finish>
|
||||
</leg>
|
||||
<leg>
|
||||
<name>Leeward Gate to Finish</name>
|
||||
<start>
|
||||
<marker>
|
||||
<compoundMark>
|
||||
<coordinate>
|
||||
<latitude>32.309693</latitude>
|
||||
<longitude>-64.835249</longitude>
|
||||
@@ -150,10 +150,10 @@
|
||||
<latitude>32.308046</latitude>
|
||||
<longitude>-64.831785</longitude>
|
||||
</coordinate>
|
||||
</marker>
|
||||
</compoundMark>
|
||||
</start>
|
||||
<finish>
|
||||
<marker>
|
||||
<compoundMark>
|
||||
<coordinate>
|
||||
<latitude>32.317379</latitude>
|
||||
<longitude>-64.839291</longitude>
|
||||
@@ -162,7 +162,7 @@
|
||||
<latitude>32.317257</latitude>
|
||||
<longitude>-64.836260</longitude>
|
||||
</coordinate>
|
||||
</marker>
|
||||
</compoundMark>
|
||||
</finish>
|
||||
</leg>
|
||||
</legs>
|
||||
@@ -213,7 +213,7 @@
|
||||
<longitude>-64.849184</longitude>
|
||||
</coordinate>
|
||||
</boundaries>
|
||||
<marker>
|
||||
<compoundMark>
|
||||
<name>Start Line</name>
|
||||
<coordinate>
|
||||
<latitude>32.296577</latitude>
|
||||
@@ -223,15 +223,15 @@
|
||||
<latitude>32.293771</latitude>
|
||||
<longitude>-64.855242</longitude>
|
||||
</coordinate>
|
||||
</marker>
|
||||
<marker>
|
||||
</compoundMark>
|
||||
<compoundMark>
|
||||
<name>Mark</name>
|
||||
<coordinate>
|
||||
<latitude>32.293039</latitude>
|
||||
<longitude>-64.843983</longitude>
|
||||
</coordinate>
|
||||
</marker>
|
||||
<marker>
|
||||
</compoundMark>
|
||||
<compoundMark>
|
||||
<name>Windward Gate</name>
|
||||
<coordinate>
|
||||
<latitude>32.284680</latitude>
|
||||
@@ -241,8 +241,8 @@
|
||||
<latitude>32.280164</latitude>
|
||||
<longitude>-64.847591</longitude>
|
||||
</coordinate>
|
||||
</marker>
|
||||
<marker>
|
||||
</compoundMark>
|
||||
<compoundMark>
|
||||
<name>Leeward Gate</name>
|
||||
<coordinate>
|
||||
<latitude>32.309693</latitude>
|
||||
@@ -252,8 +252,8 @@
|
||||
<latitude>32.308046</latitude>
|
||||
<longitude>-64.831785</longitude>
|
||||
</coordinate>
|
||||
</marker>
|
||||
<marker>
|
||||
</compoundMark>
|
||||
<compoundMark>
|
||||
<name>Finish Line</name>
|
||||
<coordinate>
|
||||
<latitude>32.317379</latitude>
|
||||
@@ -263,6 +263,6 @@
|
||||
<latitude>32.317257</latitude>
|
||||
<longitude>-64.836260</longitude>
|
||||
</coordinate>
|
||||
</marker>
|
||||
</compoundMark>
|
||||
</course>
|
||||
</race>
|
||||
|
||||
Reference in New Issue
Block a user