Search in sources :

Example 1 with PackageId

use of org.folio.holdingsiq.model.PackageId in project mod-kb-ebsco-java by folio-org.

the class EholdingsPackagesImpl method getEholdingsPackagesResourcesByPackageId.

@Override
@Validate
@HandleValidationErrors
public void getEholdingsPackagesResourcesByPackageId(String packageId, List<String> filterTags, List<String> filterAccessType, String filterSelected, String filterType, String filterName, String filterIsxn, String filterSubject, String filterPublisher, String sort, int page, int count, Map<String, String> okapiHeaders, Handler<AsyncResult<Response>> asyncResultHandler, Context vertxContext) {
    Filter filter = Filter.builder().recordType(RecordType.RESOURCE).filterTags(filterTags).packageId(packageId).filterAccessType(filterAccessType).filterSelected(filterSelected).filterType(filterType).filterName(filterName).filterIsxn(filterIsxn).filterSubject(filterSubject).filterPublisher(filterPublisher).sort(sort).page(page).count(count).build();
    RMAPITemplate template = templateFactory.createTemplate(okapiHeaders, asyncResultHandler);
    if (filter.isTagsFilter()) {
        template.requestAction(context -> filteredEntitiesLoader.fetchResourcesByTagFilter(filter.createTagFilter(), context));
    } else if (filter.isAccessTypeFilter()) {
        template.requestAction(context -> filteredEntitiesLoader.fetchResourcesByAccessTypeFilter(filter.createAccessTypeFilter(), context));
    } else {
        template.requestAction(context -> {
            PackageId pkgId = filter.getPackageId();
            long providerIdPart = pkgId.getProviderIdPart();
            long packageIdPart = pkgId.getPackageIdPart();
            return context.getTitlesService().retrieveTitles(providerIdPart, packageIdPart, filter.createFilterQuery(), searchProperties.getTitlesSearchType(), filter.getSort(), page, count).thenApply(titles -> titleCollectionConverter.convert(titles)).thenCompose(loadResourceTags(context));
        });
    }
    template.addErrorMapper(ResourceNotFoundException.class, exception -> GetEholdingsPackagesResourcesByPackageIdResponse.respond404WithApplicationVndApiJson(ErrorUtil.createError(PACKAGE_NOT_FOUND_MESSAGE))).executeWithResult(ResourceCollection.class);
}
Also used : RMAPITemplateFactory(org.folio.rest.util.template.RMAPITemplateFactory) Filter(org.folio.rest.model.filter.Filter) TagRepository(org.folio.repository.tag.TagRepository) PackageParametersValidator(org.folio.holdingsiq.service.validator.PackageParametersValidator) TitleCollectionResult(org.folio.rmapi.result.TitleCollectionResult) CompletableFuture.completedFuture(java.util.concurrent.CompletableFuture.completedFuture) ExceptionMappers.error400NotFoundMapper(org.folio.rest.util.ExceptionMappers.error400NotFoundMapper) Autowired(org.springframework.beans.factory.annotation.Autowired) PackagePut(org.folio.holdingsiq.model.PackagePut) AccessTypeMappingsService(org.folio.service.accesstypes.AccessTypeMappingsService) Context(io.vertx.core.Context) PackageId(org.folio.holdingsiq.model.PackageId) AccessType(org.folio.rest.jaxrs.model.AccessType) JSONAPI(org.folio.rest.util.RestConstants.JSONAPI) AccessTypesService(org.folio.service.accesstypes.AccessTypesService) Collectors.toMap(java.util.stream.Collectors.toMap) HandleValidationErrors(org.folio.rest.aspect.HandleValidationErrors) EholdingsPackages(org.folio.rest.jaxrs.resource.EholdingsPackages) ListUtils.parseByComma(org.folio.common.ListUtils.parseByComma) PackagePutBodyValidator(org.folio.rest.validator.PackagePutBodyValidator) Map(java.util.Map) Package(org.folio.rest.jaxrs.model.Package) ResourceCollection(org.folio.rest.jaxrs.model.ResourceCollection) IdParser.packageIdToString(org.folio.rest.util.IdParser.packageIdToString) PackageTagsItem(org.folio.rest.jaxrs.model.PackageTagsItem) OkapiData(org.folio.holdingsiq.model.OkapiData) VertxCache(org.folio.cache.VertxCache) PackageBulkFetchCollection(org.folio.rest.jaxrs.model.PackageBulkFetchCollection) RowSetUtils.toUUID(org.folio.db.RowSetUtils.toUUID) UUID(java.util.UUID) Future(io.vertx.core.Future) NotFoundException(javax.ws.rs.NotFoundException) PackageCollection(org.folio.rest.jaxrs.model.PackageCollection) List(java.util.List) CompletionStage(java.util.concurrent.CompletionStage) Response(javax.ws.rs.core.Response) PackageResult(org.folio.rmapi.result.PackageResult) ErrorUtil(org.folio.rest.util.ErrorUtil) PackagePostRequest(org.folio.rest.jaxrs.model.PackagePostRequest) RMAPITemplateContext(org.folio.rest.util.template.RMAPITemplateContext) VendorIdCacheKey(org.folio.config.cache.VendorIdCacheKey) UserKbCredentialsService(org.folio.service.kbcredentials.UserKbCredentialsService) RecordKey(org.folio.repository.RecordKey) FilteredEntitiesLoader(org.folio.service.loader.FilteredEntitiesLoader) PackageTagsDataAttributes(org.folio.rest.jaxrs.model.PackageTagsDataAttributes) RecordType(org.folio.repository.RecordType) IdParser.parsePackageId(org.folio.rest.util.IdParser.parsePackageId) Tags(org.folio.rest.jaxrs.model.Tags) CompletableFuture(java.util.concurrent.CompletableFuture) BooleanUtils(org.apache.commons.lang3.BooleanUtils) CustomPackagePutBodyValidator(org.folio.rest.validator.CustomPackagePutBodyValidator) Function(java.util.function.Function) DbPackage(org.folio.repository.packages.DbPackage) PackageRequestConverter(org.folio.rest.converter.packages.PackageRequestConverter) InputValidationException(org.folio.rest.exception.InputValidationException) SpringContextUtil(org.folio.spring.SpringContextUtil) ArrayList(java.util.ArrayList) PackagePutRequest(org.folio.rest.jaxrs.model.PackagePutRequest) Qualifier(org.springframework.beans.factory.annotation.Qualifier) PackageTagsPutBodyValidator(org.folio.rest.validator.PackageTagsPutBodyValidator) PackagePostBulkFetchRequest(org.folio.rest.jaxrs.model.PackagePostBulkFetchRequest) RelatedEntitiesLoader(org.folio.service.loader.RelatedEntitiesLoader) AsyncResult(io.vertx.core.AsyncResult) SearchProperties(org.folio.properties.common.SearchProperties) RMAPITemplate(org.folio.rest.util.template.RMAPITemplate) Converter(org.springframework.core.convert.converter.Converter) ExceptionMappers.error422InputValidationMapper(org.folio.rest.util.ExceptionMappers.error422InputValidationMapper) Vertx(io.vertx.core.Vertx) ResourceNotFoundException(org.folio.holdingsiq.service.exception.ResourceNotFoundException) ErrorHandler(org.folio.rest.util.ErrorHandler) Titles(org.folio.holdingsiq.model.Titles) PackagesPostBodyValidator(org.folio.rest.validator.PackagesPostBodyValidator) DbTag(org.folio.repository.tag.DbTag) Validate(org.folio.rest.annotations.Validate) PackageTagsPutRequest(org.folio.rest.jaxrs.model.PackageTagsPutRequest) PackageRepository(org.folio.repository.packages.PackageRepository) CustomerResources(org.folio.holdingsiq.model.CustomerResources) ConverterConsts(org.folio.rest.converter.common.ConverterConsts) TAGS_TYPE(org.folio.rest.util.RestConstants.TAGS_TYPE) TitleResult(org.folio.rmapi.result.TitleResult) PackageTags(org.folio.rest.jaxrs.model.PackageTags) Handler(io.vertx.core.Handler) PackageByIdData(org.folio.holdingsiq.model.PackageByIdData) PackagePost(org.folio.holdingsiq.model.PackagePost) Filter(org.folio.rest.model.filter.Filter) PackageId(org.folio.holdingsiq.model.PackageId) IdParser.parsePackageId(org.folio.rest.util.IdParser.parsePackageId) ResourceNotFoundException(org.folio.holdingsiq.service.exception.ResourceNotFoundException) RMAPITemplate(org.folio.rest.util.template.RMAPITemplate) Validate(org.folio.rest.annotations.Validate) HandleValidationErrors(org.folio.rest.aspect.HandleValidationErrors)

