Search in sources :

Example 1 with PackageTagsPutRequest

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

the class PackageTagsPutBodyValidatorTest method shouldThrowExceptionWhenNameIsEmpty.

@Test(expected = InputValidationException.class)
public void shouldThrowExceptionWhenNameIsEmpty() {
    PackageTagsPutRequest request = new PackageTagsPutRequest().withData(new PackageTagsPutData().withAttributes(new PackageTagsDataAttributes().withName("").withContentType(ContentType.E_BOOK)));
    validator.validate(request);
}
Also used : PackageTagsPutRequest(org.folio.rest.jaxrs.model.PackageTagsPutRequest) PackageTagsPutData(org.folio.rest.jaxrs.model.PackageTagsPutData) PackageTagsDataAttributes(org.folio.rest.jaxrs.model.PackageTagsDataAttributes) Test(org.junit.Test)

Example 2 with PackageTagsPutRequest

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

the class PackageTagsPutBodyValidatorTest method shouldThrowExceptionWhenContentTypeIsNull.

@Test(expected = InputValidationException.class)
public void shouldThrowExceptionWhenContentTypeIsNull() {
    PackageTagsPutRequest request = new PackageTagsPutRequest().withData(new PackageTagsPutData().withAttributes(new PackageTagsDataAttributes().withName("name")));
    validator.validate(request);
}
Also used : PackageTagsPutRequest(org.folio.rest.jaxrs.model.PackageTagsPutRequest) PackageTagsPutData(org.folio.rest.jaxrs.model.PackageTagsPutData) PackageTagsDataAttributes(org.folio.rest.jaxrs.model.PackageTagsDataAttributes) Test(org.junit.Test)

Example 3 with PackageTagsPutRequest

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

the class EholdingsProvidersImplTest method shouldReturn422OnPutTagsWhenRequestBodyIsInvalid.

@Test
public void shouldReturn422OnPutTagsWhenRequestBodyIsInvalid() throws IOException, URISyntaxException {
    ObjectMapper mapper = new ObjectMapper();
    PackageTagsPutRequest tags = mapper.readValue(getFile(PUT_PROVIDER_TAGS), PackageTagsPutRequest.class);
    tags.getData().getAttributes().setName("");
    JsonapiError error = putWithStatus(PROVIDER_TAGS_PATH, mapper.writeValueAsString(tags), SC_UNPROCESSABLE_ENTITY, STUB_TOKEN_HEADER).as(JsonapiError.class);
    assertErrorContainsTitle(error, "Invalid name");
    assertErrorContainsDetail(error, "name must not be empty");
}
Also used : JsonapiError(org.folio.rest.jaxrs.model.JsonapiError) PackageTagsPutRequest(org.folio.rest.jaxrs.model.PackageTagsPutRequest) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 4 with PackageTagsPutRequest

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

the class EholdingsPackagesTest method sendPutTags.

private void sendPutTags(List<String> newTags) throws IOException, URISyntaxException {
    PackageTagsPutRequest tags = mapper.readValue(getFile("requests/kb-ebsco/package/put-package-tags.json"), PackageTagsPutRequest.class);
    if (newTags != null) {
        tags.getData().getAttributes().setTags(new Tags().withTagList(newTags));
    }
    putWithOk(PACKAGE_TAGS_PATH, mapper.writeValueAsString(tags), STUB_TOKEN_HEADER).as(PackageTags.class);
}
Also used : PackageTagsPutRequest(org.folio.rest.jaxrs.model.PackageTagsPutRequest) PackageTags(org.folio.rest.jaxrs.model.PackageTags) Tags(org.folio.rest.jaxrs.model.Tags)

Example 5 with PackageTagsPutRequest

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

the class EholdingsPackagesTest method shouldReturn422OnPutTagsWhenRequestBodyIsInvalid.

@Test
public void shouldReturn422OnPutTagsWhenRequestBodyIsInvalid() throws IOException, URISyntaxException {
    PackageTagsPutRequest tags = mapper.readValue(getFile("requests/kb-ebsco/package/put-package-tags.json"), PackageTagsPutRequest.class);
    tags.getData().getAttributes().setName("");
    JsonapiError error = putWithStatus(PACKAGE_TAGS_PATH, mapper.writeValueAsString(tags), SC_UNPROCESSABLE_ENTITY, STUB_TOKEN_HEADER).as(JsonapiError.class);
    assertErrorContainsTitle(error, "Invalid name");
}
Also used : JsonapiError(org.folio.rest.jaxrs.model.JsonapiError) PackageTagsPutRequest(org.folio.rest.jaxrs.model.PackageTagsPutRequest) Test(org.junit.Test)

Aggregations

PackageTagsPutRequest (org.folio.rest.jaxrs.model.PackageTagsPutRequest)5 Test (org.junit.Test)4 JsonapiError (org.folio.rest.jaxrs.model.JsonapiError)2 PackageTagsDataAttributes (org.folio.rest.jaxrs.model.PackageTagsDataAttributes)2 PackageTagsPutData (org.folio.rest.jaxrs.model.PackageTagsPutData)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 PackageTags (org.folio.rest.jaxrs.model.PackageTags)1 Tags (org.folio.rest.jaxrs.model.Tags)1