Search in sources :

Example 6 with Timestamp

use of com.google.protobuf.Timestamp in project core-java by SpineEventEngine.

the class CommandSchedulingShould method reschedule_commands_from_storage.

@Test
public void reschedule_commands_from_storage() {
    final Timestamp schedulingTime = minutesAgo(3);
    final Duration delayPrimary = Durations2.fromMinutes(5);
    // = 5 - 3
    final Duration newDelayExpected = Durations2.fromMinutes(2);
    final List<Command> commandsPrimary = newArrayList(createProject(), addTask(), startProject());
    storeAsScheduled(commandsPrimary, delayPrimary, schedulingTime);
    commandBus.rescheduleCommands();
    final ArgumentCaptor<Command> commandCaptor = ArgumentCaptor.forClass(Command.class);
    verify(scheduler, times(commandsPrimary.size())).schedule(commandCaptor.capture());
    final List<Command> commandsRescheduled = commandCaptor.getAllValues();
    for (Command cmd : commandsRescheduled) {
        final long actualDelay = getDelaySeconds(cmd);
        Tests.assertSecondsEqual(newDelayExpected.getSeconds(), actualDelay, /*maxDiffSec=*/
        1);
    }
}
Also used : Command(io.spine.base.Command) Duration(com.google.protobuf.Duration) Timestamp(com.google.protobuf.Timestamp) Test(org.junit.Test)

Example 7 with Timestamp

use of com.google.protobuf.Timestamp in project core-java by SpineEventEngine.

the class CommandSchedulingShould method update_schedule_options.

@Test
public void update_schedule_options() {
    final Command cmd = requestFactory.command().create(Wrapper.forString(newUuid()));
    final Timestamp schedulingTime = getCurrentTime();
    final Duration delay = Durations2.minutes(5);
    final Command cmdUpdated = setSchedule(cmd, delay, schedulingTime);
    final CommandContext.Schedule schedule = cmdUpdated.getContext().getSchedule();
    assertEquals(delay, schedule.getDelay());
    assertEquals(schedulingTime, cmdUpdated.getSystemProperties().getSchedulingTime());
}
Also used : CommandContext(io.spine.base.CommandContext) Command(io.spine.base.Command) Duration(com.google.protobuf.Duration) Timestamp(com.google.protobuf.Timestamp) Test(org.junit.Test)

Example 8 with Timestamp

use of com.google.protobuf.Timestamp in project core-java by SpineEventEngine.

the class ProjectionStorageShould method writeAndReadLastEventTimeTest.

private void writeAndReadLastEventTimeTest(Timestamp expected) {
    storage.writeLastHandledEventTime(expected);
    final Timestamp actual = storage.readLastHandledEventTime();
    assertEquals(expected, actual);
}
Also used : Timestamp(com.google.protobuf.Timestamp)

Example 9 with Timestamp

use of com.google.protobuf.Timestamp in project core-java by SpineEventEngine.

the class ProjectionStorageShould method return_null_if_no_event_time_in_storage.

@Test
public void return_null_if_no_event_time_in_storage() {
    final Timestamp time = storage.readLastHandledEventTime();
    assertNull(time);
}
Also used : Timestamp(com.google.protobuf.Timestamp) Test(org.junit.Test)

Example 10 with Timestamp

use of com.google.protobuf.Timestamp in project core-java by SpineEventEngine.

the class BulkWriteOperationShould method store_given_timestamp_in_memory.

@Test
public void store_given_timestamp_in_memory() {
    final Set<TestProjection> projections = emptySet();
    final Timestamp whenHandled = TimeTests.Past.secondsAgo(5L);
    final BulkWriteOperation<Object, TestProjection> operation = newOperation(projections, whenHandled);
    assertTrue(operation.isInProgress());
    operation.storeLastHandledEventTime(whenHandled);
    operation.complete();
    assertFalse(operation.isInProgress());
}
Also used : Timestamp(com.google.protobuf.Timestamp) Test(org.junit.Test)

Aggregations

Timestamp (com.google.protobuf.Timestamp)89 Test (org.junit.Test)66 Duration (com.google.protobuf.Duration)19 Interval (io.spine.time.Interval)11 Command (io.spine.base.Command)8 AbstractZonedTimeTest (io.spine.time.AbstractZonedTimeTest)8 LocalTime (io.spine.time.LocalTime)8 Message (com.google.protobuf.Message)4 StringValue (com.google.protobuf.StringValue)4 EventStreamQuery (io.spine.server.event.EventStreamQuery)4 TimeTests (io.spine.test.TimeTests)4 Nullable (javax.annotation.Nullable)4 Event (io.spine.base.Event)3 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)3 Predicate (com.google.common.base.Predicate)2 ByteString (com.google.protobuf.ByteString)2 PubsubMessage (com.google.pubsub.v1.PubsubMessage)2 PullRequest (com.google.pubsub.v1.PullRequest)2 PullResponse (com.google.pubsub.v1.PullResponse)2 ReceivedMessage (com.google.pubsub.v1.ReceivedMessage)2