use of org.openarchives.oai._2.VerbType 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.VerbType in project mod-oai-pmh by folio-org.
the class OaiPmhImplTest method checkSupportDeletedRecordsWhenDeletedConfigTransientAndSuppressedConfigTrueAndSuppressInRecordTrue.
@ParameterizedTest
@MethodSource("metadataPrefixAndVerbProviderExceptMarc21withHoldings")
void checkSupportDeletedRecordsWhenDeletedConfigTransientAndSuppressedConfigTrueAndSuppressInRecordTrue(MetadataPrefix prefix, VerbType verb) {
String repositorySuppressDiscovery = System.getProperty(REPOSITORY_SUPPRESSED_RECORDS_PROCESSING);
String repositoryDeletedRecords = System.getProperty(REPOSITORY_DELETED_RECORDS);
System.setProperty(REPOSITORY_DELETED_RECORDS, "transient");
System.setProperty(REPOSITORY_SUPPRESSED_RECORDS_PROCESSING, "true");
RequestSpecification request = createBaseRequest().with().param(VERB_PARAM, verb.value()).param(FROM_PARAM, DATE_FOR_INSTANCES_10).param(METADATA_PREFIX_PARAM, prefix.getName());
OAIPMH oaipmh = verify200WithXml(request, verb);
verifyListResponse(oaipmh, verb, 10);
System.setProperty(REPOSITORY_SUPPRESSED_RECORDS_PROCESSING, repositorySuppressDiscovery);
System.setProperty(REPOSITORY_DELETED_RECORDS, repositoryDeletedRecords);
}
use of org.openarchives.oai._2.VerbType in project mod-oai-pmh by folio-org.
the class OaiPmhImplTest method getOaiListVerbWithBadResumptionToken.
@ParameterizedTest
@EnumSource(value = VerbType.class, names = { "LIST_IDENTIFIERS", "LIST_RECORDS" })
void getOaiListVerbWithBadResumptionToken(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=101&nextRecordId=6506b79b-7702-48b2-9774-a1c538fdd34e
String resumptionToken = "bWV0YWRhdGFQcmVmaXg9b2FpX2RjJmZyb209MjAwMy0wMS0wMVQwMDowMDowMFomdW50aWw9M" + "jAwMy0xMC0wMVQwMDowMDowMFomc2V0PWFsbCZvZmZzZXQ9MCZ0b3RhbFJlY29yZHM9MTAxJm5leHRSZWNvcmRJZD02NTA2Y" + "jc5Yi03NzAyLTQ4YjItOTc3NC1hMWM1MzhmZGQzNGU";
RequestSpecification request = createBaseRequest().with().param(VERB_PARAM, verb.value()).param(RESUMPTION_TOKEN_PARAM, resumptionToken);
OAIPMH oaipmh = verifyResponseWithErrors(request, verb, 400, 1);
assertThat(oaipmh.getErrors(), is(hasSize(1)));
assertThat(oaipmh.getErrors().get(0).getCode(), is(equalTo(BAD_RESUMPTION_TOKEN)));
assertThat(oaipmh.getRequest().getResumptionToken(), equalTo(resumptionToken));
}
use of org.openarchives.oai._2.VerbType in project mod-oai-pmh by folio-org.
the class OaiPmhImplTest method getOaiListVerbWithWrongDatesAndWrongSet.
@ParameterizedTest
@EnumSource(value = VerbType.class, names = { "LIST_IDENTIFIERS", "LIST_RECORDS" })
void getOaiListVerbWithWrongDatesAndWrongSet(VerbType verb) {
String metadataPrefix = MetadataPrefix.MARC21XML.getName();
String from = "2018-09-19T02:52:08.873";
String until = "2018-10-20T02:03:04.567";
String set = "single";
RequestSpecification request = createBaseRequest().with().param(VERB_PARAM, verb.value()).param(FROM_PARAM, from).param(UNTIL_PARAM, until).param(METADATA_PREFIX_PARAM, metadataPrefix).param(SET_PARAM, set);
OAIPMH oaipmh = verifyResponseWithErrors(request, verb, 400, 3);
assertThat(oaipmh.getRequest().getSet(), equalTo(set));
assertThat(oaipmh.getRequest().getMetadataPrefix(), equalTo(metadataPrefix));
// The dates are of invalid format so they are not present in request
assertThat(oaipmh.getRequest().getFrom(), nullValue());
assertThat(oaipmh.getRequest().getUntil(), nullValue());
List<OAIPMHerrorType> errors = oaipmh.getErrors();
List<OAIPMHerrorcodeType> codes = errors.stream().map(OAIPMHerrorType::getCode).collect(Collectors.toList());
assertThat(codes, containsInAnyOrder(BAD_ARGUMENT, BAD_ARGUMENT, NO_RECORDS_MATCH));
Optional<String> noRecordsMsg = errors.stream().filter(error -> error.getCode() == NO_RECORDS_MATCH).map(OAIPMHerrorType::getValue).findAny();
noRecordsMsg.ifPresent(msg -> assertThat(msg, equalTo(NO_RECORD_FOUND_ERROR)));
}
use of org.openarchives.oai._2.VerbType in project mod-oai-pmh by folio-org.
the class OaiPmhImplTest method verifyResponseWithErrors.
private OAIPMH verifyResponseWithErrors(RequestSpecification request, VerbType verb, int statusCode, int errorsCount) {
String response = verifyWithCodeWithXml(request, statusCode);
// Unmarshal string to OAIPMH and verify required data presents
OAIPMH oaipmhFromString = ResponseConverter.getInstance().stringToOaiPmh(response);
verifyBaseResponse(oaipmhFromString, verb);
assertThat(oaipmhFromString.getErrors(), is(notNullValue()));
assertThat(oaipmhFromString.getErrors(), hasSize(errorsCount));
return oaipmhFromString;
}
Aggregations