use of org.openarchives.oai._2.VerbType in project mod-oai-pmh by folio-org.
the class OaiPmhImplTest method getOaiListVerbResumptionFlowStartedWithFromParamHasDateAndTimeGranularity.
@ParameterizedTest
@MethodSource("metadataPrefixAndVerbProviderExceptMarc21withHoldings")
void getOaiListVerbResumptionFlowStartedWithFromParamHasDateAndTimeGranularity(MetadataPrefix prefix, VerbType verb) {
String timeGranularity = System.getProperty(REPOSITORY_TIME_GRANULARITY);
System.setProperty(REPOSITORY_TIME_GRANULARITY, GranularityType.YYYY_MM_DD_THH_MM_SS_Z.value());
RequestSpecification request = createBaseRequest().with().param(VERB_PARAM, verb.value()).param(FROM_PARAM, PARTITIONABLE_RECORDS_DATE_TIME).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_TIME_GRANULARITY_PATTERN));
}
use of org.openarchives.oai._2.VerbType in project mod-oai-pmh by folio-org.
the class OaiPmhImplTest method getOaiListVerbWithInvalidDateRange.
@ParameterizedTest
@EnumSource(value = VerbType.class, names = { "LIST_IDENTIFIERS", "LIST_RECORDS" })
void getOaiListVerbWithInvalidDateRange(VerbType verb) {
String metadataPrefix = MetadataPrefix.MARC21XML.getName();
String from = "2018-12-19T02:52:08Z";
String until = "2018-10-20T02:03:04Z";
RequestSpecification request = createBaseRequest().with().param(VERB_PARAM, verb.value()).param(FROM_PARAM, from).param(UNTIL_PARAM, until).param(METADATA_PREFIX_PARAM, metadataPrefix);
OAIPMH oaipmh = verifyResponseWithErrors(request, verb, 400, 1);
assertThat(oaipmh.getRequest().getMetadataPrefix(), equalTo(metadataPrefix));
assertThat(oaipmh.getRequest().getFrom(), equalTo(from));
assertThat(oaipmh.getRequest().getUntil(), equalTo(until));
OAIPMHerrorType error = oaipmh.getErrors().get(0);
assertThat(error.getCode(), equalTo(BAD_ARGUMENT));
}
use of org.openarchives.oai._2.VerbType in project mod-oai-pmh by folio-org.
the class OaiPmhImplTest method getOaiListVerbWithWrongSet.
@ParameterizedTest
@EnumSource(value = VerbType.class, names = { "LIST_IDENTIFIERS", "LIST_RECORDS" })
void getOaiListVerbWithWrongSet(VerbType verb) {
String metadataPrefix = MetadataPrefix.MARC21XML.getName();
String set = "single";
RequestSpecification request = createBaseRequest().with().param(VERB_PARAM, verb.value()).param(METADATA_PREFIX_PARAM, metadataPrefix).param(SET_PARAM, set);
OAIPMH oaipmh = verifyResponseWithErrors(request, verb, 404, 1);
assertThat(oaipmh.getRequest().getMetadataPrefix(), equalTo(metadataPrefix));
assertThat(oaipmh.getRequest().getSet(), equalTo(set));
OAIPMHerrorType error = oaipmh.getErrors().get(0);
assertThat(error.getCode(), equalTo(NO_RECORDS_MATCH));
assertThat(error.getValue(), equalTo(NO_RECORD_FOUND_ERROR));
}
use of org.openarchives.oai._2.VerbType in project mod-oai-pmh by folio-org.
the class OaiPmhImplTest method getOaiListVerbResumptionFlowStartedWithFromParamHasDateOnlyGranularity.
@ParameterizedTest
@MethodSource("metadataPrefixAndVerbProviderExceptMarc21withHoldings")
void getOaiListVerbResumptionFlowStartedWithFromParamHasDateOnlyGranularity(MetadataPrefix prefix, VerbType verb) {
String timeGranularity = System.getProperty(REPOSITORY_TIME_GRANULARITY);
System.setProperty(REPOSITORY_TIME_GRANULARITY, GranularityType.YYYY_MM_DD_THH_MM_SS_Z.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.VerbType in project mod-oai-pmh by folio-org.
the class OaiPmhImplTest method checkSupportDeletedRecordsWhenDeletedConfigPersistentAndSuppressedConfigFalse.
@ParameterizedTest
@MethodSource("metadataPrefixAndVerbProviderExceptMarc21withHoldings")
void checkSupportDeletedRecordsWhenDeletedConfigPersistentAndSuppressedConfigFalse(MetadataPrefix prefix, VerbType verb) {
String repositorySuppressDiscovery = System.getProperty(REPOSITORY_SUPPRESSED_RECORDS_PROCESSING);
String repositoryDeletedRecords = System.getProperty(REPOSITORY_DELETED_RECORDS);
System.setProperty(REPOSITORY_DELETED_RECORDS, "persistent");
System.setProperty(REPOSITORY_SUPPRESSED_RECORDS_PROCESSING, "false");
RequestSpecification request = createBaseRequest().with().param(VERB_PARAM, verb.value()).param(FROM_PARAM, THREE_INSTANCES_DATE).param(METADATA_PREFIX_PARAM, prefix.getName());
OAIPMH oaipmh = verify200WithXml(request, verb);
verifyListResponse(oaipmh, verb, 2);
System.setProperty(REPOSITORY_SUPPRESSED_RECORDS_PROCESSING, repositorySuppressDiscovery);
System.setProperty(REPOSITORY_DELETED_RECORDS, repositoryDeletedRecords);
}
Aggregations