Search in sources :

Example 41 with Title

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

the class TitleConverter method includeTagsIfNeeded.

private void includeTagsIfNeeded(Title title, TitleResult titleResult) {
    if (nonNull(titleResult.getResourceTagList())) {
        for (ResourceCollectionItem resourceCollectionItem : title.getIncluded()) {
            List<DbTag> tags = titleResult.getResourceTagList().stream().filter(tag -> resourceCollectionItem.getId().equals(tag.getRecordId())).collect(Collectors.toList());
            resourceCollectionItem.getAttributes().withTags(tagsConverter.convert(tags));
        }
    }
}
Also used : DbTag(org.folio.repository.tag.DbTag) TITLES_TYPE(org.folio.rest.util.RestConstants.TITLES_TYPE) Tags(org.folio.rest.jaxrs.model.Tags) Autowired(org.springframework.beans.factory.annotation.Autowired) MetaDataIncluded(org.folio.rest.jaxrs.model.MetaDataIncluded) TitleAttributes(org.folio.rest.jaxrs.model.TitleAttributes) Resources(org.folio.rest.jaxrs.model.Resources) StringUtils(org.apache.commons.lang3.StringUtils) AlternateTitle(org.folio.rest.jaxrs.model.AlternateTitle) Title(org.folio.rest.jaxrs.model.Title) TitleConverterUtils.createEmptyResourcesRelationships(org.folio.rest.converter.titles.TitleConverterUtils.createEmptyResourcesRelationships) Relationships(org.folio.rest.jaxrs.model.Relationships) IterableUtils.matchesAny(org.apache.commons.collections4.IterableUtils.matchesAny) ListUtils.mapItems(org.folio.common.ListUtils.mapItems) Comparator.nullsLast(java.util.Comparator.nullsLast) Comparator.comparing(java.util.Comparator.comparing) TitleSubject(org.folio.rest.jaxrs.model.TitleSubject) Converter(org.springframework.core.convert.converter.Converter) RestConstants(org.folio.rest.util.RestConstants) Comparator.comparingInt(java.util.Comparator.comparingInt) Subject(org.folio.holdingsiq.model.Subject) Resource(org.folio.rest.jaxrs.model.Resource) IdParser(org.folio.rest.util.IdParser) Collectors(java.util.stream.Collectors) DbTag(org.folio.repository.tag.DbTag) Data(org.folio.rest.jaxrs.model.Data) Contributor(org.folio.holdingsiq.model.Contributor) List(java.util.List) Component(org.springframework.stereotype.Component) CustomerResources(org.folio.holdingsiq.model.CustomerResources) Identifier(org.folio.holdingsiq.model.Identifier) Contributors(org.folio.rest.jaxrs.model.Contributors) ConverterConsts(org.folio.rest.converter.common.ConverterConsts) NonNull(org.springframework.lang.NonNull) TitleResult(org.folio.rmapi.result.TitleResult) Objects.nonNull(java.util.Objects.nonNull) Comparator(java.util.Comparator) RelationshipData(org.folio.rest.jaxrs.model.RelationshipData) ResourceResult(org.folio.rmapi.result.ResourceResult) ResourceCollectionItem(org.folio.rest.jaxrs.model.ResourceCollectionItem) ResourceCollectionItem(org.folio.rest.jaxrs.model.ResourceCollectionItem)

Example 42 with Title

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

the class EholdingsTitlesTest method shouldReturnTitleTagsWhenValidId.

@Test
public void shouldReturnTitleTagsWhenValidId() throws IOException, URISyntaxException {
    String stubResponseFile = "responses/rmapi/titles/get-title-by-id-response.json";
    saveTag(vertx, STUB_MANAGED_TITLE_ID, RecordType.TITLE, STUB_TAG_VALUE);
    stubFor(get(new UrlPathPattern(new RegexPattern("/rm/rmaccounts/" + STUB_CUSTOMER_ID + "/titles.*"), true)).willReturn(new ResponseDefinitionBuilder().withBody(readFile(stubResponseFile))));
    Title actualResponse = getWithOk(EHOLDINGS_TITLES_PATH + "/" + STUB_TITLE_ID, STUB_TOKEN_HEADER).as(Title.class);
    assertTrue(actualResponse.getData().getAttributes().getTags().getTagList().contains(STUB_TAG_VALUE));
}
Also used : ResponseDefinitionBuilder(com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder) UrlPathPattern(com.github.tomakehurst.wiremock.matching.UrlPathPattern) RegexPattern(com.github.tomakehurst.wiremock.matching.RegexPattern) DbTitle(org.folio.repository.titles.DbTitle) Title(org.folio.rest.jaxrs.model.Title) AssertTestUtil.assertErrorContainsTitle(org.folio.util.AssertTestUtil.assertErrorContainsTitle) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Aggregations

Title (org.folio.rest.jaxrs.model.Title)42 Test (org.junit.jupiter.api.Test)28 Piece (org.folio.rest.jaxrs.model.Piece)23 CompositePoLine (org.folio.rest.jaxrs.model.CompositePoLine)19 Location (org.folio.rest.jaxrs.model.Location)19 JsonObject (io.vertx.core.json.JsonObject)17 ArrayList (java.util.ArrayList)10 List (java.util.List)9 CompletableFuture (java.util.concurrent.CompletableFuture)8 Cost (org.folio.rest.jaxrs.model.Cost)8 PoLine (org.folio.rest.jaxrs.model.PoLine)8 PurchaseOrder (org.folio.rest.jaxrs.model.PurchaseOrder)8 CompletableFuture.completedFuture (java.util.concurrent.CompletableFuture.completedFuture)7 Collectors (java.util.stream.Collectors)7 Eresource (org.folio.rest.jaxrs.model.Eresource)7 Context (io.vertx.core.Context)6 Map (java.util.Map)6 PieceUpdateHolder (org.folio.models.pieces.PieceUpdateHolder)6 Optional (java.util.Optional)5 LogManager (org.apache.logging.log4j.LogManager)5