Search in sources :

Example 6 with TitlePostRequest

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);
}
Also used : TitlePostRequest(org.folio.rest.jaxrs.model.TitlePostRequest) TitlePostDataAttributes(org.folio.rest.jaxrs.model.TitlePostDataAttributes) Test(org.junit.Test)

Example 7 with 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;
}
Also used : TitlePostRequest(org.folio.rest.jaxrs.model.TitlePostRequest) TitlePostData(org.folio.rest.jaxrs.model.TitlePostData)

Example 8 with 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);
}
Also used : RMAPITemplateFactory(org.folio.rest.util.template.RMAPITemplateFactory) Filter(org.folio.rest.model.filter.Filter) TagRepository(org.folio.repository.tag.TagRepository) TitleCollectionResult(org.folio.rmapi.result.TitleCollectionResult) CompletableFuture.completedFuture(java.util.concurrent.CompletableFuture.completedFuture) Autowired(org.springframework.beans.factory.annotation.Autowired) Context(io.vertx.core.Context) PackageId(org.folio.holdingsiq.model.PackageId) HandleValidationErrors(org.folio.rest.aspect.HandleValidationErrors) Map(java.util.Map) TitlesPostBodyValidator(org.folio.rest.validator.TitlesPostBodyValidator) TitlePutRequest(org.folio.rest.jaxrs.model.TitlePutRequest) EholdingsTitles(org.folio.rest.jaxrs.resource.EholdingsTitles) IdParser.parseTitleId(org.folio.rest.util.IdParser.parseTitleId) RowSetUtils.toUUID(org.folio.db.RowSetUtils.toUUID) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) List(java.util.List) Response(javax.ws.rs.core.Response) ErrorUtil(org.folio.rest.util.ErrorUtil) TitlePostRequest(org.folio.rest.jaxrs.model.TitlePostRequest) RMAPITemplateContext(org.folio.rest.util.template.RMAPITemplateContext) ListUtils(org.folio.common.ListUtils) RecordKey(org.folio.repository.RecordKey) FilteredEntitiesLoader(org.folio.service.loader.FilteredEntitiesLoader) RecordType(org.folio.repository.RecordType) IdParser.parsePackageId(org.folio.rest.util.IdParser.parsePackageId) IdParser.parseResourceId(org.folio.rest.util.IdParser.parseResourceId) Tags(org.folio.rest.jaxrs.model.Tags) TitlesRepository(org.folio.repository.titles.TitlesRepository) CompletableFuture(java.util.concurrent.CompletableFuture) BooleanUtils(org.apache.commons.lang3.BooleanUtils) DbTitle(org.folio.repository.titles.DbTitle) SpringContextUtil(org.folio.spring.SpringContextUtil) TitlePost(org.folio.holdingsiq.model.TitlePost) Title(org.folio.rest.jaxrs.model.Title) RelatedEntitiesLoader(org.folio.service.loader.RelatedEntitiesLoader) AsyncResult(io.vertx.core.AsyncResult) SearchProperties(org.folio.properties.common.SearchProperties) Converter(org.springframework.core.convert.converter.Converter) TitleCommonRequestAttributesValidator(org.folio.rest.validator.TitleCommonRequestAttributesValidator) IdParser(org.folio.rest.util.IdParser) Vertx(io.vertx.core.Vertx) ResourceNotFoundException(org.folio.holdingsiq.service.exception.ResourceNotFoundException) Titles(org.folio.holdingsiq.model.Titles) Validate(org.folio.rest.annotations.Validate) CustomerResources(org.folio.holdingsiq.model.CustomerResources) TitlePutRequestConverter(org.folio.rest.converter.titles.TitlePutRequestConverter) TitleResult(org.folio.rmapi.result.TitleResult) TitleCollection(org.folio.rest.jaxrs.model.TitleCollection) ResourcePut(org.folio.holdingsiq.model.ResourcePut) Handler(io.vertx.core.Handler) PackageId(org.folio.holdingsiq.model.PackageId) IdParser.parsePackageId(org.folio.rest.util.IdParser.parsePackageId) TitlePost(org.folio.holdingsiq.model.TitlePost) HandleValidationErrors(org.folio.rest.aspect.HandleValidationErrors)

Example 9 with TitlePostRequest

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);
}
Also used : TitlePostRequest(org.folio.rest.jaxrs.model.TitlePostRequest) Test(org.junit.Test)

Example 10 with TitlePostRequest

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);
}
Also used : TitlePostRequest(org.folio.rest.jaxrs.model.TitlePostRequest) TitlePostDataAttributes(org.folio.rest.jaxrs.model.TitlePostDataAttributes) Test(org.junit.Test)

Aggregations

TitlePostRequest (org.folio.rest.jaxrs.model.TitlePostRequest)21 Test (org.junit.Test)18 TitlePostDataAttributes (org.folio.rest.jaxrs.model.TitlePostDataAttributes)14 TitlePostData (org.folio.rest.jaxrs.model.TitlePostData)8 Tags (org.folio.rest.jaxrs.model.Tags)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ResponseDefinitionBuilder (com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder)1 EqualToJsonPattern (com.github.tomakehurst.wiremock.matching.EqualToJsonPattern)1 EqualToPattern (com.github.tomakehurst.wiremock.matching.EqualToPattern)1 RegexPattern (com.github.tomakehurst.wiremock.matching.RegexPattern)1 UrlPathPattern (com.github.tomakehurst.wiremock.matching.UrlPathPattern)1 AsyncResult (io.vertx.core.AsyncResult)1 Context (io.vertx.core.Context)1 Handler (io.vertx.core.Handler)1 Vertx (io.vertx.core.Vertx)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Map (java.util.Map)1 Objects (java.util.Objects)1 UUID (java.util.UUID)1