diff --git a/account-service/src/main/resources/bootstrap.yml b/account-service/src/main/resources/bootstrap.yml index e3e4e51..b335d6e 100644 --- a/account-service/src/main/resources/bootstrap.yml +++ b/account-service/src/main/resources/bootstrap.yml @@ -1,4 +1,3 @@ -# define the name of the application as its registered with eureka spring: application: name: account-service \ No newline at end of file diff --git a/account-service/src/main/resources/logback.xml b/account-service/src/main/resources/logback.xml index 4abb454..38ad0a4 100644 --- a/account-service/src/main/resources/logback.xml +++ b/account-service/src/main/resources/logback.xml @@ -8,8 +8,10 @@ - + + + diff --git a/account-service/src/test/resources/logback-test.xml b/account-service/src/test/resources/logback-test.xml index 7359ff1..9a6d42b 100644 --- a/account-service/src/test/resources/logback-test.xml +++ b/account-service/src/test/resources/logback-test.xml @@ -8,8 +8,10 @@ - + + + diff --git a/atm-service/src/main/java/org/xpdojo/bank/cdc/atm/domain/AccountData.java b/atm-service/src/main/java/org/xpdojo/bank/cdc/atm/domain/AccountData.java index b8f9253..28734d3 100644 --- a/atm-service/src/main/java/org/xpdojo/bank/cdc/atm/domain/AccountData.java +++ b/atm-service/src/main/java/org/xpdojo/bank/cdc/atm/domain/AccountData.java @@ -10,16 +10,16 @@ public class AccountData { private final Long accountNumber; - private final String accountDescription; + private final String description; private final Double overdraftFacility; private final Double balance; public AccountData(@JsonProperty("accountNumber") final Long accountNumber, - @JsonProperty("description") final String accountDescription, + @JsonProperty("description") final String description, @JsonProperty("overdraftFacility") final Amount overdraftFacility, @JsonProperty("balance") final Amount balance) { this.accountNumber = accountNumber; - this.accountDescription = accountDescription; + this.description = description; this.overdraftFacility = overdraftFacility.getValue(); this.balance = balance.getValue(); } @@ -28,8 +28,8 @@ public Long getAccountNumber() { return accountNumber; } - public String getAccountDescription() { - return accountDescription; + public String getDescription() { + return description; } public Double getOverdraftFacility() { @@ -46,21 +46,21 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) return false; AccountData that = (AccountData) o; return Objects.equals(accountNumber, that.accountNumber) && - Objects.equals(accountDescription, that.accountDescription) && + Objects.equals(description, that.description) && Objects.equals(overdraftFacility, that.overdraftFacility) && Objects.equals(balance, that.balance); } @Override public int hashCode() { - return Objects.hash(accountNumber, accountDescription, overdraftFacility, balance); + return Objects.hash(accountNumber, description, overdraftFacility, balance); } @Override public String toString() { return "AccountData{" + "accountNumber=" + accountNumber + - ", accountDescription='" + accountDescription + '\'' + + ", description='" + description + '\'' + ", overdraftFacility=" + overdraftFacility + ", balance=" + balance + '}'; diff --git a/atm-service/src/main/resources/bootstrap.yml b/atm-service/src/main/resources/bootstrap.yml index 123e3ce..364859a 100644 --- a/atm-service/src/main/resources/bootstrap.yml +++ b/atm-service/src/main/resources/bootstrap.yml @@ -1,4 +1,3 @@ -# define the name of the application as its registered with eureka spring: application: name: atm-service \ No newline at end of file diff --git a/atm-service/src/main/resources/logback.xml b/atm-service/src/main/resources/logback.xml index 7174c4e..8995ea8 100644 --- a/atm-service/src/main/resources/logback.xml +++ b/atm-service/src/main/resources/logback.xml @@ -8,7 +8,8 @@ - + + diff --git a/atm-service/src/test/java/org/xpdojo/bank/cdc/atm/pact/AtmConsumerBalancePactTest.java b/atm-service/src/test/java/org/xpdojo/bank/cdc/atm/pact/AtmConsumerBalancePactTest.java index 4fa3b25..28d5ffe 100644 --- a/atm-service/src/test/java/org/xpdojo/bank/cdc/atm/pact/AtmConsumerBalancePactTest.java +++ b/atm-service/src/test/java/org/xpdojo/bank/cdc/atm/pact/AtmConsumerBalancePactTest.java @@ -69,7 +69,7 @@ void checkWeCanProcessTheAccountData(MockServer mockProvider) throws IOException AccountData accountData = Jackson2ObjectMapperBuilder.json().build().readValue(response.getBody(), AccountData.class); assertThat(accountData.getAccountNumber()).isEqualTo(30002468L); - assertThat(accountData.getAccountDescription()).isNotEmpty(); + assertThat(accountData.getDescription()).isNotEmpty(); assertThat(accountData.getOverdraftFacility()).isEqualTo(23.0D); assertThat(accountData.getBalance()).isEqualTo(1000.0D); } diff --git a/atm-service/src/test/resources/logback-test.xml b/atm-service/src/test/resources/logback-test.xml index 937506f..2d91278 100644 --- a/atm-service/src/test/resources/logback-test.xml +++ b/atm-service/src/test/resources/logback-test.xml @@ -8,9 +8,11 @@ - + + + diff --git a/discovery-service/src/main/resources/bootstrap.yml b/discovery-service/src/main/resources/bootstrap.yml index e69de29..ff58c85 100644 --- a/discovery-service/src/main/resources/bootstrap.yml +++ b/discovery-service/src/main/resources/bootstrap.yml @@ -0,0 +1,3 @@ +spring: + application: + name: discovery-service \ No newline at end of file diff --git a/discovery-service/src/main/resources/logback.xml b/discovery-service/src/main/resources/logback.xml index 7359ff1..dce3a36 100644 --- a/discovery-service/src/main/resources/logback.xml +++ b/discovery-service/src/main/resources/logback.xml @@ -8,7 +8,8 @@ - + + diff --git a/mobile-banking-service/src/main/resources/bootstrap.yml b/mobile-banking-service/src/main/resources/bootstrap.yml index f297bee..cab6447 100644 --- a/mobile-banking-service/src/main/resources/bootstrap.yml +++ b/mobile-banking-service/src/main/resources/bootstrap.yml @@ -1,4 +1,3 @@ -# define the name of the application as its registered with eureka spring: application: name: mobile-banking-service \ No newline at end of file diff --git a/mobile-banking-service/src/main/resources/logback.xml b/mobile-banking-service/src/main/resources/logback.xml index 0c3511f..1fc993d 100644 --- a/mobile-banking-service/src/main/resources/logback.xml +++ b/mobile-banking-service/src/main/resources/logback.xml @@ -8,7 +8,8 @@ - + + diff --git a/mobile-banking-service/src/test/java/org/xpdojo/bank/cdc/mobile/pact/Contract.java b/mobile-banking-service/src/test/java/org/xpdojo/bank/cdc/mobile/pact/Contract.java new file mode 100644 index 0000000..fe2235e --- /dev/null +++ b/mobile-banking-service/src/test/java/org/xpdojo/bank/cdc/mobile/pact/Contract.java @@ -0,0 +1,44 @@ +package org.xpdojo.bank.cdc.mobile.pact; + +import au.com.dius.pact.consumer.dsl.DslPart; +import au.com.dius.pact.consumer.dsl.PactDslJsonBody; +import au.com.dius.pact.consumer.dsl.PactDslWithProvider; +import au.com.dius.pact.model.RequestResponsePact; + +import java.util.HashMap; +import java.util.Map; + +interface Contract { + + static RequestResponsePact accountBalanceContract(PactDslWithProvider builder) { + return builder + .uponReceiving("Request for all accounts") + .path("/accounts/30002468/balance") + .method("GET") + .willRespondWith() + .status(200) + .headers(expectedHeaders()) + .body(expectedAccountsBody()) + .toPact(); + } + + private static Map expectedHeaders() { + Map headers = new HashMap<>(); + headers.put("Content-Type", "application/json"); + return headers; + } + + private static PactDslJsonBody expectedAccountsBody() { + return new PactDslJsonBody() + .id("accountNumber") + .stringType("description") + .object("overdraftFacility", valueObject()) + .object("balance", valueObject()) + .asBody(); + } + + private static DslPart valueObject() { + return new PactDslJsonBody().decimalType("value"); + } + +} diff --git a/mobile-banking-service/src/test/java/org/xpdojo/bank/cdc/mobile/pact/MobileConsumerAccountSummaryPactTest.java b/mobile-banking-service/src/test/java/org/xpdojo/bank/cdc/mobile/pact/MobileConsumerAccountSummaryPactTest.java index f5175fe..802a73b 100644 --- a/mobile-banking-service/src/test/java/org/xpdojo/bank/cdc/mobile/pact/MobileConsumerAccountSummaryPactTest.java +++ b/mobile-banking-service/src/test/java/org/xpdojo/bank/cdc/mobile/pact/MobileConsumerAccountSummaryPactTest.java @@ -2,8 +2,6 @@ import au.com.dius.pact.consumer.MockServer; import au.com.dius.pact.consumer.Pact; -import au.com.dius.pact.consumer.dsl.DslPart; -import au.com.dius.pact.consumer.dsl.PactDslJsonBody; import au.com.dius.pact.consumer.dsl.PactDslWithProvider; import au.com.dius.pact.consumer.junit5.PactConsumerTestExt; import au.com.dius.pact.consumer.junit5.PactTestFor; @@ -18,8 +16,6 @@ import org.xpdojo.bank.cdc.mobile.domain.Account; import java.io.IOException; -import java.util.HashMap; -import java.util.Map; import static org.assertj.core.api.Assertions.assertThat; @@ -27,59 +23,32 @@ @PactTestFor(providerName = "account_provider") public class MobileConsumerAccountSummaryPactTest { - private static final Logger LOG = LoggerFactory.getLogger(MobileConsumerAccountSummaryPactTest.class); + private static final Logger LOG = LoggerFactory.getLogger(MobileConsumerAccountSummaryPactTest.class); - @Pact(provider = "account_provider", consumer = "mobile_consumer") - public RequestResponsePact configureMockServer(PactDslWithProvider builder) { - return builder - .uponReceiving("Request for all accounts") - .path("/accounts/30002468/balance") - .method("GET") - .willRespondWith() - .status(200) - .headers(expectedHeaders()) - .body(expectedAccountsBody()) - .toPact(); - } + @Pact(provider = "account_provider", consumer = "mobile_consumer") + public RequestResponsePact getContract(PactDslWithProvider builder) { + return Contract.accountBalanceContract(builder); + } - private Map expectedHeaders() { - Map headers = new HashMap<>(); - headers.put("Content-Type", "application/json"); - return headers; - } + @Test + void checkWeCanProcessTheAccountData(MockServer mockProvider) throws IOException { + ResponseEntity response = retrieveAccountData(mockProvider); - private PactDslJsonBody expectedAccountsBody() { - return new PactDslJsonBody() - .id("accountNumber") - .stringType("description") - .object("overdraftFacility", valueObject()) - .object("balance", valueObject()) - .asBody(); - } + assertThat(response.getStatusCode().value()).isEqualTo(200); + assertThat(response.getHeaders().get("Content-Type")).contains("application/json"); + assertThat(response.getBody()).as("Response body from the accounts service is expected to be populated").isNotEmpty(); - private DslPart valueObject() { - return new PactDslJsonBody().decimalType("value"); - } + LOG.info(response.getBody()); - @Test - void checkWeCanProcessTheAccountData(MockServer mockProvider) throws IOException { - ResponseEntity response = retrieveAccountData(mockProvider); + Account accountData = Jackson2ObjectMapperBuilder.json().build().readValue(response.getBody(), Account.class); + assertThat(accountData.getAccountNumber()).isNotZero(); + assertThat(accountData.getDescription()).isNotEmpty(); + assertThat(accountData.getOverdraftFacility()).isNotZero(); + assertThat(accountData.getBalance()).isNotZero(); + } - assertThat(response.getStatusCode().value()).isEqualTo(200); - assertThat(response.getHeaders().get("Content-Type")).contains("application/json"); - assertThat(response.getBody()).as("Response body from the accounts service is expected to be populated").isNotEmpty(); - - LOG.info(response.getBody()); - - Account accountData = Jackson2ObjectMapperBuilder.json().build().readValue(response.getBody(), Account.class); - assertThat(accountData.getAccountNumber()).isNotZero(); - assertThat(accountData.getDescription()).isNotEmpty(); - assertThat(accountData.getOverdraftFacility()).isNotZero(); - assertThat(accountData.getBalance()).isNotZero(); - } - - private ResponseEntity retrieveAccountData(MockServer mockProvider) { - return new RestTemplate().getForEntity(mockProvider.getUrl() + "/accounts/30002468/balance", String.class); - } + private ResponseEntity retrieveAccountData(MockServer mockProvider) { + return new RestTemplate().getForEntity(mockProvider.getUrl() + "/accounts/30002468/balance", String.class); + } } \ No newline at end of file diff --git a/mobile-banking-service/src/test/resources/logback-test.xml b/mobile-banking-service/src/test/resources/logback-test.xml index 7359ff1..1fc993d 100644 --- a/mobile-banking-service/src/test/resources/logback-test.xml +++ b/mobile-banking-service/src/test/resources/logback-test.xml @@ -8,8 +8,10 @@ - + + +