diff --git a/acceptance-tests/build.gradle b/acceptance-tests/build.gradle index 60691ae..31fc2c0 100644 --- a/acceptance-tests/build.gradle +++ b/acceptance-tests/build.gradle @@ -10,7 +10,7 @@ buildscript { maven { url "https://oss.sonatype.org/content/repositories/snapshots" } } dependencies { - classpath("net.thucydides:thucydides-core:0.9.271") + classpath("net.thucydides:thucydides-core:0.9.272-SNAPSHOT") } } @@ -28,8 +28,8 @@ dependencies { compile("org.springframework.data:spring-data-rest-webmvc:2.2.0.RELEASE") testCompile "org.codehaus.groovy.modules.http-builder:http-builder:0.7" testCompile 'org.easytesting:fest-assert-core:2.0M10' - testCompile 'net.thucydides:thucydides-core:0.9.271' - testCompile 'net.thucydides:thucydides-jbehave-plugin:0.9.272' + testCompile 'net.thucydides:thucydides-core:0.9.272-SNAPSHOT' + testCompile 'net.thucydides:thucydides-jbehave-plugin:0.9.273-SNAPSHOT' } @@ -53,10 +53,10 @@ test { systemProperty 'webservice.environment', webserviceEnvironment systemProperty 'webdriver.base.url', baseUrl systemProperty 'webdriver.driver', driver - systemProperty 'thucydides.resized.image.width', 1000 - systemProperty 'dashboard.tag.list', 'capabilities, stories, layer' + systemProperty 'thucydides.browser.width', 1000 +// systemProperty 'thucydides.resized.image.width', 1000 + systemProperty 'dashboard.tag.list', 'capability, layer' useJUnit() - maxParallelForks = 4 } test.shouldRunAfter clean diff --git a/acceptance-tests/gradle.properties b/acceptance-tests/gradle.properties index 92f1786..ac5f77b 100644 --- a/acceptance-tests/gradle.properties +++ b/acceptance-tests/gradle.properties @@ -1,3 +1,3 @@ webserviceEnvironment=local -baseUrl = http://localhost:9001 -driver=chrome \ No newline at end of file +baseUrl = http://localhost:9001 +driver=chrome diff --git a/acceptance-tests/src/test/java/flyinghigh/services/acceptancetests/rest/RestClient.java b/acceptance-tests/src/test/java/flyinghigh/services/acceptancetests/rest/RestClient.java index f5bba2e..3cf03cf 100644 --- a/acceptance-tests/src/test/java/flyinghigh/services/acceptancetests/rest/RestClient.java +++ b/acceptance-tests/src/test/java/flyinghigh/services/acceptancetests/rest/RestClient.java @@ -17,7 +17,7 @@ public class RestClient { private RestTemplate restTemplate = new RestTemplate(); public String getBaseFlightUrl() { - String environment = System.getProperty("webservice.environment","local"); + String environment = "dev";//System.getProperty("webservice.environment","local"); if (environment.equals("local")) { return "http://localhost:8090/"; } else { diff --git a/acceptance-tests/src/test/resources/stories/earning_points/earning_extra_points_from_status.story b/acceptance-tests/src/test/resources/stories/earning_points/earning_extra_points_from_status.story index 0fa256f..ee489eb 100644 --- a/acceptance-tests/src/test/resources/stories/earning_points/earning_extra_points_from_status.story +++ b/acceptance-tests/src/test/resources/stories/earning_points/earning_extra_points_from_status.story @@ -2,9 +2,9 @@ Earning extra points from Frequent Flyer status Meta: @Versions Release 2 -@tag layer:webservice +@tag layer:web -Scenario Outline: Earning points on flights by Frequent Flyer status +Scenario: Earning points on flights by Frequent Flyer status Given a member has a status of When I fly on a flight that is worth base points Then I should earn a status bonus of diff --git a/acceptance-tests/src/test/resources/stories/earning_points/earning_points_from_flights.story b/acceptance-tests/src/test/resources/stories/earning_points/earning_points_from_flights.story deleted file mode 100644 index 5132020..0000000 --- a/acceptance-tests/src/test/resources/stories/earning_points/earning_points_from_flights.story +++ /dev/null @@ -1,14 +0,0 @@ -Meta: -@Versions Release 1, Iteration 1.0 -@tag layer:web - -Narrative: -In order to know how many points I have earnd -As a traveller -I want to see my total points - - -Scenario: View point balance -Given Sarah is a Frequent Flyer member with 800 points -When Sarah views her account details -Then she should see an account balance of 800 points diff --git a/acceptance-tests/src/test/resources/stories/earning_points/earning_points_from_purchases.story b/acceptance-tests/src/test/resources/stories/earning_points/earning_points_from_purchases.story index d068aa5..e694d99 100644 --- a/acceptance-tests/src/test/resources/stories/earning_points/earning_points_from_purchases.story +++ b/acceptance-tests/src/test/resources/stories/earning_points/earning_points_from_purchases.story @@ -9,8 +9,8 @@ In order to encourage travellers to book with Flying High Airlines more frequent As the Flying High sales manager I want travellers to earn Frequent Flyer points when they fly with us -Scenario: Earning standard points from an Economy flight -Given the flying distance between Sydney and Melbourne is 878 km -And I am a Bronze Frequent Flyer member -When I fly from Sydney to Melbourne on 10/10/2014 -Then I should earn 439 points \ No newline at end of file +Scenario: Earning points when I buy something in a supermarket +Given I am shopping at Woolworths +And Woolworths is a partner organisation +When I purchase a box of sardines for 5.00 +Then I should earn 5 points \ No newline at end of file diff --git a/acceptance-tests/src/test/resources/stories/earning_points/earning_points_from_special_offers.story b/acceptance-tests/src/test/resources/stories/earning_points/earning_points_from_special_offers.story deleted file mode 100644 index 7f71fff..0000000 --- a/acceptance-tests/src/test/resources/stories/earning_points/earning_points_from_special_offers.story +++ /dev/null @@ -1,16 +0,0 @@ -Earning Frequent Flyer points from special offers - -Meta: -@Versions Release 2 -@tag layer:webservice - -Narrative: -In order to encourage travellers to book with Flying High Airlines more frequently -As the Flying High sales manager -I want travellers to earn Frequent Flyer points when they fly with us - -Scenario: Earning standard points from an Economy flight -Given the flying distance between Sydney and Melbourne is 878 km -And I am a Bronze Frequent Flyer member -When I fly from Sydney to Melbourne on 10/10/2014 -Then I should earn 439 points \ No newline at end of file diff --git a/acceptance-tests/src/test/resources/stories/earning_points/view_points_summary.story b/acceptance-tests/src/test/resources/stories/earning_points/view_points_summary.story index 5132020..3b2a43e 100644 --- a/acceptance-tests/src/test/resources/stories/earning_points/view_points_summary.story +++ b/acceptance-tests/src/test/resources/stories/earning_points/view_points_summary.story @@ -3,11 +3,10 @@ Meta: @tag layer:web Narrative: -In order to know how many points I have earnd +In order to know how many points I have earned As a traveller I want to see my total points - Scenario: View point balance Given Sarah is a Frequent Flyer member with 800 points When Sarah views her account details diff --git a/acceptance-tests/src/test/resources/stories/spending_points/calculating_required_points.story b/acceptance-tests/src/test/resources/stories/spending_points/calculating_required_points.story index 1aa71bb..c53f52c 100644 --- a/acceptance-tests/src/test/resources/stories/spending_points/calculating_required_points.story +++ b/acceptance-tests/src/test/resources/stories/spending_points/calculating_required_points.story @@ -11,7 +11,6 @@ Notes: 2 points required per km Scenario: Calculate required points Meta: @tag layer:web -2 points required per km Given I am a frequent flyer And I am on the My Account page diff --git a/acceptance-tests/src/test/resources/thucydides.properties b/acceptance-tests/src/test/resources/thucydides.properties new file mode 100644 index 0000000..97f2f9f --- /dev/null +++ b/acceptance-tests/src/test/resources/thucydides.properties @@ -0,0 +1,2 @@ +dashboard.excluded.tag.list=story +webservice.environment=dev \ No newline at end of file diff --git a/build.gradle b/build.gradle index d6720e3..3efe872 100644 --- a/build.gradle +++ b/build.gradle @@ -9,7 +9,7 @@ buildscript { dependencies { classpath("org.springframework.boot:spring-boot-gradle-plugin:1.1.6.RELEASE") classpath group: 'org.cloudfoundry', name: 'cf-gradle-plugin', version: '1.0.4' - classpath("net.thucydides:thucydides-core:0.9.271") + classpath("net.thucydides:thucydides-core:0.9.272-SNAPSHOT") } } diff --git a/flights-web-service/build.gradle b/flights-web-service/build.gradle index 837ef72..92f9d9d 100644 --- a/flights-web-service/build.gradle +++ b/flights-web-service/build.gradle @@ -35,6 +35,8 @@ dependencies { testCompile 'org.springframework.boot:spring-boot-starter-test' testCompile "org.codehaus.groovy.modules.http-builder:http-builder:0.7" testCompile 'org.easytesting:fest-assert-core:2.0M10' + testCompile 'com.insightfullogic:lambda-behave:0.3' + testCompile 'org.mockito:mockito-all:1.9.5' } test { diff --git a/flights-web-service/src/test/groovy/flyinghigh/services/flights/domain/WhenCalculatingRequiredPoints.groovy b/flights-web-service/src/test/groovy/flyinghigh/services/flights/domain/WhenCalculatingRequiredPoints.groovy index b4ceb42..d6617e8 100644 --- a/flights-web-service/src/test/groovy/flyinghigh/services/flights/domain/WhenCalculatingRequiredPoints.groovy +++ b/flights-web-service/src/test/groovy/flyinghigh/services/flights/domain/WhenCalculatingRequiredPoints.groovy @@ -9,14 +9,11 @@ class WhenCalculatingRequiredPoints extends Specification { def routeRepository = Mock(RouteRepository); - def DISTANCE = 1000 - def REQUIRED_POINTS = DISTANCE * 2 - def sydney = new Airport("Australia","Sydney","SYD") def melbourne = new Airport("Australia","Melbourne","MEL") - def setup() { - } + def DISTANCE = 1000 + def REQUIRED_POINTS = DISTANCE * 2 def "Required points should be calculated based on route distance"() { given: @@ -33,7 +30,8 @@ class WhenCalculatingRequiredPoints extends Specification { def "Required points should be calculated in both directions"() { given: routeRepository.findByDepartureCodeAndDestinationCode("SYD","MEL") >> [] - routeRepository.findByDepartureCodeAndDestinationCode("MEL","SYD") >> [Route.from(sydney).to(melbourne).withDistanceOf(DISTANCE).km()] + routeRepository.findByDepartureCodeAndDestinationCode("MEL","SYD") >> + [Route.from(sydney).to(melbourne).withDistanceOf(DISTANCE).km()] def pointsCalculator = new PointsCalculator(routeRepository) when: diff --git a/flights-web-service/src/test/java/flyinghigh/services/flights/CalculatingEarnedPointsSpecification.java b/flights-web-service/src/test/java/flyinghigh/services/flights/CalculatingEarnedPointsSpecification.java new file mode 100644 index 0000000..a58f369 --- /dev/null +++ b/flights-web-service/src/test/java/flyinghigh/services/flights/CalculatingEarnedPointsSpecification.java @@ -0,0 +1,48 @@ +package flyinghigh.services.flights; + +import com.google.common.collect.ImmutableList; +import com.insightfullogic.lambdabehave.JunitSuiteRunner; +import flyinghigh.services.flights.domain.Airport; +import flyinghigh.services.flights.domain.Route; +import flyinghigh.services.flights.repositories.RouteRepository; +import flyinghigh.services.flights.services.points.PointsCalculator; +import org.junit.runner.RunWith; + +import java.util.List; + +import static com.insightfullogic.lambdabehave.Suite.describe; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +@RunWith(JunitSuiteRunner.class) +public class CalculatingEarnedPointsSpecification { + { + + Airport sydney = new Airport("Australia", "Sydney", "SYD"); + Airport melbourne = new Airport("Australia", "Melbourne", "MEL"); + + RouteRepository routeRepository = mock(RouteRepository.class); + PointsCalculator pointsCalculator = new PointsCalculator(routeRepository); + + describe("calcuating points earned for a given route", it -> { + + it.uses(6000, 12000) + .and(5000, 10000) + .toShow("2 points should be earned per km travelled", + (expect, distance, expectedPoints) -> { + List routes = ImmutableList.of(Route.from(sydney) + .to(melbourne) + .withDistanceOf(distance).km()); + when(routeRepository.findByDepartureCodeAndDestinationCode("SYD", "MEL")) + .thenReturn(routes); + + int calculatedPoints + = pointsCalculator.calculatePointsRequiredBetween("SYD", "MEL"); + + expect.that(calculatedPoints).isEqualTo(expectedPoints); + }); + }); + } + + +} diff --git a/flights-web-service/src/test/java/flyinghigh/services/flights/CheckingTheApplicationVersionIT.java b/flights-web-service/src/test/java/flyinghigh/services/flights/CheckingTheApplicationVersionIT.java index 2f9126e..55d5779 100644 --- a/flights-web-service/src/test/java/flyinghigh/services/flights/CheckingTheApplicationVersionIT.java +++ b/flights-web-service/src/test/java/flyinghigh/services/flights/CheckingTheApplicationVersionIT.java @@ -14,7 +14,6 @@ import static org.fest.assertions.api.Assertions.assertThat; -// @RunWith(SpringJUnit4ClassRunner.class) @SpringApplicationConfiguration(classes = FlightsApp.class) @WebAppConfiguration diff --git a/flights-web-service/src/test/java/flyinghigh/services/flights/CreatingAnAirportSpecification.java b/flights-web-service/src/test/java/flyinghigh/services/flights/CreatingAnAirportSpecification.java new file mode 100644 index 0000000..feb5eaf --- /dev/null +++ b/flights-web-service/src/test/java/flyinghigh/services/flights/CreatingAnAirportSpecification.java @@ -0,0 +1,28 @@ +package flyinghigh.services.flights; + +import flyinghigh.services.flights.domain.Airport; + +import com.insightfullogic.lambdabehave.JunitSuiteRunner; +import org.junit.runner.RunWith; + +import java.util.Stack; + +import static com.insightfullogic.lambdabehave.Suite.describe; +import static org.hamcrest.Matchers.equalTo; + +@RunWith(JunitSuiteRunner.class) +public class CreatingAnAirportSpecification {{ + + Airport airport = Airport.called("Sydney").inCountry("Australia").withCode("SYD"); + + describe("an airport", it -> { + + it.should("be created with the correct values", expect -> { + expect.that(airport).hasProperty("name", equalTo("Sydney")); + expect.that(airport).hasProperty("code", equalTo("SYD")); + expect.that(airport).hasProperty("country", equalTo("Australia")); + }); + }); + + +}} diff --git a/flights-web-service/src/test/java/flyinghigh/services/flights/InitializingTheAirportsIT.java b/flights-web-service/src/test/java/flyinghigh/services/flights/InitializingTheAirportsIT.java index 8f3e943..38ab7da 100644 --- a/flights-web-service/src/test/java/flyinghigh/services/flights/InitializingTheAirportsIT.java +++ b/flights-web-service/src/test/java/flyinghigh/services/flights/InitializingTheAirportsIT.java @@ -15,7 +15,6 @@ import static org.fest.assertions.api.Assertions.assertThat; -// @RunWith(SpringJUnit4ClassRunner.class) @SpringApplicationConfiguration(classes = FlightsApp.class) @WebAppConfiguration @@ -34,5 +33,4 @@ public void should_instantiate_database_with_standard_airports() { List airports = airportRepository.findAll(); assertThat(airports).isNotEmpty(); } - } diff --git a/flights-web-service/src/test/java/flyinghigh/services/flights/LookingUpAirportsIT.java b/flights-web-service/src/test/java/flyinghigh/services/flights/LookingUpAirportsIT.java index be4e00c..fc5229b 100644 --- a/flights-web-service/src/test/java/flyinghigh/services/flights/LookingUpAirportsIT.java +++ b/flights-web-service/src/test/java/flyinghigh/services/flights/LookingUpAirportsIT.java @@ -37,14 +37,8 @@ public class LookingUpAirportsIT { @Value("${local.server.port}") private int port; - private RestTemplate restTemplate = new RestTemplate(); - - private String baseUrl; - @Before public void configureBaseUrl() { - baseUrl = "http://localhost:" + port; - restTemplate = new RestTemplate(); databaseSetup.initializeReferenceData(); }