use of com.github.tomakehurst.wiremock.matching.RequestPatternBuilder in project spring-boot-admin by codecentric.
the class AbstractClientApplicationTest method test_context.
@Test
public void test_context() throws InterruptedException, UnknownHostException {
cdl.await();
Thread.sleep(2500);
String hostName = InetAddress.getLocalHost().getCanonicalHostName();
String serviceHost = "http://" + hostName + ":" + getServerPort();
String managementHost = "http://" + hostName + ":" + getManagementPort();
RequestPatternBuilder request = postRequestedFor(urlEqualTo("/instances"));
request.withHeader("Content-Type", equalTo("application/json")).withRequestBody(matchingJsonPath("$.name", equalTo("Test-Client"))).withRequestBody(matchingJsonPath("$.healthUrl", equalTo(managementHost + "/mgmt/health"))).withRequestBody(matchingJsonPath("$.managementUrl", equalTo(managementHost + "/mgmt"))).withRequestBody(matchingJsonPath("$.serviceUrl", equalTo(serviceHost + "/"))).withRequestBody(matchingJsonPath("$.metadata.startup", matching(".+")));
wireMock.verify(request);
}
use of com.github.tomakehurst.wiremock.matching.RequestPatternBuilder in project spring-boot-admin by codecentric.
the class AbstractRegistrationClientTest method register_should_return_id_when_successful.
@Test
public void register_should_return_id_when_successful() {
ResponseDefinitionBuilder response = created().withHeader("Content-Type", "application/json").withHeader("Location", this.wireMock.url("/instances/abcdef")).withBody("{ \"id\" : \"-id-\" }");
this.wireMock.stubFor(post(urlEqualTo("/instances")).willReturn(response));
assertThat(this.registrationClient.register(this.wireMock.url("/instances"), this.application)).isEqualTo("-id-");
RequestPatternBuilder expectedRequest = postRequestedFor(urlEqualTo("/instances")).withHeader("Accept", equalTo("application/json")).withHeader("Content-Type", equalTo("application/json"));
this.wireMock.verify(expectedRequest);
}
use of com.github.tomakehurst.wiremock.matching.RequestPatternBuilder in project sonar-java by SonarSource.
the class WireMockTest method verifyClient.
@Test
public void verifyClient() {
// Compliant
RequestPatternBuilder requestPatternBuilder = new RequestPatternBuilder().allRequests().withUrl("/hello/world/*");
WireMock.verify(requestPatternBuilder);
}
use of com.github.tomakehurst.wiremock.matching.RequestPatternBuilder in project sda-dropwizard-commons by SDA-SE.
the class OpaRule method verify.
@Override
void verify(int count, StubBuilder builder) {
RequestPatternBuilder requestPattern = buildRequestPattern(builder);
wireMockClassRule.verify(count, requestPattern);
}
use of com.github.tomakehurst.wiremock.matching.RequestPatternBuilder in project junit-servers by mjeanroy.
the class WireMockTestUtils method assertRequestWithHeader.
/**
* Verify that a given request has been triggered.
*
* @param endpoint Request endpoint.
* @param method Request method.
* @param headerName Header name.
* @param headerValue Header value.
*/
static void assertRequestWithHeader(String endpoint, HttpMethod method, String headerName, String headerValue) {
UrlPattern urlPattern = urlEqualTo(endpoint);
RequestMethod rqMethod = new RequestMethod(method.name());
RequestPatternBuilder rq = new RequestPatternBuilder(rqMethod, urlPattern);
rq.withHeader(headerName, equalTo(headerValue));
WireMock.verify(1, rq);
}
Aggregations