Example 2 with PackageId

use of org.folio.holdingsiq.model.PackageId in project mod-kb-ebsco-java by folio-org.

the class EholdingsPackagesImpl method deleteEholdingsPackagesByPackageId.

@Override
@HandleValidationErrors
public void deleteEholdingsPackagesByPackageId(String packageId, Map<String, String> okapiHeaders, Handler<AsyncResult<Response>> asyncResultHandler, Context vertxContext) {
    PackageId parsedPackageId = parsePackageId(packageId);
    templateFactory.createTemplate(okapiHeaders, asyncResultHandler).requestAction(context -> context.getPackagesService().retrievePackage(parsedPackageId).thenCompose(packageData -> {
        if (BooleanUtils.isNotTrue(packageData.getIsCustom())) {
            throw new InputValidationException(INVALID_PACKAGE_TITLE, INVALID_PACKAGE_DETAILS);
        }
        return context.getPackagesService().deletePackage(parsedPackageId).thenCompose(aVoid -> deleteAssignedResources(parsedPackageId, context));
    })).execute();
}
Also used : RMAPITemplateFactory(org.folio.rest.util.template.RMAPITemplateFactory) Filter(org.folio.rest.model.filter.Filter) TagRepository(org.folio.repository.tag.TagRepository) PackageParametersValidator(org.folio.holdingsiq.service.validator.PackageParametersValidator) TitleCollectionResult(org.folio.rmapi.result.TitleCollectionResult) CompletableFuture.completedFuture(java.util.concurrent.CompletableFuture.completedFuture) ExceptionMappers.error400NotFoundMapper(org.folio.rest.util.ExceptionMappers.error400NotFoundMapper) Autowired(org.springframework.beans.factory.annotation.Autowired) PackagePut(org.folio.holdingsiq.model.PackagePut) AccessTypeMappingsService(org.folio.service.accesstypes.AccessTypeMappingsService) Context(io.vertx.core.Context) PackageId(org.folio.holdingsiq.model.PackageId) AccessType(org.folio.rest.jaxrs.model.AccessType) JSONAPI(org.folio.rest.util.RestConstants.JSONAPI) AccessTypesService(org.folio.service.accesstypes.AccessTypesService) Collectors.toMap(java.util.stream.Collectors.toMap) HandleValidationErrors(org.folio.rest.aspect.HandleValidationErrors) EholdingsPackages(org.folio.rest.jaxrs.resource.EholdingsPackages) ListUtils.parseByComma(org.folio.common.ListUtils.parseByComma) PackagePutBodyValidator(org.folio.rest.validator.PackagePutBodyValidator) Map(java.util.Map) Package(org.folio.rest.jaxrs.model.Package) ResourceCollection(org.folio.rest.jaxrs.model.ResourceCollection) IdParser.packageIdToString(org.folio.rest.util.IdParser.packageIdToString) PackageTagsItem(org.folio.rest.jaxrs.model.PackageTagsItem) OkapiData(org.folio.holdingsiq.model.OkapiData) VertxCache(org.folio.cache.VertxCache) PackageBulkFetchCollection(org.folio.rest.jaxrs.model.PackageBulkFetchCollection) RowSetUtils.toUUID(org.folio.db.RowSetUtils.toUUID) UUID(java.util.UUID) Future(io.vertx.core.Future) NotFoundException(javax.ws.rs.NotFoundException) PackageCollection(org.folio.rest.jaxrs.model.PackageCollection) List(java.util.List) CompletionStage(java.util.concurrent.CompletionStage) Response(javax.ws.rs.core.Response) PackageResult(org.folio.rmapi.result.PackageResult) ErrorUtil(org.folio.rest.util.ErrorUtil) PackagePostRequest(org.folio.rest.jaxrs.model.PackagePostRequest) RMAPITemplateContext(org.folio.rest.util.template.RMAPITemplateContext) VendorIdCacheKey(org.folio.config.cache.VendorIdCacheKey) UserKbCredentialsService(org.folio.service.kbcredentials.UserKbCredentialsService) RecordKey(org.folio.repository.RecordKey) FilteredEntitiesLoader(org.folio.service.loader.FilteredEntitiesLoader) PackageTagsDataAttributes(org.folio.rest.jaxrs.model.PackageTagsDataAttributes) RecordType(org.folio.repository.RecordType) IdParser.parsePackageId(org.folio.rest.util.IdParser.parsePackageId) Tags(org.folio.rest.jaxrs.model.Tags) CompletableFuture(java.util.concurrent.CompletableFuture) BooleanUtils(org.apache.commons.lang3.BooleanUtils) CustomPackagePutBodyValidator(org.folio.rest.validator.CustomPackagePutBodyValidator) Function(java.util.function.Function) DbPackage(org.folio.repository.packages.DbPackage) PackageRequestConverter(org.folio.rest.converter.packages.PackageRequestConverter) InputValidationException(org.folio.rest.exception.InputValidationException) SpringContextUtil(org.folio.spring.SpringContextUtil) ArrayList(java.util.ArrayList) PackagePutRequest(org.folio.rest.jaxrs.model.PackagePutRequest) Qualifier(org.springframework.beans.factory.annotation.Qualifier) PackageTagsPutBodyValidator(org.folio.rest.validator.PackageTagsPutBodyValidator) PackagePostBulkFetchRequest(org.folio.rest.jaxrs.model.PackagePostBulkFetchRequest) RelatedEntitiesLoader(org.folio.service.loader.RelatedEntitiesLoader) AsyncResult(io.vertx.core.AsyncResult) SearchProperties(org.folio.properties.common.SearchProperties) RMAPITemplate(org.folio.rest.util.template.RMAPITemplate) Converter(org.springframework.core.convert.converter.Converter) ExceptionMappers.error422InputValidationMapper(org.folio.rest.util.ExceptionMappers.error422InputValidationMapper) Vertx(io.vertx.core.Vertx) ResourceNotFoundException(org.folio.holdingsiq.service.exception.ResourceNotFoundException) ErrorHandler(org.folio.rest.util.ErrorHandler) Titles(org.folio.holdingsiq.model.Titles) PackagesPostBodyValidator(org.folio.rest.validator.PackagesPostBodyValidator) DbTag(org.folio.repository.tag.DbTag) Validate(org.folio.rest.annotations.Validate) PackageTagsPutRequest(org.folio.rest.jaxrs.model.PackageTagsPutRequest) PackageRepository(org.folio.repository.packages.PackageRepository) CustomerResources(org.folio.holdingsiq.model.CustomerResources) ConverterConsts(org.folio.rest.converter.common.ConverterConsts) TAGS_TYPE(org.folio.rest.util.RestConstants.TAGS_TYPE) TitleResult(org.folio.rmapi.result.TitleResult) PackageTags(org.folio.rest.jaxrs.model.PackageTags) Handler(io.vertx.core.Handler) PackageByIdData(org.folio.holdingsiq.model.PackageByIdData) PackagePost(org.folio.holdingsiq.model.PackagePost) PackageId(org.folio.holdingsiq.model.PackageId) IdParser.parsePackageId(org.folio.rest.util.IdParser.parsePackageId) InputValidationException(org.folio.rest.exception.InputValidationException) HandleValidationErrors(org.folio.rest.aspect.HandleValidationErrors)

