From 25c2de63a2bb498476f4f0065597413f7614a631 Mon Sep 17 00:00:00 2001 From: Kusal Ekanayake Date: Sun, 13 Aug 2017 14:55:33 +1200 Subject: [PATCH] Working cucumber tests for sails toggle. When sails in will send a sails out message when sails out will send a sails in message and then checks for the new status of the sail #story[1111] --- src/main/java/seng302/model/Yacht.java | 2 +- src/test/java/steps/ToggleSailSteps.java | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/main/java/seng302/model/Yacht.java b/src/main/java/seng302/model/Yacht.java index d0203393..6e49b132 100644 --- a/src/main/java/seng302/model/Yacht.java +++ b/src/main/java/seng302/model/Yacht.java @@ -585,7 +585,7 @@ public class Yacht { this.velocity = velocity; updateVelocityProperty(velocity); for (YachtLocationListener yll : locationListeners) { - yll.notifyLocation(this, lat, lng, heading, velocity); + yll.notifyLocation(this, lat, lng, heading, velocity, clientSailsIn); } } diff --git a/src/test/java/steps/ToggleSailSteps.java b/src/test/java/steps/ToggleSailSteps.java index 43627288..2347c9ce 100644 --- a/src/test/java/steps/ToggleSailSteps.java +++ b/src/test/java/steps/ToggleSailSteps.java @@ -34,8 +34,12 @@ public class ToggleSailSteps { mst = new MainServerThread(); client = new ClientToServerThread("localhost", 4942); GameState.setCurrentStage(GameStages.RACING); + Thread.sleep(200); // Sleep needed to help the threads all be up to speed with each other + Yacht yacht = (new ArrayList<>(GameState.getYachts().values())).get(0); + Assert.assertFalse(yacht.getSailIn()); } + @When("^the user has pressed \"([^\"]*)\"$") public void the_user_has_pressed(String arg1) throws Throwable { startTime = System.currentTimeMillis(); @@ -50,7 +54,12 @@ public class ToggleSailSteps { @Then("^the sails are \"([^\"]*)\"$") public void the_sails_are(String arg1) throws Throwable { - //Yacht yacht = (new ArrayList<>(GameState.getYachts().values())).get(0); - //Assert.assertTrue(yacht.getSailIn()); + Thread.sleep(200); // Sleep needed to help the threads all be up to speed with each other + Yacht yacht = (new ArrayList<>(GameState.getYachts().values())).get(0); + if (arg1 == "in") { + Assert.assertTrue(yacht.getSailIn()); + } else { + Assert.assertFalse(yacht.getSailIn()); + } } }