use of com.github.tomakehurst.wiremock.matching.RegexPattern in project mod-kb-ebsco-java by folio-org.
the class EholdingsPackagesTest method shouldReturn400OnGetWithResourcesWhenRMAPI400.
@Test
public void shouldReturn400OnGetWithResourcesWhenRMAPI400() throws IOException, URISyntaxException {
String stubResponseFile = "responses/rmapi/packages/get-package-resources-400-response.json";
stubFor(get(new UrlPathPattern(new RegexPattern(PACKAGE_BY_ID_URL + "/titles.*"), true)).willReturn(new ResponseDefinitionBuilder().withBody(readFile(stubResponseFile)).withStatus(SC_BAD_REQUEST)));
JsonapiError error = getWithStatus(PACKAGE_RESOURCES_PATH, SC_BAD_REQUEST, STUB_TOKEN_HEADER).as(JsonapiError.class);
assertErrorContainsTitle(error, "Parameter Count is outside the range 1-100.");
}
use of com.github.tomakehurst.wiremock.matching.RegexPattern in project mod-kb-ebsco-java by folio-org.
the class EholdingsPackagesTest method shouldReturnPackagesOnGetById.
@Test
public void shouldReturnPackagesOnGetById() throws IOException, URISyntaxException, JSONException {
mockGet(new RegexPattern(PACKAGE_BY_ID_URL), CUSTOM_PACKAGE_STUB_FILE);
String packageData = getWithOk(PACKAGES_PATH, STUB_TOKEN_HEADER).asString();
JSONAssert.assertEquals(readFile(EXPECTED_PACKAGE_BY_ID_STUB_FILE), packageData, false);
}
use of com.github.tomakehurst.wiremock.matching.RegexPattern in project mod-kb-ebsco-java by folio-org.
the class EholdingsPackagesTest method shouldReturnPackagesOnGet.
@Test
public void shouldReturnPackagesOnGet() throws IOException, URISyntaxException, JSONException {
String stubResponseFile = "responses/rmapi/packages/get-packages-response.json";
mockGet(new RegexPattern("/rm/rmaccounts/" + STUB_CUSTOMER_ID + "/packages.*"), stubResponseFile);
String packages = getWithOk(PACKAGES_ENDPOINT + "?q=American&filter[type]=abstractandindex&count=5", STUB_TOKEN_HEADER).asString();
JSONAssert.assertEquals(readFile("responses/kb-ebsco/packages/expected-package-collection-with-five-elements.json"), packages, false);
}
use of com.github.tomakehurst.wiremock.matching.RegexPattern in project mod-kb-ebsco-java by folio-org.
the class EholdingsPackagesTest method shouldReturnProviderWhenIncludedFlagIsSetToProvider.
@Test
public void shouldReturnProviderWhenIncludedFlagIsSetToProvider() throws IOException, URISyntaxException, JSONException {
mockGet(new RegexPattern(PACKAGE_BY_ID_URL), CUSTOM_PACKAGE_STUB_FILE);
mockGet(new RegexPattern("/rm/rmaccounts/" + STUB_CUSTOMER_ID + "/vendors/" + STUB_VENDOR_ID), VENDOR_BY_PACKAGE_ID_STUB_FILE);
String actual = getWithOk(PACKAGES_PATH + "?include=provider", STUB_TOKEN_HEADER).asString();
String expected = readFile("responses/kb-ebsco/packages/expected-package-by-id-with-provider.json");
JSONAssert.assertEquals(expected, actual, false);
}
use of com.github.tomakehurst.wiremock.matching.RegexPattern in project mod-kb-ebsco-java by folio-org.
the class EholdingsCustomLabelsImplTest method shouldReturn403OnGetWithResourcesWhenRMAPI401.
@Test
public void shouldReturn403OnGetWithResourcesWhenRMAPI401() {
mockGet(new RegexPattern(RM_API_CUSTOMER_PATH), SC_UNAUTHORIZED);
JsonapiError error = getWithStatus(KB_CUSTOM_LABELS_PATH, SC_FORBIDDEN, STUB_TOKEN_HEADER).as(JsonapiError.class);
assertErrorContainsTitle(error, "Unauthorized Access");
}
Aggregations