use of org.openarchives.oai._2.ResumptionTokenType in project mod-oai-pmh by folio-org.
the class OaiPmhImplTest method verifyResumptionTokenFlow_whenVerbListRecordsAndMetadataPrefixMarc21WithHoldings.
@ParameterizedTest
@EnumSource(value = VerbType.class, names = { "LIST_RECORDS" })
void verifyResumptionTokenFlow_whenVerbListRecordsAndMetadataPrefixMarc21WithHoldings(VerbType verb) {
final String currentValue = System.getProperty(REPOSITORY_MAX_RECORDS_PER_RESPONSE);
System.setProperty(REPOSITORY_MAX_RECORDS_PER_RESPONSE, "4");
RequestSpecification request = createBaseRequest().with().param(VERB_PARAM, verb.value()).param(FROM_PARAM, DATE_INVENTORY_10_INSTANCE_IDS).param(METADATA_PREFIX_PARAM, MetadataPrefix.MARC21WITHHOLDINGS.getName());
OAIPMH oaipmh = verify200WithXml(request, verb);
verifyListResponse(oaipmh, verb, 4);
ResumptionTokenType resumptionToken = getResumptionToken(oaipmh, verb);
assertThat(resumptionToken, is(notNullValue()));
assertThat(resumptionToken.getValue(), is(notNullValue()));
assertEquals(0, resumptionToken.getCursor().intValue());
List<HeaderType> totalRecords = getHeadersListDependOnVerbType(verb, oaipmh);
resumptionToken = makeResumptionTokenRequestsAndVerifyCount(totalRecords, resumptionToken, verb, 4, 4);
resumptionToken = makeResumptionTokenRequestsAndVerifyCount(totalRecords, resumptionToken, verb, 2, 8);
assertThat(resumptionToken.getValue(), is(isEmptyString()));
assertThat(totalRecords.size(), is(10));
System.setProperty(REPOSITORY_MAX_RECORDS_PER_RESPONSE, currentValue);
}
use of org.openarchives.oai._2.ResumptionTokenType in project mod-oai-pmh by folio-org.
the class OaiPmhImplTest method getOaiListVerbResumptionFlowStartedWithFromParamHasDateOnlyGranularityAndGranularitySettingIsDateOnly.
@ParameterizedTest
@MethodSource("metadataPrefixAndVerbProviderExceptMarc21withHoldings")
void getOaiListVerbResumptionFlowStartedWithFromParamHasDateOnlyGranularityAndGranularitySettingIsDateOnly(MetadataPrefix prefix, VerbType verb) {
String timeGranularity = System.getProperty(REPOSITORY_TIME_GRANULARITY);
System.setProperty(REPOSITORY_TIME_GRANULARITY, GranularityType.YYYY_MM_DD.value());
RequestSpecification request = createBaseRequest().with().param(VERB_PARAM, verb.value()).param(FROM_PARAM, PARTITIONABLE_RECORDS_DATE).param(METADATA_PREFIX_PARAM, prefix.getName()).param(SET_PARAM, "all");
OAIPMH oaipmh = verify200WithXml(request, verb);
ResumptionTokenType resumptionToken = getResumptionToken(oaipmh, verb);
// rollback changes of system properties as they were before test
System.setProperty(REPOSITORY_TIME_GRANULARITY, timeGranularity);
assertThat(resumptionToken, is(notNullValue()));
String resumptionTokenValue = new String(Base64.getUrlDecoder().decode(resumptionToken.getValue()), StandardCharsets.UTF_8);
List<NameValuePair> params = URLEncodedUtils.parse(resumptionTokenValue, StandardCharsets.UTF_8);
assertThat(params, is(hasSize(8)));
assertTrue(getParamValue(params, UNTIL_PARAM).matches(DATE_ONLY_GRANULARITY_PATTERN));
}
use of org.openarchives.oai._2.ResumptionTokenType in project mod-oai-pmh by folio-org.
the class OaiPmhImplTest method getOaiRecordsMarc21WithHoldingsReturnsCorrectXmlResponseWIthDefaultBatchSize.
@Test
void getOaiRecordsMarc21WithHoldingsReturnsCorrectXmlResponseWIthDefaultBatchSize() {
final String currentValue = System.getProperty(REPOSITORY_MAX_RECORDS_PER_RESPONSE);
System.setProperty(REPOSITORY_MAX_RECORDS_PER_RESPONSE, "50");
RequestSpecification request = createBaseRequest().with().param(VERB_PARAM, LIST_RECORDS.value()).param(FROM_PARAM, INVENTORY_27_INSTANCES_IDS_DATE).param(METADATA_PREFIX_PARAM, MetadataPrefix.MARC21WITHHOLDINGS.getName());
OAIPMH oaipmh = verify200WithXml(request, LIST_RECORDS);
verifyListResponse(oaipmh, LIST_RECORDS, 27);
ResumptionTokenType actualResumptionToken = getResumptionToken(oaipmh, LIST_RECORDS);
assertThat(actualResumptionToken, is(nullValue()));
System.setProperty(REPOSITORY_MAX_RECORDS_PER_RESPONSE, currentValue);
}
use of org.openarchives.oai._2.ResumptionTokenType in project mod-oai-pmh by folio-org.
the class OaiPmhImplTest method getOaiListVerbWithResumptionTokenSuccessful.
@ParameterizedTest
@EnumSource(value = VerbType.class, names = { "LIST_IDENTIFIERS", "LIST_RECORDS" })
void getOaiListVerbWithResumptionTokenSuccessful(VerbType verb) {
// base64 encoded string:
// metadataPrefix=oai_dc&from=2003-01-01T00:00:00Z&until=2003-10-01T00:00:00Z&set=all
// &offset=0&totalRecords=100&nextRecordId=04489a01-f3cd-4f9e-9be4-d9c198703f46&expirationDate=2030-10-01T00:00:00Z
String resumptionToken = "bWV0YWRhdGFQcmVmaXg9b2FpX2RjJmZyb209MjAwMy0wMS0wMVQwMDowMDowMFomdW50aWw9M" + "jAwMy0xMC0wMVQwMDowMDowMFomc2V0PWFsbCZvZmZzZXQ9MCZ0b3RhbFJlY29yZHM9MTAwJm5leHRSZWNvcmRJZD0wNDQ4O" + "WEwMS1mM2NkLTRmOWUtOWJlNC1kOWMxOTg3MDNmNDYmZXhwaXJhdGlvbkRhdGU9MjAzMC0xMC0wMVQwMDowMDowMFo=";
RequestSpecification request = createBaseRequest().with().param(VERB_PARAM, verb.value()).param(RESUMPTION_TOKEN_PARAM, resumptionToken);
OAIPMH oaipmh = verify200WithXml(request, verb);
verifyListResponse(oaipmh, verb, 10);
ResumptionTokenType actualResumptionToken = getResumptionToken(oaipmh, verb);
assertThat(actualResumptionToken, is(notNullValue()));
assertThat(actualResumptionToken.getValue(), is(notNullValue()));
String actualValue = new String(Base64.getDecoder().decode(actualResumptionToken.getValue()), StandardCharsets.UTF_8);
String expectedValue = actualValue.replaceAll("offset=\\d+", "offset=10");
assertThat(actualValue, equalTo(expectedValue));
assertThat(actualResumptionToken.getCompleteListSize(), is(equalTo(BigInteger.valueOf(100))));
assertThat(actualResumptionToken.getCursor(), is(equalTo(BigInteger.ZERO)));
assertThat(actualResumptionToken.getExpirationDate(), is(notNullValue()));
}
use of org.openarchives.oai._2.ResumptionTokenType in project mod-oai-pmh by folio-org.
the class OaiPmhImplTest method getOaiRecordsWithFromAndMetadataPrefixMarc21AndResumptionToken.
@ParameterizedTest
@MethodSource("metadataPrefixAndVerbProviderExceptMarc21withHoldings")
void getOaiRecordsWithFromAndMetadataPrefixMarc21AndResumptionToken(MetadataPrefix prefix, VerbType verb) {
RequestSpecification request = createBaseRequest().with().param(VERB_PARAM, verb.value()).param(METADATA_PREFIX_PARAM, prefix.getName()).param(FROM_PARAM, PARTITIONABLE_RECORDS_DATE_TIME);
OAIPMH oaipmh = verify200WithXml(request, verb);
verifyListResponse(oaipmh, verb, 10);
ResumptionTokenType actualResumptionToken = getResumptionToken(oaipmh, verb);
assertThat(actualResumptionToken, is(notNullValue()));
assertThat(actualResumptionToken.getValue(), is(notNullValue()));
RequestSpecification requestWithResumptionToken = createBaseRequest().with().param(VERB_PARAM, verb.value()).param(RESUMPTION_TOKEN_PARAM, actualResumptionToken.getValue());
OAIPMH oai = verify200WithXml(requestWithResumptionToken, verb);
ResumptionTokenType nextResumptionToken = getResumptionToken(oai, verb);
assertThat(nextResumptionToken, is(notNullValue()));
assertThat(nextResumptionToken.getValue(), is(notNullValue()));
assertThat(nextResumptionToken.getCompleteListSize(), is(equalTo(BigInteger.valueOf(100))));
}
Aggregations