use of com.github.tomakehurst.wiremock.matching.UrlPathPattern in project mod-kb-ebsco-java by folio-org.
the class EholdingsPackagesTest method shouldReturnPackagesAndFailedIdsOnFetchPackagesInBulk.
@Test
public void shouldReturnPackagesAndFailedIdsOnFetchPackagesInBulk() throws IOException, URISyntaxException, JSONException {
mockGet(new RegexPattern(PACKAGE_BY_ID_URL), PACKAGE_STUB_FILE);
mockGet(new RegexPattern(PACKAGE_BY_ID_2_URL), PACKAGE_2_STUB_FILE);
String notFoundResponse = "responses/rmapi/packages/get-package-by-id-not-found-response.json";
stubFor(get(new UrlPathPattern(new EqualToPattern(PACKAGES_STUB_URL + "/9999999"), false)).willReturn(new ResponseDefinitionBuilder().withBody(readFile(notFoundResponse)).withStatus(404)));
String postBody = readFile("requests/kb-ebsco/package/post-packages-bulk-with-non-existing-id.json");
final String actualResponse = postWithOk(PACKAGES_BULK_FETCH_PATH, postBody, STUB_TOKEN_HEADER).asString();
JSONAssert.assertEquals(readFile("responses/kb-ebsco/packages/expected-post-packages-bulk-with-failed-id.json"), actualResponse, false);
}
use of com.github.tomakehurst.wiremock.matching.UrlPathPattern in project mod-kb-ebsco-java by folio-org.
the class EholdingsResourcesImplTest method shouldReturnUpdatedValuesManagedResourceOnSuccessfulPut.
@Test
public void shouldReturnUpdatedValuesManagedResourceOnSuccessfulPut() throws IOException, URISyntaxException, JSONException {
String stubResponseFile = "responses/rmapi/resources/get-managed-resource-updated-response.json";
String expectedResourceFile = "responses/kb-ebsco/resources/expected-managed-resource.json";
String actualResponse = mockUpdateResourceScenario(stubResponseFile, MANAGED_RESOURCE_ENDPOINT, STUB_MANAGED_RESOURCE_ID, readFile("requests/kb-ebsco/resource/put-managed-resource.json"));
JSONAssert.assertEquals(readFile(expectedResourceFile), actualResponse, false);
verify(1, putRequestedFor(new UrlPathPattern(new RegexPattern(MANAGED_RESOURCE_ENDPOINT), true)).withRequestBody(equalToJson(readFile("requests/rmapi/resources/put-managed-resource-is-selected-multiple-attributes.json"))));
}
use of com.github.tomakehurst.wiremock.matching.UrlPathPattern in project mod-kb-ebsco-java by folio-org.
the class EholdingsResourcesImplTest method mockUpdateResourceScenario.
private String mockUpdateResourceScenario(String updatedResourceResponseFile, String resourceEndpoint, String resourceId, String requestBody) throws IOException, URISyntaxException {
stubFor(get(new UrlPathPattern(new RegexPattern(resourceEndpoint), false)).willReturn(new ResponseDefinitionBuilder().withBody(readFile(updatedResourceResponseFile))));
stubFor(put(new UrlPathPattern(new RegexPattern(resourceEndpoint), true)).willReturn(new ResponseDefinitionBuilder().withStatus(SC_NO_CONTENT)));
return putWithOk("eholdings/resources/" + resourceId, requestBody, STUB_TOKEN_HEADER).asString();
}
use of com.github.tomakehurst.wiremock.matching.UrlPathPattern in project mod-kb-ebsco-java by folio-org.
the class EholdingsResourcesImplTest method shouldDeleteAccessTypeMappingOnSuccessfulPut.
@Test
public void shouldDeleteAccessTypeMappingOnSuccessfulPut() throws IOException, URISyntaxException, JSONException {
List<AccessType> accessTypes = insertAccessTypes(testData(configuration.getId()), vertx);
String accessTypeId = accessTypes.get(0).getId();
insertAccessTypeMapping(STUB_MANAGED_RESOURCE_ID, RESOURCE, accessTypeId, vertx);
String stubResponseFile = "responses/rmapi/resources/get-managed-resource-updated-response.json";
String expectedResourceFile = "responses/kb-ebsco/resources/expected-managed-resource.json";
String actualResponse = mockUpdateResourceScenario(stubResponseFile, MANAGED_RESOURCE_ENDPOINT, STUB_MANAGED_RESOURCE_ID, readFile("requests/kb-ebsco/resource/put-managed-resource.json"));
JSONAssert.assertEquals(readFile(expectedResourceFile), actualResponse, false);
verify(1, putRequestedFor(new UrlPathPattern(new RegexPattern(MANAGED_RESOURCE_ENDPOINT), true)).withRequestBody(equalToJson(readFile("requests/rmapi/resources/put-managed-resource-is-selected-multiple-attributes.json"))));
List<AccessTypeMapping> accessTypeMappingsInDB = getAccessTypeMappings(vertx);
assertEquals(0, accessTypeMappingsInDB.size());
}
use of com.github.tomakehurst.wiremock.matching.UrlPathPattern in project mod-kb-ebsco-java by folio-org.
the class EholdingsStatusTest method shouldReturnTrueWhenRMAPIRequestCompletesWith200Status.
@Test
public void shouldReturnTrueWhenRMAPIRequestCompletesWith200Status() throws IOException, URISyntaxException {
setupDefaultKBConfiguration(getWiremockUrl(), vertx);
stubFor(get(new UrlPathPattern(new RegexPattern("/rm/rmaccounts.*"), true)).willReturn(new ResponseDefinitionBuilder().withBody(readFile("responses/rmapi/vendors/get-zero-vendors-response.json"))));
final ConfigurationStatus status = getWithOk(EHOLDINGS_STATUS_PATH, STUB_TOKEN_HEADER).as(ConfigurationStatus.class);
assertThat(status.getData().getAttributes().getIsConfigurationValid(), equalTo(true));
}
Aggregations