use of com.github.tomakehurst.wiremock.matching.RegexPattern in project mod-kb-ebsco-java by folio-org.
the class EholdingsProvidersImplTest method shouldReturn404WhenNonProviderIdNotFound.
@Test
public void shouldReturn404WhenNonProviderIdNotFound() {
String rmapiInvalidProviderIdUrl = "/rm/rmaccounts/" + STUB_CUSTOMER_ID + "/vendors/191919/packages";
mockGet(new RegexPattern(rmapiInvalidProviderIdUrl), SC_NOT_FOUND);
JsonapiError error = getWithStatus("/eholdings/providers/191919/packages", SC_NOT_FOUND, STUB_TOKEN_HEADER).as(JsonapiError.class);
assertErrorContainsTitle(error, "Provider not found");
}
use of com.github.tomakehurst.wiremock.matching.RegexPattern in project mod-kb-ebsco-java by folio-org.
the class EholdingsProvidersImplTest method shouldReturnEmptyResponseWhenPackagesReturnedWithErrorOnSearchByAccessType.
@Test
public void shouldReturnEmptyResponseWhenPackagesReturnedWithErrorOnSearchByAccessType() {
List<AccessType> accessTypes = insertAccessTypes(testData(configuration.getId()), vertx);
insertAccessTypeMapping(FULL_PACKAGE_ID, PACKAGE, accessTypes.get(0).getId(), vertx);
insertAccessTypeMapping(FULL_PACKAGE_ID_4, PACKAGE, accessTypes.get(0).getId(), vertx);
mockGet(new RegexPattern(".*vendors/.*/packages/.*"), SC_INTERNAL_SERVER_ERROR);
String resourcePath = PROVIDER_PACKAGES + "?filter[access-type]=" + STUB_ACCESS_TYPE_NAME;
PackageCollection packageCollection = getWithOk(resourcePath, STUB_TOKEN_HEADER).as(PackageCollection.class);
List<PackageCollectionItem> packages = packageCollection.getData();
assertEquals(2, (int) packageCollection.getMeta().getTotalResults());
assertEquals(0, packages.size());
}
use of com.github.tomakehurst.wiremock.matching.RegexPattern in project mod-kb-ebsco-java by folio-org.
the class EholdingsResourcesImplTest method shouldReturn404WhenRMAPINotFoundOnResourceGet.
@Test
public void shouldReturn404WhenRMAPINotFoundOnResourceGet() throws IOException, URISyntaxException {
String stubResponseFile = "responses/rmapi/resources/get-resource-by-id-not-found-response.json";
stubFor(get(new UrlPathPattern(new RegexPattern(MANAGED_PACKAGE_ENDPOINT + "/titles.*"), true)).willReturn(new ResponseDefinitionBuilder().withBody(readFile(stubResponseFile)).withStatus(404)));
JsonapiError error = getWithStatus(STUB_MANAGED_RESOURCE_PATH, SC_NOT_FOUND, STUB_TOKEN_HEADER).as(JsonapiError.class);
assertErrorContainsTitle(error, "Title is no longer in this package.");
}
use of com.github.tomakehurst.wiremock.matching.RegexPattern in project mod-kb-ebsco-java by folio-org.
the class EholdingsResourcesImplTest method shouldDeselectManagedResourceOnPutWithSelectedFalse.
@Test
public void shouldDeselectManagedResourceOnPutWithSelectedFalse() throws IOException, URISyntaxException, JSONException {
String stubResponseFile = "responses/rmapi/resources/get-managed-resource-updated-response-is-selected-false.json";
String expectedResourceFile = "responses/kb-ebsco/resources/expected-managed-resource.json";
ResourcePutRequest request = readJsonFile("requests/kb-ebsco/resource/put-managed-resource-is-not-selected.json", ResourcePutRequest.class);
request.getData().getAttributes().setIsSelected(false);
String actualResponse = mockUpdateResourceScenario(stubResponseFile, MANAGED_RESOURCE_ENDPOINT, STUB_MANAGED_RESOURCE_ID, Json.encode(request));
Resource expectedResource = readJsonFile(expectedResourceFile, Resource.class);
expectedResource.getData().getAttributes().setIsSelected(false);
JSONAssert.assertEquals(Json.encode(expectedResource), actualResponse, false);
verify(1, putRequestedFor(new UrlPathPattern(new RegexPattern(MANAGED_RESOURCE_ENDPOINT), true)).withRequestBody(new EqualToJsonPattern(readFile("requests/rmapi/resources/put-managed-resource-is-not-selected.json"), true, true)));
}
use of com.github.tomakehurst.wiremock.matching.RegexPattern in project mod-kb-ebsco-java by folio-org.
the class EholdingsResourcesImplTest method shouldCreateNewAccessTypeMappingOnSuccessfulPut.
@Test
public void shouldCreateNewAccessTypeMappingOnSuccessfulPut() throws IOException, URISyntaxException, JSONException {
List<AccessType> accessTypes = insertAccessTypes(testData(configuration.getId()), vertx);
String accessTypeId = accessTypes.get(0).getId();
String stubResponseFile = "responses/rmapi/resources/get-managed-resource-updated-response.json";
String expectedResourceFile = "responses/kb-ebsco/resources/expected-resource-by-id-with-access-type.json";
String requestBody = format(readFile("requests/kb-ebsco/resource/put-resource-with-access-type.json"), accessTypeId);
String actualResponse = mockUpdateResourceScenario(stubResponseFile, MANAGED_RESOURCE_ENDPOINT, STUB_MANAGED_RESOURCE_ID, requestBody);
String expectedJson = format(readFile(expectedResourceFile), accessTypeId, accessTypeId);
JSONAssert.assertEquals(expectedJson, 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(1, accessTypeMappingsInDB.size());
assertEquals(accessTypeId, accessTypeMappingsInDB.get(0).getAccessTypeId().toString());
assertEquals(RESOURCE, accessTypeMappingsInDB.get(0).getRecordType());
}
Aggregations