Search in sources :

Example 6 with DataStoreOperations

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());
}
Also used : DataStoreOperations(nl.knaw.huygens.timbuctoo.core.DataStoreOperations) Collection(nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection) Test(org.junit.Test)

Aggregations

DataStoreOperations (nl.knaw.huygens.timbuctoo.core.DataStoreOperations)6 Collection (nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection)5 Test (org.junit.Test)5 UUID (java.util.UUID)4 Change (nl.knaw.huygens.timbuctoo.model.Change)3 UpdateEntity (nl.knaw.huygens.timbuctoo.core.dto.UpdateEntity)2 URI (java.net.URI)1 NotFoundException (nl.knaw.huygens.timbuctoo.core.NotFoundException)1 TimbuctooActions (nl.knaw.huygens.timbuctoo.core.TimbuctooActions)1 ImmutableEntityLookup (nl.knaw.huygens.timbuctoo.core.dto.ImmutableEntityLookup)1 Vre (nl.knaw.huygens.timbuctoo.model.vre.Vre)1 Before (org.junit.Before)1 Mockito.doThrow (org.mockito.Mockito.doThrow)1 Mockito.mock (org.mockito.Mockito.mock)1 Mockito.verify (org.mockito.Mockito.verify)1