Example 3 with PackageId

use of org.folio.holdingsiq.model.PackageId in project mod-kb-ebsco-java by folio-org.

the class EholdingsResourcesImpl method postEholdingsResources.

@Override
@HandleValidationErrors
public void postEholdingsResources(String contentType, ResourcePostRequest entity, Map<String, String> okapiHeaders, Handler<AsyncResult<Response>> asyncResultHandler, Context vertxContext) {
    postValidator.validate(entity);
    ResourcePostDataAttributes attributes = entity.getData().getAttributes();
    long titleId = parseTitleId(attributes.getTitleId());
    PackageId packageId = parsePackageId(attributes.getPackageId());
    templateFactory.createTemplate(okapiHeaders, asyncResultHandler).requestAction(context -> (CompletableFuture<?>) getObjectsForPostResource(titleId, packageId, context.getTitlesService(), context.getPackagesService()).thenCompose(result -> {
        Title title = result.getTitle();
        postValidator.validateRelatedObjects(result.getPackageData(), title, result.getTitles());
        ResourceSelectedPayload postRequest = new ResourceSelectedPayload(true, title.getTitleName(), title.getPubType(), attributes.getUrl());
        ResourceId resourceId = ResourceId.builder().providerIdPart(packageId.getProviderIdPart()).packageIdPart(packageId.getPackageIdPart()).titleIdPart(titleId).build();
        return context.getResourcesService().postResource(postRequest, resourceId);
    }).thenCompose(title -> CompletableFuture.completedFuture(new ResourceResult(title, null, null, false)))).addErrorMapper(InputValidationException.class, error422InputValidationMapper()).executeWithResult(Resource.class);
}
Also used : ResourcePostDataAttributes(org.folio.rest.jaxrs.model.ResourcePostDataAttributes) RMAPITemplateFactory(org.folio.rest.util.template.RMAPITemplateFactory) ResourcePostBulkFetchRequest(org.folio.rest.jaxrs.model.ResourcePostBulkFetchRequest) TagRepository(org.folio.repository.tag.TagRepository) ExceptionMappers.error400NotFoundMapper(org.folio.rest.util.ExceptionMappers.error400NotFoundMapper) Autowired(org.springframework.beans.factory.annotation.Autowired) ResourcePutRequest(org.folio.rest.jaxrs.model.ResourcePutRequest) AccessTypeMappingsService(org.folio.service.accesstypes.AccessTypeMappingsService) Context(io.vertx.core.Context) PackageId(org.folio.holdingsiq.model.PackageId) AccessType(org.folio.rest.jaxrs.model.AccessType) JSONAPI(org.folio.rest.util.RestConstants.JSONAPI) RowSetUtils(org.folio.db.RowSetUtils) AccessTypesService(org.folio.service.accesstypes.AccessTypesService) HandleValidationErrors(org.folio.rest.aspect.HandleValidationErrors) ResourcePostValidator(org.folio.rest.validator.ResourcePostValidator) ListUtils.parseByComma(org.folio.common.ListUtils.parseByComma) Map(java.util.Map) TitlesHoldingsIQService(org.folio.holdingsiq.service.TitlesHoldingsIQService) PackagesHoldingsIQService(org.folio.holdingsiq.service.PackagesHoldingsIQService) EholdingsResources(org.folio.rest.jaxrs.resource.EholdingsResources) OkapiData(org.folio.holdingsiq.model.OkapiData) ResourceTagsPutBodyValidator(org.folio.rest.validator.ResourceTagsPutBodyValidator) DbResource(org.folio.repository.resources.DbResource) IdParser.parseTitleId(org.folio.rest.util.IdParser.parseTitleId) UUID(java.util.UUID) Future(io.vertx.core.Future) FilterQuery(org.folio.holdingsiq.model.FilterQuery) NotFoundException(javax.ws.rs.NotFoundException) Objects(java.util.Objects) List(java.util.List) CollectionUtils.isNotEmpty(org.apache.commons.collections4.CollectionUtils.isNotEmpty) CompletionStage(java.util.concurrent.CompletionStage) Response(javax.ws.rs.core.Response) ResourceBulkFetchCollection(org.folio.rest.jaxrs.model.ResourceBulkFetchCollection) RMAPITemplateContext(org.folio.rest.util.template.RMAPITemplateContext) CONTENT_TYPE(org.apache.http.protocol.HTTP.CONTENT_TYPE) SC_NOT_FOUND(org.apache.http.HttpStatus.SC_NOT_FOUND) UserKbCredentialsService(org.folio.service.kbcredentials.UserKbCredentialsService) RecordKey(org.folio.repository.RecordKey) RecordType(org.folio.repository.RecordType) IdParser.parsePackageId(org.folio.rest.util.IdParser.parsePackageId) IdParser.parseResourceId(org.folio.rest.util.IdParser.parseResourceId) ResourceTagsPutRequest(org.folio.rest.jaxrs.model.ResourceTagsPutRequest) ResourceRequestConverter(org.folio.rest.converter.resources.ResourceRequestConverter) Sort(org.folio.holdingsiq.model.Sort) CompletableFuture(java.util.concurrent.CompletableFuture) BooleanUtils(org.apache.commons.lang3.BooleanUtils) Function(java.util.function.Function) InputValidationException(org.folio.rest.exception.InputValidationException) SpringContextUtil(org.folio.spring.SpringContextUtil) ErrorUtil.createError(org.folio.rest.util.ErrorUtil.createError) ResourceSelectedPayload(org.folio.holdingsiq.model.ResourceSelectedPayload) ResourcePostRequest(org.folio.rest.jaxrs.model.ResourcePostRequest) ResourceTags(org.folio.rest.jaxrs.model.ResourceTags) Qualifier(org.springframework.beans.factory.annotation.Qualifier) ResourceRepository(org.folio.repository.resources.ResourceRepository) RelatedEntitiesLoader(org.folio.service.loader.RelatedEntitiesLoader) AsyncResult(io.vertx.core.AsyncResult) SearchProperties(org.folio.properties.common.SearchProperties) RMAPITemplate(org.folio.rest.util.template.RMAPITemplate) ResourceId(org.folio.holdingsiq.model.ResourceId) Title(org.folio.holdingsiq.model.Title) IdParser.resourceIdToString(org.folio.rest.util.IdParser.resourceIdToString) JSON_API_TYPE(org.folio.rest.util.RestConstants.JSON_API_TYPE) Resource(org.folio.rest.jaxrs.model.Resource) ResourceTagsItem(org.folio.rest.jaxrs.model.ResourceTagsItem) IdParser(org.folio.rest.util.IdParser) ResourcePostDataAttributes(org.folio.rest.jaxrs.model.ResourcePostDataAttributes) ExceptionMappers.error422InputValidationMapper(org.folio.rest.util.ExceptionMappers.error422InputValidationMapper) Vertx(io.vertx.core.Vertx) ResourceNotFoundException(org.folio.holdingsiq.service.exception.ResourceNotFoundException) ErrorHandler(org.folio.rest.util.ErrorHandler) ObjectsForPostResourceResult(org.folio.rmapi.result.ObjectsForPostResourceResult) CustomerResources(org.folio.holdingsiq.model.CustomerResources) IdParser.getResourceId(org.folio.rest.util.IdParser.getResourceId) TAGS_TYPE(org.folio.rest.util.RestConstants.TAGS_TYPE) ResourcePut(org.folio.holdingsiq.model.ResourcePut) Handler(io.vertx.core.Handler) ResourceTagsDataAttributes(org.folio.rest.jaxrs.model.ResourceTagsDataAttributes) ResourcePutBodyValidator(org.folio.rest.validator.ResourcePutBodyValidator) ResourceResult(org.folio.rmapi.result.ResourceResult) PackageByIdData(org.folio.holdingsiq.model.PackageByIdData) ObjectsForPostResourceResult(org.folio.rmapi.result.ObjectsForPostResourceResult) ResourceResult(org.folio.rmapi.result.ResourceResult) IdParser.parseResourceId(org.folio.rest.util.IdParser.parseResourceId) ResourceId(org.folio.holdingsiq.model.ResourceId) IdParser.getResourceId(org.folio.rest.util.IdParser.getResourceId) ResourceSelectedPayload(org.folio.holdingsiq.model.ResourceSelectedPayload) Title(org.folio.holdingsiq.model.Title) PackageId(org.folio.holdingsiq.model.PackageId) IdParser.parsePackageId(org.folio.rest.util.IdParser.parsePackageId) InputValidationException(org.folio.rest.exception.InputValidationException) HandleValidationErrors(org.folio.rest.aspect.HandleValidationErrors)

