Search in sources :

Example 1 with PackagePut

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

the class EholdingsPackagesTest method shouldPassIsFullPackageAttributeToRMAPI.

@Test
public void shouldPassIsFullPackageAttributeToRMAPI() throws URISyntaxException, IOException {
    PackageByIdData updatedPackage = mapper.readValue(getFile(PACKAGE_STUB_FILE), PackageByIdData.class).toByIdBuilder().isSelected(true).build();
    mockUpdateScenario(readFile(PACKAGE_STUB_FILE), mapper.writeValueAsString(updatedPackage));
    PackagePutRequest request = mapper.readValue(readFile("requests/kb-ebsco/package/put-package-selected.json"), PackagePutRequest.class);
    request.getData().getAttributes().setIsFullPackage(false);
    putWithOk(PACKAGES_PATH, mapper.writeValueAsString(request), STUB_TOKEN_HEADER).as(Package.class);
    PackagePut rmApiPutRequest = mapper.readValue(readFile("requests/rmapi/packages/put-package-is-selected.json"), PackagePut.class).toBuilder().isFullPackage(false).build();
    verify(putRequestedFor(PACKAGE_URL_PATTERN).withRequestBody(new EqualToJsonPattern(mapper.writeValueAsString(rmApiPutRequest), true, true)));
}
Also used : EqualToJsonPattern(com.github.tomakehurst.wiremock.matching.EqualToJsonPattern) PackagePut(org.folio.holdingsiq.model.PackagePut) PackagePutRequest(org.folio.rest.jaxrs.model.PackagePutRequest) PackageByIdData(org.folio.holdingsiq.model.PackageByIdData) Test(org.junit.Test)

Example 2 with PackagePut

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

the class PackageRequestConverter method convertToRMAPICustomPackagePutRequest.

public PackagePut convertToRMAPICustomPackagePutRequest(PackagePutRequest request) {
    PackagePutDataAttributes attributes = request.getData().getAttributes();
    PackagePut.PackagePutBuilder builder = convertCommonAttributesToPackagePutRequest(attributes);
    builder.packageName(attributes.getName());
    Integer contentType = contentTypeToRMAPICode.get(attributes.getContentType());
    builder.contentType(contentType != null ? contentType : 6);
    return builder.build();
}
Also used : PackagePutDataAttributes(org.folio.rest.jaxrs.model.PackagePutDataAttributes) PackagePut(org.folio.holdingsiq.model.PackagePut)

Example 3 with PackagePut

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

the class PackageRequestConverterTest method shouldCreateRequestToChangeCustomPackageCoverageDatesToEmpty.

@Test
public void shouldCreateRequestToChangeCustomPackageCoverageDatesToEmpty() {
    PackagePut packagePut = packagesConverter.convertToRMAPICustomPackagePutRequest(PackagesTestData.getPackagePutRequest(new PackagePutDataAttributes().withCustomCoverage(new Coverage().withBeginCoverage("").withEndCoverage(""))));
    assertEquals("", packagePut.getCustomCoverage().getBeginCoverage());
    assertEquals("", packagePut.getCustomCoverage().getEndCoverage());
}
Also used : PackagePutDataAttributes(org.folio.rest.jaxrs.model.PackagePutDataAttributes) PackagePut(org.folio.holdingsiq.model.PackagePut) Coverage(org.folio.rest.jaxrs.model.Coverage) Test(org.junit.Test)

Example 4 with PackagePut

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

the class PackageRequestConverterTest method shouldCreateRequestToChangeCustomPackageCoverageDates.

@Test
public void shouldCreateRequestToChangeCustomPackageCoverageDates() {
    PackagePut packagePut = packagesConverter.convertToRMAPICustomPackagePutRequest(PackagesTestData.getPackagePutRequest(new PackagePutDataAttributes().withCustomCoverage(new Coverage().withBeginCoverage("2003-01-01").withEndCoverage("2004-01-01"))));
    assertEquals("2003-01-01", packagePut.getCustomCoverage().getBeginCoverage());
    assertEquals("2004-01-01", packagePut.getCustomCoverage().getEndCoverage());
}
Also used : PackagePutDataAttributes(org.folio.rest.jaxrs.model.PackagePutDataAttributes) PackagePut(org.folio.holdingsiq.model.PackagePut) Coverage(org.folio.rest.jaxrs.model.Coverage) Test(org.junit.Test)

Example 5 with PackagePut

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

the class PackageRequestConverterTest method shouldCreateRequestToAddCustomCoverage.

@Test
public void shouldCreateRequestToAddCustomCoverage() {
    PackagePut packagePut = packagesConverter.convertToRMAPIPackagePutRequest(PackagesTestData.getPackagePutRequest(new PackagePutDataAttributes().withIsSelected(true).withCustomCoverage(new Coverage().withBeginCoverage("2000-10-10").withEndCoverage("2000-11-10"))));
    assertEquals("2000-10-10", packagePut.getCustomCoverage().getBeginCoverage());
    assertEquals("2000-11-10", packagePut.getCustomCoverage().getEndCoverage());
}
Also used : PackagePutDataAttributes(org.folio.rest.jaxrs.model.PackagePutDataAttributes) PackagePut(org.folio.holdingsiq.model.PackagePut) Coverage(org.folio.rest.jaxrs.model.Coverage) Test(org.junit.Test)

Aggregations

PackagePut (org.folio.holdingsiq.model.PackagePut)13 PackagePutDataAttributes (org.folio.rest.jaxrs.model.PackagePutDataAttributes)11 Test (org.junit.Test)10 Coverage (org.folio.rest.jaxrs.model.Coverage)3 VisibilityData (org.folio.rest.jaxrs.model.VisibilityData)2 EqualToJsonPattern (com.github.tomakehurst.wiremock.matching.EqualToJsonPattern)1 PackageByIdData (org.folio.holdingsiq.model.PackageByIdData)1 TokenInfo (org.folio.holdingsiq.model.TokenInfo)1 PackagePutRequest (org.folio.rest.jaxrs.model.PackagePutRequest)1