-
Notifications
You must be signed in to change notification settings - Fork 13
Initial code checkin #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 5 commits
639b8c0
f52cc66
005c866
2c43cdd
cbaec2b
b94cc66
3592f8f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| package shouty; | ||
|
|
||
| public class PersonLocation { | ||
| public String person; | ||
| public int x; | ||
| public int y; | ||
|
|
||
| public PersonLocation(String person_, int x_, int y_) { | ||
| person = person_; | ||
|
||
| x = x_; | ||
| y = y_; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| package shouty; | ||
|
|
||
| public class Shout { | ||
| public String person; | ||
| public String message; | ||
| public int x; | ||
| public int y; | ||
|
|
||
| public Shout(String person_, String message_) { | ||
| person = person_; | ||
| message = message_; | ||
| } | ||
|
|
||
| public Shout(String person_, String message_, int x_, int y_) { | ||
| person = person_; | ||
| message = message_; | ||
| x = x_; | ||
| y = y_; | ||
| } | ||
| } |
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| package shouty; | ||
|
|
||
| import kong.unirest.GenericType; | ||
| import kong.unirest.Unirest; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| public class ShoutyServiceWrapper { | ||
|
|
||
| private static final String REST_ROOT_URI | ||
| = "https://virtserver.swaggerhub.com/smartbear/Shout/1.3."; | ||
|
|
||
| private String REST_URI; | ||
|
|
||
| public void chooseStubbedData(String dataSet) { | ||
| REST_URI = REST_ROOT_URI + dataSet; | ||
| } | ||
|
|
||
| public void setLocation(PersonLocation personLocation) { | ||
| // Unirest.post(REST_URI + "/shouts") | ||
| // .body(personLocation) | ||
| // .asEmpty(); | ||
| } | ||
|
|
||
| public void shout(Shout shout) { | ||
| // Unirest.post(REST_URI + "/shouts") | ||
| // .body(shout) | ||
| // .asEmpty(); | ||
| } | ||
|
|
||
| public List<Shout> getShouts() { | ||
| return Unirest.get(REST_URI + "/shouts").asObject(new GenericType<List<Shout>>() { | ||
| }).getBody(); | ||
| } | ||
| } |
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,13 @@ | ||
| package shouty; | ||
|
|
||
| import cucumber.api.CucumberOptions; | ||
| import cucumber.api.SnippetType; | ||
| import cucumber.api.junit.Cucumber; | ||
| import io.cucumber.junit.Cucumber; | ||
| import io.cucumber.junit.CucumberOptions; | ||
| import org.junit.runner.RunWith; | ||
|
|
||
| @RunWith(Cucumber.class) | ||
| @CucumberOptions(monochrome = true, plugin = {"pretty", "html:target/cucumber", "rerun:target/rerun.txt", "json:target/cucumber.json", "io.cucumber.pro.JsonReporter"}, snippets = SnippetType.CAMELCASE) | ||
| @CucumberOptions(strict=true, plugin="pretty") | ||
| public class RunCukesTest { | ||
| // this is the adapter/bridge code | ||
| // between cucumber jvm and junit | ||
| // you do not need to edit this | ||
| // this is the adapter/bridge code | ||
| // between cucumber jvm and junit | ||
| // you do not need to edit this | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,39 +1,48 @@ | ||
| package shouty; | ||
|
|
||
| import cucumber.api.java.en.Given; | ||
| import cucumber.api.java.en.Then; | ||
| import cucumber.api.java.en.When; | ||
| import java.util.List; | ||
|
|
||
| import static java.util.Collections.emptyMap; | ||
| import io.cucumber.java.Before; | ||
| import io.cucumber.java.Scenario; | ||
| import io.cucumber.java.en.Given; | ||
| import io.cucumber.java.en.When; | ||
| import io.cucumber.java.en.Then; | ||
|
|
||
| import static java.util.Collections.emptyList; | ||
| import static org.junit.Assert.assertEquals; | ||
| import static org.junit.Assert.assertNotEquals; | ||
|
|
||
|
|
||
| public class ShoutSteps { | ||
| private static final String ARBITRARY_MESSAGE = "Hello, world"; | ||
| private final Shouty shouty = new Shouty(); | ||
| private final ShoutyServiceWrapper shouty; | ||
| private List<Shout> shouts; | ||
|
|
||
| public ShoutSteps(ShoutyServiceWrapper shouty_){ | ||
| shouty = shouty_; | ||
| } | ||
|
|
||
| @Given("Lucy is at {int}, {int}") | ||
| public void lucy_is_at(int xCoord, int yCoord) { | ||
| shouty.setLocation("Lucy", new Coordinate(xCoord, yCoord)); | ||
| @Given("{word} is at {int}, {int}") | ||
| public void person_is_at(String person, int x, int y) { | ||
| shouty.setLocation(new PersonLocation(person, x, y)); | ||
| } | ||
|
|
||
| @Given("Sean is at {int}, {int}") | ||
| public void sean_is_at(int xCoord, int yCoord) { | ||
| shouty.setLocation("Sean", new Coordinate(xCoord, yCoord)); | ||
| @When("{word} shouts") | ||
| public void person_shouts(String person) { | ||
| shouty.shout(new Shout(person, "Hello, world")); | ||
| } | ||
|
|
||
| @When("Sean shouts") | ||
| public void sean_shouts() { | ||
| shouty.shout("Sean", ARBITRARY_MESSAGE); | ||
| @When("{word} shouts from {int}, {int}") | ||
| public void person_shouts(String person, int x, int y) { | ||
| shouty.shout(new Shout(person, "Hello, world", x, y)); | ||
| } | ||
|
|
||
| @Then("Lucy should hear Sean") | ||
| public void lucy_should_hear_sean() { | ||
| assertEquals(1, shouty.getShoutsHeardBy("Lucy").size()); | ||
| @Then("{word} should hear {word}") | ||
| public void listener_should_hear_shouter(String listener, String shouter) { | ||
| assertEquals(shouter, shouty.getShouts().get(0).person); | ||
| } | ||
|
|
||
| @Then("Lucy should hear nothing") | ||
| public void lucy_should_hear_nothing() { | ||
| assertEquals(emptyMap(), shouty.getShoutsHeardBy("Lucy")); | ||
| @Then("{word} should not hear {word}") | ||
| public void listener_should_not_hear_shouter(String listener, String shouter) { | ||
| assertEquals(0, shouty.getShouts().size()); | ||
| } | ||
| } |
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| package shouty; | ||
|
|
||
| import io.cucumber.java.Before; | ||
| import io.cucumber.java.Scenario; | ||
|
|
||
| import java.io.Console; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not used |
||
|
|
||
| public class SmokeAndMirrors { | ||
| private final ShoutyServiceWrapper shouty; | ||
|
|
||
| public SmokeAndMirrors(ShoutyServiceWrapper shouty_){ | ||
| shouty = shouty_; | ||
| } | ||
|
|
||
| @Before | ||
| public void setupExampleData(Scenario scenario) { | ||
| switch (scenario.getName()) { | ||
| case "In range shout is heard": | ||
| case "Range calculated using specified location of business shout": | ||
| shouty.chooseStubbedData("0"); | ||
| break; | ||
| case "Out of range shout is not heard": | ||
| shouty.chooseStubbedData("1"); | ||
| break; | ||
| default: | ||
| throw new RuntimeException("Unrecognised scenario name"); | ||
| } | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Be a good citizen - declare all immutable fields as
final