Search in sources :

Example 1 with GET_RECORD

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

the class OaiPmhImplTest method getOaiGetRecordVerbWithoutMetadataPrefix.

@Test
void getOaiGetRecordVerbWithoutMetadataPrefix(VertxTestContext testContext) {
    String identifier = IDENTIFIER_PREFIX + OkapiMockServer.EXISTING_IDENTIFIER;
    RequestSpecification request = createBaseRequest().with().param(VERB_PARAM, GET_RECORD.value()).param(IDENTIFIER_PARAM, identifier);
    OAIPMH oaipmh = verifyResponseWithErrors(request, GET_RECORD, 400, 1);
    assertThat(oaipmh.getGetRecord(), is(nullValue()));
    assertThat(oaipmh.getErrors().get(0).getCode(), equalTo(BAD_ARGUMENT));
    testContext.completeNow();
}
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) Test(org.junit.jupiter.api.Test)

Example 2 with GET_RECORD

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

the class OaiPmhImplTest method getOaiRecordByIdInvalidIdentifier.

@ParameterizedTest
@EnumSource(MetadataPrefix.class)
void getOaiRecordByIdInvalidIdentifier(MetadataPrefix metadataPrefix) {
    RequestSpecification requestSpecification = createBaseRequest().with().param(VERB_PARAM, GET_RECORD.value()).param(IDENTIFIER_PARAM, INVALID_IDENTIFIER).param(METADATA_PREFIX_PARAM, metadataPrefix.getName());
    String response = verifyWithCodeWithXml(requestSpecification, 400);
    // Check that error message is returned
    assertThat(response, is(notNullValue()));
    // Unmarshal string to OAIPMH and verify required data presents
    OAIPMH oaipmh = ResponseConverter.getInstance().stringToOaiPmh(response);
    verifyBaseResponse(oaipmh, GET_RECORD);
    assertThat(oaipmh.getGetRecord(), is(nullValue()));
    assertThat(oaipmh.getErrors().get(0).getCode(), equalTo(BAD_ARGUMENT));
}
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 GET_RECORD

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

the class OaiPmhImplTest method headerDatestampOfGetRecordVerbShouldCorrespondToGranularitySetting.

@ParameterizedTest
@MethodSource("allMetadataPrefixesAndGranularityTypesProvider")
void headerDatestampOfGetRecordVerbShouldCorrespondToGranularitySetting(MetadataPrefix prefix, GranularityType granularityType) {
    String timeGranularity = System.getProperty(REPOSITORY_TIME_GRANULARITY);
    System.setProperty(REPOSITORY_TIME_GRANULARITY, granularityType.value());
    String identifier = IDENTIFIER_PREFIX + OkapiMockServer.EXISTING_IDENTIFIER;
    RequestSpecification request = createBaseRequest().with().param(VERB_PARAM, GET_RECORD.value()).param(IDENTIFIER_PARAM, identifier).param(METADATA_PREFIX_PARAM, prefix.getName());
    OAIPMH oaipmh = verify200WithXml(request, GET_RECORD);
    verifyHeaderDateStamp(oaipmh, GET_RECORD, granularityType.value());
    System.setProperty(REPOSITORY_TIME_GRANULARITY, timeGranularity);
}
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 GET_RECORD

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

the class OaiPmhImplTest method getOaiGetRecordVerbWithNonExistingIdentifier.

@ParameterizedTest
@EnumSource(MetadataPrefix.class)
void getOaiGetRecordVerbWithNonExistingIdentifier(MetadataPrefix metadataPrefix) {
    String identifier = IDENTIFIER_PREFIX + OkapiMockServer.NON_EXISTING_IDENTIFIER;
    RequestSpecification request = createBaseRequest().with().param(VERB_PARAM, GET_RECORD.value()).param(IDENTIFIER_PARAM, identifier).param(METADATA_PREFIX_PARAM, metadataPrefix.getName());
    OAIPMH oaipmh = verifyResponseWithErrors(request, GET_RECORD, 404, 1);
    assertThat(oaipmh.getGetRecord(), is(nullValue()));
    assertThat(oaipmh.getErrors().get(0).getCode(), equalTo(ID_DOES_NOT_EXIST));
}
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 5 with GET_RECORD

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

the class OaiPmhImplTest method getOaiGetRecordVerbWithWrongMetadataPrefix.

@Test
void getOaiGetRecordVerbWithWrongMetadataPrefix() {
    String metadataPrefix = "mark_xml";
    String identifier = IDENTIFIER_PREFIX + OkapiMockServer.EXISTING_IDENTIFIER;
    RequestSpecification request = createBaseRequest().with().param(VERB_PARAM, GET_RECORD.value()).param(IDENTIFIER_PARAM, identifier).param(METADATA_PREFIX_PARAM, metadataPrefix);
    OAIPMH oaipmh = verifyResponseWithErrors(request, GET_RECORD, 422, 1);
    assertThat(oaipmh.getGetRecord(), is(nullValue()));
    assertThat(oaipmh.getErrors().get(0).getCode(), equalTo(CANNOT_DISSEMINATE_FORMAT));
}
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) Test(org.junit.jupiter.api.Test)

Aggregations

RequestSpecification (io.restassured.specification.RequestSpecification)6 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)6 Matchers.isEmptyString (org.hamcrest.Matchers.isEmptyString)6 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)6 OAIPMH (org.openarchives.oai._2.OAIPMH)6 EnumSource (org.junit.jupiter.params.provider.EnumSource)3 Test (org.junit.jupiter.api.Test)2 MethodSource (org.junit.jupiter.params.provider.MethodSource)1 HeaderType (org.openarchives.oai._2.HeaderType)1