use of com.github.tomakehurst.wiremock.client.UrlMatchingStrategy in project eCRNow by drajer-health.
the class WireMockHelper method stubAuthAndMetadata.
public void stubAuthAndMetadata(Map<String, ?> otherMappings) {
Set<String> mappingKey = otherMappings.keySet();
for (String key : mappingKey) {
String url = "";
if (key.equalsIgnoreCase("default")) {
UrlMatchingStrategy urlMatchingStrategy = new UrlMatchingStrategy();
urlMatchingStrategy.setUrlPattern(baseUrl + "/.*");
wireMockServer.stubFor(any(urlMatchingStrategy).atPriority(10).willReturn(aResponse().withStatus(404).withBody(TestUtils.getFileContentAsString((String) otherMappings.get(key))).withHeader("Content-Type", "application/fhir+json; charset=utf-8")));
logger.info("Stub Created for default: /FHIR/.*");
} else if (key.equalsIgnoreCase("metadata")) {
url = baseUrl + "/" + key;
// TODO - Change to pull token url from client detail instead of hard coding.
String tokenUrl = "http://localhost:" + wireMockPort + "/FHIR/token";
String response = TestUtils.getFileContentAsString((String) otherMappings.get(key));
response = response.replace("Replace this with mock URL for test", tokenUrl);
wireMockServer.stubFor(get(urlEqualTo(url)).atPriority(1).willReturn(aResponse().withStatus(200).withBody(response).withHeader("Content-Type", "application/fhir+json; charset=utf-8")));
logger.info("Stub Created for Metadata uri: {}", url);
} else if (key.equalsIgnoreCase("token")) {
url = baseUrl + "/" + key;
wireMockServer.stubFor(post(urlEqualTo(url)).atPriority(1).willReturn(aResponse().withStatus(200).withBody(TestUtils.getFileContentAsString((String) otherMappings.get(key))).withHeader("Content-Type", "application/fhir+json; charset=utf-8")));
logger.info("Stub Created for AccessToken uri: {}", url);
}
}
}
use of com.github.tomakehurst.wiremock.client.UrlMatchingStrategy in project styx by ExpediaGroup.
the class UrlMatchingStrategies method urlStartingWith.
public static UrlMatchingStrategy urlStartingWith(String url) {
UrlMatchingStrategy urlStrategy = new UrlMatchingStrategy();
urlStrategy.setUrlPattern(url + ".*");
return urlStrategy;
}
use of com.github.tomakehurst.wiremock.client.UrlMatchingStrategy in project streamline by hortonworks.
the class AmbariInfraWithStormLogSearchTest method stubSolrUrl.
private void stubSolrUrl() throws IOException {
try (InputStream is = getClass().getResourceAsStream("/ambari-infra-log-search-output.xml")) {
String body = IOUtils.toString(is, Charset.forName("UTF-8"));
UrlMatchingStrategy strategyForWorkerLog = urlPathMatching(STUB_REQUEST_API_PATH + ".+" + AmbariInfraWithStormLogSearch.COLUMN_NAME_TYPE + "%3A" + AmbariInfraWithStormLogSearch.COLUMN_VALUE_TYPE_WORKER_LOG + ".+");
wireMockRule.stubFor(get(strategyForWorkerLog).willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/xml; charset=UTF-8").withHeader("Transfer-Encoding", "chunked").withBody(body)));
}
try (InputStream is = getClass().getResourceAsStream("/ambari-infra-event-search-output.xml")) {
String body = IOUtils.toString(is, Charset.forName("UTF-8"));
UrlMatchingStrategy strategyForWorkerLog = urlPathMatching(STUB_REQUEST_API_PATH + ".+" + AmbariInfraWithStormLogSearch.COLUMN_NAME_TYPE + "%3A" + AmbariInfraWithStormLogSearch.COLUMN_VALUE_TYPE_EVENT + ".+");
wireMockRule.stubFor(get(strategyForWorkerLog).willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/xml; charset=UTF-8").withHeader("Transfer-Encoding", "chunked").withBody(body)));
}
}
use of com.github.tomakehurst.wiremock.client.UrlMatchingStrategy in project styx by ExpediaGroup.
the class UrlMatchingStrategies method urlEndingWith.
public static UrlMatchingStrategy urlEndingWith(String url) {
UrlMatchingStrategy urlStrategy = new UrlMatchingStrategy();
urlStrategy.setUrlPattern(".*" + url);
return urlStrategy;
}
Aggregations