mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 06:18:44 +00:00
Merge branch 'develop' of https://eng-git.canterbury.ac.nz/seng302-2017/team-13 into develop
# Conflicts: # src/test/java/seng302/models/BoatGroupTest.java
This commit is contained in:
@@ -1,35 +1,35 @@
|
||||
package seng302;
|
||||
|
||||
import org.junit.Test;
|
||||
import seng302.models.Boat;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Unit test for the Team class.
|
||||
*/
|
||||
public class BoatTest {
|
||||
|
||||
@Test
|
||||
public void testBoatCreation() {
|
||||
Boat boat1 = new Boat("Team 1");
|
||||
assertEquals(boat1.getTeamName(), "Team 1");
|
||||
assertEquals(boat1.getVelocity(), (double) 10.0, 1e-15);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testChangeTeamName() {
|
||||
Boat boat1 = new Boat("Team 1");
|
||||
boat1.setTeamName("Team 2");
|
||||
assertEquals(boat1.getTeamName(), "Team 2");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetVelocity() {
|
||||
Boat boat1 = new Boat("Team 1", 29.0, "", 100);
|
||||
assertEquals(boat1.getVelocity(), (double) 29.0, 1e-15);
|
||||
|
||||
boat1.setVelocity(12.0);
|
||||
assertEquals(boat1.getVelocity(), (double)12.0, 1e-15);
|
||||
}
|
||||
}
|
||||
//package seng302;
|
||||
//
|
||||
//import org.junit.Test;
|
||||
//import seng302.models.Boat;
|
||||
//
|
||||
//import static org.junit.Assert.assertEquals;
|
||||
//
|
||||
///**
|
||||
// * Unit test for the Team class.
|
||||
// */
|
||||
//public class BoatTest {
|
||||
//
|
||||
// @Test
|
||||
// public void testBoatCreation() {
|
||||
// Boat boat1 = new Boat("Team 1");
|
||||
// assertEquals(boat1.getTeamName(), "Team 1");
|
||||
// assertEquals(boat1.getVelocity(), (double) 10.0, 1e-15);
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void testChangeTeamName() {
|
||||
// Boat boat1 = new Boat("Team 1");
|
||||
// boat1.setTeamName("Team 2");
|
||||
// assertEquals(boat1.getTeamName(), "Team 2");
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void testSetVelocity() {
|
||||
// Boat boat1 = new Boat("Team 1", 29.0, "", 100);
|
||||
// assertEquals(boat1.getVelocity(), (double) 29.0, 1e-15);
|
||||
//
|
||||
// boat1.setVelocity(12.0);
|
||||
// assertEquals(boat1.getVelocity(), (double)12.0, 1e-15);
|
||||
// }
|
||||
//}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package seng302;
|
||||
|
||||
import org.junit.Test;
|
||||
import seng302.models.Boat;
|
||||
import seng302.models.Event;
|
||||
import seng302.models.Yacht;
|
||||
import seng302.models.mark.SingleMark;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
@@ -15,14 +15,14 @@ public class EventTest {
|
||||
|
||||
@Test
|
||||
public void getTimeString() throws Exception {
|
||||
Boat boat = new Boat("testBoat");
|
||||
Yacht boat = new Yacht("testBoat");
|
||||
Event event = new Event(1231242.2, boat, new SingleMark("mark1"), new SingleMark("mark2"), 0);
|
||||
assertEquals("20:31:242", event.getTimeString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBoatHeading() throws Exception {
|
||||
Boat boat = new Boat("testBoat");
|
||||
Yacht boat = new Yacht("testBoat");
|
||||
Event event = new Event(1231242.2, boat, new SingleMark("mark1", 142.5, 122.1, 1), new SingleMark("mark2", 121.9,99.2, 2), 0);
|
||||
|
||||
assertEquals(event.getBoatHeading(), 228.0266137055349, 1e-15);
|
||||
@@ -30,7 +30,7 @@ public class EventTest {
|
||||
|
||||
@Test
|
||||
public void testDistanceBetweenMarks() throws Exception {
|
||||
Boat boat = new Boat("testBoat");
|
||||
Yacht boat = new Yacht("testBoat");
|
||||
Event event = new Event(1231242.2, boat, new SingleMark("mark1", 142.5, 122.1, 1), new SingleMark("mark2", 121.9,99.2, 2), 0);
|
||||
|
||||
assertEquals(event.getDistanceBetweenMarks(), 339059.653830461, 1e-15);
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package seng302;
|
||||
|
||||
import org.junit.Test;
|
||||
import seng302.models.Boat;
|
||||
import seng302.models.Race;
|
||||
import seng302.models.Yacht;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
|
||||
@@ -17,8 +17,8 @@ public class RaceTest {
|
||||
*/
|
||||
@Test
|
||||
public void testAddingBoatsToRace() {
|
||||
Boat boat1 = new Boat("Team 1");
|
||||
Boat boat2 = new Boat("Team 2");
|
||||
Yacht boat1 = new Yacht("Team 1");
|
||||
Yacht boat2 = new Yacht("Team 2");
|
||||
|
||||
Race race = new Race();
|
||||
race.addBoat(boat1);
|
||||
@@ -29,8 +29,8 @@ public class RaceTest {
|
||||
|
||||
@Test
|
||||
public void testGetShuffledBoats(){
|
||||
Boat boat1 = new Boat("Team 1");
|
||||
Boat boat2 = new Boat("Team 2");
|
||||
Yacht boat1 = new Yacht("Team 1");
|
||||
Yacht boat2 = new Yacht("Team 2");
|
||||
|
||||
Race race = new Race();
|
||||
race.addBoat(boat1);
|
||||
|
||||
@@ -1,100 +1,98 @@
|
||||
// TODO: 4/05/17 cir27 - Find out why this test is causing build failures
|
||||
package seng302.models;
|
||||
import seng302.*;
|
||||
import javafx.scene.paint.*;
|
||||
import javafx.scene.paint.Color;
|
||||
import javafx.scene.shape.Polygon;
|
||||
import javafx.scene.transform.Rotate;
|
||||
import javafx.scene.transform.Transform;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
//package seng302.models;
|
||||
//import seng302.*;
|
||||
//import javafx.scene.paint.*;
|
||||
//import javafx.scene.paint.Color;
|
||||
//import javafx.scene.shape.Polygon;
|
||||
//import javafx.scene.transform.Rotate;
|
||||
//import javafx.scene.transform.Transform;
|
||||
//import org.junit.Assert;
|
||||
//import org.junit.Before;
|
||||
//import org.junit.Test;
|
||||
//
|
||||
///**
|
||||
// * Created by cir27 on 4/05/17.
|
||||
// */
|
||||
//public class BoatGroupTest {
|
||||
// BoatGroup boatGroup;
|
||||
// @Before
|
||||
// public void setUp () {
|
||||
// Boat b = new Boat("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());
|
||||
// }
|
||||
//}
|
||||
/**
|
||||
* Created by cir27 on 4/05/17.
|
||||
*/
|
||||
public class BoatGroupTest {
|
||||
BoatGroup boatGroup;
|
||||
@Before
|
||||
public void setUp () {
|
||||
Boat b = new Boat("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,35 +1,36 @@
|
||||
package seng302.models.parsers;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import seng302.models.Boat;
|
||||
|
||||
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<Boat> boats = tp.getBoats();
|
||||
|
||||
assertEquals(6, boats.size(), 1e-10);
|
||||
|
||||
assertEquals("Oracle Team USA", boats.get(0).getTeamName());
|
||||
//assertEquals(30.9, boats.get(0).getVelocity(), 1e-10);
|
||||
|
||||
assertEquals("Groupama Team France", boats.get(5).getTeamName());
|
||||
//assertEquals(45.6, boats.get(5).getVelocity(), 1e-10);
|
||||
}
|
||||
|
||||
}
|
||||
//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);
|
||||
// }
|
||||
//
|
||||
//}
|
||||
Reference in New Issue
Block a user