Last active
September 1, 2023 20:16
-
-
Save up1/579a527696a6ec0e86f08cd90dffd3d5 to your computer and use it in GitHub Desktop.
Revisions
-
up1 revised this gist
Nov 18, 2021 . 1 changed file with 15 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,15 @@ @SpringBootTest(webEnvironment= WebEnvironment.NONE) @AutoConfigureStubRunner(ids = "com.example:provider:+:8081", stubsMode = StubRunnerProperties.StubsMode.LOCAL) public class CustomerGatewayTest { @Autowired private CustomerGateway gateway; @Test void getAllCustomers() { List<Customer> customers = this.gateway.getAllCustomers(); BDDAssertions.then(customers).size().isEqualTo(2); BDDAssertions.then(customers.iterator().next().getId()).isEqualTo(1L); BDDAssertions.then(customers.iterator().next().getName()).isEqualTo("Test 01"); } } -
up1 revised this gist
Nov 18, 2021 . 1 changed file with 17 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,17 @@ @SpringBootTest (classes = ProviderApplication.class) class BaseTests { @Autowired private CustomerRestController customerRestController; @MockBean private CustomerRepository customerRepository; @BeforeEach public void before() { when(this.customerRepository.findAll()) .thenReturn(Arrays.asList(new Customer(1L, "Test 01"), new Customer(2L, "Test 02"))); RestAssuredMockMvc.standaloneSetup(this.customerRestController); } } -
up1 created this gist
Nov 18, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ import org.springframework.cloud.contract.spec.Contract import org.springframework.http.HttpHeaders import org.springframework.http.MediaType Contract.make { description "should return all customers" request { url "/customers" method GET() } response { status 200 headers { header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) } body([[id: 1L, name: "Test 01"], [id: 2L, name: "Test 02"]]) } }