Search in sources :

Example 1 with LIST_METADATA_FORMATS

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

the class OaiPmhImplTest method getOaiMetadataFormatsWithExistingIdentifier.

@Test
void getOaiMetadataFormatsWithExistingIdentifier(VertxTestContext testContext) {
    logger.info("=== Test Metadata Formats with existing identifier ===");
    String identifier = IDENTIFIER_PREFIX + OkapiMockServer.EXISTING_IDENTIFIER;
    RequestSpecification request = createBaseRequest().with().param(VERB_PARAM, LIST_METADATA_FORMATS.value()).param(IDENTIFIER_PARAM, identifier);
    OAIPMH oaiPmhResponseWithExistingIdentifier = verify200WithXml(request, LIST_METADATA_FORMATS);
    assertThat(oaiPmhResponseWithExistingIdentifier.getListMetadataFormats(), is(notNullValue()));
    assertThat(oaiPmhResponseWithExistingIdentifier.getErrors(), is(empty()));
    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 LIST_METADATA_FORMATS

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

the class OaiPmhImplTest method getOaiMetadataFormatsAndCheckMarc21WithHoldingsMetadataPrefixIsPresent.

@Test
void getOaiMetadataFormatsAndCheckMarc21WithHoldingsMetadataPrefixIsPresent() {
    RequestSpecification request = createBaseRequest().with().param(VERB_PARAM, LIST_METADATA_FORMATS.value());
    OAIPMH oaiPmhResponse = verify200WithXml(request, LIST_METADATA_FORMATS);
    boolean isMarc21WithHoldingsPrefixPresent = oaiPmhResponse.getListMetadataFormats().getMetadataFormats().stream().anyMatch(metadataFormatType -> metadataFormatType.getMetadataPrefix().equals(MetadataPrefix.MARC21WITHHOLDINGS.getName()));
    assertThat(oaiPmhResponse.getListMetadataFormats().getMetadataFormats(), is(notNullValue()));
    assertThat(oaiPmhResponse.getListMetadataFormats().getMetadataFormats().size(), equalTo(3));
    assertTrue(isMarc21WithHoldingsPrefixPresent);
    assertThat(oaiPmhResponse.getErrors(), is(empty()));
}
Also used : OAIPMH(org.openarchives.oai._2.OAIPMH) RequestSpecification(io.restassured.specification.RequestSpecification) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Test(org.junit.jupiter.api.Test)

Example 3 with LIST_METADATA_FORMATS

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

the class OaiPmhImplTest method getOaiMetadataFormats.

@Test
void getOaiMetadataFormats(VertxTestContext testContext) {
    logger.info("=== Test Metadata Formats without identifier ===");
    RequestSpecification request = createBaseRequest().with().param(VERB_PARAM, LIST_METADATA_FORMATS.value());
    OAIPMH oaiPmhResponseWithoutIdentifier = verify200WithXml(request, LIST_METADATA_FORMATS);
    assertThat(oaiPmhResponseWithoutIdentifier.getListMetadataFormats(), is(notNullValue()));
    assertThat(oaiPmhResponseWithoutIdentifier.getErrors(), is(empty()));
    testContext.completeNow();
}
Also used : OAIPMH(org.openarchives.oai._2.OAIPMH) RequestSpecification(io.restassured.specification.RequestSpecification) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Test(org.junit.jupiter.api.Test)

Example 4 with LIST_METADATA_FORMATS

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

the class OaiPmhImplTest method getOaiMetadataFormatsWithInvalidIdentifier.

@Test
void getOaiMetadataFormatsWithInvalidIdentifier(VertxTestContext testContext) {
    logger.info("=== Test Metadata Formats with invalid identifier format ===");
    // Check that error message is returned
    RequestSpecification request = createBaseRequest().with().param(VERB_PARAM, LIST_METADATA_FORMATS.value()).param(IDENTIFIER_PARAM, OkapiMockServer.INVALID_IDENTIFIER);
    OAIPMH oaipmh = verifyResponseWithErrors(request, LIST_METADATA_FORMATS, 400, 1);
    assertThat(oaipmh.getListMetadataFormats(), 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) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Test(org.junit.jupiter.api.Test)

Example 5 with LIST_METADATA_FORMATS

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

the class OaiPmhImplTest method getOaiMetadataFormatsWithNonExistingIdentifier.

@Test
void getOaiMetadataFormatsWithNonExistingIdentifier(VertxTestContext testContext) {
    logger.info("=== Test Metadata Formats with non-existing identifier ===");
    // Check that error message is returned
    String identifier = IDENTIFIER_PREFIX + OkapiMockServer.NON_EXISTING_IDENTIFIER;
    RequestSpecification request = createBaseRequest().with().param(VERB_PARAM, LIST_METADATA_FORMATS.value()).param(IDENTIFIER_PARAM, identifier);
    OAIPMH oaipmh = verifyResponseWithErrors(request, LIST_METADATA_FORMATS, 404, 1);
    assertThat(oaipmh.getListMetadataFormats(), is(nullValue()));
    assertThat(oaipmh.getErrors().get(0).getCode(), equalTo(ID_DOES_NOT_EXIST));
    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)

Aggregations

RequestSpecification (io.restassured.specification.RequestSpecification)5 Test (org.junit.jupiter.api.Test)5 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)5 OAIPMH (org.openarchives.oai._2.OAIPMH)5 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)2 Matchers.isEmptyString (org.hamcrest.Matchers.isEmptyString)2