Naveen Purswani01
04/20/2023, 3:50 AMJoydeep Das
04/21/2023, 6:43 AMDat Do Van
04/21/2023, 8:33 AMMuthukkumar Ponnusamy
04/22/2023, 4:06 PMCarlos Roig
04/26/2023, 8:31 AMCallum Johnson
04/26/2023, 10:40 AMAndres Martin Saldaña
04/26/2023, 12:33 PM@EventListener(ApplicationReadyEvent.class)
void configureStubs() {
stubFor(get(urlPathMatching("/hello-world")).willReturn(aResponse()
.withHeader("Content-Type", "text/plain")
.withBody("Hello World")));
}
the endpoint works properly… How can I set the jsons file directory in application.yml to configure all my endpoints?
Thanks!Nalinda Karunaratna
04/26/2023, 3:28 PMwiremock
in k8s
environment and make it use redis to store the mappings so it can withstand pods going down or scaleout/scalein scenarios. What's the best way to approach this? Or any other recommended setup? Help is greatly appreciated 🙏Kaushal Gupta
04/28/2023, 6:24 AM{
"request": {
"url": "/wiremock/middesk/v1/businesses",
"method": "POST",
"bodyPatterns": [
{
"matchesJsonPath": {
"expression": "$..tin",
"contains": "123"
}
}
]
},
"response": {
"status": 200,
"bodyFileName": "middesk-compliance-partner/customer_response/middeskInitiateResponse_success.json",
"headers": {
"Content-Type": "application/json; charset=utf-8"
},
"transformers": [
"response-template",
"body-transformer"
]
},
"postServeActions": [
{
"name": "webhook",
"parameters": {
"headers": {
"Content-Type": "application/json"
},
"method": "POST",
"url": "{{request.baseUrl}}/?code={{randomValue type='UUID'}}&state={{originalRequest.query.state}}",
"delay": {
"type": "fixed",
"milliseconds": 10
}
}
}
]
}
Bas Dijkstra
04/28/2023, 6:53 AMAnton Smirnov
04/28/2023, 11:07 AMHaneesha Arimilli
04/28/2023, 1:54 PMHaneesha Arimilli
04/28/2023, 2:01 PMShruti Mishra
04/29/2023, 5:49 PMShruti Mishra
04/30/2023, 7:31 AMRobert Strauch
05/02/2023, 6:42 AMWireMock.stubFor()
or WireMockExtension's wireMockExtension.stubFor()
. In the following @SpringBootTest
only wireMockExtension.stubFor()
seems to work. WireMock.stubFor()
gives a 404 and a message that there are no registered stubs. What's the difference between both variants and in which cases would one use one or the other?
Here is a sample test...
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@WireMockTest
class WiremockSpringbootApplicationTests {
@Value("${remote.url}")
private String remoteUrl;
@RegisterExtension
static WireMockExtension wireMockExtension = WireMockExtension.newInstance()
.options(wireMockConfig().dynamicPort())
.build();
// set remote.url dynamically based on WireMock instance
@DynamicPropertySource
static void dynamicProperties(DynamicPropertyRegistry registry) {
registry.add("remote.url", wireMockExtension::baseUrl);
}
@Test
void should_return_test() {
final WebClient webClient = WebClient.builder().baseUrl(remoteUrl).build();
// this stubbing works...
wireMockExtension.stubFor(get("/test")
.willReturn(aResponse().withBody("test")));
// ... this doesn't and gives a 404
// WireMock.stubFor(get("/test")
// .willReturn(aResponse().withBody("test")));
final String responseString = webClient.get().uri("/test")
.retrieve()
.bodyToMono(String.class)
.block();
Assertions.assertThat(responseString).isEqualTo("test");
}
}
Shruti Mishra
05/02/2023, 2:39 PMShruti Mishra
05/02/2023, 2:41 PMCute pk
05/04/2023, 4:14 AMTomas Belda
05/04/2023, 2:06 PM{
"mappings": [
{
"scenarioName": "PDP Product",
"requiredScenarioState": "Started",
"newScenarioState": "Product selected",
"request": {
"method": "GET",
"url": "/api/v3/xxxlutz.at/products/008021030201"
},
"response": {
"status": 200,
"bodyFileName": "req.json"
}
},
{
"scenarioName": "PDP Product",
"requiredScenarioState": "Product selected",
"request": {
"method": "GET",
"url": "api/v3/xxxlutz.at/carts/155294111"
},
"response": {
"status": 200,
"bodyFileName": "cart.json"
}
}
]
}
the route is samples/hello/stubs/mappings/expensive.jsonTomas Belda
05/04/2023, 2:07 PMTomas Belda
05/04/2023, 2:27 PMTomas Belda
05/04/2023, 2:27 PMTomas Belda
05/04/2023, 2:27 PMSreedhar Singaraju
05/05/2023, 4:36 AMSreedhar Singaraju
05/05/2023, 4:37 AMSreedhar Singaraju
05/05/2023, 4:38 AMSreedhar Singaraju
05/05/2023, 4:39 AMSreedhar Singaraju
05/05/2023, 4:44 AMSreedhar Singaraju
05/05/2023, 4:45 AM