Search in sources :

Example 6 with Database

use of nl.knaw.huygens.timbuctoo.rdf.Database in project timbuctoo by HuygensING.

the class CollectionMembershipTripleProcessorTest method processMovesTheEntityToTheKnownCollectionIfItIsAnAssertion.

@Test
public void processMovesTheEntityToTheKnownCollectionIfItIsAnAssertion() {
    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(database.findOrCreateEntity("vreName", SUBJECT_URI)).thenReturn(entity);
    CollectionMembershipTripleProcessor instance = new CollectionMembershipTripleProcessor(database, mock(RdfImportSession.class));
    instance.process("vreName", SUBJECT_URI, PREDICATE_URI, OBJECT_URI, true);
    verify(entity).moveToNewCollection(defaultCollection, collectionFromTriple);
}
Also used : Entity(nl.knaw.huygens.timbuctoo.rdf.Entity) RdfImportSession(nl.knaw.huygens.timbuctoo.core.RdfImportSession) Database(nl.knaw.huygens.timbuctoo.rdf.Database) Collection(nl.knaw.huygens.timbuctoo.rdf.Collection) Test(org.junit.Test)

Example 7 with Database

use of nl.knaw.huygens.timbuctoo.rdf.Database in project timbuctoo by HuygensING.

the class RelationTripleProcessorTest method setup.

@Before
public void setup() {
    final Database database = mock(Database.class);
    subjectEntity = mock(Entity.class);
    objectEntity = mock(Entity.class);
    relation = mock(Relation.class);
    relationType = mock(RelationType.class);
    given(database.findOrCreateEntity(VRE_NAME, SUBJECT_URI)).willReturn(subjectEntity);
    given(database.findOrCreateEntity(VRE_NAME, OBJECT_URI)).willReturn(objectEntity);
    given(database.findOrCreateRelationType(PREDICATE_URI, PREDICATE_NAME)).willReturn(relationType);
    given(subjectEntity.addRelation(any(), any())).willReturn(relation);
    instance = new RelationTripleProcessor(database);
}
Also used : Entity(nl.knaw.huygens.timbuctoo.rdf.Entity) Relation(nl.knaw.huygens.timbuctoo.rdf.Relation) RelationType(nl.knaw.huygens.timbuctoo.rdf.RelationType) Database(nl.knaw.huygens.timbuctoo.rdf.Database) Before(org.junit.Before)

Aggregations

Database (nl.knaw.huygens.timbuctoo.rdf.Database)7 Entity (nl.knaw.huygens.timbuctoo.rdf.Entity)7 RdfImportSession (nl.knaw.huygens.timbuctoo.core.RdfImportSession)4 Test (org.junit.Test)4 Collection (nl.knaw.huygens.timbuctoo.rdf.Collection)3 Before (org.junit.Before)3 RdfImportErrorReporter (nl.knaw.huygens.timbuctoo.core.RdfImportErrorReporter)1 CreateEntity (nl.knaw.huygens.timbuctoo.core.dto.CreateEntity)1 ReadEntity (nl.knaw.huygens.timbuctoo.core.dto.ReadEntity)1 UpdateEntity (nl.knaw.huygens.timbuctoo.core.dto.UpdateEntity)1 Vre (nl.knaw.huygens.timbuctoo.model.vre.Vre)1 VreStubs.minimalCorrectVre (nl.knaw.huygens.timbuctoo.model.vre.VreStubs.minimalCorrectVre)1 Relation (nl.knaw.huygens.timbuctoo.rdf.Relation)1 RelationType (nl.knaw.huygens.timbuctoo.rdf.RelationType)1 TinkerPopGraphManager (nl.knaw.huygens.timbuctoo.server.TinkerPopGraphManager)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1 InOrder (org.mockito.InOrder)1 Matchers.anyString (org.mockito.Matchers.anyString)1