Skip to content

Commit

Permalink
Working demo
Browse files Browse the repository at this point in the history
  • Loading branch information
wakaleo committed Oct 1, 2014
1 parent a301646 commit 8571bdc
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public class FrequentFlyerMember {
private String lastName;
private String homeAirportCode;
private int statusPoints;
private String status;

public FrequentFlyerMember() {
}
Expand Down Expand Up @@ -64,4 +65,12 @@ public String getHomeAirportCode() {
public void setHomeAirportCode(String homeAirportCode) {
this.homeAirportCode = homeAirportCode;
}

public String getStatus() {
return status;
}

public void setStatus(String status) {
this.status = status;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ public int getPointBalance() {
}

public void waitForFieldsToLoad() {
waitFor(".possible-destination");
waitFor("#departure option:nth-child(2)");
waitFor("#destination option:nth-child(2)");
// waitFor(".possible-destination");
// waitFor("#departure option:nth-child(2)");
// waitFor("#destination option:nth-child(2)");
waitFor(250).milliseconds();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,15 @@ public class AirportStepDefinitions {
public void givenAFrequentFlyer() {
}

@Pending
@Given("$frequentFlyer is a Frequent Flyer member with $points points")
public void giveSarahSomePoints(String name, int points) throws URISyntaxException {
// TODO
// FrequentFlyer frequentFlyer = FrequentFlyer.valueOf(name);
// restClient.updatePointsFor(frequentFlyer.getNumber(), points);
public void giveSarahSomePoints(FrequentFlyer flyer, int points) throws URISyntaxException {
restClient.updatePointsFor(flyer.getNumber(), points);
}


@Pending
@Then("she should see an account balance of $expectedPoints points")
public void shouldSeePointBalanceOf(int expectedPoints) {
// TODO
// sarah.shouldSeeAccountBalanceOf(expectedPoints);
sarah.shouldSeeAccountBalanceOf(expectedPoints);
}

@Pending
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,9 @@ public class FrequentFlyerStepDefinitions {
@Given("$frequentFlyer is a Frequent Flyer member")
public void giveSarahSomePoints(FrequentFlyer frequentFlyer) {}

@Pending
@When("she views her account details")
public void viewAccountDetails() {
// TODO
// sarah.openAccountPage();
sarah.openAccountPage();
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@

public class MyAccountUISteps {

MyAccountPage myAccountPage;

@Step
public void openAccountPage() {
myAccountPage.open();
myAccountPage.waitForFieldsToLoad();
}

MyAccountPage myAccountPage;

@Step
public int calculatePointsNeededBetween(String departure,
String destination) {
Expand All @@ -29,19 +28,16 @@ public int calculatePointsNeededBetween(String departure,

@Step
public void shouldSeeAccountBalanceOf(int expectedPoints) {
// TODO
// assertThat(myAccountPage.getPointBalance()).isEqualTo(expectedPoints);
assertThat(myAccountPage.getPointBalance()).isEqualTo(expectedPoints);
}

@Step
public void shouldSeeHomeCity(String expectedHomeCity) {
// TODO
// assertThat(myAccountPage.getHomeCity()).isEqualTo(expectedHomeCity);
assertThat(myAccountPage.getHomeCity()).isEqualTo(expectedHomeCity);
}

@Step
public void shouldSeePossibleDestinations(List<String> expectedAirports) {
// TODO
// assertThat(myAccountPage.getPossibleDestinations()).containsAll(expectedAirports);
assertThat(myAccountPage.getPossibleDestinations()).containsAll(expectedAirports);
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package flyinghigh.services.accounts.domain;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import org.springframework.data.annotation.Id;

import java.lang.String;

@JsonIgnoreProperties({"_links"})
public class FrequentFlyerMember {
@Id
private String id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.google.common.collect.ImmutableList;
import flyinghigh.services.accounts.domain.FrequentFlyerMember;
import flyinghigh.services.accounts.domain.Status;
import flyinghigh.services.accounts.repositories.AccountRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
Expand All @@ -12,7 +13,7 @@
public class DatabaseSetupImpl implements DatabaseSetup {

private final static List<FrequentFlyerMember> DEFAULT_ACCOUNTS = ImmutableList.of(
new FrequentFlyerMember("123456","Sarah-Jane","Smith",500,"SYD"),
new FrequentFlyerMember("123456","Sarah-Jane","Smith",2000,"SYD").withStatus(Status.Silver),
new FrequentFlyerMember("123457","Harry","Sullivan",1000,"SYD"),
new FrequentFlyerMember("123458","Jo","Grant", 2000,"SYD")
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ class WhenManagingFrequentFlyerMemberStatusUpdates extends Specification {

def "A frequent flyer requires a first name, a last name, and a frequent flyer number"() {
when:
def member = FrequentFlyerMember.withFrequentFlyerNumber("12345678").named("Joe","Bloggs")
def member = FrequentFlyerMember.withFrequentFlyerNumber("12345678")
.named("Joe","Bloggs")
then:
member.accountNumber == "12345678"
and:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@

import flyinghigh.services.accounts.AccountsApp;
import flyinghigh.services.accounts.domain.FrequentFlyerMember;
import flyinghigh.services.accounts.domain.Status;
import flyinghigh.services.accounts.repositories.AccountRepository;
import flyinghigh.services.accounts.services.database.DatabaseSetup;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
Expand Down Expand Up @@ -61,4 +64,17 @@ public void should_list_all_known_accounts() {
assertThat(account).isNotEmpty();
}

@Test
public void should_read_account_details_via_the_web_service() {
String url = getResultUrl(restTemplate.getForObject(baseUrl + "/accounts/search/findByAccountNumber?number={number}", JSONObject.class, "123456"));
FrequentFlyerMember member = restTemplate.getForObject(url, FrequentFlyerMember.class);

assertThat(member.getFirstName()).isEqualTo("Sarah-Jane");
assertThat(member.getStatus()).isEqualTo(Status.Silver);
}

private String getResultUrl(JSONObject result) {
return ((JSONObject)((JSONArray)result.get("links")).get(0)).get("href").toString();
}

}

0 comments on commit 8571bdc

Please sign in to comment.