Search in sources :

Example 1 with VerbType

use of org.openarchives.oai._2.VerbType in project mod-oai-pmh by folio-org.

the class OaiPmhImplTest method makeResumptionTokenRequestsAndVerifyCount.

private ResumptionTokenType makeResumptionTokenRequestsAndVerifyCount(List<HeaderType> totalRecords, ResumptionTokenType resumptionToken, VerbType verb, int desiredCount, int expectedCursor) {
    RequestSpecification request = createBaseRequest().with().param(VERB_PARAM, verb.value()).param(RESUMPTION_TOKEN_PARAM, resumptionToken.getValue());
    OAIPMH oaipmh;
    List<HeaderType> records;
    oaipmh = verify200WithXml(request, verb);
    verifyListResponse(oaipmh, verb, desiredCount);
    resumptionToken = getResumptionToken(oaipmh, verb);
    assertThat(resumptionToken, is(notNullValue()));
    assertEquals(expectedCursor, resumptionToken.getCursor().intValue());
    records = getHeadersListDependOnVerbType(verb, oaipmh);
    totalRecords.addAll(records);
    return resumptionToken;
}
Also used : OAIPMH(org.openarchives.oai._2.OAIPMH) HeaderType(org.openarchives.oai._2.HeaderType) RequestSpecification(io.restassured.specification.RequestSpecification)

Example 2 with VerbType

use of org.openarchives.oai._2.VerbType in project mod-oai-pmh by folio-org.

the class OaiPmhImplTest method checkSupportDeletedRecordsWhenDeletedConfigIsNoAndSuppressedConfigTrue.

@ParameterizedTest
@MethodSource("metadataPrefixAndVerbProviderExceptMarc21withHoldings")
void checkSupportDeletedRecordsWhenDeletedConfigIsNoAndSuppressedConfigTrue(MetadataPrefix prefix, VerbType verb) {
    String repositorySuppressDiscovery = System.getProperty(REPOSITORY_SUPPRESSED_RECORDS_PROCESSING);
    String repositoryDeletedRecords = System.getProperty(REPOSITORY_DELETED_RECORDS);
    System.setProperty(REPOSITORY_DELETED_RECORDS, "no");
    System.setProperty(REPOSITORY_SUPPRESSED_RECORDS_PROCESSING, "true");
    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, 3);
    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)

Example 3 with VerbType

use of org.openarchives.oai._2.VerbType in project mod-oai-pmh by folio-org.

the class OaiPmhImplTest method checkSupportDeletedRecordsWhenDeletedConfigTransientAndSuppressedConfigTrueAndRecordMarkAsDeleted.

@ParameterizedTest
@MethodSource("metadataPrefixAndVerbProviderExceptMarc21withHoldings")
void checkSupportDeletedRecordsWhenDeletedConfigTransientAndSuppressedConfigTrueAndRecordMarkAsDeleted(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, THREE_INSTANCES_DATE_WITH_ONE_MARK_DELETED_RECORD).param(METADATA_PREFIX_PARAM, prefix.getName());
    OAIPMH oaipmh = verify200WithXml(request, verb);
    verifyListResponse(oaipmh, verb, 3);
    if (verb.equals(LIST_RECORDS)) {
        assertThat(oaipmh.getListRecords().getRecords().get(2).getHeader().getStatus(), is(StatusType.DELETED));
    } else {
        assertThat(oaipmh.getListIdentifiers().getHeaders().get(2).getStatus(), is(StatusType.DELETED));
    }
    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)

Example 4 with VerbType

use of org.openarchives.oai._2.VerbType in project mod-oai-pmh by folio-org.

the class OaiPmhImplTest method getOaiListVerbResumptionFlowStarted.

@ParameterizedTest
@MethodSource("metadataPrefixAndVerbProviderExceptMarc21withHoldings")
void getOaiListVerbResumptionFlowStarted(MetadataPrefix metadataPrefix, VerbType verb) {
    RequestSpecification request = createBaseRequest().with().param(VERB_PARAM, verb.value()).param(FROM_PARAM, PARTITIONABLE_RECORDS_DATE_TIME).param(METADATA_PREFIX_PARAM, metadataPrefix.getName()).param(SET_PARAM, "all");
    OAIPMH oaipmh = verify200WithXml(request, verb);
    verifyListResponse(oaipmh, verb, 10);
    ResumptionTokenType resumptionToken = getResumptionToken(oaipmh, verb);
    assertThat(resumptionToken, is(notNullValue()));
    assertThat(resumptionToken.getCompleteListSize(), is(equalTo(BigInteger.valueOf(100))));
    assertThat(resumptionToken.getCursor(), is(equalTo(BigInteger.ZERO)));
    assertThat(resumptionToken.getExpirationDate(), 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)));
    assertThat(getParamValue(params, METADATA_PREFIX_PARAM), is(equalTo(metadataPrefix.getName())));
    assertThat(getParamValue(params, FROM_PARAM), is(equalTo(PARTITIONABLE_RECORDS_DATE_TIME)));
    assertThat(getParamValue(params, UNTIL_PARAM), is((notNullValue())));
    assertThat(getParamValue(params, SET_PARAM), is(equalTo("all")));
    assertThat(getParamValue(params, OFFSET_PARAM), is(equalTo("10")));
    assertThat(getParamValue(params, TOTAL_RECORDS_PARAM), is(equalTo("100")));
    assertThat(getParamValue(params, NEXT_RECORD_ID_PARAM), is(equalTo("6506b79b-7702-48b2-9774-a1c538fdd34e")));
}
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 5 with VerbType

use of org.openarchives.oai._2.VerbType in project mod-oai-pmh by folio-org.

the class OaiPmhImplTest method verify200WithXml.

private OAIPMH verify200WithXml(RequestSpecification request, VerbType verb) {
    String response = verifyWithCodeWithXml(request, 200);
    // Unmarshal string to OAIPMH and verify required data presents
    OAIPMH oaipmh = ResponseConverter.getInstance().stringToOaiPmh(response);
    verifyBaseResponse(oaipmh, verb);
    return oaipmh;
}
Also used : OAIPMH(org.openarchives.oai._2.OAIPMH) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Matchers.isEmptyString(org.hamcrest.Matchers.isEmptyString)

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