|
|
|
@ -1,7 +1,7 @@
|
|
|
|
package seng302.Model;
|
|
|
|
package seng302.Model;
|
|
|
|
|
|
|
|
|
|
|
|
import javafx.scene.paint.Color;
|
|
|
|
|
|
|
|
import org.junit.BeforeClass;
|
|
|
|
import org.junit.Before;
|
|
|
|
import org.junit.Ignore;
|
|
|
|
import org.junit.Ignore;
|
|
|
|
import org.junit.Test;
|
|
|
|
import org.junit.Test;
|
|
|
|
import org.mockito.Mockito;
|
|
|
|
import org.mockito.Mockito;
|
|
|
|
@ -17,11 +17,9 @@ import javax.xml.parsers.ParserConfigurationException;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.text.ParseException;
|
|
|
|
import java.text.ParseException;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import static org.junit.Assert.assertEquals;
|
|
|
|
|
|
|
|
import static org.junit.Assert.assertTrue;
|
|
|
|
import static org.junit.Assert.*;
|
|
|
|
import static org.junit.Assert.fail;
|
|
|
|
|
|
|
|
import static org.mockito.Matchers.*;
|
|
|
|
import static org.mockito.Matchers.*;
|
|
|
|
import static org.mockito.Mockito.*;
|
|
|
|
import static org.mockito.Mockito.*;
|
|
|
|
|
|
|
|
|
|
|
|
@ -30,6 +28,24 @@ import static org.mockito.Mockito.*;
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public class RaceTest{
|
|
|
|
public class RaceTest{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static final Marker ORIGIN = new Marker(new GPSCoordinate(0, 0));
|
|
|
|
|
|
|
|
public static final Marker THREE_NM_FROM_ORIGIN = new Marker(new GPSCoordinate(0.050246769, 0));
|
|
|
|
|
|
|
|
public static final Marker FIFTEEN_NM_FROM_ORIGIN = new Marker(new GPSCoordinate(0.251233845, 0));
|
|
|
|
|
|
|
|
public static ArrayList<Leg> TEST_LEGS = new ArrayList<>();
|
|
|
|
|
|
|
|
public static final int START_LEG_DISTANCE = 3;
|
|
|
|
|
|
|
|
public static final int MIDDLE_LEG_DISTANCE = 12;
|
|
|
|
|
|
|
|
public static final Leg START_LEG = new Leg("Start", ORIGIN, THREE_NM_FROM_ORIGIN, 0);
|
|
|
|
|
|
|
|
public static final Leg MIDDLE_LEG = new Leg("Middle", THREE_NM_FROM_ORIGIN, FIFTEEN_NM_FROM_ORIGIN, 1);
|
|
|
|
|
|
|
|
public static final Leg FINISH_LEG = new Leg("Finish", FIFTEEN_NM_FROM_ORIGIN, FIFTEEN_NM_FROM_ORIGIN, 2);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Before
|
|
|
|
|
|
|
|
public void setUp() {
|
|
|
|
|
|
|
|
TEST_LEGS.add(START_LEG);
|
|
|
|
|
|
|
|
TEST_LEGS.add(MIDDLE_LEG);
|
|
|
|
|
|
|
|
TEST_LEGS.add(FINISH_LEG);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Ignore
|
|
|
|
@Ignore
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void countdownTimerSendsBoatLocations() {
|
|
|
|
public void countdownTimerSendsBoatLocations() {
|
|
|
|
@ -67,145 +83,208 @@ public class RaceTest{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// @Test
|
|
|
|
@Test
|
|
|
|
// public void checkPositionUpdatesNumberFinishedBoats() {
|
|
|
|
public void checkPositionFinishedUpdatesNumberFinishedBoats() {
|
|
|
|
//
|
|
|
|
|
|
|
|
// Boat finishedBoat = new Boat(1000, "Name", "Country");
|
|
|
|
try {
|
|
|
|
// finishedBoat.setDistanceTravelledInLeg(500);
|
|
|
|
MockOutput mockOutput = Mockito.mock(MockOutput.class);
|
|
|
|
//
|
|
|
|
RaceDataSource dataSource = new RaceXMLReader("mockXML/raceTest.xml", new BoatXMLReader("mockXML/boatTest.xml"));
|
|
|
|
// finishedBoat.setCurrentLeg(FINISH_LEG);
|
|
|
|
Race testRace = new Race(dataSource, mockOutput);
|
|
|
|
//
|
|
|
|
testRace.initialiseBoats();
|
|
|
|
// ArrayList<Boat> boats = new ArrayList<>();
|
|
|
|
Boat testBoat = testRace.startingBoats.get(0);
|
|
|
|
// boats.add(finishedBoat);
|
|
|
|
testBoat.setCurrentLeg(FINISH_LEG);
|
|
|
|
//
|
|
|
|
testBoat.setDistanceTravelledInLeg(1);
|
|
|
|
// ArrayList<Leg> legs = new ArrayList<>();
|
|
|
|
testRace.checkPosition(testBoat, 1);
|
|
|
|
// legs.add(FINISH_LEG);
|
|
|
|
|
|
|
|
//
|
|
|
|
assertEquals(testRace.boatsFinished, 1);
|
|
|
|
// Race race = new Race(boats, legs, 5, mockOutput);
|
|
|
|
|
|
|
|
// assertEquals(race.boatsFinished, 0);
|
|
|
|
} catch (ParserConfigurationException | IOException | SAXException | ParseException | StreamedCourseXMLException e) {
|
|
|
|
//
|
|
|
|
e.printStackTrace();
|
|
|
|
// race.checkPosition(finishedBoat, 100000);
|
|
|
|
fail();
|
|
|
|
// assertEquals(race.boatsFinished, 1);
|
|
|
|
}
|
|
|
|
// assertEquals(finishedBoat.getTimeFinished(), 100000);
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
// @Test
|
|
|
|
public void checkPositionSetFinishedBoatVelocityTo0() {
|
|
|
|
// public void checkPositionDoesntUpdateNumberFinishedBoats() {
|
|
|
|
|
|
|
|
//
|
|
|
|
try {
|
|
|
|
// Boat unFinishedBoat = new Boat("Test", 10, Color.ALICEBLUE, "tt", 1);
|
|
|
|
MockOutput mockOutput = Mockito.mock(MockOutput.class);
|
|
|
|
// unFinishedBoat.setDistanceTravelledInLeg(0);
|
|
|
|
RaceDataSource dataSource = new RaceXMLReader("mockXML/raceTest.xml", new BoatXMLReader("mockXML/boatTest.xml"));
|
|
|
|
//
|
|
|
|
Race testRace = new Race(dataSource, mockOutput);
|
|
|
|
// unFinishedBoat.setCurrentLeg(FINISH_LEG);
|
|
|
|
testRace.initialiseBoats();
|
|
|
|
//
|
|
|
|
Boat testBoat = testRace.startingBoats.get(0);
|
|
|
|
// ArrayList<Boat> boats = new ArrayList<>();
|
|
|
|
testBoat.setCurrentLeg(FINISH_LEG);
|
|
|
|
// boats.add(unFinishedBoat);
|
|
|
|
testBoat.setDistanceTravelledInLeg(1);
|
|
|
|
//
|
|
|
|
testRace.checkPosition(testBoat, 1);
|
|
|
|
// ArrayList<Leg> legs = new ArrayList<>();
|
|
|
|
|
|
|
|
// legs.add(FINISH_LEG);
|
|
|
|
assertEquals(testBoat.getVelocity(), 0, 1e-8);
|
|
|
|
//
|
|
|
|
|
|
|
|
//
|
|
|
|
} catch (ParserConfigurationException | IOException | SAXException | ParseException | StreamedCourseXMLException e) {
|
|
|
|
// Race race = new Race(boats, legs, 1, mockOutput);
|
|
|
|
e.printStackTrace();
|
|
|
|
// race.setDnfChance(0);
|
|
|
|
fail();
|
|
|
|
// assertEquals(race.boatsFinished, 0);
|
|
|
|
}
|
|
|
|
// race.checkPosition(unFinishedBoat, 100);
|
|
|
|
}
|
|
|
|
// assertEquals(race.boatsFinished, 0);
|
|
|
|
|
|
|
|
//
|
|
|
|
@Test
|
|
|
|
// }
|
|
|
|
public void checkPositionSetsFinishTime() {
|
|
|
|
//
|
|
|
|
|
|
|
|
// @Test
|
|
|
|
try {
|
|
|
|
// public void distanceTravelledBeforeUpdatingLegIsRetained() {
|
|
|
|
MockOutput mockOutput = Mockito.mock(MockOutput.class);
|
|
|
|
//
|
|
|
|
RaceDataSource dataSource = new RaceXMLReader("mockXML/raceTest.xml", new BoatXMLReader("mockXML/boatTest.xml"));
|
|
|
|
// ArrayList<Boat> boats = new ArrayList<>();
|
|
|
|
Race testRace = new Race(dataSource, mockOutput);
|
|
|
|
//
|
|
|
|
testRace.initialiseBoats();
|
|
|
|
// ArrayList<Leg> legs = new ArrayList<>();
|
|
|
|
Boat testBoat = testRace.startingBoats.get(0);
|
|
|
|
//
|
|
|
|
testBoat.setCurrentLeg(FINISH_LEG);
|
|
|
|
// legs.add(START_LEG);
|
|
|
|
testBoat.setDistanceTravelledInLeg(1);
|
|
|
|
// legs.add(FINISH_LEG);
|
|
|
|
testRace.checkPosition(testBoat, 1);
|
|
|
|
//
|
|
|
|
|
|
|
|
// Race race = new Race(boats, legs, 1, mockOutput);
|
|
|
|
assertEquals(testBoat.getTimeFinished(), 1, 1e-8);
|
|
|
|
// race.setDnfChance(0);
|
|
|
|
|
|
|
|
//
|
|
|
|
} catch (ParserConfigurationException | IOException | SAXException | ParseException | StreamedCourseXMLException e) {
|
|
|
|
// Boat unFinishedBoat = new Boat("Test", 10, Color.ALICEBLUE, "tt", 4);
|
|
|
|
e.printStackTrace();
|
|
|
|
// unFinishedBoat.setDistanceTravelledInLeg(100);
|
|
|
|
fail();
|
|
|
|
// unFinishedBoat.setCurrentLeg(START_LEG);
|
|
|
|
}
|
|
|
|
//
|
|
|
|
}
|
|
|
|
// race.checkPosition(unFinishedBoat, 100);
|
|
|
|
|
|
|
|
// assertEquals(unFinishedBoat.getCurrentLeg().getName(), "Finish");
|
|
|
|
@Test
|
|
|
|
// assertTrue(unFinishedBoat.getDistanceTravelledInLeg() > 0);
|
|
|
|
public void checkPositionUnfinishedDoesntUpdateNumberFinishedBoats() {
|
|
|
|
// assertTrue(unFinishedBoat.getDistanceTravelledInLeg() < 100);
|
|
|
|
|
|
|
|
// }
|
|
|
|
try {
|
|
|
|
//
|
|
|
|
MockOutput mockOutput = Mockito.mock(MockOutput.class);
|
|
|
|
// @Ignore
|
|
|
|
RaceDataSource dataSource = new RaceXMLReader("mockXML/raceTest.xml", new BoatXMLReader("mockXML/boatTest.xml"));
|
|
|
|
// @Test
|
|
|
|
Race testRace = new Race(dataSource, mockOutput);
|
|
|
|
// public void timerDelaysByHalfSecond() throws InterruptedException {
|
|
|
|
testRace.initialiseBoats();
|
|
|
|
//
|
|
|
|
Boat testBoat = testRace.startingBoats.get(0);
|
|
|
|
// ArrayList<Boat> boats = new ArrayList<>();
|
|
|
|
testBoat.setCurrentLeg(START_LEG);
|
|
|
|
//
|
|
|
|
testBoat.setDistanceTravelledInLeg(START_LEG_DISTANCE);
|
|
|
|
// ArrayList<Leg> legs = new ArrayList<>();
|
|
|
|
testRace.checkPosition(testBoat, 1);
|
|
|
|
// legs.add(START_LEG);
|
|
|
|
|
|
|
|
//
|
|
|
|
assertEquals(testRace.boatsFinished, 0);
|
|
|
|
// Race race = new Race(boats, legs, 1, mockOutput);
|
|
|
|
|
|
|
|
// race.PRERACE_TIME = 500;
|
|
|
|
} catch (ParserConfigurationException | IOException | SAXException | ParseException | StreamedCourseXMLException e) {
|
|
|
|
// race.runRace = false;
|
|
|
|
e.printStackTrace();
|
|
|
|
//
|
|
|
|
fail();
|
|
|
|
// race.countdownTimer();
|
|
|
|
}
|
|
|
|
//
|
|
|
|
}
|
|
|
|
// long timeStarted = System.currentTimeMillis();
|
|
|
|
|
|
|
|
// long currentTime = System.currentTimeMillis();
|
|
|
|
|
|
|
|
// while (!race.countdownFinish) {
|
|
|
|
|
|
|
|
// currentTime = System.currentTimeMillis();
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// assertTrue(currentTime - timeStarted > 500);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// @Test
|
|
|
|
|
|
|
|
// public void scalerScalesVelocityCorrectly() {
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// int scaleFactor = 3;
|
|
|
|
|
|
|
|
// float vel1 = 0;
|
|
|
|
|
|
|
|
// float vel2 = (float) 1.999;
|
|
|
|
|
|
|
|
// float vel3 = (float) 32.5;
|
|
|
|
|
|
|
|
// float vel4 = 500;
|
|
|
|
|
|
|
|
// Boat boat1 = new Boat("test", vel1, Color.ALICEBLUE, "tt",1);
|
|
|
|
|
|
|
|
// Boat boat2 = new Boat("test", vel2, Color.ALICEBLUE, "tt", 2);
|
|
|
|
|
|
|
|
// Boat boat3 = new Boat("test", vel3, Color.ALICEBLUE, "tt", 3);
|
|
|
|
|
|
|
|
// Boat boat4 = new Boat("test", vel4, Color.ALICEBLUE, "tt", 4);
|
|
|
|
|
|
|
|
// ArrayList<Boat> boats = new ArrayList<>();
|
|
|
|
|
|
|
|
// boats.add(boat1);
|
|
|
|
|
|
|
|
// boats.add(boat2);
|
|
|
|
|
|
|
|
// boats.add(boat3);
|
|
|
|
|
|
|
|
// boats.add(boat4);
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// ArrayList<Leg> legs = new ArrayList<>();
|
|
|
|
|
|
|
|
// legs.add(START_LEG);
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// Race race = new Race(boats, legs, scaleFactor, mockOutput);
|
|
|
|
|
|
|
|
// race.setDnfChance(0);
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// assertEquals(race.getStartingBoats().get(0).getScaledVelocity(), vel1 * scaleFactor, 1e-6);
|
|
|
|
|
|
|
|
// assertEquals(race.getStartingBoats().get(1).getScaledVelocity(), vel2 * scaleFactor, 1e-6);
|
|
|
|
|
|
|
|
// assertEquals(race.getStartingBoats().get(2).getScaledVelocity(), vel3 * scaleFactor, 1e-6);
|
|
|
|
|
|
|
|
// assertEquals(race.getStartingBoats().get(3).getScaledVelocity(), vel4 * scaleFactor, 1e-6);
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// @Test
|
|
|
|
|
|
|
|
// public void doNotFinishCorrectly() {
|
|
|
|
|
|
|
|
// ArrayList<Boat> boats = new ArrayList<>();
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// ArrayList<Leg> legs = new ArrayList<>();
|
|
|
|
|
|
|
|
// legs.add(START_LEG);
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// Race race = new Race(boats, legs, 1, mockOutput);
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// race.setDnfChance(100);
|
|
|
|
|
|
|
|
// assertTrue(race.doNotFinish());
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// race.setDnfChance(0);
|
|
|
|
|
|
|
|
// assertTrue(!race.doNotFinish());
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
|
|
public void distanceTravelledBeforeUpdatingLegIsRetained() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
MockOutput mockOutput = Mockito.mock(MockOutput.class);
|
|
|
|
|
|
|
|
RaceDataSource dataSource = new RaceXMLReader("mockXML/raceTest.xml", new BoatXMLReader("mockXML/boatTest.xml"));
|
|
|
|
|
|
|
|
Race testRace = new Race(dataSource, mockOutput);
|
|
|
|
|
|
|
|
testRace.initialiseBoats();
|
|
|
|
|
|
|
|
Boat testBoat = testRace.startingBoats.get(0);
|
|
|
|
|
|
|
|
testBoat.setCurrentLeg(START_LEG);
|
|
|
|
|
|
|
|
testBoat.setDistanceTravelledInLeg(START_LEG_DISTANCE + 1);
|
|
|
|
|
|
|
|
testRace.checkPosition(testBoat, 0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assertEquals(testBoat.getDistanceTravelledInLeg(), 1, 1e-7);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (ParserConfigurationException | IOException | SAXException | ParseException | StreamedCourseXMLException e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
fail();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
|
|
public void doNotFinishAnswersYesIf100PercentChance() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
MockOutput mockOutput = Mockito.mock(MockOutput.class);
|
|
|
|
|
|
|
|
BoatDataSource boatDataSource = new BoatXMLReader("mockXML/boatTest.xml");
|
|
|
|
|
|
|
|
RaceDataSource raceDataSource = new RaceXMLReader("mockXML/raceTest.xml", boatDataSource);
|
|
|
|
|
|
|
|
Race testRace = new Race(raceDataSource, mockOutput);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
testRace.setDnfChance(100);
|
|
|
|
|
|
|
|
assertTrue(testRace.doNotFinish());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (ParserConfigurationException | IOException | SAXException | ParseException | StreamedCourseXMLException e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
fail();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
|
|
public void doNotFinishAnswersNoIf0PercentChance() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
MockOutput mockOutput = Mockito.mock(MockOutput.class);
|
|
|
|
|
|
|
|
BoatDataSource boatDataSource = new BoatXMLReader("mockXML/boatTest.xml");
|
|
|
|
|
|
|
|
RaceDataSource raceDataSource = new RaceXMLReader("mockXML/raceTest.xml", boatDataSource);
|
|
|
|
|
|
|
|
Race testRace = new Race(raceDataSource, mockOutput);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
testRace.setDnfChance(0);
|
|
|
|
|
|
|
|
assertFalse(testRace.doNotFinish());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (ParserConfigurationException | IOException | SAXException | ParseException | StreamedCourseXMLException e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
fail();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
|
|
public void boatsAreSetToDNF() {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
MockOutput mockOutput = Mockito.mock(MockOutput.class);
|
|
|
|
|
|
|
|
BoatDataSource boatDataSource = new BoatXMLReader("mockXML/boatTest.xml");
|
|
|
|
|
|
|
|
RaceDataSource raceDataSource = new RaceXMLReader("mockXML/raceTest.xml", boatDataSource);
|
|
|
|
|
|
|
|
Race testRace = new Race(raceDataSource, mockOutput);
|
|
|
|
|
|
|
|
testRace.setDnfChance(100);
|
|
|
|
|
|
|
|
Boat testBoat = testRace.startingBoats.get(0);
|
|
|
|
|
|
|
|
testBoat.setCurrentLeg(START_LEG);
|
|
|
|
|
|
|
|
testBoat.setDistanceTravelledInLeg(START_LEG_DISTANCE + 1);
|
|
|
|
|
|
|
|
testRace.checkPosition(testBoat, 1);
|
|
|
|
|
|
|
|
assertEquals(testBoat.getCurrentLeg().getName(), "DNF");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (ParserConfigurationException | IOException | SAXException | ParseException | StreamedCourseXMLException e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
fail();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
|
|
public void updatePositionIgnoresFinishedBoats() {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
MockOutput mockOutput = Mockito.mock(MockOutput.class);
|
|
|
|
|
|
|
|
BoatDataSource boatDataSource = new BoatXMLReader("mockXML/boatTest.xml");
|
|
|
|
|
|
|
|
RaceDataSource raceDataSource = new RaceXMLReader("mockXML/raceTest.xml", boatDataSource);
|
|
|
|
|
|
|
|
Race testRace = new Race(raceDataSource, mockOutput);
|
|
|
|
|
|
|
|
Boat testBoat = testRace.startingBoats.get(0);
|
|
|
|
|
|
|
|
testBoat.setCurrentLeg(FINISH_LEG);
|
|
|
|
|
|
|
|
testBoat.setCurrentPosition(ORIGIN.getAverageGPSCoordinate());
|
|
|
|
|
|
|
|
testRace.updatePosition(testBoat, 1);
|
|
|
|
|
|
|
|
assertEquals(testBoat.getCurrentPosition(), ORIGIN.getAverageGPSCoordinate());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (ParserConfigurationException | IOException | SAXException | ParseException | StreamedCourseXMLException e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
fail();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
|
|
public void updatePositionChangesBoatPosition() {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
MockOutput mockOutput = Mockito.mock(MockOutput.class);
|
|
|
|
|
|
|
|
BoatDataSource boatDataSource = new BoatXMLReader("mockXML/boatTest.xml");
|
|
|
|
|
|
|
|
RaceDataSource raceDataSource = new RaceXMLReader("mockXML/raceTest.xml", boatDataSource);
|
|
|
|
|
|
|
|
Race testRace = new Race(raceDataSource, mockOutput);
|
|
|
|
|
|
|
|
testRace.initialiseBoats();
|
|
|
|
|
|
|
|
Boat testBoat = testRace.startingBoats.get(0);
|
|
|
|
|
|
|
|
testBoat.setCurrentLeg(START_LEG);
|
|
|
|
|
|
|
|
testBoat.setDistanceTravelledInLeg(START_LEG_DISTANCE - 1);
|
|
|
|
|
|
|
|
testBoat.setCurrentPosition(ORIGIN.getAverageGPSCoordinate());
|
|
|
|
|
|
|
|
testRace.updatePosition(testBoat, 100);
|
|
|
|
|
|
|
|
assertFalse(testBoat.getCurrentPosition() == ORIGIN.getAverageGPSCoordinate());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (ParserConfigurationException | IOException | SAXException | ParseException | StreamedCourseXMLException e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
fail();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|