Search in sources :

Example 36 with VerbType

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

Example 37 with VerbType

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));
}
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 38 with VerbType

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));
}
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 39 with VerbType

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

Example 40 with VerbType

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);
}
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) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Aggregations

OAIPMH (org.openarchives.oai._2.OAIPMH)39 RequestSpecification (io.restassured.specification.RequestSpecification)38 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)36 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)35 Matchers.isEmptyString (org.hamcrest.Matchers.isEmptyString)35 MethodSource (org.junit.jupiter.params.provider.MethodSource)25 ResumptionTokenType (org.openarchives.oai._2.ResumptionTokenType)13 EnumSource (org.junit.jupiter.params.provider.EnumSource)12 OAIPMHerrorType (org.openarchives.oai._2.OAIPMHerrorType)8 NameValuePair (org.apache.http.NameValuePair)6 HeaderType (org.openarchives.oai._2.HeaderType)4 OAIPMHerrorcodeType (org.openarchives.oai._2.OAIPMHerrorcodeType)2 DataFieldType (gov.loc.marc21.slim.DataFieldType)1 SubfieldatafieldType (gov.loc.marc21.slim.SubfieldatafieldType)1 RestAssured (io.restassured.RestAssured)1 RestAssured.given (io.restassured.RestAssured.given)1 DecoderConfig (io.restassured.config.DecoderConfig)1 ContentDecoder (io.restassured.config.DecoderConfig.ContentDecoder)1 RestAssuredConfig (io.restassured.config.RestAssuredConfig)1 ContentType (io.restassured.http.ContentType)1