Search in sources :

Example 1 with LIST_IDENTIFIERS

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));
}
Also used : OAIPMH(org.openarchives.oai._2.OAIPMH) OAIPMHerrorType(org.openarchives.oai._2.OAIPMHerrorType) RequestSpecification(io.restassured.specification.RequestSpecification) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Matchers.isEmptyString(org.hamcrest.Matchers.isEmptyString) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 2 with LIST_IDENTIFIERS

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));
}
Also used : OAIPMH(org.openarchives.oai._2.OAIPMH) RequestSpecification(io.restassured.specification.RequestSpecification) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Matchers.isEmptyString(org.hamcrest.Matchers.isEmptyString) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 3 with LIST_IDENTIFIERS

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));
}
Also used : OAIPMHerrorType(org.openarchives.oai._2.OAIPMHerrorType) RequestSpecification(io.restassured.specification.RequestSpecification) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 4 with LIST_IDENTIFIERS

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));
}
Also used : OAIPMH(org.openarchives.oai._2.OAIPMH) OAIPMHerrorType(org.openarchives.oai._2.OAIPMHerrorType) RequestSpecification(io.restassured.specification.RequestSpecification) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Matchers.isEmptyString(org.hamcrest.Matchers.isEmptyString) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 5 with LIST_IDENTIFIERS

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));
}
Also used : OAIPMH(org.openarchives.oai._2.OAIPMH) RequestSpecification(io.restassured.specification.RequestSpecification) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)13 RequestSpecification (io.restassured.specification.RequestSpecification)12 OAIPMH (org.openarchives.oai._2.OAIPMH)12 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)10 Matchers.isEmptyString (org.hamcrest.Matchers.isEmptyString)10 EnumSource (org.junit.jupiter.params.provider.EnumSource)10 OAIPMHerrorType (org.openarchives.oai._2.OAIPMHerrorType)7 MethodSource (org.junit.jupiter.params.provider.MethodSource)2 ValueSource (org.junit.jupiter.params.provider.ValueSource)1 OAIPMHerrorcodeType (org.openarchives.oai._2.OAIPMHerrorcodeType)1 ResumptionTokenType (org.openarchives.oai._2.ResumptionTokenType)1