Example 4 with PackageId

use of org.folio.holdingsiq.model.PackageId in project mod-kb-ebsco-java by folio-org.

the class PackageServiceImpl method retrievePackagesBulk.

public CompletableFuture<PackageBulkResult> retrievePackagesBulk(Set<String> packageIds) {
    Set<CompletableFuture<Result<PackageResult, String>>> futures = new HashSet<>();
    packageIds.forEach(inputId -> {
        try {
            PackageId id = IdParser.parsePackageId(inputId);
            futures.add(retrievePackageForBulk(id));
        } catch (ValidationException e) {
            futures.add(completedFuture(new Failure<>(inputId)));
        }
    });
    return allOfSucceeded(futures, throwable -> LOG.warn(throwable.getMessage(), throwable)).thenApply(this::mapToPackageBulk);
}
Also used : CompletableFuture.completedFuture(java.util.concurrent.CompletableFuture.completedFuture) Sort(org.folio.holdingsiq.model.Sort) CompletableFuture(java.util.concurrent.CompletableFuture) Function(java.util.function.Function) PackageId(org.folio.holdingsiq.model.PackageId) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) FutureUtils.allOfSucceeded(org.folio.util.FutureUtils.allOfSucceeded) PackageBulkResult(org.folio.rmapi.result.PackageBulkResult) SearchProperties(org.folio.properties.common.SearchProperties) NoSuchElementException(java.util.NoSuchElementException) TitlesHoldingsIQService(org.folio.holdingsiq.service.TitlesHoldingsIQService) PackageCacheKey(org.folio.rmapi.cache.PackageCacheKey) VertxCache(org.folio.cache.VertxCache) IdParser(org.folio.rest.util.IdParser) Vertx(io.vertx.core.Vertx) Set(java.util.Set) Titles(org.folio.holdingsiq.model.Titles) VendorResult(org.folio.rmapi.result.VendorResult) Collectors(java.util.stream.Collectors) FilterQuery(org.folio.holdingsiq.model.FilterQuery) Consumer(java.util.function.Consumer) List(java.util.List) Logger(org.apache.logging.log4j.Logger) Packages(org.folio.holdingsiq.model.Packages) PackageResult(org.folio.rmapi.result.PackageResult) ValidationException(javax.validation.ValidationException) Configuration(org.folio.holdingsiq.model.Configuration) PackageData(org.folio.holdingsiq.model.PackageData) Comparator(java.util.Comparator) Collections(java.util.Collections) LogManager(org.apache.logging.log4j.LogManager) PackageByIdData(org.folio.holdingsiq.model.PackageByIdData) PackagesHoldingsIQServiceImpl(org.folio.holdingsiq.service.impl.PackagesHoldingsIQServiceImpl) CompletableFuture(java.util.concurrent.CompletableFuture) ValidationException(javax.validation.ValidationException) PackageResult(org.folio.rmapi.result.PackageResult) PackageId(org.folio.holdingsiq.model.PackageId) HashSet(java.util.HashSet)

