Bumping versions
This commit is contained in:
@@ -51,22 +51,19 @@ public class LoanApplicationService {
|
||||
return buildResponseFromFraudResult(response);
|
||||
}
|
||||
|
||||
private FraudServiceResponse sendRequestToFraudDetectionService(
|
||||
FraudServiceRequest request) {
|
||||
private FraudServiceResponse sendRequestToFraudDetectionService(FraudServiceRequest request) {
|
||||
HttpHeaders httpHeaders = new HttpHeaders();
|
||||
httpHeaders.add(HttpHeaders.CONTENT_TYPE, FRAUD_SERVICE_JSON_VERSION_1);
|
||||
|
||||
// tag::client_call_server[]
|
||||
ResponseEntity<FraudServiceResponse> response = this.restTemplate.exchange(
|
||||
this.fraudUrl + "/fraudcheck", HttpMethod.PUT,
|
||||
new HttpEntity<>(request, httpHeaders), FraudServiceResponse.class);
|
||||
ResponseEntity<FraudServiceResponse> response = this.restTemplate.exchange(this.fraudUrl + "/fraudcheck",
|
||||
HttpMethod.PUT, new HttpEntity<>(request, httpHeaders), FraudServiceResponse.class);
|
||||
// end::client_call_server[]
|
||||
|
||||
return response.getBody();
|
||||
}
|
||||
|
||||
private LoanApplicationResult buildResponseFromFraudResult(
|
||||
FraudServiceResponse response) {
|
||||
private LoanApplicationResult buildResponseFromFraudResult(FraudServiceResponse response) {
|
||||
LoanApplicationStatus applicationStatus = null;
|
||||
if (FraudCheckStatus.OK == response.getFraudCheckStatus()) {
|
||||
applicationStatus = LoanApplicationStatus.LOAN_APPLIED;
|
||||
@@ -75,8 +72,7 @@ public class LoanApplicationService {
|
||||
applicationStatus = LoanApplicationStatus.LOAN_APPLICATION_REJECTED;
|
||||
}
|
||||
|
||||
return new LoanApplicationResult(applicationStatus,
|
||||
response.getRejectionReason());
|
||||
return new LoanApplicationResult(applicationStatus, response.getRejectionReason());
|
||||
}
|
||||
|
||||
public void setFraudUrl(String fraudUrl) {
|
||||
|
||||
@@ -25,8 +25,7 @@ public class LoanApplicationResult {
|
||||
public LoanApplicationResult() {
|
||||
}
|
||||
|
||||
public LoanApplicationResult(LoanApplicationStatus loanApplicationStatus,
|
||||
String rejectionReason) {
|
||||
public LoanApplicationResult(LoanApplicationStatus loanApplicationStatus, String rejectionReason) {
|
||||
this.loanApplicationStatus = loanApplicationStatus;
|
||||
this.rejectionReason = rejectionReason;
|
||||
}
|
||||
|
||||
@@ -35,10 +35,9 @@ public class FailFastLoanApplicationServiceTests {
|
||||
@Test
|
||||
public void shouldFailToStartContextWhenNoStubCanBeFound() {
|
||||
// When
|
||||
final Throwable throwable = catchThrowable(() -> new SpringApplicationBuilder(
|
||||
Application.class, StubRunnerConfiguration.class)
|
||||
.properties(ImmutableMap.of("stubrunner.stubsMode", "REMOTE",
|
||||
"stubrunner.repositoryRoot",
|
||||
final Throwable throwable = catchThrowable(
|
||||
() -> new SpringApplicationBuilder(Application.class, StubRunnerConfiguration.class)
|
||||
.properties(ImmutableMap.of("stubrunner.stubsMode", "REMOTE", "stubrunner.repositoryRoot",
|
||||
"classpath:m2repo/repository/", "stubrunner.ids",
|
||||
new String[] {
|
||||
"org.springframework.cloud.contract.verifier.stubs:should-not-be-found" }))
|
||||
@@ -46,26 +45,23 @@ public class FailFastLoanApplicationServiceTests {
|
||||
|
||||
// Then
|
||||
assertThat(throwable).isInstanceOf(BeanCreationException.class);
|
||||
assertThat(throwable.getCause().getCause())
|
||||
.isInstanceOf(BeanInstantiationException.class).hasMessageContaining(
|
||||
"No stubs or contracts were found for [org.springframework.cloud.contract.verifier.stubs:should-not-be-found:+:stubs] and the switch to fail on no stubs was set.");
|
||||
assertThat(throwable.getCause().getCause()).isInstanceOf(BeanInstantiationException.class).hasMessageContaining(
|
||||
"No stubs or contracts were found for [org.springframework.cloud.contract.verifier.stubs:should-not-be-found:+:stubs] and the switch to fail on no stubs was set.");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldNotTryAndWorkOfflineWhenRemoteModeIsOn() {
|
||||
// When
|
||||
final Throwable throwable = catchThrowable(() -> new SpringApplicationBuilder(
|
||||
Application.class, StubRunnerConfiguration.class)
|
||||
.properties(ImmutableMap.of("stubrunner.stubsMode", "CLASSPATH",
|
||||
"stubrunner.ids",
|
||||
final Throwable throwable = catchThrowable(
|
||||
() -> new SpringApplicationBuilder(Application.class, StubRunnerConfiguration.class)
|
||||
.properties(ImmutableMap.of("stubrunner.stubsMode", "CLASSPATH", "stubrunner.ids",
|
||||
new String[] {
|
||||
"org.springframework.cloud.contract.verifier.stubs:should-not-be-found" }))
|
||||
.run());
|
||||
|
||||
// Then
|
||||
assertThat(throwable).isInstanceOf(BeanCreationException.class);
|
||||
assertThat(throwable.getCause().getCause())
|
||||
.isInstanceOf(BeanInstantiationException.class)
|
||||
assertThat(throwable.getCause().getCause()).isInstanceOf(BeanInstantiationException.class)
|
||||
.hasMessageContaining("No stubs were found on classpath ");
|
||||
}
|
||||
|
||||
|
||||
@@ -39,8 +39,8 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
// tag::autoconfigure_stubrunner[]
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
|
||||
@AutoConfigureStubRunner(repositoryRoot = "classpath:m2repo/repository/", ids = {
|
||||
"org.springframework.cloud.contract.verifier.stubs:contextPathFraudDetectionServer" },
|
||||
@AutoConfigureStubRunner(repositoryRoot = "classpath:m2repo/repository/",
|
||||
ids = { "org.springframework.cloud.contract.verifier.stubs:contextPathFraudDetectionServer" },
|
||||
stubsMode = StubRunnerProperties.StubsMode.REMOTE)
|
||||
public class LoanApplicationServiceTests {
|
||||
|
||||
@@ -58,14 +58,13 @@ public class LoanApplicationServiceTests {
|
||||
@Before
|
||||
public void setPort() {
|
||||
this.service.setFraudUrl(
|
||||
this.stubFinder.findStubUrl("contextPathFraudDetectionServer").toString()
|
||||
+ "/fraud-path/");
|
||||
this.stubFinder.findStubUrl("contextPathFraudDetectionServer").toString() + "/fraud-path/");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldStartThisAppWithContextPath() {
|
||||
String response = new RestTemplate().getForObject(
|
||||
"http://localhost:" + this.port + "/my-path/foo", String.class);
|
||||
String response = new RestTemplate().getForObject("http://localhost:" + this.port + "/my-path/foo",
|
||||
String.class);
|
||||
|
||||
assertThat(response).isNotEmpty();
|
||||
}
|
||||
@@ -73,13 +72,11 @@ public class LoanApplicationServiceTests {
|
||||
@Test
|
||||
public void shouldSuccessfullyApplyForLoan() {
|
||||
// given:
|
||||
LoanApplication application = new LoanApplication(new Client("1234567890"),
|
||||
123.123);
|
||||
LoanApplication application = new LoanApplication(new Client("1234567890"), 123.123);
|
||||
// when:
|
||||
LoanApplicationResult loanApplication = this.service.loanApplication(application);
|
||||
// then:
|
||||
assertThat(loanApplication.getLoanApplicationStatus())
|
||||
.isEqualTo(LoanApplicationStatus.LOAN_APPLIED);
|
||||
assertThat(loanApplication.getLoanApplicationStatus()).isEqualTo(LoanApplicationStatus.LOAN_APPLIED);
|
||||
assertThat(loanApplication.getRejectionReason()).isNull();
|
||||
}
|
||||
|
||||
@@ -87,8 +84,7 @@ public class LoanApplicationServiceTests {
|
||||
@Test
|
||||
public void shouldBeRejectedDueToAbnormalLoanAmount() {
|
||||
// given:
|
||||
LoanApplication application = new LoanApplication(new Client("1234567890"),
|
||||
99999);
|
||||
LoanApplication application = new LoanApplication(new Client("1234567890"), 99999);
|
||||
// when:
|
||||
LoanApplicationResult loanApplication = this.service.loanApplication(application);
|
||||
// then:
|
||||
|
||||
Reference in New Issue
Block a user