Search in sources :

Example 1 with SubfieldatafieldType

use of gov.loc.marc21.slim.SubfieldatafieldType in project mod-oai-pmh by folio-org.

the class OaiPmhImplTest method getOaiRecordsMarc21WithHoldingsWhenNoItems.

@Test
void getOaiRecordsMarc21WithHoldingsWhenNoItems() {
    RequestSpecification request = createBaseRequest().with().param(VERB_PARAM, LIST_RECORDS.value()).param(FROM_PARAM, NO_ITEMS_DATE).param(METADATA_PREFIX_PARAM, MetadataPrefix.MARC21WITHHOLDINGS.getName());
    OAIPMH response = verify200WithXml(request, LIST_RECORDS);
    assertThat(response.getErrors(), is(empty()));
    response.getListRecords().getRecords().forEach(r -> {
        Optional<SubfieldatafieldType> optInstitutionName = findSubfieldByFiledTagAndSubfieldCode(r, "952", "a");
        Optional<SubfieldatafieldType> optCampusName = findSubfieldByFiledTagAndSubfieldCode(r, "952", "b");
        Optional<SubfieldatafieldType> optLibraryName = findSubfieldByFiledTagAndSubfieldCode(r, "952", "c");
        Optional<SubfieldatafieldType> optLocationName = findSubfieldByFiledTagAndSubfieldCode(r, "952", "d");
        Optional<SubfieldatafieldType> optCallNumber = findSubfieldByFiledTagAndSubfieldCode(r, "952", "e");
        Optional<SubfieldatafieldType> optHoldingsUrlField = findSubfieldByFiledTagAndSubfieldCode(r, "856", "u");
        Optional<SubfieldatafieldType> optHoldingsType = findSubfieldByFiledTagAndSubfieldCode(r, "856", "3");
        Optional<SubfieldatafieldType> optHoldingsUrlNote = findSubfieldByFiledTagAndSubfieldCode(r, "856", "z");
        assertTrue(optInstitutionName.isPresent());
        assertTrue(optCampusName.isPresent());
        assertTrue(optLibraryName.isPresent());
        assertTrue(optLocationName.isPresent());
        assertTrue(optCallNumber.isPresent());
        assertTrue(optHoldingsUrlField.isPresent());
        assertTrue(optHoldingsType.isPresent());
        assertTrue(optHoldingsUrlNote.isPresent());
    });
}
Also used : SubfieldatafieldType(gov.loc.marc21.slim.SubfieldatafieldType) OAIPMH(org.openarchives.oai._2.OAIPMH) RequestSpecification(io.restassured.specification.RequestSpecification) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Test(org.junit.jupiter.api.Test)

Example 2 with SubfieldatafieldType

use of gov.loc.marc21.slim.SubfieldatafieldType in project mod-oai-pmh by folio-org.

the class OaiPmhImplTest method shouldDecodeCyrillicSymbols_whenGetListRecordsAndSomeRecordsHaveCyrillicData.

@ParameterizedTest
// metadata only marc21 and marc21_withh
@MethodSource("metadataPrefixAndEncodingProviderExceptOaiDc")
void shouldDecodeCyrillicSymbols_whenGetListRecordsAndSomeRecordsHaveCyrillicData(MetadataPrefix metadataPrefix, String encoding) {
    RequestSpecification request = createBaseRequest().with().param(VERB_PARAM, LIST_RECORDS.value()).param(FROM_PARAM, SRS_RECORDS_WITH_CYRILLIC_DATA_DATE).param(METADATA_PREFIX_PARAM, metadataPrefix.getName());
    addAcceptEncodingHeader(request, encoding);
    OAIPMH oaipmh = verify200WithXml(request, LIST_RECORDS);
    verifyListResponse(oaipmh, LIST_RECORDS, 2);
    oaipmh.getListRecords().getRecords().forEach(record -> {
        Optional<SubfieldatafieldType> optioanlSubfieldWithCyrillicData = findSubfieldByFiledTagAndSubfieldCode(record, "880", "a");
        assertTrue(optioanlSubfieldWithCyrillicData.isPresent());
        optioanlSubfieldWithCyrillicData.ifPresent(subfield -> assertEquals(EXPECTED_SUBFIELD_VALUE, subfield.getValue()));
    });
}
Also used : SubfieldatafieldType(gov.loc.marc21.slim.SubfieldatafieldType) OAIPMH(org.openarchives.oai._2.OAIPMH) RequestSpecification(io.restassured.specification.RequestSpecification) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 3 with SubfieldatafieldType

use of gov.loc.marc21.slim.SubfieldatafieldType in project mod-oai-pmh by folio-org.

the class OaiPmhImplTest method setupPredicates.

private void setupPredicates() {
    suppressedDiscoveryMarcFieldPredicate = (dataField) -> {
        List<SubfieldatafieldType> subfields = dataField.getSubfields();
        if (Objects.nonNull(subfields) && subfields.size() > 0) {
            return subfields.stream().anyMatch(subfieldatafieldType -> {
                String value = subfieldatafieldType.getValue();
                return subfieldatafieldType.getCode().equals("t") && value.equals("0") || value.equals("1");
            });
        }
        return false;
    };
    suppressedDiscoveryDcFieldPredicate = (jaxbElement) -> {
        String value = jaxbElement.getValue().getValue();
        return jaxbElement.getName().getLocalPart().equals("rights") && value.equals("discovery suppressed") || value.equals("discovery not suppressed");
    };
}
Also used : SubfieldatafieldType(gov.loc.marc21.slim.SubfieldatafieldType) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Matchers.isEmptyString(org.hamcrest.Matchers.isEmptyString)

Aggregations

SubfieldatafieldType (gov.loc.marc21.slim.SubfieldatafieldType)3 RequestSpecification (io.restassured.specification.RequestSpecification)2 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2 OAIPMH (org.openarchives.oai._2.OAIPMH)2 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1 Matchers.isEmptyString (org.hamcrest.Matchers.isEmptyString)1 Test (org.junit.jupiter.api.Test)1 MethodSource (org.junit.jupiter.params.provider.MethodSource)1