use of com.github.tomakehurst.wiremock.matching.RegexPattern in project mod-kb-ebsco-java by folio-org.
the class EholdingsResourcesImplTest method shouldReturnUpdatedValuesCustomResourceOnSuccessfulPut.
@Test
public void shouldReturnUpdatedValuesCustomResourceOnSuccessfulPut() throws IOException, URISyntaxException, JSONException {
String stubResponseFile = "responses/rmapi/resources/get-custom-resource-updated-response.json";
String expectedResourceFile = "responses/kb-ebsco/resources/expected-custom-resource.json";
String actualResponse = mockUpdateResourceScenario(stubResponseFile, CUSTOM_RESOURCE_ENDPOINT, STUB_CUSTOM_RESOURCE_ID, readFile("requests/kb-ebsco/resource/put-custom-resource.json"));
JSONAssert.assertEquals(readFile(expectedResourceFile), actualResponse, false);
verify(1, putRequestedFor(new UrlPathPattern(new RegexPattern(CUSTOM_RESOURCE_ENDPOINT), true)).withRequestBody(equalToJson(readFile("requests/rmapi/resources/put-custom-resource-is-selected-multiple-attributes.json"))));
}
use of com.github.tomakehurst.wiremock.matching.RegexPattern in project mod-kb-ebsco-java by folio-org.
the class EholdingsResourcesImplTest method shouldReturnErrorWhenRMApiFails.
@Test
public void shouldReturnErrorWhenRMApiFails() throws IOException, URISyntaxException {
mockGet(new RegexPattern(MANAGED_PACKAGE_ENDPOINT + "/titles.*"), SC_INTERNAL_SERVER_ERROR);
String postBody = readFile("requests/kb-ebsco/resource/post-resources-bulk.json");
final ResourceBulkFetchCollection bulkFetchCollection = postWithOk(RESOURCES_BULK_FETCH, postBody, STUB_TOKEN_HEADER).as(ResourceBulkFetchCollection.class);
assertThat(bulkFetchCollection.getIncluded().size(), equalTo(0));
assertThat(bulkFetchCollection.getMeta().getFailed().getResources().size(), equalTo(1));
assertThat(bulkFetchCollection.getMeta().getFailed().getResources().get(0), equalTo("19-3964-762169"));
}
use of com.github.tomakehurst.wiremock.matching.RegexPattern in project mod-kb-ebsco-java by folio-org.
the class EholdingsStatusTest method shouldReturnFalseWhenRMAPIRequestCompletesWithErrorStatus.
@Test
public void shouldReturnFalseWhenRMAPIRequestCompletesWithErrorStatus() {
setupDefaultKBConfiguration(getWiremockUrl(), vertx);
stubFor(get(new UrlPathPattern(new RegexPattern("/rm/rmaccounts.*"), true)).willReturn(new ResponseDefinitionBuilder().withStatus(401)));
final ConfigurationStatus status = getWithOk(EHOLDINGS_STATUS_PATH, STUB_TOKEN_HEADER).as(ConfigurationStatus.class);
assertThat(status.getData().getAttributes().getIsConfigurationValid(), equalTo(false));
}
use of com.github.tomakehurst.wiremock.matching.RegexPattern in project mod-kb-ebsco-java by folio-org.
the class EholdingsStatusTest method shouldReturnErrorWhenRMAPIRequestCompletesWith429.
@Test
public void shouldReturnErrorWhenRMAPIRequestCompletesWith429() {
setupDefaultKBConfiguration(getWiremockUrl(), vertx);
stubFor(get(new UrlPathPattern(new RegexPattern("/rm/rmaccounts.*"), true)).willReturn(new ResponseDefinitionBuilder().withStatus(429).withBody("{\n" + " \"Errors\": [\n" + " {\n" + " \"Code\": 1010,\n" + " \"Message\": \"Too Many Requests.\",\n" + " \"SubCode\": 0\n" + " }\n" + " ]\n" + "}")));
final JsonapiError error = getWithStatus(EHOLDINGS_STATUS_PATH, 429, STUB_TOKEN_HEADER).as(JsonapiError.class);
AssertTestUtil.assertErrorContainsTitle(error, "Too Many Requests");
}
use of com.github.tomakehurst.wiremock.matching.RegexPattern in project mod-kb-ebsco-java by folio-org.
the class EholdingsTitlesTest method shouldReturn500WhenRMApiReturns500Error.
@Test
public void shouldReturn500WhenRMApiReturns500Error() {
stubFor(get(new UrlPathPattern(new RegexPattern("/rm/rmaccounts/" + STUB_CUSTOMER_ID + "/titles.*"), true)).willReturn(new ResponseDefinitionBuilder().withStatus(500)));
JsonapiError error = getWithStatus(EHOLDINGS_TITLES_PATH + "?filter[name]=news", SC_INTERNAL_SERVER_ERROR, STUB_TOKEN_HEADER).as(JsonapiError.class);
assertErrorContainsTitle(error, "Invalid RMAPI response");
}
Aggregations