use of com.google.protobuf.Timestamp in project core-java by SpineEventEngine.
the class AggregateBuilderShould method create_aggregate.
@Test
public void create_aggregate() {
final int id = 2048;
final int version = 2017;
final Timestamp whenModified = Time.getCurrentTime();
final Timestamp state = TimeTests.Past.minutesAgo(60);
final Aggregate aggregate = givenAggregate().withId(id).withVersion(version).withState(state).modifiedOn(whenModified).build();
assertEquals(TestAggregate.class, aggregate.getClass());
assertEquals(id, aggregate.getId());
assertEquals(state, aggregate.getState());
assertEquals(version, aggregate.getVersion().getNumber());
assertEquals(whenModified, aggregate.whenModified());
}
use of com.google.protobuf.Timestamp in project core-java by SpineEventEngine.
the class EntityBuilderShould method create_entity.
@Test
public void create_entity() {
final long id = 1024L;
final int version = 100500;
final StringValue state = Wrapper.forString(getClass().getName());
final Timestamp timestamp = Time.getCurrentTime();
final VersionableEntity entity = givenEntity().withId(id).withVersion(version).withState(state).modifiedOn(timestamp).build();
assertEquals(TestEntity.class, entity.getClass());
assertEquals(id, entity.getId());
assertEquals(state, entity.getState());
assertEquals(version, entity.getVersion().getNumber());
assertEquals(timestamp, entity.getVersion().getTimestamp());
}
use of com.google.protobuf.Timestamp in project core-java by SpineEventEngine.
the class CommandTestShould method create_command_with_custom_Timestamp.
@Test
public void create_command_with_custom_Timestamp() {
final StringValue commandMessage = newUuidValue();
final Timestamp timestamp = TimeTests.Past.minutesAgo(5);
final Command command = commandTest.createCommand(commandMessage, timestamp);
assertEquals(timestamp, command.getContext().getActorContext().getTimestamp());
}
use of com.google.protobuf.Timestamp in project core-java by SpineEventEngine.
the class TimeTestsShould method have_frozen_time_provider.
@Test
public void have_frozen_time_provider() {
final Timestamp fiveMinutesAgo = subtract(getCurrentTime(), fromMinutes(5));
final Time.Provider provider = new TimeTests.FrozenMadHatterParty(fiveMinutesAgo);
assertEquals(fiveMinutesAgo, provider.getCurrentTime());
}
use of com.google.protobuf.Timestamp in project core-java by SpineEventEngine.
the class MessageFieldValidator method validateTimestamps.
private void validateTimestamps() {
final Time when = timeOption.getIn();
if (when == TIME_UNDEFINED) {
return;
}
final Timestamp now = getCurrentTime();
for (Message value : getValues()) {
final Timestamp time = (Timestamp) value;
if (isTimeInvalid(time, when, now)) {
addViolation(newTimeViolation(time));
// return because one error message is enough for the "time" option
return;
}
}
}
Aggregations