use of nl.knaw.huygens.timbuctoo.rdf.Database in project timbuctoo by HuygensING.
the class TinkerPopOperationsTest method getEntitiesWithUnknownTypeDoesNotReturnEntitiesWithACollection.
@Test
public void getEntitiesWithUnknownTypeDoesNotReturnEntitiesWithACollection() {
TinkerPopGraphManager wrap = newGraph().wrap();
TinkerPopOperations instance = forGraphWrapper(wrap);
final Database legacyRdfDatabase = new Database(wrap);
Vre vre = instance.ensureVreExists("vre");
instance.addCollectionToVre(vre, CreateCollection.defaultCollection("vre"));
Vre admin = instance.ensureVreExists("Admin");
instance.addCollectionToVre(admin, CreateCollection.defaultCollection("Admin"));
vre = instance.loadVres().getVre("vre");
instance.assertEntity(vre, "http://example.org/entity1");
instance.assertEntity(vre, "http://example.org/entity2");
nl.knaw.huygens.timbuctoo.rdf.Collection collection = legacyRdfDatabase.findOrCreateCollection("vre", NodeFactory.createURI("http://example.org/myCollection").getURI(), NodeFactory.createURI("http://example.org/myCollection").getLocalName());
Optional<Entity> entity = legacyRdfDatabase.findEntity("vre", NodeFactory.createURI("http://example.org/entity1"));
entity.get().addToCollection(collection);
List<String> entitiesWithUnknownType = instance.getEntitiesWithUnknownType(vre);
assertThat(entitiesWithUnknownType, containsInAnyOrder("http://example.org/entity2"));
}
use of nl.knaw.huygens.timbuctoo.rdf.Database 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);
}
use of nl.knaw.huygens.timbuctoo.rdf.Database in project timbuctoo by HuygensING.
the class CollectionMembershipTripleProcessorTest method processRemovesTheEntityToTheRequestedCollectionIfItIsARetraction.
@Test
public void processRemovesTheEntityToTheRequestedCollectionIfItIsARetraction() {
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, false);
InOrder inOrder = inOrder(entity, database);
inOrder.verify(database).findOrCreateCollection("vreName", OBJECT_URI, OBJECT_NAME);
inOrder.verify(entity).removeFromCollection(collectionFromTriple);
}
use of nl.knaw.huygens.timbuctoo.rdf.Database 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);
}
use of nl.knaw.huygens.timbuctoo.rdf.Database in project timbuctoo by HuygensING.
the class AltLabelTripleProcessorTest method setup.
@Before
public void setup() {
final Database database = mock(Database.class);
entity = mock(Entity.class);
instance = new AltLabelTripleProcessor(database);
given(database.findOrCreateEntity(VRE_NAME, SUBJECT_URI)).willReturn(entity);
}
Aggregations