Search in sources :

Example 1 with JsonapiError

use of org.folio.rest.jaxrs.model.JsonapiError in project mod-kb-ebsco-java by folio-org.

the class EholdingsUsageConsolidationImplTest method shouldReturn422WhenUCCredentialNotExist.

@Test
public void shouldReturn422WhenUCCredentialNotExist() {
    clearDataFromTable(vertx, UC_CREDENTIALS_TABLE_NAME);
    String resourcePath = String.format(UC_SETTINGS_ENDPOINT, credentialsId);
    String postBody = Json.encode(getPostRequest());
    JsonapiError error = postWithStatus(resourcePath, postBody, SC_UNPROCESSABLE_ENTITY, JOHN_TOKEN_HEADER).as(JsonapiError.class);
    String expectedErrorMessage = "Invalid UC API Credentials";
    assertErrorContainsTitle(error, expectedErrorMessage);
}
Also used : JsonapiError(org.folio.rest.jaxrs.model.JsonapiError) Test(org.junit.Test)

Example 2 with JsonapiError

use of org.folio.rest.jaxrs.model.JsonapiError in project mod-kb-ebsco-java by folio-org.

the class EholdingsUsageConsolidationImplTest method shouldReturn401WhenAuthTokenExpired.

@Test
public void shouldReturn401WhenAuthTokenExpired() {
    mockAuthToken();
    mockFailed401Verification();
    setUpUCCredentials(vertx);
    String resourcePath = String.format(UC_SETTINGS_ENDPOINT, credentialsId);
    String postBody = Json.encode(getPostRequest());
    JsonapiError error = postWithStatus(resourcePath, postBody, SC_UNAUTHORIZED).as(JsonapiError.class);
    assertErrorContainsTitle(error, "Invalid token");
}
Also used : JsonapiError(org.folio.rest.jaxrs.model.JsonapiError) Test(org.junit.Test)

Example 3 with JsonapiError

use of org.folio.rest.jaxrs.model.JsonapiError in project mod-kb-ebsco-java by folio-org.

the class LoadHoldingsStatusImplTest method shouldReturn404WhenNoKbCredentialsFound.

@Test
public void shouldReturn404WhenNoKbCredentialsFound() {
    final String url = String.format(HOLDINGS_LOAD_STATUS_BY_ID_URL, UUID.randomUUID().toString());
    final JsonapiError error = getWithStatus(url, SC_NOT_FOUND, JOHN_TOKEN_HEADER).as(JsonapiError.class);
    assertThat(error.getErrors().get(0).getTitle(), containsString("not exist"));
}
Also used : JsonapiError(org.folio.rest.jaxrs.model.JsonapiError) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Example 4 with JsonapiError

use of org.folio.rest.jaxrs.model.JsonapiError in project mod-kb-ebsco-java by folio-org.

the class EholdingsPackagesTest method shouldReturn422OnPutWhenUnselectNonCustomPackageIsHidden.

@Test
public void shouldReturn422OnPutWhenUnselectNonCustomPackageIsHidden() throws URISyntaxException, IOException {
    String putBody = readFile("requests/kb-ebsco/package/put-package-not-selected-non-empty-fields.json");
    mockGet(new RegexPattern(PACKAGE_BY_ID_URL), 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, "Invalid visibilityData.isHidden");
}
Also used : RegexPattern(com.github.tomakehurst.wiremock.matching.RegexPattern) JsonapiError(org.folio.rest.jaxrs.model.JsonapiError) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Example 5 with JsonapiError

use of org.folio.rest.jaxrs.model.JsonapiError 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");
}
Also used : RegexPattern(com.github.tomakehurst.wiremock.matching.RegexPattern) JsonapiError(org.folio.rest.jaxrs.model.JsonapiError) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Aggregations

JsonapiError (org.folio.rest.jaxrs.model.JsonapiError)135 Test (org.junit.Test)133 Matchers.containsString (org.hamcrest.Matchers.containsString)53 RegexPattern (com.github.tomakehurst.wiremock.matching.RegexPattern)31 ResponseDefinitionBuilder (com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder)12 UrlPathPattern (com.github.tomakehurst.wiremock.matching.UrlPathPattern)9 KbCredentials (org.folio.rest.jaxrs.model.KbCredentials)8 KbCredentialsPatchRequest (org.folio.rest.jaxrs.model.KbCredentialsPatchRequest)8 KbCredentialsTestUtil.getKbCredentials (org.folio.util.KbCredentialsTestUtil.getKbCredentials)8 KbCredentialsTestUtil.saveKbCredentials (org.folio.util.KbCredentialsTestUtil.saveKbCredentials)8 KbCredentialsPutRequest (org.folio.rest.jaxrs.model.KbCredentialsPutRequest)7 AccessType (org.folio.rest.jaxrs.model.AccessType)5 AssignedUserPostRequest (org.folio.rest.jaxrs.model.AssignedUserPostRequest)5 KbCredentialsPostRequest (org.folio.rest.jaxrs.model.KbCredentialsPostRequest)5 AccessTypesTestUtil.insertAccessType (org.folio.util.AccessTypesTestUtil.insertAccessType)5 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)4 EqualToPattern (com.github.tomakehurst.wiremock.matching.EqualToPattern)4 AccessTypePostRequest (org.folio.rest.jaxrs.model.AccessTypePostRequest)4 AssignedUser (org.folio.rest.jaxrs.model.AssignedUser)4 AssignedUsersTestUtil.saveAssignedUser (org.folio.util.AssignedUsersTestUtil.saveAssignedUser)4