use of nl.knaw.huygens.timbuctoo.core.DataStoreOperations in project timbuctoo by HuygensING.
the class ChangeListenerTest method callsOnCreateAndOnAddToCollectionOnCreateEntity.
@Test
public void callsOnCreateAndOnAddToCollectionOnCreateEntity() throws Exception {
ChangeListener changeListener = new ChangeListenerImpl(vertex -> {
assertThat(vertex, likeVertex().withProperty(IS_LATEST, true).withProperty("rev", 1));
Long prevVersions = stream(vertex.vertices(Direction.BOTH, VERSION_OF)).collect(Collectors.counting());
assertThat(prevVersions, is(1L));
});
ChangeListener spy = spy(changeListener);
DataStoreOperations instance = TinkerPopOperationsStubs.forChangeListenerMock(spy);
Collection collectionMock = mock(Collection.class);
Collection baseCollectionMock = mock(Collection.class);
instance.createEntity(collectionMock, Optional.of(baseCollectionMock), CreateEntityStubs.dummy());
verify(spy).onCreate(same(collectionMock), any());
verify(spy).onAddToCollection(same(collectionMock), eq(Optional.empty()), any());
verify(spy).onAddToCollection(same(baseCollectionMock), eq(Optional.empty()), any());
}
Aggregations