use of nl.knaw.huygens.timbuctoo.core.DataStoreOperations in project timbuctoo by HuygensING.
the class ChangeListenerTest method callsOnRemoveFromCollectionOnDeleteEntity.
@Test
public void callsOnRemoveFromCollectionOnDeleteEntity() throws Exception {
ChangeListener changeListener = new ChangeListenerImpl(vertex -> {
assertThat(vertex, likeVertex().withProperty("isLatest", true).withProperty("rev", 2));
Long prevVersions = stream(vertex.vertices(Direction.BOTH, VERSION_OF)).collect(Collectors.counting());
assertThat(prevVersions, is(1L));
});
UUID id = UUID.randomUUID();
ChangeListener spy = spy(changeListener);
DataStoreOperations instance = forDeleteCall(spy, id, 1, "someName");
Collection collection = mock(Collection.class);
when(collection.getEntityTypeName()).thenReturn("someName");
when(collection.getVre()).thenReturn(mock(Vre.class));
instance.deleteEntity(collection, id, new Change());
verify(spy).onRemoveFromCollection(same(collection), any(), any());
}
use of nl.knaw.huygens.timbuctoo.core.DataStoreOperations in project timbuctoo by HuygensING.
the class ChangeListenerTest method callsOnPropertyUpdateOnReplaceEntity.
@Test
public void callsOnPropertyUpdateOnReplaceEntity() throws Exception {
ChangeListener changeListener = new ChangeListenerImpl(vertex -> {
assertThat(vertex, likeVertex().withProperty("isLatest", true).withProperty("rev", 2));
Long prevVersions = stream(vertex.vertices(Direction.BOTH, VERSION_OF)).collect(Collectors.counting());
assertThat(prevVersions, is(1L));
});
UUID id = UUID.randomUUID();
ChangeListener spy = spy(changeListener);
DataStoreOperations instance = forReplaceCall(spy, id, 1);
UpdateEntity updateEntity = new UpdateEntity(id, newArrayList(), 1);
updateEntity.setModified(new Change());
Collection collectionMock = mock(Collection.class);
instance.replaceEntity(collectionMock, updateEntity);
verify(spy).onPropertyUpdate(same(collectionMock), any(), any());
}
use of nl.knaw.huygens.timbuctoo.core.DataStoreOperations in project timbuctoo by HuygensING.
the class TimbuctooActionsAddPidTest method setup.
@Before
public void setup() throws Exception {
dataStoreOperations = mock(DataStoreOperations.class);
instance = new TimbuctooActions(null, null, null, (coll, id, rev) -> URI.create("http://example.org/persistent"), dataStoreOperations, null);
id = UUID.randomUUID();
pidUri = new URI("http://example.com/pid");
}
use of nl.knaw.huygens.timbuctoo.core.DataStoreOperations in project timbuctoo by HuygensING.
the class ChangeListenerTest method callsOnAddToCollectionOnReplaceEntityWithNewCollection.
@Test
public void callsOnAddToCollectionOnReplaceEntityWithNewCollection() throws Exception {
ChangeListener changeListener = new ChangeListenerImpl(vertex -> {
assertThat(vertex, likeVertex().withProperty("isLatest", true).withProperty("rev", 2));
Long prevVersions = stream(vertex.vertices(Direction.BOTH, VERSION_OF)).collect(Collectors.counting());
assertThat(prevVersions, is(1L));
});
UUID id = UUID.randomUUID();
ChangeListener spy = spy(changeListener);
DataStoreOperations instance = forReplaceCall(spy, id, 1);
UpdateEntity updateEntity = new UpdateEntity(id, newArrayList(), 1);
updateEntity.setModified(new Change());
Collection collectionMock = mock(Collection.class);
given(collectionMock.getEntityTypeName()).willReturn("something");
instance.replaceEntity(collectionMock, updateEntity);
verify(spy).onAddToCollection(same(collectionMock), any(), any());
}
use of nl.knaw.huygens.timbuctoo.core.DataStoreOperations in project timbuctoo by HuygensING.
the class LoadSaveVreTest method save.
private List<Vertex> save(Vre vre, Tuple<DataStoreOperations, Graph> dataAccess) {
DataStoreOperations db = dataAccess.getLeft();
db.saveVre(vre);
db.success();
return dataAccess.getRight().traversal().V().toList();
}
Aggregations