use of com.github.tomakehurst.wiremock.matching.RegexPattern in project mod-kb-ebsco-java by folio-org.
the class EholdingsPackagesTest method shouldReturnPackageWithTagOnGetById.
@Test
public void shouldReturnPackageWithTagOnGetById() throws IOException, URISyntaxException {
String packageId = FULL_PACKAGE_ID;
saveTag(vertx, packageId, PACKAGE, STUB_TAG_VALUE);
mockGet(new RegexPattern(PACKAGE_BY_ID_URL), CUSTOM_PACKAGE_STUB_FILE);
Package packageData = getWithOk(PACKAGES_ENDPOINT + "/" + packageId, STUB_TOKEN_HEADER).as(Package.class);
assertTrue(packageData.getData().getAttributes().getTags().getTagList().contains(STUB_TAG_VALUE));
}
use of com.github.tomakehurst.wiremock.matching.RegexPattern in project mod-kb-ebsco-java by folio-org.
the class EholdingsPackagesTest method shouldReturn422OnPutWhenCustomPackageUpdateLikeNotCustom.
@Test
public void shouldReturn422OnPutWhenCustomPackageUpdateLikeNotCustom() throws URISyntaxException, IOException {
String putBody = readFile("requests/kb-ebsco/package/put-package-selected.json");
mockGet(new RegexPattern(PACKAGE_BY_ID_URL), CUSTOM_PACKAGE_STUB_FILE);
JsonapiError error = putWithStatus(PACKAGES_PATH, putBody, SC_UNPROCESSABLE_ENTITY, CONTENT_TYPE_HEADER, STUB_TOKEN_HEADER).as(JsonapiError.class);
verify(0, putRequestedFor(PACKAGE_URL_PATTERN));
assertErrorContainsTitle(error, "Package isCustom not matched");
}
use of com.github.tomakehurst.wiremock.matching.RegexPattern in project mod-kb-ebsco-java by folio-org.
the class EholdingsPackagesTest method shouldReturn400WhenPackagePostDataIsInvalid.
@Test
public void shouldReturn400WhenPackagePostDataIsInvalid() throws URISyntaxException, IOException {
String providerStubResponseFile = "responses/rmapi/packages/get-package-provider-by-id.json";
String packagePostStubRequestFile = "requests/kb-ebsco/package/post-package-request.json";
String response = "responses/rmapi/packages/post-package-400-error-response.json";
EqualToJsonPattern postBodyPattern = new EqualToJsonPattern("{\n \"contentType\" : 1,\n \"packageName\" : \"TEST_NAME\",\n \"customCoverage\" : {\n \"beginCoverage\" : \"2017-12-23\",\n \"endCoverage\" : \"2018-03-30\"\n }\n}", false, true);
mockGet(new RegexPattern("/rm/rmaccounts/" + STUB_CUSTOMER_ID + "/vendors.*"), providerStubResponseFile);
mockPost(new EqualToPattern(PACKAGES_STUB_URL), postBodyPattern, response, SC_BAD_REQUEST);
RestAssured.given().spec(getRequestSpecification()).header(STUB_TOKEN_HEADER).body(readFile(packagePostStubRequestFile)).when().post(PACKAGES_ENDPOINT).then().statusCode(SC_BAD_REQUEST);
}
use of com.github.tomakehurst.wiremock.matching.RegexPattern in project mod-kb-ebsco-java by folio-org.
the class EholdingsPackagesTest method shouldReturnPackageWithAccessTypeOnGetById.
@Test
public void shouldReturnPackageWithAccessTypeOnGetById() throws IOException, URISyntaxException {
List<AccessType> accessTypes = insertAccessTypes(testData(configuration.getId()), vertx);
String expectedAccessTypeId = accessTypes.get(0).getId();
insertAccessTypeMapping(FULL_PACKAGE_ID, PACKAGE, expectedAccessTypeId, vertx);
mockGet(new RegexPattern(PACKAGE_BY_ID_URL), CUSTOM_PACKAGE_STUB_FILE);
Package packageData = getWithOk(PACKAGES_ENDPOINT + "/" + FULL_PACKAGE_ID, STUB_TOKEN_HEADER).as(Package.class);
assertNotNull(packageData.getIncluded());
assertEquals(expectedAccessTypeId, packageData.getData().getRelationships().getAccessType().getData().getId());
assertEquals(expectedAccessTypeId, ((LinkedHashMap<?, ?>) packageData.getIncluded().get(0)).get("id"));
}
use of com.github.tomakehurst.wiremock.matching.RegexPattern in project mod-kb-ebsco-java by folio-org.
the class EholdingsProvidersImplTest method shouldReturnEmptyPackageListWhenNoProviderPackagesAreFound.
@Test
public void shouldReturnEmptyPackageListWhenNoProviderPackagesAreFound() throws IOException, URISyntaxException {
String packageStubResponseFile = "responses/rmapi/packages/get-packages-by-provider-id-empty.json";
mockGet(new RegexPattern(PROVIDER_PACKAGES_RM_API_PATH), packageStubResponseFile);
PackageCollection packages = getWithOk(PROVIDER_PACKAGES, STUB_TOKEN_HEADER).as(PackageCollection.class);
assertThat(packages.getData(), empty());
assertEquals(0, (int) packages.getMeta().getTotalResults());
}
Aggregations