Merge remote-tracking branch 'remotes/origin/master' into wind_(story53)

# Conflicts:
#	racevisionGame/src/main/java/mock/app/Event.java
#	racevisionGame/src/main/java/mock/model/MockRace.java
This commit is contained in:
hba56
2017-09-05 23:37:17 +12:00
73 changed files with 2721 additions and 749 deletions
@@ -3,6 +3,7 @@ package mock.model;
import org.junit.Before;
import org.junit.Test;
import shared.model.Bearing;
import shared.model.Boat;
import shared.model.GPSCoordinate;
import shared.model.Mark;
@@ -13,6 +14,13 @@ public class MockBoatTest {
private Mark near;
private Mark far;
public static MockBoat createMockBoat() {
Boat boat = new Boat(121, "Test boat", "TS");
MockBoat mockBoat = new MockBoat(boat, null);
return mockBoat;
}
@Before
public void setUp() {
boat = new MockBoat(0, "Bob", "NZ", null);
@@ -1,6 +1,7 @@
package mock.model;
import mock.exceptions.SourceIDAllocationException;
import network.Messages.Enums.RaceStatusEnum;
import org.junit.Before;
import org.junit.Test;
@@ -15,30 +16,16 @@ import static org.junit.Assert.*;
*/
public class SourceIdAllocatorTest {
/**
* This is the list of source IDs that we start with.
*/
private List<Integer> originalSourceIDs;
/**
* Used to allocate source IDs.
*/
private MockRace mockRace;
private SourceIdAllocator sourceIdAllocator;
@Before
public void setUp() throws Exception {
originalSourceIDs = new ArrayList<>();
originalSourceIDs.add(120);
originalSourceIDs.add(121);
originalSourceIDs.add(122);
originalSourceIDs.add(123);
originalSourceIDs.add(124);
originalSourceIDs.add(125);
mockRace = MockRaceTest.createMockRace();
sourceIdAllocator = new SourceIdAllocator(originalSourceIDs);
sourceIdAllocator = new SourceIdAllocator(mockRace);
}
@@ -49,11 +36,12 @@ public class SourceIdAllocatorTest {
@Test
public void emptyAllocationTest() {
SourceIdAllocator allocator = new SourceIdAllocator(new ArrayList<>());
mockRace.getRaceDataSource().getParticipants().removeAll(mockRace.getBoatDataSource().getBoats().keySet());
mockRace.getRaceDataSource().getParticipants().addAll(mockRace.getBoatDataSource().getBoats().keySet());
try {
int sourceID = allocator.allocateSourceID();
int sourceID = sourceIdAllocator.allocateSourceID();
fail("Exception should have been thrown, but wasn't.");
@@ -73,6 +61,7 @@ public class SourceIdAllocatorTest {
@Test
public void allocationTest() throws Exception {
mockRace.setRaceStatusEnum(RaceStatusEnum.PRESTART);
int sourceID = sourceIdAllocator.allocateSourceID();
@@ -108,10 +97,7 @@ public class SourceIdAllocatorTest {
@Test
public void reallocationTest() throws Exception {
List<Integer> sourceIDList = new ArrayList<>();
sourceIDList.add(123);
SourceIdAllocator sourceIdAllocator = new SourceIdAllocator(sourceIDList);
mockRace.setRaceStatusEnum(RaceStatusEnum.PRESTART);
//Allocate.
int sourceID = sourceIdAllocator.allocateSourceID();
@@ -1,11 +1,11 @@
package mock.model.commandFactory;
import mock.exceptions.CommandConstructionException;
import mock.model.MockBoat;
import mock.model.MockRace;
import mock.model.MockRaceTest;
import mock.exceptions.SourceIDAllocationException;
import mock.model.*;
import network.Messages.BoatAction;
import network.Messages.Enums.BoatActionEnum;
import network.Messages.Enums.RaceStatusEnum;
import org.junit.Before;
import org.junit.Test;
import shared.exceptions.InvalidBoatDataException;
@@ -21,6 +21,7 @@ import static org.mockito.Mockito.mock;
*/
public class WindCommandTest {
private MockRace race;
private SourceIdAllocator allocator;
private MockBoat boat;
private Command upwind;
private Command downwind;
@@ -29,12 +30,15 @@ public class WindCommandTest {
private double offset = 3.0;
@Before
public void setUp() throws CommandConstructionException, InvalidBoatDataException, InvalidRegattaDataException, InvalidRaceDataException {
public void setUp() throws CommandConstructionException, InvalidBoatDataException, InvalidRegattaDataException, InvalidRaceDataException, SourceIDAllocationException {
race = MockRaceTest.createMockRace();
allocator = new SourceIdAllocator(race);
race.setRaceStatusEnum(RaceStatusEnum.PRESTART);
allocator.allocateSourceID();
boat = race.getBoats().get(0);
//when(race.getWindDirection()).thenReturn(Bearing.fromDegrees(0.0));
boat.setBearing(Bearing.fromDegrees(45.0));
@@ -94,7 +94,7 @@ public class ConnectionToServerParticipantTest {
incomingCommands.put(command);
//Need to wait for connection thread to execute commands.
Thread.sleep(250);
Thread.sleep(500);
assertEquals(ConnectionToServerState.CONNECTED, connectionToServer.getConnectionState());
assertTrue(connectionToServer.getJoinAcceptance() != null);
@@ -5,12 +5,6 @@
<CreationTimeDate>2017-04-19T15:30:00+1200</CreationTimeDate>
<RaceStartTime Postpone="false" Time="2017-04-19T15:33:00+1200"/>
<Participants>
<Yacht SourceID="121"/>
<Yacht SourceID="122"/>
<Yacht SourceID="123"/>
<Yacht SourceID="124"/>
<Yacht SourceID="125"/>
<Yacht SourceID="126"/>
</Participants>
<CompoundMarkSequence>
<Corner CompoundMarkID="1" SeqID="1"/>
@@ -54,4 +48,4 @@
<Limit Lat="32.297164" Lon="-64.856394" SeqID="10"/>
<Limit Lat="32.296148" Lon="-64.849184" SeqID="11"/>
</CourseLimit>
</Race>
</Race>