Example 5 with PackageId

use of org.folio.holdingsiq.model.PackageId in project mod-kb-ebsco-java by folio-org.

the class PackageServiceImplTest method shouldReturnCachedPackage.

@Test
public void shouldReturnCachedPackage() throws IOException, URISyntaxException {
    RegexPattern getPackagePattern = new RegexPattern("/rm/rmaccounts/" + STUB_CUSTOMER_ID + "/vendors/" + STUB_VENDOR_ID + "/packages/" + STUB_PACKAGE_ID);
    Configuration configuration = Configuration.builder().url("http://127.0.0.1:" + userMockServer.port()).customerId(STUB_CUSTOMER_ID).apiKey("API KEY").build();
    PackageServiceImpl service = new PackageServiceImpl(configuration, Vertx.vertx(), STUB_TENANT, null, null, new VertxCache<>(Vertx.vertx(), 60, "packageCache"), null);
    mockGet(getPackagePattern, CUSTOM_PACKAGE_STUB_FILE);
    PackageId packageId = PackageId.builder().packageIdPart(STUB_PACKAGE_ID).providerIdPart(STUB_VENDOR_ID).build();
    service.retrievePackage(packageId, Collections.emptyList(), true).join();
    service.retrievePackage(packageId, Collections.emptyList(), true).join();
    verify(1, getRequestedFor(new UrlPattern(getPackagePattern, true)));
}
Also used : WireMockConfiguration(com.github.tomakehurst.wiremock.core.WireMockConfiguration) Configuration(org.folio.holdingsiq.model.Configuration) RegexPattern(com.github.tomakehurst.wiremock.matching.RegexPattern) PackageId(org.folio.holdingsiq.model.PackageId) UrlPattern(com.github.tomakehurst.wiremock.matching.UrlPattern) Test(org.junit.Test)

Aggregations

PackageId (org.folio.holdingsiq.model.PackageId)10 Vertx (io.vertx.core.Vertx)8 List (java.util.List)8 CompletableFuture (java.util.concurrent.CompletableFuture)8 PackageByIdData (org.folio.holdingsiq.model.PackageByIdData)8 SearchProperties (org.folio.properties.common.SearchProperties)8 AsyncResult (io.vertx.core.AsyncResult)7 Context (io.vertx.core.Context)7 Handler (io.vertx.core.Handler)7 Map (java.util.Map)7 UUID (java.util.UUID)7 CompletableFuture.completedFuture (java.util.concurrent.CompletableFuture.completedFuture)7 Function (java.util.function.Function)7 Response (javax.ws.rs.core.Response)7 BooleanUtils (org.apache.commons.lang3.BooleanUtils)7 CustomerResources (org.folio.holdingsiq.model.CustomerResources)7 Titles (org.folio.holdingsiq.model.Titles)7 ResourceNotFoundException (org.folio.holdingsiq.service.exception.ResourceNotFoundException)7 RecordKey (org.folio.repository.RecordKey)7 RecordType (org.folio.repository.RecordType)7