Search in sources :

Example 1 with BulkWriteOperation

use of io.spine.server.projection.BulkWriteOperation 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)

Example 2 with BulkWriteOperation

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

the class BulkWriteOperationShould method newOperation.

private static BulkWriteOperation<Object, TestProjection> newOperation() {
    final Duration duration = Durations2.seconds(100);
    final BulkWriteOperation<Object, TestProjection> operation = new BulkWriteOperation<>(duration, new EmptyCallback());
    return operation;
}
Also used : BulkWriteOperation(io.spine.server.projection.BulkWriteOperation) Duration(com.google.protobuf.Duration)

Example 3 with BulkWriteOperation

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

the class BulkWriteOperationShould method return_own_in_progress_state.

@Test
public void return_own_in_progress_state() {
    final BulkWriteOperation operation = newOperation();
    assertTrue(operation.isInProgress());
    operation.complete();
    assertFalse(operation.isInProgress());
}
Also used : BulkWriteOperation(io.spine.server.projection.BulkWriteOperation) Test(org.junit.Test)

Example 4 with BulkWriteOperation

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

the class BulkWriteOperationShould method close_on_complete.

@Test
public void close_on_complete() {
    final BulkWriteOperation operationSpy = spy(newOperation());
    operationSpy.complete();
    verify(operationSpy).close();
}
Also used : BulkWriteOperation(io.spine.server.projection.BulkWriteOperation) Test(org.junit.Test)

Example 5 with BulkWriteOperation

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

the class BulkWriteOperationShould method newOperation.

private static BulkWriteOperation<Object, TestProjection> newOperation(Set<TestProjection> projections, Timestamp lastHandldEventTime) {
    final Duration duration = Durations2.seconds(100);
    final BulkWriteOperation<Object, TestProjection> operation = new BulkWriteOperation<>(duration, new AssertResults(projections, lastHandldEventTime));
    return operation;
}
Also used : BulkWriteOperation(io.spine.server.projection.BulkWriteOperation) Duration(com.google.protobuf.Duration)

Aggregations

BulkWriteOperation (io.spine.server.projection.BulkWriteOperation)9 Test (org.junit.Test)7 Duration (com.google.protobuf.Duration)4 Timestamp (com.google.protobuf.Timestamp)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