Did the bare minimum to get the mock.model, mock.dataInput, shared.model tests working - many of them need to be tidied/refactored/moved as they don't take into account most of the refactorings.main
parent
d0c6b5f716
commit
10e80bca05
@ -1,36 +1,74 @@
|
||||
package mock.dataInput;
|
||||
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
import seng302.Exceptions.InvalidPolarFileException;
|
||||
import seng302.Model.Polars;
|
||||
import mock.exceptions.InvalidPolarFileException;
|
||||
import mock.model.Polars;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.testng.Assert.assertTrue;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
/**
|
||||
* Created by f123 on 10-May-17.
|
||||
* Tests the polar parser.
|
||||
*/
|
||||
public class PolarParserTest {
|
||||
|
||||
|
||||
/**
|
||||
* Tests if we can parse a valid polar data file (stored in a string), and create a polar table.
|
||||
*/
|
||||
@Test
|
||||
/*
|
||||
Tests if we can parse a polar data file (stored in a string), and create a polar table.
|
||||
public void testParseValidFile() {
|
||||
|
||||
try {
|
||||
//Parse data file.
|
||||
Polars polars = PolarParser.parse("mock/polars/acc_polars.csv");
|
||||
|
||||
} catch (InvalidPolarFileException e) {
|
||||
fail("Couldn't parse polar file.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if we can parse an invalid polar data file - it is expected that parsing will fail.
|
||||
*/
|
||||
public void testParse() throws Exception {
|
||||
@Test
|
||||
public void testParseInvalidFile() {
|
||||
|
||||
try {
|
||||
//Parse data file.
|
||||
Polars polars = PolarParser.parse("polars/acc_polars.csv");
|
||||
Polars polars = PolarParser.parse("mock/polars/invalid_polars.csv");
|
||||
|
||||
//As the file is invalid, we shouldn't reach here.
|
||||
fail("exception should have been thrown, but wasn't.");
|
||||
|
||||
//If the parse function didn't through, it worked.
|
||||
} catch (InvalidPolarFileException e) {
|
||||
assertTrue(true);
|
||||
}
|
||||
catch (InvalidPolarFileException e) {
|
||||
assertTrue(false);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if we can parse an non-existent polar data file - it is expected that parsing will fail.
|
||||
*/
|
||||
@Test
|
||||
public void testParseNonExistentFile() {
|
||||
|
||||
try {
|
||||
//Parse data file.
|
||||
Polars polars = PolarParser.parse("mock/polars/this_does_not_exist.csv");
|
||||
|
||||
//As the file doesn't exist, we shouldn't reach here.
|
||||
fail("exception should have been thrown, but wasn't.");
|
||||
|
||||
} catch (InvalidPolarFileException e) {
|
||||
assertTrue(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -1,101 +0,0 @@
|
||||
package mock.model;
|
||||
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Created by esa46 on 22/03/17.
|
||||
*/
|
||||
public class BoatTest {
|
||||
|
||||
|
||||
private GPSCoordinate ORIGIN_COORDS;
|
||||
private Boat TEST_BOAT;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
ORIGIN_COORDS = new GPSCoordinate(0, 0);
|
||||
TEST_BOAT = new Boat(1, "Test", "tt", new Polars());
|
||||
TEST_BOAT.setCurrentPosition(ORIGIN_COORDS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void calculateDueNorthAzimuthReturns0() {
|
||||
|
||||
CompoundMark startMarker = new CompoundMark(new Mark(1, "test origin 1", ORIGIN_COORDS));
|
||||
CompoundMark endMarker = new CompoundMark(new Mark(2, "test mark 2", new GPSCoordinate(50, 0)));
|
||||
Leg start = new Leg("Start", startMarker, endMarker, 0);
|
||||
TEST_BOAT.setCurrentLeg(start);
|
||||
assertEquals(GPSCoordinate.calculateAzimuth(startMarker.getAverageGPSCoordinate(), endMarker.getAverageGPSCoordinate()).degrees(), 0, 1e-8);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void calculateDueSouthAzimuthReturns180() {
|
||||
CompoundMark startMarker = new CompoundMark(new Mark(1, "test origin 1", ORIGIN_COORDS));
|
||||
CompoundMark endMarker = new CompoundMark(new Mark(2, "test mark 2", new GPSCoordinate(-50, 0)));
|
||||
Leg start = new Leg("Start", startMarker, endMarker, 0);
|
||||
TEST_BOAT.setCurrentLeg(start);
|
||||
assertEquals(GPSCoordinate.calculateAzimuth(startMarker.getAverageGPSCoordinate(), endMarker.getAverageGPSCoordinate()).degrees(), -180, 1e-8);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void calculateDueEastAzimuthReturns90() {
|
||||
|
||||
CompoundMark startMarker = new CompoundMark(new Mark(1, "test origin 1", ORIGIN_COORDS));
|
||||
CompoundMark endMarker = new CompoundMark(new Mark(2, "test mark 2", new GPSCoordinate(0, 50)));
|
||||
Leg start = new Leg("Start", startMarker, endMarker, 0);
|
||||
TEST_BOAT.setCurrentLeg(start);
|
||||
assertEquals(GPSCoordinate.calculateAzimuth(startMarker.getAverageGPSCoordinate(), endMarker.getAverageGPSCoordinate()).degrees(), 90, 1e-8);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void calculateDueWestAzimuthReturnsNegative90() {
|
||||
CompoundMark startMarker = new CompoundMark(new Mark(1, "test origin 1", ORIGIN_COORDS));
|
||||
CompoundMark endMarker = new CompoundMark(new Mark(2, "test mark 2", new GPSCoordinate(0, -50)));
|
||||
Leg start = new Leg("Start", startMarker, endMarker, 0);
|
||||
TEST_BOAT.setCurrentLeg(start);
|
||||
assertEquals(GPSCoordinate.calculateAzimuth(startMarker.getAverageGPSCoordinate(), endMarker.getAverageGPSCoordinate()).degrees(), -90, 1e-8);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void calculateDueNorthHeadingReturns0() {
|
||||
|
||||
CompoundMark startMarker = new CompoundMark(new Mark(1, "test origin 1", ORIGIN_COORDS));
|
||||
CompoundMark endMarker = new CompoundMark(new Mark(2, "test mark 2", new GPSCoordinate(50, 0)));
|
||||
Leg start = new Leg("Start", startMarker, endMarker, 0);
|
||||
TEST_BOAT.setCurrentLeg(start);
|
||||
assertEquals(TEST_BOAT.calculateBearingToNextMarker().degrees(), 0, 1e-8);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void calculateDueEastHeadingReturns90() {
|
||||
CompoundMark startMarker = new CompoundMark(new Mark(1, "test origin 1", ORIGIN_COORDS));
|
||||
CompoundMark endMarker = new CompoundMark(new Mark(2, "test mark 2", new GPSCoordinate(0, 50)));
|
||||
Leg start = new Leg("Start", startMarker, endMarker, 0);
|
||||
TEST_BOAT.setCurrentLeg(start);
|
||||
assertEquals(TEST_BOAT.calculateBearingToNextMarker().degrees(), 90, 1e-8);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void calculateDueSouthHeadingReturns180() {
|
||||
CompoundMark startMarker = new CompoundMark(new Mark(1, "test origin 1", ORIGIN_COORDS));
|
||||
CompoundMark endMarker = new CompoundMark(new Mark(2, "test mark 2", new GPSCoordinate(-50, 0)));
|
||||
Leg start = new Leg("Start", startMarker, endMarker, 0);
|
||||
TEST_BOAT.setCurrentLeg(start);
|
||||
assertEquals(TEST_BOAT.calculateBearingToNextMarker().degrees(), 180, 1e-8);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void calculateDueWestHeadingReturns270() {
|
||||
CompoundMark startMarker = new CompoundMark(new Mark(1, "test origin 1", ORIGIN_COORDS));
|
||||
CompoundMark endMarker = new CompoundMark(new Mark(2, "test mark 2", new GPSCoordinate(0, -50)));
|
||||
Leg start = new Leg("Start", startMarker, endMarker, 0);
|
||||
TEST_BOAT.setCurrentLeg(start);
|
||||
assertEquals(TEST_BOAT.calculateBearingToNextMarker().degrees(), 270, 1e-8);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
package mock.model;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class MockBoatTest {
|
||||
//TODO
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
package mock.model;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class MockRaceTest {
|
||||
//TODO
|
||||
}
|
||||
@ -1,314 +0,0 @@
|
||||
package mock.model;
|
||||
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
import org.xml.sax.SAXException;
|
||||
import seng302.DataInput.BoatDataSource;
|
||||
import seng302.DataInput.BoatXMLReader;
|
||||
import seng302.DataInput.RaceDataSource;
|
||||
import seng302.DataInput.RaceXMLReader;
|
||||
import seng302.Exceptions.StreamedCourseXMLException;
|
||||
import seng302.MockOutput;
|
||||
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
/**
|
||||
* Created by esa46 on 15/03/17.
|
||||
*/
|
||||
public class RaceTest{
|
||||
|
||||
|
||||
public static final CompoundMark ORIGIN = new CompoundMark(new Mark(1, "test origin 1", new GPSCoordinate(0, 0)));
|
||||
public static final CompoundMark THREE_NM_FROM_ORIGIN = new CompoundMark(new Mark(2, "test mark 2", new GPSCoordinate(0.050246769, 0)));
|
||||
public static final CompoundMark FIFTEEN_NM_FROM_ORIGIN = new CompoundMark(new Mark(3, "test mark 3", 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
|
||||
@Test
|
||||
public void countdownTimerSendsBoatLocations() {
|
||||
|
||||
try {
|
||||
MockOutput mockOutput = Mockito.mock(MockOutput.class);
|
||||
BoatDataSource boatDataSource = new BoatXMLReader("mockXML/boatTest.xml", new Polars());
|
||||
RaceDataSource raceDataSource = new RaceXMLReader("mockXML/raceTest.xml", boatDataSource);
|
||||
Race testRace = new Race(raceDataSource, mockOutput);
|
||||
testRace.initialiseBoats();
|
||||
testRace.countdownTimer.handle(1);
|
||||
verify(mockOutput, atLeast(boatDataSource.getBoats().size())).parseBoatLocation(anyInt(), anyDouble(), anyDouble(), anyDouble(), anyDouble(), anyLong());
|
||||
|
||||
} catch (ParserConfigurationException | IOException | SAXException | ParseException | StreamedCourseXMLException e) {
|
||||
e.printStackTrace();
|
||||
fail();
|
||||
}
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void countdownTimerSendsRaceStatusMessages() {
|
||||
|
||||
try {
|
||||
MockOutput mockOutput = Mockito.mock(MockOutput.class);
|
||||
RaceDataSource dataSource = new RaceXMLReader("mockXML/raceTest.xml", new BoatXMLReader("mockXML/boatTest.xml", new Polars()));
|
||||
Race testRace = new Race(dataSource, mockOutput);
|
||||
testRace.initialiseBoats();
|
||||
testRace.countdownTimer.handle(1);
|
||||
verify(mockOutput, atLeast(1)).parseRaceStatus(any());
|
||||
|
||||
} catch (ParserConfigurationException | IOException | SAXException | ParseException | StreamedCourseXMLException e) {
|
||||
e.printStackTrace();
|
||||
fail();
|
||||
}
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void checkPositionFinishedUpdatesNumberFinishedBoats() {
|
||||
|
||||
try {
|
||||
MockOutput mockOutput = Mockito.mock(MockOutput.class);
|
||||
RaceDataSource dataSource = new RaceXMLReader("mockXML/raceTest.xml", new BoatXMLReader("mockXML/boatTest.xml", new Polars()));
|
||||
Race testRace = new Race(dataSource, mockOutput);
|
||||
testRace.initialiseBoats();
|
||||
Boat testBoat = testRace.getBoats().get(0);
|
||||
testBoat.setCurrentLeg(FINISH_LEG);
|
||||
testBoat.setDistanceTravelledInLeg(1);
|
||||
testRace.checkPosition(testBoat, 1);
|
||||
|
||||
assertEquals(testRace.getNumberOfActiveBoats(), 0);
|
||||
|
||||
} catch (ParserConfigurationException | IOException | SAXException | ParseException | StreamedCourseXMLException e) {
|
||||
e.printStackTrace();
|
||||
fail();
|
||||
}
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void checkPositionSetFinishedBoatVelocityTo0() {
|
||||
|
||||
try {
|
||||
MockOutput mockOutput = Mockito.mock(MockOutput.class);
|
||||
RaceDataSource dataSource = new RaceXMLReader("mockXML/raceTest.xml", new BoatXMLReader("mockXML/boatTest.xml", new Polars()));
|
||||
Race testRace = new Race(dataSource, mockOutput);
|
||||
testRace.initialiseBoats();
|
||||
Boat testBoat = testRace.getBoats().get(0);
|
||||
testBoat.setCurrentLeg(FINISH_LEG);
|
||||
testBoat.setDistanceTravelledInLeg(1);
|
||||
testRace.checkPosition(testBoat, 1);
|
||||
|
||||
assertEquals(testBoat.getCurrentSpeed(), 0, 1e-8);
|
||||
|
||||
} catch (ParserConfigurationException | IOException | SAXException | ParseException | StreamedCourseXMLException e) {
|
||||
e.printStackTrace();
|
||||
fail();
|
||||
}
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void checkPositionSetsFinishTime() {
|
||||
|
||||
try {
|
||||
MockOutput mockOutput = Mockito.mock(MockOutput.class);
|
||||
RaceDataSource dataSource = new RaceXMLReader("mockXML/raceTest.xml", new BoatXMLReader("mockXML/boatTest.xml", new Polars()));
|
||||
Race testRace = new Race(dataSource, mockOutput);
|
||||
testRace.initialiseBoats();
|
||||
Boat testBoat = testRace.getBoats().get(0);
|
||||
testBoat.setCurrentLeg(FINISH_LEG);
|
||||
testBoat.setDistanceTravelledInLeg(1);
|
||||
testRace.checkPosition(testBoat, 1);
|
||||
|
||||
assertEquals(testBoat.getTimeFinished(), 1, 1e-8);
|
||||
|
||||
} catch (ParserConfigurationException | IOException | SAXException | ParseException | StreamedCourseXMLException e) {
|
||||
e.printStackTrace();
|
||||
fail();
|
||||
}
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void checkPositionUnfinishedDoesntUpdateNumberFinishedBoats() {
|
||||
|
||||
try {
|
||||
MockOutput mockOutput = Mockito.mock(MockOutput.class);
|
||||
RaceDataSource dataSource = new RaceXMLReader("mockXML/raceTest.xml", new BoatXMLReader("mockXML/boatTest.xml", new Polars()));
|
||||
Race testRace = new Race(dataSource, mockOutput);
|
||||
testRace.initialiseBoats();
|
||||
Boat testBoat = testRace.getBoats().get(0);
|
||||
testBoat.setCurrentLeg(START_LEG);
|
||||
testBoat.setDistanceTravelledInLeg(START_LEG_DISTANCE);
|
||||
testRace.checkPosition(testBoat, 1);
|
||||
|
||||
assertEquals(testRace.getNumberOfActiveBoats(), 1);
|
||||
|
||||
} catch (ParserConfigurationException | IOException | SAXException | ParseException | StreamedCourseXMLException e) {
|
||||
e.printStackTrace();
|
||||
fail();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void distanceTravelledBeforeUpdatingLegIsRetained() {
|
||||
|
||||
try {
|
||||
MockOutput mockOutput = Mockito.mock(MockOutput.class);
|
||||
RaceDataSource dataSource = new RaceXMLReader("mockXML/raceTest.xml", new BoatXMLReader("mockXML/boatTest.xml", new Polars()));
|
||||
Race testRace = new Race(dataSource, mockOutput);
|
||||
testRace.initialiseBoats();
|
||||
Boat testBoat = testRace.getBoats().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();
|
||||
}
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void doNotFinishAnswersYesIf100PercentChance() {
|
||||
|
||||
try {
|
||||
MockOutput mockOutput = Mockito.mock(MockOutput.class);
|
||||
BoatDataSource boatDataSource = new BoatXMLReader("mockXML/boatTest.xml", new Polars());
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void doNotFinishAnswersNoIf0PercentChance() {
|
||||
|
||||
try {
|
||||
MockOutput mockOutput = Mockito.mock(MockOutput.class);
|
||||
BoatDataSource boatDataSource = new BoatXMLReader("mockXML/boatTest.xml", new Polars());
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void boatsAreSetToDNF() {
|
||||
try {
|
||||
MockOutput mockOutput = Mockito.mock(MockOutput.class);
|
||||
BoatDataSource boatDataSource = new BoatXMLReader("mockXML/boatTest.xml", new Polars());
|
||||
RaceDataSource raceDataSource = new RaceXMLReader("mockXML/raceTest.xml", boatDataSource);
|
||||
Race testRace = new Race(raceDataSource, mockOutput);
|
||||
testRace.setDnfChance(100);
|
||||
Boat testBoat = testRace.getBoats().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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void updatePositionIgnoresFinishedBoats() {
|
||||
try {
|
||||
MockOutput mockOutput = Mockito.mock(MockOutput.class);
|
||||
BoatDataSource boatDataSource = new BoatXMLReader("mockXML/boatTest.xml", new Polars());
|
||||
RaceDataSource raceDataSource = new RaceXMLReader("mockXML/raceTest.xml", boatDataSource);
|
||||
Race testRace = new Race(raceDataSource, mockOutput);
|
||||
Boat testBoat = testRace.getBoats().get(0);
|
||||
testBoat.setCurrentLeg(FINISH_LEG);
|
||||
testBoat.setCurrentPosition(ORIGIN.getAverageGPSCoordinate());
|
||||
testRace.updatePosition(testBoat, 1, 1);
|
||||
assertEquals(testBoat.getCurrentPosition(), ORIGIN.getAverageGPSCoordinate());
|
||||
|
||||
} catch (ParserConfigurationException | IOException | SAXException | ParseException | StreamedCourseXMLException e) {
|
||||
e.printStackTrace();
|
||||
fail();
|
||||
}
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void updatePositionChangesBoatPosition() {
|
||||
try {
|
||||
MockOutput mockOutput = Mockito.mock(MockOutput.class);
|
||||
BoatDataSource boatDataSource = new BoatXMLReader("mockXML/boatTest.xml", new Polars());
|
||||
RaceDataSource raceDataSource = new RaceXMLReader("mockXML/raceTest.xml", boatDataSource);
|
||||
Race testRace = new Race(raceDataSource, mockOutput);
|
||||
testRace.initialiseBoats();
|
||||
Boat testBoat = testRace.getBoats().get(0);
|
||||
testBoat.setCurrentLeg(START_LEG);
|
||||
testBoat.setDistanceTravelledInLeg(START_LEG_DISTANCE - 1);
|
||||
testBoat.setCurrentPosition(ORIGIN.getAverageGPSCoordinate());
|
||||
testRace.updatePosition(testBoat, 100, 100);
|
||||
assertFalse(testBoat.getCurrentPosition() == ORIGIN.getAverageGPSCoordinate());
|
||||
} catch (ParserConfigurationException | IOException | SAXException | ParseException | StreamedCourseXMLException e) {
|
||||
e.printStackTrace();
|
||||
fail();
|
||||
}
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void windDirectionCorrectValues(){
|
||||
// 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.setChangeWind(1);
|
||||
// testRace.setWindDir(65535);
|
||||
// testRace.changeWindDir();
|
||||
// assertEquals(100, testRace.getWind());
|
||||
// } catch (ParserConfigurationException | IOException | SAXException | ParseException | StreamedCourseXMLException e) {
|
||||
// e.printStackTrace();
|
||||
// fail();
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,58 @@
|
||||
package mock.model;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import shared.model.Bearing;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class VMGTest {
|
||||
|
||||
/**
|
||||
* VMG object to test.
|
||||
*/
|
||||
private VMG vmg;
|
||||
|
||||
/**
|
||||
* Speed of the VMG, in knots.
|
||||
*/
|
||||
private double speed;
|
||||
|
||||
private double speedEpsilon = 0.001;
|
||||
|
||||
/**
|
||||
* Bearing of the vmg.
|
||||
*/
|
||||
private Bearing bearing;
|
||||
|
||||
private double bearingDegreeEpsilon = 0.001;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Constructs a VMG object.
|
||||
*/
|
||||
@Before
|
||||
public void setUp() {
|
||||
|
||||
speed = 14.98;
|
||||
|
||||
bearing = Bearing.fromDegrees(78.5);
|
||||
|
||||
|
||||
vmg = new VMG(speed, bearing);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testVMGSpeed() {
|
||||
|
||||
assertEquals(speed, vmg.getSpeed(), speedEpsilon);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testVMGBearing() {
|
||||
|
||||
assertEquals(bearing.degrees(), vmg.getBearing().degrees(), bearingDegreeEpsilon);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
package shared.model;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class AngleTest {
|
||||
//TODO
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
package shared.model;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class AzimuthTest {
|
||||
//TODO
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
package shared.model;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class BearingTest {
|
||||
//TODO
|
||||
}
|
||||
@ -0,0 +1,173 @@
|
||||
package shared.model;
|
||||
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Created by esa46 on 22/03/17.
|
||||
*/
|
||||
public class BoatTest {
|
||||
|
||||
|
||||
private GPSCoordinate ORIGIN_COORDS;
|
||||
private Boat TEST_BOAT;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
ORIGIN_COORDS = new GPSCoordinate(0, 0);
|
||||
TEST_BOAT = new Boat(1, "Test", "tt");
|
||||
TEST_BOAT.setCurrentPosition(ORIGIN_COORDS);
|
||||
}
|
||||
|
||||
//TODO these bearing tests could be tidied up to reduce code repetition.
|
||||
//TODO also, most of these tests may be more appropriate in GPSCoordinateTest
|
||||
|
||||
@Test
|
||||
public void calculateDueNorthAzimuthReturns0() {
|
||||
|
||||
CompoundMark startMarker = new CompoundMark(
|
||||
1,
|
||||
"start",
|
||||
new Mark(1, "test origin 1", ORIGIN_COORDS) );
|
||||
|
||||
CompoundMark endMarker = new CompoundMark(
|
||||
2,
|
||||
"end",
|
||||
new Mark(2, "test mark 2", new GPSCoordinate(50, 0)) );
|
||||
|
||||
Leg start = new Leg("Start", startMarker, endMarker, 0);
|
||||
TEST_BOAT.setCurrentLeg(start);
|
||||
assertEquals(GPSCoordinate.calculateAzimuth(startMarker.getAverageGPSCoordinate(), endMarker.getAverageGPSCoordinate()).degrees(), 0, 1e-8);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void calculateDueSouthAzimuthReturns180() {
|
||||
CompoundMark startMarker = new CompoundMark(
|
||||
1,
|
||||
"start",
|
||||
new Mark(1, "test origin 1", ORIGIN_COORDS) );
|
||||
|
||||
CompoundMark endMarker = new CompoundMark(
|
||||
2,
|
||||
"end",
|
||||
new Mark(2, "test mark 2", new GPSCoordinate(-50, 0)) );
|
||||
|
||||
Leg start = new Leg("Start", startMarker, endMarker, 0);
|
||||
TEST_BOAT.setCurrentLeg(start);
|
||||
assertEquals(GPSCoordinate.calculateAzimuth(startMarker.getAverageGPSCoordinate(), endMarker.getAverageGPSCoordinate()).degrees(), -180, 1e-8);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void calculateDueEastAzimuthReturns90() {
|
||||
|
||||
CompoundMark startMarker = new CompoundMark(
|
||||
1,
|
||||
"start",
|
||||
new Mark(1, "test origin 1", ORIGIN_COORDS) );
|
||||
|
||||
CompoundMark endMarker = new CompoundMark(
|
||||
2,
|
||||
"end",
|
||||
new Mark(2, "test mark 2", new GPSCoordinate(0, 50)) );
|
||||
|
||||
Leg start = new Leg("Start", startMarker, endMarker, 0);
|
||||
TEST_BOAT.setCurrentLeg(start);
|
||||
assertEquals(GPSCoordinate.calculateAzimuth(startMarker.getAverageGPSCoordinate(), endMarker.getAverageGPSCoordinate()).degrees(), 90, 1e-8);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void calculateDueWestAzimuthReturnsNegative90() {
|
||||
CompoundMark startMarker = new CompoundMark(
|
||||
1,
|
||||
"start",
|
||||
new Mark(1, "test origin 1", ORIGIN_COORDS) );
|
||||
|
||||
CompoundMark endMarker = new CompoundMark(
|
||||
2,
|
||||
"end",
|
||||
new Mark(2, "test mark 2", new GPSCoordinate(0, -50)) );
|
||||
|
||||
Leg start = new Leg("Start", startMarker, endMarker, 0);
|
||||
TEST_BOAT.setCurrentLeg(start);
|
||||
assertEquals(GPSCoordinate.calculateAzimuth(startMarker.getAverageGPSCoordinate(), endMarker.getAverageGPSCoordinate()).degrees(), -90, 1e-8);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void calculateDueNorthHeadingReturns0() {
|
||||
|
||||
CompoundMark startMarker = new CompoundMark(
|
||||
1,
|
||||
"start",
|
||||
new Mark(1, "test origin 1", ORIGIN_COORDS) );
|
||||
|
||||
CompoundMark endMarker = new CompoundMark(
|
||||
2,
|
||||
"end",
|
||||
new Mark(2, "test mark 2", new GPSCoordinate(50, 0)) );
|
||||
|
||||
Leg start = new Leg("Start", startMarker, endMarker, 0);
|
||||
TEST_BOAT.setCurrentLeg(start);
|
||||
assertEquals(GPSCoordinate.calculateAzimuth(TEST_BOAT.getCurrentPosition(), endMarker.getAverageGPSCoordinate()).degrees(), 0, 1e-8);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void calculateDueEastHeadingReturns90() {
|
||||
CompoundMark startMarker = new CompoundMark(
|
||||
1,
|
||||
"start",
|
||||
new Mark(1, "test origin 1", ORIGIN_COORDS) );
|
||||
|
||||
CompoundMark endMarker = new CompoundMark(
|
||||
2,
|
||||
"end",
|
||||
new Mark(2, "test mark 2", new GPSCoordinate(0, 50)) );
|
||||
|
||||
Leg start = new Leg("Start", startMarker, endMarker, 0);
|
||||
TEST_BOAT.setCurrentLeg(start);
|
||||
assertEquals(GPSCoordinate.calculateAzimuth(TEST_BOAT.getCurrentPosition(), endMarker.getAverageGPSCoordinate()).degrees(), 90, 1e-8);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void calculateDueSouthHeadingReturns180() {
|
||||
CompoundMark startMarker = new CompoundMark(
|
||||
1,
|
||||
"start",
|
||||
new Mark(1, "test origin 1", ORIGIN_COORDS) );
|
||||
|
||||
CompoundMark endMarker = new CompoundMark(
|
||||
2,
|
||||
"end",
|
||||
new Mark(2, "test mark 2", new GPSCoordinate(-50, 0)) );
|
||||
|
||||
Leg start = new Leg("Start", startMarker, endMarker, 0);
|
||||
TEST_BOAT.setCurrentLeg(start);
|
||||
assertEquals(GPSCoordinate.calculateAzimuth(TEST_BOAT.getCurrentPosition(), endMarker.getAverageGPSCoordinate()).degrees(), -180, 1e-8);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void calculateDueWestHeadingReturns270() {
|
||||
CompoundMark startMarker = new CompoundMark(
|
||||
1,
|
||||
"start",
|
||||
new Mark(1, "test origin 1", ORIGIN_COORDS) );
|
||||
|
||||
CompoundMark endMarker = new CompoundMark(
|
||||
2,
|
||||
"end",
|
||||
new Mark(2, "test mark 2", new GPSCoordinate(0, -50)) );
|
||||
|
||||
Leg start = new Leg("Start", startMarker, endMarker, 0);
|
||||
TEST_BOAT.setCurrentLeg(start);
|
||||
assertEquals(GPSCoordinate.calculateBearing(TEST_BOAT.getCurrentPosition(), endMarker.getAverageGPSCoordinate()).degrees(), 270, 1e-8);
|
||||
}
|
||||
|
||||
|
||||
//TODO test Boat#setCurrentLeg and it's effects.
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
package shared.model;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class MarkTest {
|
||||
//TODO
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
package shared.model;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class RaceClockTest {
|
||||
//TODO
|
||||
}
|
||||
@ -0,0 +1,345 @@
|
||||
//package shared.model;
|
||||
//
|
||||
//
|
||||
//import mock.model.Polars;
|
||||
//import org.junit.Before;
|
||||
//import org.junit.Ignore;
|
||||
//import org.junit.Test;
|
||||
//import org.mockito.Mockito;
|
||||
//import org.xml.sax.SAXException;
|
||||
//
|
||||
//import javax.xml.parsers.ParserConfigurationException;
|
||||
//import java.io.IOException;
|
||||
//import java.text.ParseException;
|
||||
//import java.util.ArrayList;
|
||||
//
|
||||
//import static org.junit.Assert.*;
|
||||
//import static org.mockito.Mockito.*;
|
||||
//
|
||||
///**
|
||||
// * Created by esa46 on 15/03/17.
|
||||
// */
|
||||
//public class RaceTest{
|
||||
//
|
||||
//
|
||||
// private CompoundMark ORIGIN;
|
||||
//
|
||||
// private CompoundMark THREE_NM_FROM_ORIGIN;
|
||||
//
|
||||
// private CompoundMark FIFTEEN_NM_FROM_ORIGIN;
|
||||
//
|
||||
// private ArrayList<Leg> TEST_LEGS = new ArrayList<>();
|
||||
//
|
||||
// private int START_LEG_DISTANCE = 3;
|
||||
// private int MIDDLE_LEG_DISTANCE = 12;
|
||||
//
|
||||
// private Leg START_LEG;
|
||||
//
|
||||
// private Leg MIDDLE_LEG;
|
||||
//
|
||||
// private Leg FINISH_LEG;
|
||||
//
|
||||
//
|
||||
// @Before
|
||||
// public void setUp() {
|
||||
//
|
||||
// ORIGIN = new CompoundMark(
|
||||
// 1,
|
||||
// "origin compound",
|
||||
// new Mark(1, "test origin 1", new GPSCoordinate(0, 0)) );
|
||||
//
|
||||
//
|
||||
// THREE_NM_FROM_ORIGIN = new CompoundMark(
|
||||
// 2,
|
||||
// "3 NM from origin compound",
|
||||
// new Mark(2, "test mark 2", new GPSCoordinate(0.050246769, 0)) );
|
||||
//
|
||||
//
|
||||
// FIFTEEN_NM_FROM_ORIGIN = new CompoundMark(
|
||||
// 3,
|
||||
// "15 NM from origin compound",
|
||||
// new Mark(3, "test mark 3", new GPSCoordinate(0.251233845, 0)) );
|
||||
//
|
||||
//
|
||||
// START_LEG = new Leg("Start", ORIGIN, THREE_NM_FROM_ORIGIN, 0);
|
||||
//
|
||||
//
|
||||
// MIDDLE_LEG = new Leg("Middle", THREE_NM_FROM_ORIGIN, FIFTEEN_NM_FROM_ORIGIN, 1);
|
||||
//
|
||||
//
|
||||
// FINISH_LEG = new Leg("Finish", FIFTEEN_NM_FROM_ORIGIN, FIFTEEN_NM_FROM_ORIGIN, 2);
|
||||
//
|
||||
//
|
||||
// TEST_LEGS.add(START_LEG);
|
||||
// TEST_LEGS.add(MIDDLE_LEG);
|
||||
// TEST_LEGS.add(FINISH_LEG);
|
||||
// }
|
||||
//
|
||||
// @Ignore
|
||||
// @Test
|
||||
// public void countdownTimerSendsBoatLocations() {
|
||||
//
|
||||
// try {
|
||||
// MockOutput mockOutput = Mockito.mock(MockOutput.class);
|
||||
// BoatDataSource boatDataSource = new BoatXMLReader("mockXML/boatTest.xml", new Polars());
|
||||
// RaceDataSource raceDataSource = new RaceXMLReader("mockXML/raceTest.xml", boatDataSource);
|
||||
// Race testRace = new Race(raceDataSource, mockOutput);
|
||||
// testRace.initialiseBoats();
|
||||
// testRace.countdownTimer.handle(1);
|
||||
// verify(mockOutput, atLeast(boatDataSource.getBoats().size())).parseBoatLocation(anyInt(), anyDouble(), anyDouble(), anyDouble(), anyDouble(), anyLong());
|
||||
//
|
||||
// } catch (ParserConfigurationException | IOException | SAXException | ParseException | StreamedCourseXMLException e) {
|
||||
// e.printStackTrace();
|
||||
// fail();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Ignore
|
||||
// @Test
|
||||
// public void countdownTimerSendsRaceStatusMessages() {
|
||||
//
|
||||
// try {
|
||||
// MockOutput mockOutput = Mockito.mock(MockOutput.class);
|
||||
// RaceDataSource dataSource = new RaceXMLReader("mockXML/raceTest.xml", new BoatXMLReader("mockXML/boatTest.xml", new Polars()));
|
||||
// Race testRace = new Race(dataSource, mockOutput);
|
||||
// testRace.initialiseBoats();
|
||||
// testRace.countdownTimer.handle(1);
|
||||
// verify(mockOutput, atLeast(1)).parseRaceStatus(any());
|
||||
//
|
||||
// } catch (ParserConfigurationException | IOException | SAXException | ParseException | StreamedCourseXMLException e) {
|
||||
// e.printStackTrace();
|
||||
// fail();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Ignore
|
||||
// @Test
|
||||
// public void checkPositionFinishedUpdatesNumberFinishedBoats() {
|
||||
//
|
||||
// try {
|
||||
// MockOutput mockOutput = Mockito.mock(MockOutput.class);
|
||||
// RaceDataSource dataSource = new RaceXMLReader("mockXML/raceTest.xml", new BoatXMLReader("mockXML/boatTest.xml", new Polars()));
|
||||
// Race testRace = new Race(dataSource, mockOutput);
|
||||
// testRace.initialiseBoats();
|
||||
// Boat testBoat = testRace.getBoats().get(0);
|
||||
// testBoat.setCurrentLeg(FINISH_LEG);
|
||||
// testBoat.setDistanceTravelledInLeg(1);
|
||||
// testRace.checkPosition(testBoat, 1);
|
||||
//
|
||||
// assertEquals(testRace.getNumberOfActiveBoats(), 0);
|
||||
//
|
||||
// } catch (ParserConfigurationException | IOException | SAXException | ParseException | StreamedCourseXMLException e) {
|
||||
// e.printStackTrace();
|
||||
// fail();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Ignore
|
||||
// @Test
|
||||
// public void checkPositionSetFinishedBoatVelocityTo0() {
|
||||
//
|
||||
// try {
|
||||
// MockOutput mockOutput = Mockito.mock(MockOutput.class);
|
||||
// RaceDataSource dataSource = new RaceXMLReader("mockXML/raceTest.xml", new BoatXMLReader("mockXML/boatTest.xml", new Polars()));
|
||||
// Race testRace = new Race(dataSource, mockOutput);
|
||||
// testRace.initialiseBoats();
|
||||
// Boat testBoat = testRace.getBoats().get(0);
|
||||
// testBoat.setCurrentLeg(FINISH_LEG);
|
||||
// testBoat.setDistanceTravelledInLeg(1);
|
||||
// testRace.checkPosition(testBoat, 1);
|
||||
//
|
||||
// assertEquals(testBoat.getCurrentSpeed(), 0, 1e-8);
|
||||
//
|
||||
// } catch (ParserConfigurationException | IOException | SAXException | ParseException | StreamedCourseXMLException e) {
|
||||
// e.printStackTrace();
|
||||
// fail();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Ignore
|
||||
// @Test
|
||||
// public void checkPositionSetsFinishTime() {
|
||||
//
|
||||
// try {
|
||||
// MockOutput mockOutput = Mockito.mock(MockOutput.class);
|
||||
// RaceDataSource dataSource = new RaceXMLReader("mockXML/raceTest.xml", new BoatXMLReader("mockXML/boatTest.xml", new Polars()));
|
||||
// Race testRace = new Race(dataSource, mockOutput);
|
||||
// testRace.initialiseBoats();
|
||||
// Boat testBoat = testRace.getBoats().get(0);
|
||||
// testBoat.setCurrentLeg(FINISH_LEG);
|
||||
// testBoat.setDistanceTravelledInLeg(1);
|
||||
// testRace.checkPosition(testBoat, 1);
|
||||
//
|
||||
// assertEquals(testBoat.getTimeFinished(), 1, 1e-8);
|
||||
//
|
||||
// } catch (ParserConfigurationException | IOException | SAXException | ParseException | StreamedCourseXMLException e) {
|
||||
// e.printStackTrace();
|
||||
// fail();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Ignore
|
||||
// @Test
|
||||
// public void checkPositionUnfinishedDoesntUpdateNumberFinishedBoats() {
|
||||
//
|
||||
// try {
|
||||
// MockOutput mockOutput = Mockito.mock(MockOutput.class);
|
||||
// RaceDataSource dataSource = new RaceXMLReader("mockXML/raceTest.xml", new BoatXMLReader("mockXML/boatTest.xml", new Polars()));
|
||||
// Race testRace = new Race(dataSource, mockOutput);
|
||||
// testRace.initialiseBoats();
|
||||
// Boat testBoat = testRace.getBoats().get(0);
|
||||
// testBoat.setCurrentLeg(START_LEG);
|
||||
// testBoat.setDistanceTravelledInLeg(START_LEG_DISTANCE);
|
||||
// testRace.checkPosition(testBoat, 1);
|
||||
//
|
||||
// assertEquals(testRace.getNumberOfActiveBoats(), 1);
|
||||
//
|
||||
// } catch (ParserConfigurationException | IOException | SAXException | ParseException | StreamedCourseXMLException e) {
|
||||
// e.printStackTrace();
|
||||
// fail();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @Ignore
|
||||
// @Test
|
||||
// public void distanceTravelledBeforeUpdatingLegIsRetained() {
|
||||
//
|
||||
// try {
|
||||
// MockOutput mockOutput = Mockito.mock(MockOutput.class);
|
||||
// RaceDataSource dataSource = new RaceXMLReader("mockXML/raceTest.xml", new BoatXMLReader("mockXML/boatTest.xml", new Polars()));
|
||||
// Race testRace = new Race(dataSource, mockOutput);
|
||||
// testRace.initialiseBoats();
|
||||
// Boat testBoat = testRace.getBoats().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();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Ignore
|
||||
// @Test
|
||||
// public void doNotFinishAnswersYesIf100PercentChance() {
|
||||
//
|
||||
// try {
|
||||
// MockOutput mockOutput = Mockito.mock(MockOutput.class);
|
||||
// BoatDataSource boatDataSource = new BoatXMLReader("mockXML/boatTest.xml", new Polars());
|
||||
// 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();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Ignore
|
||||
// @Test
|
||||
// public void doNotFinishAnswersNoIf0PercentChance() {
|
||||
//
|
||||
// try {
|
||||
// MockOutput mockOutput = Mockito.mock(MockOutput.class);
|
||||
// BoatDataSource boatDataSource = new BoatXMLReader("mockXML/boatTest.xml", new Polars());
|
||||
// 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();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Ignore
|
||||
// @Test
|
||||
// public void boatsAreSetToDNF() {
|
||||
// try {
|
||||
// MockOutput mockOutput = Mockito.mock(MockOutput.class);
|
||||
// BoatDataSource boatDataSource = new BoatXMLReader("mockXML/boatTest.xml", new Polars());
|
||||
// RaceDataSource raceDataSource = new RaceXMLReader("mockXML/raceTest.xml", boatDataSource);
|
||||
// Race testRace = new Race(raceDataSource, mockOutput);
|
||||
// testRace.setDnfChance(100);
|
||||
// Boat testBoat = testRace.getBoats().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();
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
// @Ignore
|
||||
// @Test
|
||||
// public void updatePositionIgnoresFinishedBoats() {
|
||||
// try {
|
||||
// MockOutput mockOutput = Mockito.mock(MockOutput.class);
|
||||
// BoatDataSource boatDataSource = new BoatXMLReader("mockXML/boatTest.xml", new Polars());
|
||||
// RaceDataSource raceDataSource = new RaceXMLReader("mockXML/raceTest.xml", boatDataSource);
|
||||
// Race testRace = new Race(raceDataSource, mockOutput);
|
||||
// Boat testBoat = testRace.getBoats().get(0);
|
||||
// testBoat.setCurrentLeg(FINISH_LEG);
|
||||
// testBoat.setCurrentPosition(ORIGIN.getAverageGPSCoordinate());
|
||||
// testRace.updatePosition(testBoat, 1, 1);
|
||||
// assertEquals(testBoat.getCurrentPosition(), ORIGIN.getAverageGPSCoordinate());
|
||||
//
|
||||
// } catch (ParserConfigurationException | IOException | SAXException | ParseException | StreamedCourseXMLException e) {
|
||||
// e.printStackTrace();
|
||||
// fail();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Ignore
|
||||
// @Test
|
||||
// public void updatePositionChangesBoatPosition() {
|
||||
// try {
|
||||
// MockOutput mockOutput = Mockito.mock(MockOutput.class);
|
||||
// BoatDataSource boatDataSource = new BoatXMLReader("mockXML/boatTest.xml", new Polars());
|
||||
// RaceDataSource raceDataSource = new RaceXMLReader("mockXML/raceTest.xml", boatDataSource);
|
||||
// Race testRace = new Race(raceDataSource, mockOutput);
|
||||
// testRace.initialiseBoats();
|
||||
// Boat testBoat = testRace.getBoats().get(0);
|
||||
// testBoat.setCurrentLeg(START_LEG);
|
||||
// testBoat.setDistanceTravelledInLeg(START_LEG_DISTANCE - 1);
|
||||
// testBoat.setCurrentPosition(ORIGIN.getAverageGPSCoordinate());
|
||||
// testRace.updatePosition(testBoat, 100, 100);
|
||||
// assertFalse(testBoat.getCurrentPosition() == ORIGIN.getAverageGPSCoordinate());
|
||||
// } catch (ParserConfigurationException | IOException | SAXException | ParseException | StreamedCourseXMLException e) {
|
||||
// e.printStackTrace();
|
||||
// fail();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Ignore
|
||||
// @Test
|
||||
// public void windDirectionCorrectValues(){
|
||||
//// 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.setChangeWind(1);
|
||||
//// testRace.setWindDir(65535);
|
||||
//// testRace.changeWindDir();
|
||||
//// assertEquals(100, testRace.getWind());
|
||||
//// } catch (ParserConfigurationException | IOException | SAXException | ParseException | StreamedCourseXMLException e) {
|
||||
//// e.printStackTrace();
|
||||
//// fail();
|
||||
//// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
//}
|
||||
|
Loading…
Reference in new issue