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);
}
}
use of com.google.protobuf.Timestamp in project core-java by SpineEventEngine.
the class EntityClassShould method create_and_initialize_entity_instance.
@Test
public void create_and_initialize_entity_instance() {
final Long id = 100L;
final Timestamp before = TimeTests.Past.secondsAgo(1);
// Create and init the entity.
final EntityClass<NanoEntity> entityClass = new EntityClass<>(NanoEntity.class);
final AbstractVersionableEntity<Long, StringValue> entity = entityClass.createEntity(id);
final Timestamp after = Time.getCurrentTime();
// The interval with a much earlier start to allow non-zero interval on faster computers.
final Interval whileWeCreate = Intervals.between(before, after);
assertEquals(id, entity.getId());
assertEquals(0, entity.getVersion().getNumber());
assertTrue(Intervals.contains(whileWeCreate, entity.whenModified()));
assertEquals(StringValue.getDefaultInstance(), entity.getState());
assertFalse(entity.isArchived());
assertFalse(entity.isDeleted());
}
use of com.google.protobuf.Timestamp in project core-java by SpineEventEngine.
the class QueryParametersShould method keep_multiple_filters_for_single_column.
@Test
public void keep_multiple_filters_for_single_column() throws ParseException {
final String columnName = "time";
final EntityColumn column = mock(EntityColumn.class);
// Some valid Timestamp values
final Timestamp startTime = Timestamps.parse("2000-01-01T10:00:00.000-05:00");
final Timestamp deadline = Timestamps.parse("2017-01-01T10:00:00.000-05:00");
final ColumnFilter startTimeFilter = gt(columnName, startTime);
final ColumnFilter deadlineFilter = le(columnName, deadline);
final Multimap<EntityColumn, ColumnFilter> columnFilters = ImmutableMultimap.<EntityColumn, ColumnFilter>builder().put(column, startTimeFilter).put(column, deadlineFilter).build();
final CompositeQueryParameter parameter = from(columnFilters, ALL);
final QueryParameters parameters = newBuilder().add(parameter).build();
final List<CompositeQueryParameter> aggregatingParameters = newArrayList(parameters);
assertSize(1, aggregatingParameters);
final Multimap<EntityColumn, ColumnFilter> actualColumnFilters = aggregatingParameters.get(0).getFilters();
final Collection<ColumnFilter> timeFilters = actualColumnFilters.get(column);
assertSize(2, timeFilters);
assertContainsAll(timeFilters, startTimeFilter, deadlineFilter);
}
use of com.google.protobuf.Timestamp in project core-java by SpineEventEngine.
the class AggregateShould method return_non_null_time_when_was_last_modified.
@Test
public void return_non_null_time_when_was_last_modified() {
final Timestamp creationTime = new TestAggregate(ID).whenModified();
assertNotNull(creationTime);
}
use of com.google.protobuf.Timestamp in project core-java by SpineEventEngine.
the class AggregateShould method record_modification_time_when_command_handled.
@Test
public void record_modification_time_when_command_handled() {
try {
final Timestamp frozenTime = Time.getCurrentTime();
Time.setProvider(new TimeTests.FrozenMadHatterParty(frozenTime));
dispatchCommand(aggregate, env(createProject));
assertEquals(frozenTime, aggregate.whenModified());
} finally {
Time.resetProvider();
}
}
Aggregations