use of com.github.tomakehurst.wiremock.matching.UrlPathPattern in project mod-kb-ebsco-java by folio-org.
the class EholdingsResourcesImplTest method shouldReturn400OnPutPackageWithNotExistedAccessType.
@Test
public void shouldReturn400OnPutPackageWithNotExistedAccessType() throws URISyntaxException, IOException {
String requestBody = readFile("requests/kb-ebsco/resource/put-managed-resource-with-missing-access-type.json");
JsonapiError error = putWithStatus(STUB_MANAGED_RESOURCE_PATH, requestBody, SC_BAD_REQUEST, CONTENT_TYPE_HEADER, STUB_TOKEN_HEADER).as(JsonapiError.class);
verify(0, putRequestedFor(new UrlPathPattern(new RegexPattern(MANAGED_RESOURCE_ENDPOINT), true)));
assertErrorContainsTitle(error, "Access type not found: id = 99999999-9999-1999-a999-999999999999");
}
use of com.github.tomakehurst.wiremock.matching.UrlPathPattern 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.UrlPathPattern in project mod-kb-ebsco-java by folio-org.
the class EholdingsResourcesImplTest method shouldSendDeleteRequestForResourceAssociatedWithCustomPackage.
@Test
public void shouldSendDeleteRequestForResourceAssociatedWithCustomPackage() throws IOException, URISyntaxException {
EqualToJsonPattern putBodyPattern = new EqualToJsonPattern("{\"isSelected\":false}", true, true);
deleteResource(putBodyPattern);
verify(1, putRequestedFor(new UrlPathPattern(new EqualToPattern(CUSTOM_RESOURCE_ENDPOINT), false)).withRequestBody(putBodyPattern));
}
use of com.github.tomakehurst.wiremock.matching.UrlPathPattern 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.UrlPathPattern 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");
}
Aggregations