use of com.google.protobuf.Timestamp in project core-java by SpineEventEngine.
the class OffsetTimesShould method subtract_millis.
@Test
public void subtract_millis() {
final int millisDelta = random(1, 999_999);
final Duration deltaDuration = Durations.fromMillis(millisDelta);
final Timestamp gmtPast = Timestamps.subtract(gmtNow, deltaDuration);
final LocalTime expectedPast = LocalTimes.timeAt(gmtPast, zoneOffset);
final LocalTime actualPast = subtractMillis(now, millisDelta).getTime();
assertEquals(expectedPast, actualPast);
}
use of com.google.protobuf.Timestamp in project core-java by SpineEventEngine.
the class TimeChangesShould method do_not_accept_equal_Interval_values.
@Test(expected = IllegalArgumentException.class)
public void do_not_accept_equal_Interval_values() {
final Timestamp fourMinutesAgo = TimeTests.Past.minutesAgo(4);
final Timestamp now = getCurrentTime();
final Interval fourMinutes = Intervals.between(now, fourMinutesAgo);
TimeChanges.of(fourMinutes, fourMinutes);
}
use of com.google.protobuf.Timestamp in project core-java by SpineEventEngine.
the class CommandSchedulingShould method update_scheduling_time.
@Test
public void update_scheduling_time() {
final Command cmd = requestFactory.command().create(toMessage(newUuid()));
final Timestamp schedulingTime = getCurrentTime();
final Command cmdUpdated = CommandScheduler.setSchedulingTime(cmd, schedulingTime);
assertEquals(schedulingTime, cmdUpdated.getSystemProperties().getSchedulingTime());
}
use of com.google.protobuf.Timestamp in project core-java by SpineEventEngine.
the class CommandStoreShould method set_expired_scheduled_command_status_to_error_if_time_to_post_them_passed.
@Test
public void set_expired_scheduled_command_status_to_error_if_time_to_post_them_passed() {
final List<Command> commands = newArrayList(createProject(), addTask(), startProject());
final Duration delay = fromMinutes(5);
// time to post passed
final Timestamp schedulingTime = TimeTests.Past.minutesAgo(10);
storeAsScheduled(commands, delay, schedulingTime);
commandBus.rescheduleCommands();
for (Command cmd : commands) {
final CommandEnvelope envelope = CommandEnvelope.of(cmd);
final Message msg = envelope.getMessage();
final CommandId id = envelope.getId();
// Check the expired status error was set.
final ProcessingStatus status = getProcessingStatus(envelope);
// Check that the logging was called.
verify(log).errorExpiredCommand(msg, id);
final Error expected = CommandExpiredException.commandExpired(cmd);
assertEquals(expected, status.getError());
}
}
use of com.google.protobuf.Timestamp in project core-java by SpineEventEngine.
the class AggregateShould method record_modification_timestamp.
@Test
public void record_modification_timestamp() {
try {
final TimeTests.BackToTheFuture provider = new TimeTests.BackToTheFuture();
Time.setProvider(provider);
Timestamp currentTime = Time.getCurrentTime();
aggregate.dispatchCommands(command(createProject));
assertEquals(currentTime, aggregate.whenModified());
currentTime = provider.forward(10);
aggregate.dispatchCommands(command(startProject));
assertEquals(currentTime, aggregate.whenModified());
} finally {
Time.resetProvider();
}
}
Aggregations