use of com.github.tomakehurst.wiremock.matching.RequestPatternBuilder in project dsbulk by datastax.
the class PrometheusManagerTest method should_push_metrics_to_gateway.
@ParameterizedTest
@MethodSource
@ExtendWith(WiremockResolver.class)
void should_push_metrics_to_gateway(boolean success, boolean groupByInstance, boolean groupByOperationId, ImmutableMap<String, String> groupingKeys, String pathRegex, @Wiremock WireMockServer server) throws MalformedURLException {
// given
PushConfig pushConfig = new PushConfig(new URL(server.baseUrl()), "user1", "password1", groupByInstance, groupByOperationId, groupingKeys);
PrometheusManager manager = new PrometheusManager(registry, "execution1", "job1", ImmutableMap.of("name1", "value1"), null, pushConfig);
server.givenThat(post(urlPathEqualTo(pathRegex)).willReturn(aResponse().withStatus(201)));
// when
manager.init();
registry.counter("records/total").inc(123456);
manager.pushMetrics(Duration.ofSeconds(123), success);
// then
String version = WorkflowUtils.getBulkLoaderVersion();
String driverVersion = Session.OSS_DRIVER_COORDINATES.getVersion().toString();
String expectedLabelsAsString = "{name1=\"value1\",application_version=\"" + version + "\",application_name=\"DataStax Bulk Loader execution1\",client_id=\"de13b396-eb09-31d1-9876-cba56b790be0\",driver_version=\"" + driverVersion + "\",operation_id=\"execution1\",job=\"job1\",}";
RequestPatternBuilder builder = postRequestedFor(urlPathMatching(pathRegex)).withHeader("Content-Type", containing("text/plain")).withHeader("Authorization", equalTo("Basic dXNlcjE6cGFzc3dvcmQx")).withRequestBody(containing("dsbulk_elapsed_time_seconds" + expectedLabelsAsString + " 123.0")).withRequestBody(containing("dsbulk_records_total" + expectedLabelsAsString + " 123456.0"));
if (success) {
builder = builder.withRequestBody(containing("dsbulk_success" + expectedLabelsAsString + " 1.0")).withRequestBody(containing("dsbulk_last_success" + expectedLabelsAsString));
} else {
builder = builder.withRequestBody(containing("dsbulk_success" + expectedLabelsAsString + " 0.0")).withRequestBody(notMatching(".*dsbulk_last_success.*"));
}
server.verify(builder);
}
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 mule-oauth-module by mulesoft.
the class AbstractOAuthAuthorizationTestCase method verifyRequestDoneToTokenUrlForAuthorizationCode.
protected void verifyRequestDoneToTokenUrlForAuthorizationCode(boolean requestThroughProxy) throws UnsupportedEncodingException {
final RequestPatternBuilder verification = postRequestedFor(urlEqualTo(TOKEN_PATH)).withRequestBody(containing(CLIENT_ID_PARAMETER + "=" + encode(clientId.getValue(), UTF_8.name()))).withRequestBody(containing(CODE_PARAMETER + "=" + encode(AUTHENTICATION_CODE, UTF_8.name()))).withRequestBody(containing(CLIENT_SECRET_PARAMETER + "=" + encode(clientSecret.getValue(), UTF_8.name()))).withRequestBody(containing(GRANT_TYPE_PARAMETER + "=" + encode(GRANT_TYPE_AUTHENTICATION_CODE, UTF_8.name()))).withRequestBody(containing(REDIRECT_URI_PARAMETER + "=" + encode(localCallbackUrl.getValue(), UTF_8.name())));
if (requestThroughProxy) {
verification.withHeader(PROXY_CONNECTION_HEADER, containing(KEEP_ALIVE));
proxyWireMockRule.verify(postRequestedFor(urlEqualTo(TOKEN_PATH)));
}
wireMockRule.verify(verification);
}
Aggregations