Commit 2389aa73 authored by Jonas Waeber's avatar Jonas Waeber
Browse files

Add test which confirms that exception is thrown if the property in agent is invalid.

parent 4a04581c
Pipeline #21262 passed with stage
in 1 minute and 45 seconds
package ch.memobase.test package ch.memobase.test
import ch.memobase.exceptions.InvalidMappingException
import ch.memobase.mapping.MapperParsers import ch.memobase.mapping.MapperParsers
import ch.memobase.mapping.mappers.AgentFieldMapper import ch.memobase.mapping.mappers.AgentFieldMapper
import java.util.function.Consumer import java.util.function.Consumer
import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Disabled
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 org.junit.jupiter.api.assertThrows
@TestInstance(TestInstance.Lifecycle.PER_CLASS) @TestInstance(TestInstance.Lifecycle.PER_CLASS)
class TestMapperParseHelpers { class TestMapperParseHelpers {
...@@ -81,28 +82,21 @@ class TestMapperParseHelpers { ...@@ -81,28 +82,21 @@ class TestMapperParseHelpers {
.satisfies(mapperReqs) .satisfies(mapperReqs)
} }
// TODO: This throws an exception. Which needs to be handled. currently it will just fail the program.
@Test @Test
@Disabled
fun `test extractAgentTypeMapper with different property`() { fun `test extractAgentTypeMapper with different property`() {
val mappers = MapperParsers.buildAgentMapper( assertThrows<InvalidMappingException> {
"creators", MapperParsers.buildAgentMapper(
listOf( "creators",
mapOf( listOf(
Pair( mapOf(
"person", mapOf( Pair(
Pair("people", "creatorPerson.name") "person", mapOf(
Pair("people", "creatorPerson.name")
)
) )
) )
) )
) )
)
val mapperReqs: Consumer<AgentFieldMapper> = Consumer { agentFieldMapper: AgentFieldMapper ->
assertThat(agentFieldMapper.sourceKey).isEqualTo("creators")
assertThat(agentFieldMapper.agentClassType).isEqualTo("person")
} }
val mapper = mappers[0] as AgentFieldMapper
assertThat(mapper)
.satisfies(mapperReqs)
} }
} }
...@@ -5,6 +5,15 @@ ...@@ -5,6 +5,15 @@
@prefix ebucore: <http://www.ebu.ch/metadata/ontologies/ebucore/ebucore#> . @prefix ebucore: <http://www.ebu.ch/metadata/ontologies/ebucore/ebucore#> .
@prefix skos: <http://www.w3.org/2004/02/skos/core#> . @prefix skos: <http://www.w3.org/2004/02/skos/core#> .
_:b0 a rico:CreationRelation ;
rico:creationRelationHasSource <https://memobase.ch/record/rs1-1> ;
rico:creationRelationHasTarget [ a rico:Person ;
rico:agentIsTargetOfCreationRelation
_:b0 ;
rico:name "Hans Zimmer"
] ;
rico:type "creator" .
<https://memobase.ch/record/rs1-1> <https://memobase.ch/record/rs1-1>
a rico:Record ; a rico:Record ;
rdau:P60451 <https://memobase.ch/institution/mrv> ; rdau:P60451 <https://memobase.ch/institution/mrv> ;
...@@ -19,12 +28,3 @@ ...@@ -19,12 +28,3 @@
rico:recordResourceOrInstantiationIsSourceOfCreationRelation rico:recordResourceOrInstantiationIsSourceOfCreationRelation
_:b0 ; _:b0 ;
rico:type "Foto" . rico:type "Foto" .
_:b0 a rico:CreationRelation ;
rico:creationRelationHasSource <https://memobase.ch/record/rs1-1> ;
rico:creationRelationHasTarget [ a rico:Person ;
rico:agentIsTargetOfCreationRelation
_:b0 ;
rico:name "Hans Zimmer"
] ;
rico:type "creator" .
Markdown is supported
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