Search in sources :

Example 1 with RdfImportSession

use of nl.knaw.huygens.timbuctoo.core.RdfImportSession in project timbuctoo by HuygensING.

the class PropertyTripleProcessorTest method processAddsThePropertyToTheEntity.

@Test
public void processAddsThePropertyToTheEntity() {
    RdfImportSession rdfImportSession = mock(RdfImportSession.class);
    PropertyTripleProcessor instance = new PropertyTripleProcessor(rdfImportSession);
    instance.process("vreName", SUBJECT_URI, PREDICATE_URI, OBJECT_VALUE, OBJECT_TYPE, true);
    verify(rdfImportSession).assertProperty(eq(SUBJECT_URI), argThat(allOf(hasProperty("predicateUri", equalTo(PREDICATE_URI)), hasProperty("value", equalTo(OBJECT_VALUE)), hasProperty("typeUri", equalTo(OBJECT_TYPE)))));
}
Also used : RdfImportSession(nl.knaw.huygens.timbuctoo.core.RdfImportSession) Test(org.junit.Test)

Example 2 with RdfImportSession

use of nl.knaw.huygens.timbuctoo.core.RdfImportSession in project timbuctoo by HuygensING.

the class CollectionMembershipTripleProcessorTest method processLogsAnExceptionWhenTheEntityAlreadyIsPartOfACollectionWhenAsserted.

@Test
public void processLogsAnExceptionWhenTheEntityAlreadyIsPartOfACollectionWhenAsserted() {
    Database database = mock(Database.class);
    Collection collectionFromTriple = mock(Collection.class);
    Collection archetypeCollection = mock(Collection.class);
    when(collectionFromTriple.getArchetype()).thenReturn(Optional.of(archetypeCollection));
    when(database.findOrCreateCollection(anyString(), anyString(), anyString())).thenReturn(collectionFromTriple);
    Collection defaultCollection = mock(Collection.class);
    when(database.getDefaultCollection("vreName")).thenReturn(defaultCollection);
    Entity entity = mock(Entity.class);
    when(entity.isInKnownCollection()).thenReturn(true);
    when(database.findOrCreateEntity("vreName", SUBJECT_URI)).thenReturn(entity);
    RdfImportSession rdfImportSession = mock(RdfImportSession.class);
    RdfImportErrorReporter errorReporter = mock(RdfImportErrorReporter.class);
    when(rdfImportSession.getErrorReporter()).thenReturn(errorReporter);
    CollectionMembershipTripleProcessor instance = new CollectionMembershipTripleProcessor(database, rdfImportSession);
    instance.process("vreName", SUBJECT_URI, PREDICATE_URI, OBJECT_URI, true);
    verify(errorReporter).multipleRdfTypes(SUBJECT_URI, OBJECT_URI);
}
Also used : Entity(nl.knaw.huygens.timbuctoo.rdf.Entity) RdfImportSession(nl.knaw.huygens.timbuctoo.core.RdfImportSession) RdfImportErrorReporter(nl.knaw.huygens.timbuctoo.core.RdfImportErrorReporter) Database(nl.knaw.huygens.timbuctoo.rdf.Database) Collection(nl.knaw.huygens.timbuctoo.rdf.Collection) Test(org.junit.Test)

Example 3 with RdfImportSession

use of nl.knaw.huygens.timbuctoo.core.RdfImportSession in project timbuctoo by HuygensING.

the class PersonNamesTripleProcessorTest method setUp.

@Before
public void setUp() throws Exception {
    RdfImportSession rdfImportSession = mock(RdfImportSession.class);
    database = mock(Database.class);
    instance = new PersonNamesTripleProcessor(rdfImportSession, database);
    entity = mock(Entity.class);
    given(entity.getPropertyValue(PROPERTY_NAME)).willReturn(Optional.empty());
    given(database.findOrCreateEntity(VRE_NAME, SUBJECT_URI)).willReturn(entity);
}
Also used : Entity(nl.knaw.huygens.timbuctoo.rdf.Entity) RdfImportSession(nl.knaw.huygens.timbuctoo.core.RdfImportSession) Database(nl.knaw.huygens.timbuctoo.rdf.Database) Before(org.junit.Before)

Example 4 with RdfImportSession

use of nl.knaw.huygens.timbuctoo.core.RdfImportSession in project timbuctoo by HuygensING.

the class PropertyTripleProcessorTest method processRemovesThePropertyFromTheEntityIfTheCallIsARetraction.

@Test
public void processRemovesThePropertyFromTheEntityIfTheCallIsARetraction() {
    RdfImportSession rdfImportSession = mock(RdfImportSession.class);
    PropertyTripleProcessor instance = new PropertyTripleProcessor(rdfImportSession);
    instance.process("vreName", SUBJECT_URI, PREDICATE_URI, OBJECT_VALUE, OBJECT_TYPE, false);
    verify(rdfImportSession).retractProperty(eq(SUBJECT_URI), argThat(allOf(hasProperty("predicateUri", equalTo(PREDICATE_URI)), hasProperty("typeUri", equalTo(OBJECT_TYPE)))));
}
Also used : RdfImportSession(nl.knaw.huygens.timbuctoo.core.RdfImportSession) Test(org.junit.Test)

Aggregations

RdfImportSession (nl.knaw.huygens.timbuctoo.core.RdfImportSession)4 Test (org.junit.Test)3 Database (nl.knaw.huygens.timbuctoo.rdf.Database)2 Entity (nl.knaw.huygens.timbuctoo.rdf.Entity)2 RdfImportErrorReporter (nl.knaw.huygens.timbuctoo.core.RdfImportErrorReporter)1 Collection (nl.knaw.huygens.timbuctoo.rdf.Collection)1 Before (org.junit.Before)1