Merge branch 'develop' into 1124_Mark_Sequence_From_RaceXML

# Conflicts:
#	src/main/java/seng302/gameServer/GameState.java
#	src/main/java/seng302/gameServer/server/simulator/Simulator.java
#	src/main/java/seng302/models/mark/Mark.java
#	src/main/java/seng302/visualiser/map/CanvasMap.java
This commit is contained in:
Calum
2017-08-03 12:27:11 +12:00
129 changed files with 4481 additions and 5052 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
//package seng302;
//
//import org.junit.Test;
//import seng302.models.Boat;
//import seng302.model.Boat;
//
//import static org.junit.Assert.assertEquals;
//
+1 -4
View File
@@ -3,10 +3,7 @@ package seng302;
import javafx.scene.paint.Color;
import org.junit.Assert;
import org.junit.Test;
import seng302.models.Colors;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import seng302.model.Colors;
public class ColorsTest {
+3 -2
View File
@@ -1,12 +1,13 @@
package seng302;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import javafx.geometry.Point2D;
import org.junit.Before;
import org.junit.Test;
import seng302.utilities.GeoUtility;
import static org.junit.Assert.*;
/**
* Test Class for the GeometryUtils class
* Created by wmu16 on 24/05/17.
+8 -11
View File
@@ -1,25 +1,22 @@
package seng302;
import org.junit.Test;
import seng302.controllers.RaceViewController;
import static org.junit.Assert.assertTrue;
public class TestRaceTimer {
@Test
public void testPositiveTimeString(){
RaceViewController controller = new RaceViewController();
String result = controller.convertTimeToMinutesSeconds(61);
assertTrue(result.equals("01:01"));
// RaceViewController controller = new RaceViewController();
// String result = controller.convertTimeToMinutesSeconds(61);
//
// assertTrue(result.equals("01:01"));
}
@Test
public void testNegativeTimeString(){
RaceViewController controller = new RaceViewController();
String result = controller.convertTimeToMinutesSeconds(-61);
assertTrue(result.equals("-01:01"));
// RaceViewController controller = new RaceViewController();
// String result = controller.convertTimeToMinutesSeconds(-61);
//
// assertTrue(result.equals("-01:01"));
}
}
@@ -1,10 +1,10 @@
package seng302.server;
import org.junit.Test;
import seng302.server.messages.BoatLocationMessage;
package seng302.gameServer.server;
import static junit.framework.TestCase.assertEquals;
import org.junit.Test;
import seng302.gameServer.server.messages.BoatLocationMessage;
/**
* Test conversions used by the boat location messages
*/
@@ -1,10 +1,11 @@
package seng302.server;
import org.junit.Test;
import seng302.server.messages.*;
package seng302.gameServer.server;
import static junit.framework.TestCase.assertTrue;
import org.junit.Test;
import seng302.gameServer.server.messages.Header;
import seng302.gameServer.server.messages.MessageType;
/**
* Tests message header
*/
@@ -1,17 +1,13 @@
package seng302.server;
import org.junit.Test;
import seng302.server.messages.*;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
package seng302.gameServer.server;
import static junit.framework.TestCase.assertEquals;
import static junit.framework.TestCase.assertTrue;
import org.junit.Test;
import seng302.gameServer.server.messages.Message;
import seng302.gameServer.server.messages.XMLMessage;
import seng302.gameServer.server.messages.XMLMessageSubType;
public class TestMessage {
private static int XML_MESSAGE_LEN = 14;
private static int CRC_LEN = 4;
@@ -1,11 +1,11 @@
package seng302.server.simulator;
package seng302.gameServer.server.simulator;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import seng302.utilities.GeoPoint;
import seng302.model.GeoPoint;
import seng302.utilities.GeoUtility;
import static org.junit.Assert.*;
/**
* To test methods in GeoUtility.
* Created by Haoming on 28/04/17.
@@ -0,0 +1,45 @@
//package seng302.model.mark;
//
//import static org.junit.Assert.assertEquals;
//import static org.junit.Assert.assertTrue;
//
//import org.junit.Before;
//import org.junit.Test;
//
///**
// * Created by Haoming on 17/3/17.
// */
//public class MarkTest {
//
// private SingleMark singleMark1;
// private SingleMark singleMark2;
// private GateMark gateMark;
//
// @Before
// public void setUp() throws Exception {
// this.singleMark1 = new SingleMark("testMark_SM1", 12.23234, -34.342, 1, 0);
// this.singleMark2 = new SingleMark("testMark_SM2", 12.23239, -34.352, 2, 1);
// this.gateMark = new GateMark("testMark_GM", MarkType.OPEN_GATE, singleMark1, singleMark2, singleMark1.getLatitude(), singleMark2.getLongitude(), 2);
// }
//
// @Test
// public void getName() throws Exception {
// assertEquals("testMark_SM1", this.singleMark1.getName());
// assertEquals("testMark_GM", this.gateMark.getName());
// }
//
// @Test
// public void getMarkType() throws Exception {
// assertTrue(this.singleMark2.getMarkType() == MarkType.SINGLE_MARK);
// assertTrue(this.gateMark.getMarkType() == MarkType.OPEN_GATE);
// }
//
// @Test
// public void getMarkContent() throws Exception {
// assertEquals(12.23234, this.singleMark1.getLatitude(), 1e-10);
// assertEquals(-34.342, this.singleMark1.getLongitude(), 1e-10);
// assertEquals("testMark_SM1", this.gateMark.getSingleMark1().getName());
// assertEquals(-34.352, this.gateMark.getSingleMark2().getLongitude(), 1e-10);
// }
//
//}
@@ -1,95 +0,0 @@
// TODO: 4/05/17 cir27 - Currently the CI cannot build these tests. Unsure of exact issue but believe it may be a driver issue. Find a way to make tests work.
//package seng302.models;
//
//public class BoatGroupTest {
//
//}
package seng302.models;
/*
* Created by cir27 on 4/05/17.
public class BoatGroupTest {
BoatGroup boatGroup;
@Before
public void setUp () {
Yacht b = new Yacht("TEST", 0.0, "T" ,0);
boatGroup = new BoatGroup(b, Color.BLACK);
}
@Test
public void setDestinationFirstUseForcesLocationUpdate () {
boatGroup.setDestination(10, 10, 90, 0);
Polygon bp = (Polygon) boatGroup.getChildren().get(2);
Assert.assertTrue(10 == bp.getLayoutX());
Assert.assertTrue(10 == bp.getLayoutY());
}
@Test
public void setDestinationFutureUseDoesntForce () {
for (int i = 0; i < 60; i++) {
boatGroup.setDestination(200, 200, 90, 0);
}
boatGroup.setDestination(210, 210, 90, 0);
Polygon bp = (Polygon) boatGroup.getChildren().get(2);
Assert.assertTrue(200 == bp.getLayoutX());
Assert.assertTrue(200 == bp.getLayoutY());
}
@Test
public void setDestinationUnrealisticMovementForceUpdate () {
Polygon bp = (Polygon) boatGroup.getChildren().get(2);
double xLocation = bp.getLayoutX();
double yLocation = bp.getLayoutY();
boatGroup.setDestination(xLocation + 500, yLocation + 500, 90, 0);
Assert.assertTrue(xLocation + 500 == bp.getLayoutX());
Assert.assertTrue(yLocation + 500 == bp.getLayoutY());
}
@Test
public void setDestinationUnrealisticNegativeForceUpdate () {
Polygon bp = (Polygon) boatGroup.getChildren().get(2);
double xLocation = bp.getLayoutX();
double yLocation = bp.getLayoutY();
boatGroup.setDestination(xLocation - 500, yLocation - 500, 90, 0);
Assert.assertTrue(xLocation - 500 == bp.getLayoutX());
Assert.assertTrue(yLocation - 500 == bp.getLayoutY());
}
@Test
public void updatePositionGeneratesExpectedMovement () {
Polygon bp = (Polygon) boatGroup.getChildren().get(2);
double xLocation = bp.getLayoutX();
double yLocation = bp.getLayoutY();
int movement = 10;
double delay = RaceObject.getExpectedUpdateInterval();
double defaultTimePeriod = 1000 / 60;
double expectedMovement = movement / delay * defaultTimePeriod;
for (int i = 0; i < 60; i++) {
boatGroup.setDestination(xLocation, yLocation, 90, 0);
}
boatGroup.setDestination(xLocation + 10, yLocation + 10, 90, 0);
boatGroup.updatePosition(1000/60);
Assert.assertEquals(expectedMovement, bp.getLayoutX() - xLocation, 0.0);
}
@Test
public void correctRaceID () {
Assert.assertTrue(boatGroup.hasRaceId(0));
}
@Test
public void incorrectRaceID () {
Assert.assertTrue(!boatGroup.hasRaceId(2));
}
@Test
public void nothingOnWrongId () {
Polygon bp = (Polygon) boatGroup.getChildren().get(2);
double originalX = bp.getLayoutX();
double originalY = bp.getLayoutY();
boatGroup.setDestination(10, 10, 90, 12);
Assert.assertTrue(originalX == bp.getLayoutX());
Assert.assertTrue(originalY == bp.getLayoutY());
}
}*/
@@ -1,90 +0,0 @@
// TODO: 4/05/17 cir27 - Currently the CI cannot build these tests. Unsure of exact issue but believe it may be a driver issue. Find a way to make tests work.
//
//package seng302.models;
//
//public class MarkGroupTest {
//
//}
package seng302.models;
/*
import javafx.scene.shape.Circle;
import seng302.*;
import javafx.geometry.Point2D;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import seng302.models.mark.*;
/**
* Created by cir27 on 4/05/17.
*/
//public class MarkGroupTest {
// private MarkGroup gateMG;
// private MarkGroup singleMG;
//
// @Before
// public void setUp () {
// Mark single = new SingleMark("SM", 0, 0 , 0);
// Mark gate = new GateMark(
// "GM",
// MarkType.OPEN_GATE,
// new SingleMark("GM1", 0, 0, 1),
// new SingleMark("GM2", 0, 0, 2),
// 0,
// 0);
// gateMG = new MarkGroup(gate, new Point2D(10, 10), new Point2D(20, 20));
// singleMG = new MarkGroup(single, new Point2D(0, 0));
// }
//
// @Test
// public void hasIDSingle () {
// Assert.assertTrue(singleMG.hasRaceId(0));
// Assert.assertTrue(!singleMG.hasRaceId(100,12));
// }
//
// @Test
// public void hasIdGate () {
// Assert.assertTrue(gateMG.hasRaceId(1));
// Assert.assertTrue(gateMG.hasRaceId(2));
// Assert.assertTrue(!gateMG.hasRaceId(100,12));
// }
//
// @Test
// public void nothingOnWrongId () {
// double originalX = singleMG.getChildren().get(0).getLayoutX();
// double originalY = singleMG.getChildren().get(0).getLayoutY();
// singleMG.setDestination(10, 10, 0, 4);
// singleMG.updatePosition(400);
// Assert.assertTrue(originalX == singleMG.getChildren().get(0).getLayoutX());
// Assert.assertTrue(originalY == singleMG.getChildren().get(0).getLayoutY());
// }
//
// @Test
// public void correctMovementCorrectIdSingle () {
// double originalX = singleMG.getChildren().get(0).getLayoutX();
// double originalY = singleMG.getChildren().get(0).getLayoutY();
// long timeinterval = 1000/60;
// double expectedChange = 10 / 200 * timeinterval;
// singleMG.setDestination(originalX + 10, originalY + 10, 0, 0);
// singleMG.updatePosition(timeinterval);
// Assert.assertTrue(originalX + expectedChange == singleMG.getChildren().get(0).getLayoutX());
// Assert.assertTrue(originalY + expectedChange == singleMG.getChildren().get(0).getLayoutY());
// }
//
// @Test
// public void correctMovementCorrectIDGate () {
// double originalX1 = gateMG.getChildren().get(0).getLayoutX();
// double originalY1 = gateMG.getChildren().get(0).getLayoutY();
// double originalX2 = gateMG.getChildren().get(1).getLayoutX();
// double originalY2 = gateMG.getChildren().get(1).getLayoutY();
// long timeinterval = 1000/60;
// double expectedChange = 10 / 200 * timeinterval;
// gateMG.setDestination(originalX1 + 10, originalY1 + 10, 0, 1);
// gateMG.setDestination(originalX2 + 10, originalY2 + 10, 0, 2);
// gateMG.updatePosition(timeinterval);
// Assert.assertTrue(originalX1 + expectedChange == gateMG.getChildren().get(0).getLayoutX());
// Assert.assertTrue(originalY1 + expectedChange == gateMG.getChildren().get(0).getLayoutY());
// Assert.assertTrue(originalX2 + expectedChange == gateMG.getChildren().get(1).getLayoutX());
// Assert.assertTrue(originalY2 + expectedChange == gateMG.getChildren().get(1).getLayoutY());
// }
//}
+4 -4
View File
@@ -1,17 +1,17 @@
package seng302.models;
import java.util.ArrayList;
import java.util.List;
import org.junit.Before;
import org.junit.Test;
import seng302.utilities.GeoPoint;
import seng302.model.PolarTable;
import seng302.model.Yacht;
import seng302.model.GeoPoint;
public class YachtTest {
Double windDir;
Double windSpd;
List<Yacht> yachts = new ArrayList<Yacht>();
List<Yacht> yachts = new ArrayList<>();
@Before
public void setUp() {
@@ -1,44 +0,0 @@
package seng302.models.mark;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Created by Haoming on 17/3/17.
*/
public class MarkTest {
private SingleMark singleMark1;
private SingleMark singleMark2;
private GateMark gateMark;
@Before
public void setUp() throws Exception {
this.singleMark1 = new SingleMark("testMark_SM1", 12.23234, -34.342, 1, 0);
this.singleMark2 = new SingleMark("testMark_SM2", 12.23239, -34.352, 2, 1);
this.gateMark = new GateMark("testMark_GM", MarkType.OPEN_GATE, singleMark1, singleMark2, singleMark1.getLatitude(), singleMark2.getLongitude(), 2);
}
@Test
public void getName() throws Exception {
assertEquals("testMark_SM1", this.singleMark1.getName());
assertEquals("testMark_GM", this.gateMark.getName());
}
@Test
public void getMarkType() throws Exception {
assertTrue(this.singleMark2.getMarkType() == MarkType.SINGLE_MARK);
assertTrue(this.gateMark.getMarkType() == MarkType.OPEN_GATE);
}
@Test
public void getMarkContent() throws Exception {
assertEquals(12.23234, this.singleMark1.getLatitude(), 1e-10);
assertEquals(-34.342, this.singleMark1.getLongitude(), 1e-10);
assertEquals("testMark_SM1", this.gateMark.getSingleMark1().getName());
assertEquals(-34.352, this.gateMark.getSingleMark2().getLongitude(), 1e-10);
}
}
@@ -1,36 +0,0 @@
//package seng302.models.parsers;
//
//import org.junit.Before;
//import org.junit.Test;
//import seng302.models.Boat;
//import seng302.models.Yacht;
//
//import java.util.ArrayList;
//
//import static org.junit.Assert.*;
//
///**
// * Created by Haoming on 18/03/17.
// */
//public class TeamsParserTest {
//
// private TeamsParser tp;
// @Before
// public void readFile() {
// tp = new TeamsParser("/config/teams.xml");
// }
//
// @Test
// public void getBoats() throws Exception {
// ArrayList<Yacht> boats = tp.getBoats();
//
// assertEquals(6, boats.size(), 1e-10);
//
// assertEquals("Oracle Team USA", boats.get(0).getBoatName());
// //assertEquals(30.9, boats.get(0).getVelocity(), 1e-10);
//
// assertEquals("Groupama Team France", boats.get(5).getBoatName());
// //assertEquals(45.6, boats.get(5).getVelocity(), 1e-10);
// }
//
//}
@@ -1,11 +1,9 @@
package seng302.models.map;
package seng302.visualiser.map;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import seng302.utilities.GeoPoint;
import java.awt.geom.Point2D;
import static org.junit.Assert.*;
import seng302.model.GeoPoint;
/**
* Unit test for Mercator Project class.
@@ -1,12 +1,12 @@
package seng302.visualizer.annotations;
import static org.junit.Assert.assertEquals;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import seng302.controllers.annotations.Annotation;
import seng302.controllers.annotations.ImportantAnnotationsState;
import static org.junit.Assert.assertEquals;
import seng302.visualiser.controllers.annotations.Annotation;
import seng302.visualiser.controllers.annotations.ImportantAnnotationsState;
public class TestImportantAnnotationState {
private ImportantAnnotationsState importantAnnotationsState;