use of org.openarchives.oai._2.VerbType.LIST_IDENTIFIERS in project mod-oai-pmh by folio-org.
the class OaiPmhImplTest method getOaiListVerbWithWrongMetadataPrefix.
@ParameterizedTest
@EnumSource(value = VerbType.class, names = { "LIST_IDENTIFIERS", "LIST_RECORDS" })
void getOaiListVerbWithWrongMetadataPrefix(VerbType verb) {
String metadataPrefix = "abc";
RequestSpecification request = createBaseRequest().with().param(VERB_PARAM, verb.value()).param(METADATA_PREFIX_PARAM, metadataPrefix);
OAIPMH oaipmh = verifyResponseWithErrors(request, verb, 422, 1);
assertThat(oaipmh.getRequest().getMetadataPrefix(), equalTo(metadataPrefix));
List<OAIPMHerrorType> errors = oaipmh.getErrors();
assertThat(errors.get(0).getCode(), equalTo(CANNOT_DISSEMINATE_FORMAT));
}
use of org.openarchives.oai._2.VerbType.LIST_IDENTIFIERS in project mod-oai-pmh by folio-org.
the class OaiPmhImplTest method getOaiListVerbWithBadResumptionTokenExpiredDate.
@ParameterizedTest
@EnumSource(value = VerbType.class, names = { "LIST_IDENTIFIERS", "LIST_RECORDS" })
void getOaiListVerbWithBadResumptionTokenExpiredDate(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&expirationDate=2003-10-01T00:00:00Z
String resumptionToken = "bWV0YWRhdGFQcmVmaXg9b2FpX2RjJmZyb209MjAwMy0wMS0wMVQwMDowMDowMFomdW50aWw9M" + "jAwMy0xMC0wMVQwMDowMDowMFomc2V0PWFsbCZvZmZzZXQ9MCZ0b3RhbFJlY29yZHM9MTAxJm5leHRSZWNvcmRJZD02NTA2Y" + "jc5Yi03NzAyLTQ4YjItOTc3NC1hMWM1MzhmZGQzNGUmZXhwaXJhdGlvbkRhdGU9MjAwMy0xMC0wMVQwMDowMDowMFo=";
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.LIST_IDENTIFIERS in project mod-oai-pmh by folio-org.
the class OaiPmhImplTest method getOaiListVerbWithoutParams.
@ParameterizedTest
@EnumSource(value = VerbType.class, names = { "LIST_IDENTIFIERS", "LIST_RECORDS" })
void getOaiListVerbWithoutParams(VerbType verb) {
RequestSpecification request = createBaseRequest().with().param(VERB_PARAM, verb.value());
List<OAIPMHerrorType> errors = verifyResponseWithErrors(request, verb, 400, 1).getErrors();
OAIPMHerrorType error = errors.get(0);
assertThat(error.getCode(), equalTo(BAD_ARGUMENT));
assertThat(error.getValue(), equalTo(LIST_NO_REQUIRED_PARAM_ERROR));
}
use of org.openarchives.oai._2.VerbType.LIST_IDENTIFIERS in project mod-oai-pmh by folio-org.
the class OaiPmhImplTest method getOaiListVerbWithNoRecordsFoundFromStorage.
@ParameterizedTest
@EnumSource(value = VerbType.class, names = { "LIST_IDENTIFIERS", "LIST_RECORDS" })
void getOaiListVerbWithNoRecordsFoundFromStorage(VerbType verb) {
String metadataPrefix = MetadataPrefix.DC.getName();
String from = NO_RECORDS_DATE;
String set = "all";
RequestSpecification request = createBaseRequest().with().param(VERB_PARAM, verb.value()).param(FROM_PARAM, from).param(SET_PARAM, set).param(METADATA_PREFIX_PARAM, metadataPrefix);
// Unmarshal string to OAIPMH and verify required data presents
OAIPMH oaipmh = verifyResponseWithErrors(request, verb, 404, 1);
// The dates are of invalid format so they are not present in request
assertThat(oaipmh.getRequest().getMetadataPrefix(), equalTo(metadataPrefix));
assertThat(oaipmh.getRequest().getFrom(), equalTo(from));
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.LIST_IDENTIFIERS in project mod-oai-pmh by folio-org.
the class OaiPmhImplTest method getOaiIdentifiersSuccess.
@ParameterizedTest
@ValueSource(strings = { "GZIP", "DEFLATE", "IDENTITY" })
void getOaiIdentifiersSuccess(String encoding) {
logger.debug(format("==== Starting getOaiIdentifiersSuccess(%s) ====", encoding));
RequestSpecification request = createBaseRequest().with().param(VERB_PARAM, LIST_IDENTIFIERS.value()).param(FROM_PARAM, DATE_FOR_INSTANCES_10).param(METADATA_PREFIX_PARAM, MetadataPrefix.MARC21XML.getName());
addAcceptEncodingHeader(request, encoding);
OAIPMH oaipmh = verify200WithXml(request, LIST_IDENTIFIERS);
verifyListResponse(oaipmh, LIST_IDENTIFIERS, 10);
assertThat(oaipmh.getListIdentifiers().getResumptionToken(), is(nullValue()));
logger.debug(format("==== getOaiIdentifiersSuccess(%s) successfully completed ====", encoding));
}
Aggregations