Skip to content

Commit

Permalink
[MODSOURMAN-1227] Test subject type mapped if no second id (#365)
Browse files Browse the repository at this point in the history
  • Loading branch information
RomanChernetskyi authored Oct 8, 2024
1 parent 70d4f4b commit 9ff0f67
Show file tree
Hide file tree
Showing 2 changed files with 313 additions and 10 deletions.
30 changes: 20 additions & 10 deletions src/test/java/org/folio/processing/mapping/InstanceMappingTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -544,17 +544,27 @@ public void testMarcToInstanceWithRepeatableSubjects() throws IOException {
}

@Test
public void testMarcToInstanceWithRepeatableSubjectsButWithoutIndicators() throws IOException {
public void testMarcToInstanceWithRepeatableSubjectsMappedWithTypeButWithoutIndicators() throws IOException {
final String FIRST_SUBJECT_TYPE_ID = "d6488f88-1e74-40ce-81b5-b19a928ff5b1";
final String SECOND_SUBJECT_TYPE_ID = "d6488f88-1e74-40ce-81b5-b19a928ff5b2";
final String THIRD_SUBJECT_TYPE_ID = "d6488f88-1e74-40ce-81b5-b19a928ff5b3";
final String FOURTH_SUBJECT_TYPE_ID = "d6488f88-1e74-40ce-81b5-b19a928ff5b4";
final String FIFTH_SUBJECT_TYPE_ID = "d6488f88-1e74-40ce-81b5-b19a928ff5b5";
final String SIXTH_SUBJECT_TYPE_ID = "d6488f88-1e74-40ce-81b5-b19a928ff5b6";
final String SEVENTH_SUBJECT_TYPE_ID = "d6488f88-1e74-40ce-81b5-b19a928ff5b7";
final String EIGHTH_SUBJECT_TYPE_ID = "d6488f88-1e74-40ce-81b5-b19a928ff5b8";
final String NINTH_SUBJECT_TYPE_ID = "d6488f88-1e74-40ce-81b5-b19a928ff511";

final List<Subject> expectedResults = List.of(
new Subject().withValue("Test 600.2 subject"),
new Subject().withValue("Test 610 subject"),
new Subject().withValue("Test 611 subject"),
new Subject().withValue("Test 630 subject"),
new Subject().withValue("Test 647 subject"),
new Subject().withValue("Test 648 subject"),
new Subject().withValue("Test 650 subject"),
new Subject().withValue("Test 651 subject"),
new Subject().withValue("Test 655 subject")
new Subject().withValue("Test 600.2 subject").withTypeId(FIRST_SUBJECT_TYPE_ID),
new Subject().withValue("Test 610 subject").withTypeId(SECOND_SUBJECT_TYPE_ID),
new Subject().withValue("Test 611 subject").withTypeId(THIRD_SUBJECT_TYPE_ID),
new Subject().withValue("Test 630 subject").withTypeId(FOURTH_SUBJECT_TYPE_ID),
new Subject().withValue("Test 647 subject").withTypeId(FIFTH_SUBJECT_TYPE_ID),
new Subject().withValue("Test 648 subject").withTypeId(SIXTH_SUBJECT_TYPE_ID),
new Subject().withValue("Test 650 subject").withTypeId(SEVENTH_SUBJECT_TYPE_ID),
new Subject().withValue("Test 651 subject").withTypeId(EIGHTH_SUBJECT_TYPE_ID),
new Subject().withValue("Test 655 subject").withTypeId(NINTH_SUBJECT_TYPE_ID)
);

MarcReader reader = new MarcStreamReader(new ByteArrayInputStream(TestUtil.readFileFromPath(BIB_WITH_REPEATED_600_SUBFIELD_AND_EMPTY_INDICATOR).getBytes(StandardCharsets.UTF_8)));
Expand Down
293 changes: 293 additions & 0 deletions src/test/resources/org/folio/processing/mapping/instance/rules.json
Original file line number Diff line number Diff line change
Expand Up @@ -5836,6 +5836,49 @@
"subfield": [
"9"
]
},
{
"target": "subjects.typeId",
"description": "Subject type id",
"subfield": [
"a",
"b",
"c",
"d",
"e",
"f",
"g",
"h",
"j",
"k",
"l",
"m",
"n",
"o",
"p",
"q",
"r",
"s",
"t",
"u",
"v",
"x",
"y",
"z"
],
"applyRulesOnConcatenatedData": true,
"rules": [
{
"conditions": [
{
"type": "set_subject_type_id",
"parameter": {
"name": "Personal name"
}
}
]
}
]
}
]
},
Expand Down Expand Up @@ -7345,6 +7388,47 @@
"subfield": [
"9"
]
},
{
"target": "subjects.typeId",
"description": "Subject type id",
"subfield": [
"a",
"b",
"c",
"d",
"e",
"f",
"g",
"h",
"k",
"l",
"m",
"n",
"o",
"p",
"r",
"s",
"t",
"u",
"v",
"x",
"y",
"z"
],
"applyRulesOnConcatenatedData": true,
"rules": [
{
"conditions": [
{
"type": "set_subject_type_id",
"parameter": {
"name": "Corporate name"
}
}
]
}
]
}
]
},
Expand Down Expand Up @@ -8781,6 +8865,45 @@
"subfield": [
"9"
]
},
{
"target": "subjects.typeId",
"description": "Subject type id",
"subfield": [
"a",
"c",
"d",
"e",
"f",
"g",
"h",
"j",
"k",
"l",
"n",
"p",
"q",
"s",
"t",
"u",
"v",
"x",
"y",
"z"
],
"applyRulesOnConcatenatedData": true,
"rules": [
{
"conditions": [
{
"type": "set_subject_type_id",
"parameter": {
"name": "Meeting name"
}
}
]
}
]
}
]
},
Expand Down Expand Up @@ -10180,6 +10303,44 @@
"subfield": [
"9"
]
},
{
"target": "subjects.typeId",
"description": "Subject type id",
"subfield": [
"a",
"d",
"e",
"f",
"g",
"h",
"k",
"l",
"m",
"n",
"o",
"p",
"r",
"s",
"t",
"v",
"x",
"y",
"z"
],
"applyRulesOnConcatenatedData": true,
"rules": [
{
"conditions": [
{
"type": "set_subject_type_id",
"parameter": {
"name": "Uniform title"
}
}
]
}
]
}
]
},
Expand Down Expand Up @@ -11500,6 +11661,33 @@
"subfield": [
"9"
]
},
{
"target": "subjects.typeId",
"description": "Subject type id",
"subfield": [
"a",
"c",
"d",
"g",
"x",
"y",
"z",
"v"
],
"applyRulesOnConcatenatedData": true,
"rules": [
{
"conditions": [
{
"type": "set_subject_type_id",
"parameter": {
"name": "Named event"
}
}
]
}
]
}
]
},
Expand Down Expand Up @@ -12442,6 +12630,30 @@
"subfield": [
"9"
]
},
{
"target": "subjects.typeId",
"description": "Subject type id",
"subfield": [
"a",
"x",
"y",
"z",
"v"
],
"applyRulesOnConcatenatedData": true,
"rules": [
{
"conditions": [
{
"type": "set_subject_type_id",
"parameter": {
"name": "Chronological term"
}
}
]
}
]
}
]
},
Expand Down Expand Up @@ -13266,6 +13478,35 @@
"subfield": [
"9"
]
},
{
"target": "subjects.typeId",
"description": "Subject type id",
"subfield": [
"a",
"b",
"c",
"d",
"e",
"g",
"v",
"x",
"y",
"z"
],
"applyRulesOnConcatenatedData": true,
"rules": [
{
"conditions": [
{
"type": "set_subject_type_id",
"parameter": {
"name": "Topical term"
}
}
]
}
]
}
]
},
Expand Down Expand Up @@ -14244,6 +14485,32 @@
"subfield": [
"9"
]
},
{
"target": "subjects.typeId",
"description": "Subject type id",
"subfield": [
"a",
"e",
"g",
"v",
"x",
"y",
"z"
],
"applyRulesOnConcatenatedData": true,
"rules": [
{
"conditions": [
{
"type": "set_subject_type_id",
"parameter": {
"name": "Geographic name"
}
}
]
}
]
}
]
},
Expand Down Expand Up @@ -15126,6 +15393,32 @@
"subfield": [
"9"
]
},
{
"target": "subjects.typeId",
"description": "Subject type id",
"subfield": [
"a",
"b",
"c",
"v",
"x",
"y",
"z"
],
"applyRulesOnConcatenatedData": true,
"rules": [
{
"conditions": [
{
"type": "set_subject_type_id",
"parameter": {
"name": "Genre/Form"
}
}
]
}
]
}
]
},
Expand Down

0 comments on commit 9ff0f67

Please sign in to comment.