diff --git a/mock/src/main/java/seng302/Constants.java b/mock/src/main/java/seng302/Constants.java index 04eee894..321bdab3 100644 --- a/mock/src/main/java/seng302/Constants.java +++ b/mock/src/main/java/seng302/Constants.java @@ -8,4 +8,7 @@ public class Constants { public static final int NMToMetersConversion = 1852; // 1 nautical mile = 1852 meters + public static final int PRE_RACE_WAIT_TIME = 18000; + + public static final int TEST_VELOCITIES[] = new int[] { 30, 15, 64, 52, 25, 24 }; } diff --git a/mock/src/main/java/seng302/DataInput/RegattaDataSource.java b/mock/src/main/java/seng302/DataInput/RegattaDataSource.java deleted file mode 100644 index 69a04822..00000000 --- a/mock/src/main/java/seng302/DataInput/RegattaDataSource.java +++ /dev/null @@ -1,11 +0,0 @@ -package seng302.DataInput; - - -import seng302.Model.Regatta; - -/** - * Created by zwu18 on 25/04/17. - */ -public interface RegattaDataSource { - Regatta getRegatta(); -} diff --git a/mock/src/main/java/seng302/DataInput/RegattaXMLReader.java b/mock/src/main/java/seng302/DataInput/RegattaXMLReader.java deleted file mode 100644 index 406d923f..00000000 --- a/mock/src/main/java/seng302/DataInput/RegattaXMLReader.java +++ /dev/null @@ -1,75 +0,0 @@ -package seng302.DataInput; - -import org.w3c.dom.Element; -import org.w3c.dom.NodeList; -import org.xml.sax.SAXException; -import seng302.Model.Regatta; - - -import javax.xml.parsers.ParserConfigurationException; -import java.io.IOException; - -/** - * Created by jjg64 on 19/04/17. - */ -public class RegattaXMLReader extends XMLReader implements RegattaDataSource { - private Regatta regatta; - - /** - * Constructor for Regatta XML - * - * @param filePath path of the file - * @throws IOException error - * @throws SAXException error - * @throws ParserConfigurationException error - */ - public RegattaXMLReader(String filePath) throws IOException, SAXException, ParserConfigurationException { - this(filePath, true); - } - - /** - * Constructor for Regatta XML - * - * @param filePath file path to read - * @param read whether or not to read and store the files straight away. - * @throws IOException error - * @throws SAXException error - * @throws ParserConfigurationException error - */ - public RegattaXMLReader(String filePath, boolean read) throws IOException, SAXException, ParserConfigurationException { - super(filePath); - if (read) { - read(); - } - } - - /** - * Read the XML - */ - private void read() { - NodeList attributeConfig = doc.getElementsByTagName("RegattaConfig"); - Element attributes = (Element) attributeConfig.item(0); - makeRegatta(attributes); - } - - /** - * Create new regatta - * @param attributes - */ - private void makeRegatta(Element attributes) { - int regattaID = Integer.parseInt(getTextValueOfNode(attributes, "RegattaID")); - String regattaName = getTextValueOfNode(attributes, "RegattaName"); - String courseName = getTextValueOfNode(attributes, "CourseName"); - double centralLatitude = Double.parseDouble(getTextValueOfNode(attributes, "CentralLatitude")); - double centralLongitude = Double.parseDouble(getTextValueOfNode(attributes, "CentralLongitude")); - double centralAltitude = Double.parseDouble(getTextValueOfNode(attributes, "CentralAltitude")); - float utcOffset = Float.parseFloat(getTextValueOfNode(attributes, "UtcOffset")); - float magneticVariation = Float.parseFloat(getTextValueOfNode(attributes, "MagneticVariation")); - - regatta = new Regatta(regattaID, regattaName, courseName, centralLatitude, centralLongitude, centralAltitude, utcOffset, magneticVariation); - } - - public Regatta getRegatta() { - return regatta; - } -} diff --git a/mock/src/main/java/seng302/DataInput/XMLReader.java b/mock/src/main/java/seng302/DataInput/XMLReader.java index e24fb160..13c4808b 100644 --- a/mock/src/main/java/seng302/DataInput/XMLReader.java +++ b/mock/src/main/java/seng302/DataInput/XMLReader.java @@ -29,8 +29,6 @@ public abstract class XMLReader { */ public XMLReader(String filePath) throws ParserConfigurationException, IOException, SAXException { - - InputSource fXmlFile; if (filePath.contains("<")) { fXmlFile = new InputSource(); diff --git a/mock/src/main/java/seng302/Exceptions/InvalidRegattaDataException.java b/mock/src/main/java/seng302/Exceptions/InvalidRegattaDataException.java deleted file mode 100644 index 1249ae96..00000000 --- a/mock/src/main/java/seng302/Exceptions/InvalidRegattaDataException.java +++ /dev/null @@ -1,17 +0,0 @@ -package seng302.Exceptions; - -/** - * Created by f123 on 25-Apr-17. - */ - -/** - * An exception thrown when a Regatta.xml message cannot be generated and sent. - */ -public class InvalidRegattaDataException extends RuntimeException { - public InvalidRegattaDataException() { - } - - public InvalidRegattaDataException(String message) { - super(message); - } -} diff --git a/mock/src/main/java/seng302/Model/Boat.java b/mock/src/main/java/seng302/Model/Boat.java index 91fe6f24..98162abf 100644 --- a/mock/src/main/java/seng302/Model/Boat.java +++ b/mock/src/main/java/seng302/Model/Boat.java @@ -27,7 +27,6 @@ public class Boat { * @param country nam abbreviation */ public Boat(int sourceID, String name, String country) { - this.velocity = 30; // TODO - please dont commit this.country = this.country; this.name = name; this.sourceID = sourceID; diff --git a/mock/src/main/java/seng302/Model/Race.java b/mock/src/main/java/seng302/Model/Race.java index a8dbece1..2ef104c7 100644 --- a/mock/src/main/java/seng302/Model/Race.java +++ b/mock/src/main/java/seng302/Model/Race.java @@ -1,12 +1,10 @@ package seng302.Model; - import javafx.animation.AnimationTimer; import javafx.collections.FXCollections; import javafx.collections.ObservableList; import org.geotools.referencing.GeodeticCalculator; - import seng302.Constants; import seng302.DataInput.RaceDataSource; import seng302.MockOutput; @@ -19,7 +17,6 @@ import java.util.ArrayList; import java.util.List; import java.util.Random; - /** * Parent class for races * Created by fwy13 on 3/03/17. @@ -30,60 +27,19 @@ public class Race implements Runnable { protected List legs; protected int boatsFinished = 0; protected long totalTimeElapsed; - protected int scaleFactor = 20; - protected int PRERACE_TIME = 18000; //time in milliseconds to pause during pre-race. At the moment, 3 minutes + protected int scaleFactor = 3; private long startTime; - protected boolean countdownFinish = false; - protected boolean runRace = true; - private int lastFPS = 20; private int raceId; private int dnfChance = 0; //percentage chance a boat fails at each checkpoint private MockOutput mockOutput; - private static int boatOffset = 0; - private int finished = 0; - - /** - * Initailiser for Race - * - * @param boats Takes in an array of boats that are participating in the race. - * @param legs Number of marks in order that the boats pass in order to complete the race. - */ - public Race(List boats, List legs, int raceID, MockOutput mockOutput) { - this.startingBoats = FXCollections.observableArrayList(boats); - this.legs = legs; + public Race(RaceDataSource raceData, MockOutput mockOutput) { + this.startingBoats = FXCollections.observableArrayList(raceData.getBoats()); + this.legs = raceData.getLegs(); this.legs.add(new Leg("Finish", this.legs.size())); - this.raceId = raceID; + this.raceId = raceData.getRaceId(); this.mockOutput = mockOutput; - - this.startTime = System.currentTimeMillis() + (this.PRERACE_TIME / this.scaleFactor); - } - - public Race(RaceDataSource raceData, MockOutput mockOutput) { - this(raceData.getBoats(), raceData.getLegs(), raceData.getRaceId(), mockOutput); - } - - /** - * Calculates the boats next GPS position based on its distance travelled and heading - * - * @param oldCoordinates GPS coordinates of the boat's starting position - * @param distanceTravelled distance in nautical miles - * @param azimuth boat's current direction. Value between -180 and 180 - * @return The boat's new coordinate - */ - public static GPSCoordinate calculatePosition(GPSCoordinate oldCoordinates, double distanceTravelled, double azimuth) { - - //Find new coordinate using current heading and distance - GeodeticCalculator geodeticCalculator = new GeodeticCalculator(); - //Load start point into calculator - Point2D startPoint = new Point2D.Double(oldCoordinates.getLongitude(), oldCoordinates.getLatitude()); - geodeticCalculator.setStartingGeographicPoint(startPoint); - //load direction and distance tranvelled into calculator - geodeticCalculator.setDirection(azimuth, distanceTravelled * Constants.NMToMetersConversion); - //get new point - Point2D endPoint = geodeticCalculator.getDestinationGeographicPoint(); - - return new GPSCoordinate(endPoint.getY(), endPoint.getX()); + this.startTime = System.currentTimeMillis() + (Constants.PRE_RACE_WAIT_TIME / this.scaleFactor); } /** @@ -91,123 +47,94 @@ public class Race implements Runnable { */ public void run() { initialiseBoats(); - countdownTimer(); + countdownTimer.start(); } /** - * Starts the heartbeat timer, which sends a heartbeat message every so often (i.e., 5 seconds). - */ - /** - * Countdown timer until race starts. Use PRERACE_TIME to set countdown duration. + * Countdown timer until race starts. */ - protected void countdownTimer() { - AnimationTimer timer = new AnimationTimer() { - long currentTime = System.currentTimeMillis(); - long timeLeft; - - @Override - public void handle(long arg0) { - timeLeft = startTime - currentTime; - ArrayList boatStatuses = new ArrayList<>(); - //For each boat, we update its position, and generate a BoatLocationMessage. - for (int i = 0; i < startingBoats.size(); i++) { - Boat boat = startingBoats.get((i + boatOffset) % startingBoats.size()); - mockOutput.parseBoatLocation(boat.getSourceID(), boat.getCurrentPosition().getLatitude(), boat.getCurrentPosition().getLongitude(), boat.getHeading(), 0); - boatStatuses.add(new BoatStatus(boat.getSourceID(), BoatStatusEnum.PRESTART, boat.getCurrentLeg().getLegNumber())); - } - boatOffset = (boatOffset + 1) % (startingBoats.size()); - if (timeLeft <= 60000/scaleFactor && timeLeft > 0) { - RaceStatus raceStatus = new RaceStatus(System.currentTimeMillis(), raceId, 2, startTime, 0, 2300, 1, boatStatuses); - mockOutput.parseRaceStatus(raceStatus); - } - else if (timeLeft <= 0) { - countdownFinish = true; - if (runRace) { - simulateRace(); - } - stop(); - } - else { - RaceStatus raceStatus = new RaceStatus(System.currentTimeMillis(), raceId, 1, startTime, 0, 2300,1, boatStatuses); - mockOutput.parseRaceStatus(raceStatus); - } - currentTime = System.currentTimeMillis(); + private AnimationTimer countdownTimer = new AnimationTimer() { + long currentTime = System.currentTimeMillis(); + long timeLeft; + @Override + public void handle(long arg0) { + timeLeft = startTime - currentTime; + if (timeLeft <= 0) { + System.setProperty("javafx.animation.fullspeed", "true"); + raceTimer.start(); + stop(); } - }; - timer.start(); - } - /** - * Starts the Race Simulation, playing the race start to finish with the timescale. - * This prints the boats participating, the order that the events occur in time order, and the respective information of the events. - */ - private void simulateRace() { + ArrayList boatStatuses = new ArrayList<>(); + for (Boat boat : startingBoats) { + mockOutput.parseBoatLocation(boat.getSourceID(), boat.getCurrentPosition().getLatitude(), + boat.getCurrentPosition().getLongitude(), boat.getHeading(), 0); + boatStatuses.add(new BoatStatus(boat.getSourceID(), BoatStatusEnum.PRESTART, 0)); + } - System.setProperty("javafx.animation.fullspeed", "true"); + int raceStatusNumber = timeLeft <= 60000 / scaleFactor && timeLeft > 0? 2 : 1; + RaceStatus raceStatus = new RaceStatus(System.currentTimeMillis(), raceId, raceStatusNumber, startTime, 0, 2300, 1, boatStatuses); + mockOutput.parseRaceStatus(raceStatus); - for (Boat boat : startingBoats) { - boat.setStarted(true); + currentTime = System.currentTimeMillis(); } + }; - new AnimationTimer() { - //Start time of loop. - long timeRaceStarted = System.currentTimeMillis(); - - @Override - public void handle(long arg0) { - if (boatsFinished < startingBoats.size()) { - //Get the current time. - long currentTime = System.currentTimeMillis(); - //Update the total elapsed time. - totalTimeElapsed = currentTime - timeRaceStarted; - ArrayList boatStatuses = new ArrayList<>(); - finished = 0; - //For each boat, we update it's position, and generate a BoatLocationMessage. - for (int i = 0; i < startingBoats.size(); i++) { - Boat boat = startingBoats.get((i + boatOffset) % startingBoats.size()); - if (boat != null) { - //Update position. - if (boat.getTimeFinished() < 0) { - updatePosition(boat, Math.round(1000 / lastFPS) > 20 ? 15 : Math.round(1000 / lastFPS)); - checkPosition(boat, totalTimeElapsed); - } - if (boat.getTimeFinished() > 0) { - mockOutput.parseBoatLocation(boat.getSourceID(), boat.getCurrentPosition().getLatitude(), boat.getCurrentPosition().getLongitude(), boat.getHeading(), boat.getVelocity()); - boatStatuses.add(new BoatStatus(boat.getSourceID(), BoatStatusEnum.FINISHED, boat.getCurrentLeg().getLegNumber())); - finished++; - } else { - mockOutput.parseBoatLocation(boat.getSourceID(), boat.getCurrentPosition().getLatitude(), boat.getCurrentPosition().getLongitude(), boat.getHeading(), boat.getVelocity()); - boatStatuses.add(new BoatStatus(boat.getSourceID(), - boat.getCurrentLeg().getLegNumber() >= 0 ? BoatStatusEnum.RACING : BoatStatusEnum.DNF, boat.getCurrentLeg().getLegNumber())); - } - if (startingBoats.size()==finished){ - RaceStatus raceStatus = new RaceStatus(System.currentTimeMillis(), raceId, 4, startTime, 0, 2300, 2, boatStatuses); - mockOutput.parseRaceStatus(raceStatus); - } + private AnimationTimer raceTimer = new AnimationTimer() { + //Start time of loop. + long timeRaceStarted = System.currentTimeMillis(); + int boatOffset = 0; + + @Override + public void handle(long arg0) { + if (boatsFinished < startingBoats.size()) { + //Get the current time. + long currentTime = System.currentTimeMillis(); + //Update the total elapsed time. + totalTimeElapsed = currentTime - timeRaceStarted; + ArrayList boatStatuses = new ArrayList<>(); + //For each boat, we update its position, and generate a BoatLocationMessage. + for (int i = 0; i < startingBoats.size(); i++) { + Boat boat = startingBoats.get((i + boatOffset) % startingBoats.size()); + if (boat != null) { + //Update position. + if (boat.getTimeFinished() < 0) { + updatePosition(boat, 15); + checkPosition(boat, totalTimeElapsed); + } + if (boat.getTimeFinished() > 0) { + mockOutput.parseBoatLocation(boat.getSourceID(), boat.getCurrentPosition().getLatitude(), boat.getCurrentPosition().getLongitude(), boat.getHeading(), boat.getVelocity()); + boatStatuses.add(new BoatStatus(boat.getSourceID(), BoatStatusEnum.FINISHED, boat.getCurrentLeg().getLegNumber())); } else { - stop(); + mockOutput.parseBoatLocation(boat.getSourceID(), boat.getCurrentPosition().getLatitude(), boat.getCurrentPosition().getLongitude(), boat.getHeading(), boat.getVelocity()); + boatStatuses.add(new BoatStatus(boat.getSourceID(), + boat.getCurrentLeg().getLegNumber() >= 0 ? BoatStatusEnum.RACING : BoatStatusEnum.DNF, boat.getCurrentLeg().getLegNumber())); } + } else { + stop(); } - boatOffset = (boatOffset + 1) % (startingBoats.size()); - RaceStatus raceStatus = new RaceStatus(System.currentTimeMillis(), raceId, 3, startTime, 0, 2300, 2, boatStatuses); - mockOutput.parseRaceStatus(raceStatus); } + boatOffset = (boatOffset + 1) % (startingBoats.size()); + RaceStatus raceStatus = new RaceStatus(System.currentTimeMillis(), raceId, 3, startTime, 0, 2300, 2, boatStatuses); + mockOutput.parseRaceStatus(raceStatus); } - }.start(); - } + } + }; + public void initialiseBoats() { Leg officialStart = legs.get(0); String name = officialStart.getName(); Marker endMark = officialStart.getEndCompoundMark(); - ArrayList startingPositions = getSpreadStartingPositions(); + for (int i = 0; i < startingBoats.size(); i++) { Boat boat = startingBoats.get(i); if (boat != null) { Leg newLeg = new Leg(name, new Marker(startingPositions.get(i)), endMark, 0); boat.setCurrentLeg(newLeg); + boat.setVelocity(Constants.TEST_VELOCITIES[i]); boat.setScaledVelocity(boat.getVelocity() * scaleFactor); boat.setCurrentPosition(startingPositions.get(i)); boat.setHeading(boat.calculateHeading()); @@ -249,19 +176,26 @@ public class Race implements Runnable { } /** - * Sets the chance each boat has of failing at a gate or marker + * Calculates the boats next GPS position based on its distance travelled and heading * - * @param chance percentage chance a boat has of failing per checkpoint. + * @param oldCoordinates GPS coordinates of the boat's starting position + * @param distanceTravelled distance in nautical miles + * @param azimuth boat's current direction. Value between -180 and 180 + * @return The boat's new coordinate */ - protected void setDnfChance(int chance) { - if (chance >= 0 && chance <= 100) { - dnfChance = chance; - } - } + public static GPSCoordinate calculatePosition(GPSCoordinate oldCoordinates, double distanceTravelled, double azimuth) { - protected boolean doNotFinish() { - Random rand = new Random(); - return rand.nextInt(100) < dnfChance; + //Find new coordinate using current heading and distance + GeodeticCalculator geodeticCalculator = new GeodeticCalculator(); + //Load start point into calculator + Point2D startPoint = new Point2D.Double(oldCoordinates.getLongitude(), oldCoordinates.getLatitude()); + geodeticCalculator.setStartingGeographicPoint(startPoint); + //load direction and distance travelled into calculator + geodeticCalculator.setDirection(azimuth, distanceTravelled * Constants.NMToMetersConversion); + //get new point + Point2D endPoint = geodeticCalculator.getDestinationGeographicPoint(); + + return new GPSCoordinate(endPoint.getY(), endPoint.getX()); } /** @@ -316,13 +250,19 @@ public class Race implements Runnable { } /** - * Returns the boats that have started the race. + * Sets the chance each boat has of failing at a gate or marker * - * @return ObservableList of Boat class that participated in the race. - * @see ObservableList - * @see Boat + * @param chance percentage chance a boat has of failing per checkpoint. */ - public ObservableList getStartingBoats() { - return startingBoats; + protected void setDnfChance(int chance) { + if (chance >= 0 && chance <= 100) { + dnfChance = chance; + } } + + protected boolean doNotFinish() { + Random rand = new Random(); + return rand.nextInt(100) < dnfChance; + } + } diff --git a/mock/src/main/java/seng302/Model/Regatta.java b/mock/src/main/java/seng302/Model/Regatta.java deleted file mode 100644 index 0060f2c4..00000000 --- a/mock/src/main/java/seng302/Model/Regatta.java +++ /dev/null @@ -1,99 +0,0 @@ -package seng302.Model; - -/** - * Created by jjg64 on 19/04/17. - */ -public class Regatta { - int regattaID; - String RegattaName; - int raceID = 0; - String courseName; - double centralLatitude; - double centralLongitude; - double centralAltitude; - float utcOffset; - float magneticVariation; - - public Regatta(int regattaID, String regattaName, String courseName, double centralLatitude, double centralLongitude, double centralAltitude, float utcOffset, float magneticVariation) { - this.regattaID = regattaID; - this.RegattaName = regattaName; - this.courseName = courseName; - this.centralLatitude = centralLatitude; - this.centralLongitude = centralLongitude; - this.centralAltitude = centralAltitude; - this.utcOffset = utcOffset; - this.magneticVariation = magneticVariation; - } - - public int getRegattaID() { - return regattaID; - } - - public void setRegattaID(int ID) { - this.regattaID = ID; - } - - public String getRegattaName() { - return RegattaName; - } - - public void setRegattaName(String regattaName) { - RegattaName = regattaName; - } - - public int getRaceID() { - return raceID; - } - - public void setRaceID(int raceID) { - this.raceID = raceID; - } - - public String getCourseName() { - return courseName; - } - - public void setCourseName(String courseName) { - this.courseName = courseName; - } - - public double getCentralLatitude() { - return centralLatitude; - } - - public void setCentralLatitude(double centralLatitude) { - this.centralLatitude = centralLatitude; - } - - public double getCentralLongitude() { - return centralLongitude; - } - - public void setCentralLongitude(double centralLongitude) { - this.centralLongitude = centralLongitude; - } - - public double getCentralAltitude() { - return centralAltitude; - } - - public void setCentralAltitude(double centralAltitude) { - this.centralAltitude = centralAltitude; - } - - public float getUtcOffset() { - return utcOffset; - } - - public void setUtcOffset(float utcOffset) { - this.utcOffset = utcOffset; - } - - public float getMagneticVariation() { - return magneticVariation; - } - - public void setMagneticVariation(float magneticVariation) { - this.magneticVariation = magneticVariation; - } -} diff --git a/mock/src/main/resources/mockXML/raceTest.xml b/mock/src/main/resources/mockXML/raceTest.xml index 85ff00eb..63fac32d 100644 --- a/mock/src/main/resources/mockXML/raceTest.xml +++ b/mock/src/main/resources/mockXML/raceTest.xml @@ -15,9 +15,9 @@ - - - + + + diff --git a/mock/src/main/resources/raceXML/bermuda_AC35.xml b/mock/src/main/resources/raceXML/bermuda_AC35.xml deleted file mode 100644 index 7a73fc7f..00000000 --- a/mock/src/main/resources/raceXML/bermuda_AC35.xml +++ /dev/null @@ -1,286 +0,0 @@ - - 5326 - - - Team ORACLE USA - 20 - USA - 121 - BLUEVIOLET - - - Land Rover BAR - 30 - GBR - 122 - BLACK - - - SoftBank Team Japan - 25 - JPN - 123 - RED - - - Groupama Team France - 20 - FRA - 124 - ORANGE - - - Artemis Racing - 29 - SWE - 125 - DARKOLIVEGREEN - - - Emirates Team New Zealand - 62 - NZL - 126 - LIMEGREEN - - - - - Start to Mark 1 - - - - 32.296577 - -64.854304 - - - 32.293771 - -64.855242 - - - - - - - 32.293039 - -64.843983 - - - - - - Mark 1 to Leeward Gate - - - - 32.293039 - -64.843983 - - - - - - - 32.309693 - -64.835249 - - - 32.308046 - -64.831785 - - - - - - Leeward Gate to Windward Gate - - - - 32.309693 - -64.835249 - - - 32.308046 - -64.831785 - - - - - - - 32.284680 - -64.850045 - - - 32.280164 - -64.847591 - - - - - - Windward Gate to Leeward Gate - - - - 32.284680 - -64.850045 - - - 32.280164 - -64.847591 - - - - - - - 32.309693 - -64.835249 - - - 32.308046 - -64.831785 - - - - - - Leeward Gate to Finish - - - - 32.309693 - -64.835249 - - - 32.308046 - -64.831785 - - - - - - - 32.317379 - -64.839291 - - - 32.317257 - -64.836260 - - - - - - - - - 32.313922 - -64.837168 - - - 32.317379 - -64.839291 - - - 32.317911 - -64.836996 - - - 32.317257 - -64.836260 - - - 32.304273 - -64.822834 - - - 32.279097 - -64.841545 - - - 32.279604 - -64.849871 - - - 32.289545 - -64.854162 - - - 32.290198 - -64.858711 - - - 32.297164 - -64.856394 - - - 32.296148 - -64.849184 - - - - Start Line - - 32.296577 - -64.854304 - - - 32.293771 - -64.855242 - - - - Mark - - 32.293039 - -64.843983 - - - - Windward Gate - - 32.284680 - -64.850045 - - - 32.280164 - -64.847591 - - - - Leeward Gate - - 32.309693 - -64.835249 - - - 32.308046 - -64.831785 - - - - Windward Gate - - 32.284680 - -64.850045 - - - 32.280164 - -64.847591 - - - - Finish Line - - 32.317379 - -64.839291 - - - 32.317257 - -64.836260 - - - - diff --git a/mock/src/test/java/seng302/DataInput/RegattaXMLTest.java b/mock/src/test/java/seng302/DataInput/RegattaXMLTest.java deleted file mode 100644 index 44b7f1c5..00000000 --- a/mock/src/test/java/seng302/DataInput/RegattaXMLTest.java +++ /dev/null @@ -1,51 +0,0 @@ -package seng302.DataInput; - -import org.junit.Before; -import org.junit.Test; -import seng302.Model.Regatta; - -import static org.junit.Assert.*; - -/** - * Created by jjg64 on 19/04/17. - */ -public class RegattaXMLTest { - RegattaXMLReader regattaXMLReader; - - @Before - public void findFile() { - try { - regattaXMLReader = new RegattaXMLReader("mockXML/regattaTest.xml", false); - } catch (Exception e) { - fail("Cannot find mockXML/regattaXML/regattaTest.xml in the resources folder"); - } - } - - @Test - public void makeRegattaTest() { - try { - regattaXMLReader = new RegattaXMLReader("mockXML/regattaTest.xml"); - assertNotEquals(regattaXMLReader.getRegatta(), null); - } catch (Exception e) { - fail("Did not make a Regatta object"); - } - } - - @Test - public void correctValuesTest() { - try { - regattaXMLReader = new RegattaXMLReader("mockXML/regattaTest.xml"); - Regatta regatta = regattaXMLReader.getRegatta(); - assertEquals(regatta.getRegattaID(), 3); - assertEquals(regatta.getRegattaName(), "New Zealand Test"); - assertEquals(regatta.getCourseName(), "North Head"); - assertEquals(regatta.getCentralLatitude(), -36.82791529, 0.00000001); - assertEquals(regatta.getCentralLongitude(), 174.81218919, 0.00000001); - assertEquals(regatta.getCentralAltitude(), 0.00, 0.00000001); - assertEquals(regatta.getUtcOffset(), 12.0, 0.001); - assertEquals(regatta.getMagneticVariation(), 14.1, 0.001); - } catch (Exception e) { - fail("Did not have the correct values"); - } - } -}