Search in sources :

Example 1 with DbPackage

use of org.folio.repository.packages.DbPackage in project mod-kb-ebsco-java by folio-org.

the class EholdingsPackagesTest method shouldDeletePackageOnDeleteRequest.

@Test
public void shouldDeletePackageOnDeleteRequest() throws IOException, URISyntaxException {
    sendPost(readFile("requests/kb-ebsco/package/post-package-request.json"));
    sendPutTags(Collections.singletonList(STUB_TAG_VALUE));
    mockGet(new EqualToPattern(PACKAGE_BY_ID_URL), CUSTOM_PACKAGE_STUB_FILE);
    mockPut(new EqualToPattern(PACKAGE_BY_ID_URL), new AnythingPattern(), SC_NO_CONTENT);
    deleteWithNoContent(PACKAGES_PATH, STUB_TOKEN_HEADER);
    List<DbPackage> packages = PackagesTestUtil.getPackages(vertx);
    assertThat(packages, is(empty()));
}
Also used : PackagesTestUtil.buildDbPackage(org.folio.util.PackagesTestUtil.buildDbPackage) DbPackage(org.folio.repository.packages.DbPackage) AnythingPattern(com.github.tomakehurst.wiremock.matching.AnythingPattern) EqualToPattern(com.github.tomakehurst.wiremock.matching.EqualToPattern) Test(org.junit.Test)

Example 2 with DbPackage

use of org.folio.repository.packages.DbPackage in project mod-kb-ebsco-java by folio-org.

the class PackageCollectionResultConverter method convert.

@Override
public PackageCollection convert(@NonNull PackageCollectionResult packagesResult) {
    Packages packages = packagesResult.getPackages();
    List<DbPackage> dbPackages = packagesResult.getDbPackages();
    List<PackageCollectionItem> packageList = mapItems(packages.getPackagesList(), packageData -> {
        PackageCollectionItem item = packageCollectionItemConverter.convert(packageData);
        item.getAttributes().withTags(new Tags().withTagList(getTagsById(dbPackages, createPackageId(packageData))));
        return item;
    });
    return new PackageCollection().withJsonapi(RestConstants.JSONAPI).withMeta(new MetaTotalResults().withTotalResults(packages.getTotalResults())).withData(packageList);
}
Also used : PackageCollectionItem(org.folio.rest.jaxrs.model.PackageCollectionItem) Packages(org.folio.holdingsiq.model.Packages) DbPackage(org.folio.repository.packages.DbPackage) MetaTotalResults(org.folio.rest.jaxrs.model.MetaTotalResults) PackageCollection(org.folio.rest.jaxrs.model.PackageCollection) Tags(org.folio.rest.jaxrs.model.Tags)

Aggregations

DbPackage (org.folio.repository.packages.DbPackage)2 AnythingPattern (com.github.tomakehurst.wiremock.matching.AnythingPattern)1 EqualToPattern (com.github.tomakehurst.wiremock.matching.EqualToPattern)1 Packages (org.folio.holdingsiq.model.Packages)1 MetaTotalResults (org.folio.rest.jaxrs.model.MetaTotalResults)1 PackageCollection (org.folio.rest.jaxrs.model.PackageCollection)1 PackageCollectionItem (org.folio.rest.jaxrs.model.PackageCollectionItem)1 Tags (org.folio.rest.jaxrs.model.Tags)1 PackagesTestUtil.buildDbPackage (org.folio.util.PackagesTestUtil.buildDbPackage)1 Test (org.junit.Test)1