Fixed tests.
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -60,6 +61,7 @@ public class SourceIdAllocatorTest {
|
||||
@Test
|
||||
public void allocationTest() throws Exception {
|
||||
|
||||
mockRace.setRaceStatusEnum(RaceStatusEnum.PRESTART);
|
||||
|
||||
int sourceID = sourceIdAllocator.allocateSourceID();
|
||||
|
||||
@@ -95,6 +97,7 @@ public class SourceIdAllocatorTest {
|
||||
@Test
|
||||
public void reallocationTest() throws Exception {
|
||||
|
||||
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));
|
||||
|
||||
|
||||
+1
-1
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user