use of org.folio.rest.jaxrs.model.TitlePostRequest in project mod-kb-ebsco-java by folio-org.
the class TitlePostBodyValidatorTest method shouldNotThrowExceptionIfTitleEditionIsNull.
@Test
public void shouldNotThrowExceptionIfTitleEditionIsNull() {
TitlePostRequest titlePostRequest = createRequest(new TitlePostDataAttributes().withName(TITLE_TEST_NAME).withPublicationType(PublicationType.BOOK).withEdition(null));
validator.validate(titlePostRequest);
}
use of org.folio.rest.jaxrs.model.TitlePostRequest in project mod-kb-ebsco-java by folio-org.
the class TitlePostBodyValidatorTest method createRequest.
private TitlePostRequest createRequest(TitlePostDataAttributes attributes) {
TitlePostRequest titlePostRequest = new TitlePostRequest();
titlePostRequest.withData(new TitlePostData().withAttributes(attributes)).withIncluded(getTitlePostIncluded());
return titlePostRequest;
}
use of org.folio.rest.jaxrs.model.TitlePostRequest in project mod-kb-ebsco-java by folio-org.
the class EholdingsTitlesImpl method postEholdingsTitles.
@Override
@HandleValidationErrors
public void postEholdingsTitles(String contentType, TitlePostRequest entity, Map<String, String> okapiHeaders, Handler<AsyncResult<Response>> asyncResultHandler, Context vertxContext) {
titlesPostBodyValidator.validate(entity);
TitlePost titlePost = titlePostRequestConverter.convert(entity);
PackageId packageId = parsePackageId(entity.getIncluded().get(0).getAttributes().getPackageId());
templateFactory.createTemplate(okapiHeaders, asyncResultHandler).requestAction(context -> context.getTitlesService().postTitle(titlePost, packageId).thenCompose(title -> completedFuture(toTitleResult(title, false))).thenCompose(titleResult -> updateTags(titleResult, context, entity.getData().getAttributes().getTags()))).executeWithResult(Title.class);
}
use of org.folio.rest.jaxrs.model.TitlePostRequest in project mod-kb-ebsco-java by folio-org.
the class TitlePostBodyValidatorTest method shouldThrowExceptionWhenEmptyBody.
@Test(expected = InputValidationException.class)
public void shouldThrowExceptionWhenEmptyBody() {
TitlePostRequest postRequest = new TitlePostRequest();
validator.validate(postRequest);
}
use of org.folio.rest.jaxrs.model.TitlePostRequest in project mod-kb-ebsco-java by folio-org.
the class TitlePostBodyValidatorTest method shouldThrowExceptionIfTitleEditionIsTooLong.
@Test(expected = InputValidationException.class)
public void shouldThrowExceptionIfTitleEditionIsTooLong() {
TitlePostRequest titlePostRequest = createRequest(new TitlePostDataAttributes().withName(TITLE_TEST_NAME).withPublisherName(TEXT_LONGER_THAN_250_CHARACTERS));
validator.validate(titlePostRequest);
}
Aggregations