-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MODLD-647: Include Work note in 500 of the derived MARC record (#45)
- Loading branch information
Showing
6 changed files
with
126 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
src/test/java/org/folio/marc4ld/mapper/field500/Ld2Marc500IT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package org.folio.marc4ld.mapper.field500; | ||
|
||
import static org.folio.ld.dictionary.PropertyDictionary.NOTE; | ||
import static org.folio.ld.dictionary.ResourceTypeDictionary.INSTANCE; | ||
import static org.folio.ld.dictionary.ResourceTypeDictionary.WORK; | ||
import static org.folio.marc4ld.mapper.test.TestUtil.loadResourceAsString; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Set; | ||
import org.assertj.core.api.AssertionsForClassTypes; | ||
import org.folio.ld.dictionary.PredicateDictionary; | ||
import org.folio.ld.dictionary.model.Resource; | ||
import org.folio.marc4ld.mapper.test.MonographTestUtil; | ||
import org.folio.marc4ld.mapper.test.SpringTestConfig; | ||
import org.folio.marc4ld.service.ld2marc.Ld2MarcMapperImpl; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.context.properties.EnableConfigurationProperties; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
|
||
@EnableConfigurationProperties | ||
@SpringBootTest(classes = SpringTestConfig.class) | ||
class Ld2Marc500IT { | ||
|
||
@Autowired | ||
private Ld2MarcMapperImpl ld2MarcMapper; | ||
|
||
@Test | ||
void shouldMapField500() { | ||
// given | ||
var expectedMarc = loadResourceAsString("fields/500/marc_500.jsonl"); | ||
var resource = createResourceWith500(); | ||
|
||
//when | ||
var result = ld2MarcMapper.toMarcJson(resource); | ||
|
||
// then | ||
AssertionsForClassTypes.assertThat(result) | ||
.isEqualTo(expectedMarc); | ||
} | ||
|
||
private Resource createResourceWith500() { | ||
var work = MonographTestUtil.createResource( | ||
Map.of(NOTE, List.of("note 2")), | ||
Set.of(WORK), | ||
Collections.emptyMap() | ||
).setLabel("Work: label"); | ||
|
||
return MonographTestUtil.createResource( | ||
Map.of(NOTE, List.of("note 1")), | ||
Set.of(INSTANCE), | ||
Map.of(PredicateDictionary.INSTANTIATES, List.of(work)) | ||
); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
src/test/java/org/folio/marc4ld/mapper/field500/Marc2Ld500IT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package org.folio.marc4ld.mapper.field500; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.folio.marc4ld.mapper.test.TestUtil.loadResourceAsString; | ||
import static org.folio.marc4ld.mapper.test.TestUtil.validateResource; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
import org.assertj.core.api.InstanceOfAssertFactories; | ||
import org.folio.ld.dictionary.ResourceTypeDictionary; | ||
import org.folio.marc4ld.Marc2LdTestBase; | ||
import org.folio.marc4ld.test.helper.ResourceEdgeHelper; | ||
import org.junit.jupiter.api.Test; | ||
|
||
class Marc2Ld500IT extends Marc2LdTestBase { | ||
|
||
@Test | ||
void shouldMapField500() { | ||
// given | ||
var marc = loadResourceAsString("fields/500/marc_500.jsonl"); | ||
|
||
// when | ||
var result = marcBibToResource(marc); | ||
|
||
// then | ||
assertThat(result) | ||
.satisfies(resource -> validateResource(resource, | ||
List.of(ResourceTypeDictionary.INSTANCE), | ||
Map.of( | ||
"http://bibfra.me/vocab/lite/note", List.of("note 1", "note 2") | ||
), "" | ||
)).extracting(ResourceEdgeHelper::getEdges) | ||
.asInstanceOf(InstanceOfAssertFactories.LIST) | ||
.isEmpty(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"leader" : "00124nam a2200061uc 4500", | ||
"fields" : [ { | ||
"008" : " " | ||
}, { | ||
"500" : { | ||
"subfields" : [ { | ||
"a" : "note 1" | ||
} ], | ||
"ind1" : " ", | ||
"ind2" : " " | ||
} | ||
}, { | ||
"500" : { | ||
"subfields" : [ { | ||
"a" : "note 2" | ||
} ], | ||
"ind1" : " ", | ||
"ind2" : " " | ||
} | ||
} ] | ||
} |