Search in sources :

Example 1 with FlushCallback

use of io.spine.server.projection.BulkWriteOperation.FlushCallback in project core-java by SpineEventEngine.

the class BulkWriteOperationShould method complete_on_timeout.

@SuppressWarnings("MagicNumber")
@Test
public void complete_on_timeout() throws InterruptedException {
    final Duration duration = Durations2.nanos(1L);
    final FlushCallback callback = spy(new EmptyCallback());
    // Due to `spy` usage
    @SuppressWarnings("unchecked") final BulkWriteOperation operation = spy(new BulkWriteOperation(duration, callback));
    assertTrue(operation.isInProgress());
    Thread.sleep(10L);
    operation.checkExpiration();
    assertFalse(operation.isInProgress());
    verify(operation).complete();
    verify(callback).onFlushResults(any(Set.class), any(Timestamp.class));
}
Also used : BulkWriteOperation(io.spine.server.projection.BulkWriteOperation) Collections.emptySet(java.util.Collections.emptySet) Set(java.util.Set) HashSet(java.util.HashSet) FlushCallback(io.spine.server.projection.BulkWriteOperation.FlushCallback) Duration(com.google.protobuf.Duration) Timestamp(com.google.protobuf.Timestamp) Test(org.junit.Test)

Aggregations

Duration (com.google.protobuf.Duration)1 Timestamp (com.google.protobuf.Timestamp)1 BulkWriteOperation (io.spine.server.projection.BulkWriteOperation)1 FlushCallback (io.spine.server.projection.BulkWriteOperation.FlushCallback)1 Collections.emptySet (java.util.Collections.emptySet)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1 Test (org.junit.Test)1