use of com.github.tomakehurst.wiremock.matching.UrlPathPattern in project cos-fleetshard by bf2fc6cc711aee1a0c2a.
the class WireMockServer method stubMatching.
public void stubMatching(RequestMethod method, String pattern, ContentPattern<?> content, Consumer<ResponseDefinitionBuilder> consumer) {
UrlPathPattern matcher = WireMock.urlPathMatching(pattern);
MappingBuilder request = WireMock.request(method.getName(), matcher).withRequestBody(content);
ResponseDefinitionBuilder response = WireMock.aResponse();
consumer.accept(response);
stubFor(request.willReturn(response));
}
use of com.github.tomakehurst.wiremock.matching.UrlPathPattern in project cos-fleetshard by bf2fc6cc711aee1a0c2a.
the class WireMockServer method stubMatching.
public void stubMatching(RequestMethod method, String pattern, Consumer<MappingBuilder> mappingConsumer, Consumer<ResponseDefinitionBuilder> consumer) {
UrlPathPattern matcher = WireMock.urlPathMatching(pattern);
MappingBuilder request = WireMock.request(method.getName(), matcher);
mappingConsumer.accept(request);
ResponseDefinitionBuilder response = WireMock.aResponse();
consumer.accept(response);
stubFor(request.willReturn(response));
}
use of com.github.tomakehurst.wiremock.matching.UrlPathPattern in project cos-fleetshard by bf2fc6cc711aee1a0c2a.
the class WireMockServer method stubPathEquals.
public void stubPathEquals(RequestMethod method, String pattern, Consumer<ResponseDefinitionBuilder> consumer) {
UrlPathPattern matcher = WireMock.urlPathEqualTo(pattern);
MappingBuilder request = WireMock.request(method.getName(), matcher);
ResponseDefinitionBuilder response = WireMock.aResponse();
consumer.accept(response);
stubFor(request.willReturn(response));
}
use of com.github.tomakehurst.wiremock.matching.UrlPathPattern in project cos-fleetshard by bf2fc6cc711aee1a0c2a.
the class AuthUrlTest method namespaceIsProvisioned.
@Test
void namespaceIsProvisioned() {
UrlPathPattern cosUrl = urlPathMatching("/api/connector_mgmt/v1/agent/kafka_connector_clusters/.*/namespaces");
UrlPathPattern ssoUrl = urlPathMatching("/api/kafkas_mgmt/v1/sso_providers");
given().contentType(MediaType.TEXT_PLAIN).body(0L).post("/test/provisioner/namespaces");
untilAsserted(() -> {
server.verify(exactly(1), getRequestedFor(cosUrl));
server.verify(exactly(1), getRequestedFor(ssoUrl));
});
untilAsserted(() -> {
given().contentType(MediaType.TEXT_PLAIN).body(0L).post("/test/provisioner/namespaces");
server.verify(moreThanOrExactly(2), getRequestedFor(cosUrl));
server.verify(moreThanOrExactly(2), getRequestedFor(ssoUrl));
});
}
use of com.github.tomakehurst.wiremock.matching.UrlPathPattern in project mod-source-record-manager by folio-org.
the class RecordProcessedEventHandlingServiceImplTest method setUp.
@Before
public void setUp() throws IOException {
String[] hostAndPort = kafkaCluster.getBrokerList().split(":");
kafkaConfig = KafkaConfig.builder().kafkaHost(hostAndPort[0]).kafkaPort(hostAndPort[1]).envId(KAFKA_ENV_ID).build();
String rules = TestUtil.readFileFromPath(RULES_PATH);
MockitoAnnotations.openMocks(this);
mappingRuleCache = new MappingRuleCache(mappingRuleDao, vertx);
marcRecordAnalyzer = new MarcRecordAnalyzer();
mappingRuleService = new MappingRuleServiceImpl(mappingRuleDao, mappingRuleCache);
mappingRuleDao = when(mock(MappingRuleDaoImpl.class).get(any(), anyString())).thenReturn(Future.succeededFuture(Optional.of(new JsonObject(rules)))).getMock();
mappingParametersProvider = when(mock(MappingParametersProvider.class).get(anyString(), any(OkapiConnectionParams.class))).thenReturn(Future.succeededFuture(new MappingParameters())).getMock();
mappingMetadataService = new MappingMetadataServiceImpl(mappingParametersProvider, mappingRuleService, mappingRulesSnapshotDao, mappingParamsSnapshotDao);
changeEngineService = new ChangeEngineServiceImpl(jobExecutionSourceChunkDao, jobExecutionService, marcRecordAnalyzer, hrIdFieldService, recordsPublishingService, mappingMetadataService, kafkaConfig);
ReflectionTestUtils.setField(changeEngineService, "maxDistributionNum", 10);
ReflectionTestUtils.setField(changeEngineService, "batchSize", 100);
chunkProcessingService = new EventDrivenChunkProcessingServiceImpl(jobExecutionSourceChunkDao, jobExecutionService, changeEngineService, jobExecutionProgressService);
recordProcessedEventHandlingService = new RecordProcessedEventHandlingServiceImpl(jobExecutionProgressService, jobExecutionService, journalService, jobMonitoringService);
HashMap<String, String> headers = new HashMap<>();
headers.put(OKAPI_URL_HEADER, "http://localhost:" + snapshotMockServer.port());
headers.put(OKAPI_TENANT_HEADER, TENANT_ID);
headers.put(OKAPI_TOKEN_HEADER, "token");
params = new OkapiConnectionParams(headers, vertx);
WireMock.stubFor(post(RECORDS_SERVICE_URL).willReturn(created().withTransformers(RequestToResponseTransformer.NAME)));
WireMock.stubFor(get(new UrlPathPattern(new RegexPattern("/data-import-profiles/jobProfiles/" + ".*"), true)).willReturn(ok().withBody(JsonObject.mapFrom(jobProfile).encode())));
}
Aggregations