Commit 96dff57e authored by Jonas Waeber's avatar Jonas Waeber
Browse files

Add more tests and a check for unknown relation types.

parent da6bbc41
Pipeline #47555 passed with stage
in 4 minutes and 31 seconds
...@@ -133,7 +133,12 @@ abstract class RecordResource(institutionId: String) : IResource { ...@@ -133,7 +133,12 @@ abstract class RecordResource(institutionId: String) : IResource {
properties: List<Pair<String, Literal>> properties: List<Pair<String, Literal>>
) { ) {
val relation = model.createResource() val relation = model.createResource()
relation.addProperty(RICO.type, KEYS.relationTypeMap[relationType]) if (relationType in KEYS.relationTypeMap) {
relation.addProperty(RICO.type, KEYS.relationTypeMap[relationType])
} else {
log.error("Unexpected relation type found: $relationType.")
return
}
relationName.forEach { relationName.forEach {
relation.addProperty(RICO.name, it) relation.addProperty(RICO.name, it)
} }
......
...@@ -20,11 +20,13 @@ package ch.memobase.test ...@@ -20,11 +20,13 @@ package ch.memobase.test
import ch.memobase.builder.ResourceBuilder import ch.memobase.builder.ResourceBuilder
import ch.memobase.mapping.MappingConfigurationParser import ch.memobase.mapping.MappingConfigurationParser
import com.beust.klaxon.Klaxon
import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance import org.junit.jupiter.api.TestInstance
import java.io.File import java.io.File
import java.io.FileInputStream import java.io.FileInputStream
import java.nio.charset.Charset
@TestInstance(TestInstance.Lifecycle.PER_CLASS) @TestInstance(TestInstance.Lifecycle.PER_CLASS)
class TestResourceBuilder { class TestResourceBuilder {
...@@ -65,4 +67,21 @@ class TestResourceBuilder { ...@@ -65,4 +67,21 @@ class TestResourceBuilder {
assertThat(resourceBuilder.errorMessages) assertThat(resourceBuilder.errorMessages)
.isEqualTo(emptyList<String>()) .isEqualTo(emptyList<String>())
} }
@Test
fun `test custom input`() {
val config = MappingConfigurationParser((FileInputStream(File("$path/mapping2.yml")).readBytes())).get()
val resourceBuilder = ResourceBuilder(
Klaxon().parseJsonObject(FileInputStream(File("$path/input2.json"))
.reader(Charset.defaultCharset())) as Map<String, Any>,
config,
"tst",
"tst-001",
false
)
resourceBuilder.generateRecord()
resourceBuilder.generateDigitalObject()
assertThat(resourceBuilder.errorMessages)
.isEqualTo(emptyList<String>())
}
} }
{
"Memobase-ID": "212853_1",
"longTitle": "Jazz Konzerte Willisau 2002: Tin Hat Trio",
"broadcast": "Jazz Konzerte Willisau 2002",
"backlink": "https://www.fonoteca.ch/cgi-bin/oecgi3.exe/inet_fnbasedetail?REC_ID=212853.011",
"stream": "https://vault.fonoteca.ch/archive/FILE1-1000/FILE800/FILE800_1.mp3",
"objUniqueKey": "212853.011",
"objLang": "de",
"objCallNr": "FILE800",
"objThumbnailK": "tdb",
"objRemarks": "",
"objSupportType": "Elektronische Ressource mit Fernzugriff",
"objGenre": "Jazzmusik",
"objSchemaProfile": "",
"objItemNbr": "1",
"objItemCondition": "",
"objItemLocation": "FONOTECA NAZIONALE SVIZZERA; Lugano",
"objItemSubLocation": "",
"objItemOrigin": "BIBLIOTHEK HOCHSCHULE LUZERN - MUSIK; Luzern",
"objItemSubOrigin": "W. 1564",
"objItemCollection": "WILLISAU JAZZ ARCHIV",
"objItemReceivedDate": "2014-03-14",
"objItemReceivedOwnership": "Depositum",
"objItemCopies": "",
"isPublic": "0",
"mp3Ready": "1",
"Trägertitel": ["Jazz Konzerte Willisau 2002: Tin Hat Trio"],
"Elektronische Ressource": ["Dati informatici sonori"],
"Produktion": [
{"name": "TROXLER, Niklaus",
"activity": "Ansager"}],
"Produktionsjahr": ["2002"],
"Produktionsart": ["Einmalige Direktproduktion"],
"Musikart": ["Jazz"],
"Position": ["1"],
"Ansagen": ["Announcement"],
"Aktivität": ["Ansager"],
"Interpret": [
{"name": "TIN HAT TRIO"},
{"name": "KIHLSTEDT, Carla",
"instrument": "Violine"},
{"name": "BURGER, Rob",
"instrument": "Akkordeon Klavier"},
{"name": "ORTON, Mark",
"instrument": "Gitarre"}],
"Musikinstrument": ["Violine","Akkordeon","Klavier","Gitarre"],
"Aufnahmeortschaft": ["Willisau"],
"Aufnahmeort": ["JAZZ KONZERT WILLISAU"],
"Aufnahme-Datum": ["12.04.2002"],
"Aufnahme-Bedingungen": ["Direktaufnahme"],
"Applaus": ["Mit Applaus"],
}
record:
uri: Memobase-ID
identifiers:
original: Memobase-ID
type:
const: "Ton"
title: longTitle
titles:
- main: longTitle
- series: Trägertitel
- broadcast: broadcast
scopeAndContent:
- Produktionsart
- Aufnahme-Bedingungen
- Applaus
sameAs: backlink
abstract:
- prefix:
value: "Ereignis: "
field: Ereignis
- prefix:
value: "Ansagen: "
field: Ansagen
- prefix:
value: "Musikinstrumente: "
field: Musikinstrument
- prefix:
value: "Körperschaft: "
field: Körperschaft
- prefix:
value: "Stimme: "
field: Stimme
descriptiveNote:
- objRemarks
- Bemerkungen/Kommentar
- prefix:
value: "Version: "
field: Version
source:
- objItemOrigin
- objItemSubOrigin
#relation: relatedMaterial
isSponsoredByMemoriav: true
rights:
holder:
const: "HSLU (gemäss Schenkungsvertrag); Es gelten die üblichen Urheber- und anverwandten Schutzrechte"
languages:
- content: #language
const: "Deutsch"
#- caption: captioningFormat
#subject:
# - prefLabel: Keywords
genre:
- prefLabel: objGenre
- prefLabel: Musikart
placeOfCapture:
- name: Aufnahmeortschaft
relatedPlaces:
- name: Aufnahmeortschaft
creationDate: Aufnahme-Datum
#issuedDate: issuedDate
#temporal: PeriodOfTimeDate
creators:
- person:
name: Autor.name
relationName:
- Autor.activity
- Autor.role
#const: "Autor"
#- corporateBody:
# name: creatorCorporateBody.name
# relationName: creatorCorporateBody.role
contributors:
- person:
name: Interpret.name
relationName: Interpret.instrument
#- corporateBody:
# name: contributorCorporateBody.name
# relationName: contributorCorporateBody.role
#- agent:
# name: contributorAgent.name
# relationName: contributorAgent.role
producers:
- person:
name: Produktion.name
relationName:
- Produktion.activity
- Produktion.role
#- person:
# name: producerCorporateBodyName
relatedAgents:
- person:
name: Technik.name
relationName:
- prefix:
value: "Technik"
field: Technik.activity
- person:
name: Teilnehmer.relationName
relationName: Teilnehmer.activity
#- corporateBody:
# name: FeaturedOrganisation
#publishedBy:
# - person:
# name: publisherPerson.name
#- corporateBody:
# name: publisherCorporateBody.name
conditionsOfUse: "Es gelten die üblichen Urheber- und anverwandten Schutzrechte"
physical:
carrierType: objSupportType
#duration: duration
physicalCharacteristics:
- prefix:
value: "Mass:"
field: Mass
- prefix:
value: "Material: "
field: Material
- prefix:
value: "Marke und Modell: "
field: Marke und Modell
- prefix:
value: "Tonaufnahmeverfahren: "
field: Aufnahmeverfahren
- prefix:
value: "Spulage: "
field: Spurlage
- prefix:
value: "Abspielgeschwindigkeit: "
field: Abspielgeschwindigkeit
- prefix:
value: "Zustand: "
field: objItemCondition
identifiers:
callNumber: objCallNr
rights:
access:
const: "onsite"
usage:
name:
const: "In Copyright (InC)"
sameAs:
const: "http://rightsstatements.org/vocab/CNE/1.0/"
digital:
locator: stream #essenceLocator
rights:
access:
const: "private"
usage:
name:
const: "In Copyright (InC)"
sameAs:
const: "http://rightsstatements.org/vocab/CNE/1.0/"
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment