use of com.google.protobuf.Timestamp in project core-java by SpineEventEngine.
the class Commands method wereWithinPeriod.
/**
* Creates a predicate for filtering commands created withing given timerange.
*/
public static Predicate<Command> wereWithinPeriod(final Timestamp from, final Timestamp to) {
checkNotNull(from);
checkNotNull(to);
return new Predicate<Command>() {
@Override
public boolean apply(@Nullable Command request) {
checkNotNull(request);
final Timestamp timestamp = getTimestamp(request);
return Timestamps2.isBetween(timestamp, from, to);
}
};
}
use of com.google.protobuf.Timestamp in project core-java by SpineEventEngine.
the class WebSafeTimestampStringifierShould method convert_back_and_forth.
@Test
public void convert_back_and_forth() {
final Timestamp timestamp = getCurrentTime();
final Stringifier<Timestamp> stringifier = forTimestampWebSafe();
final String str = stringifier.convert(timestamp);
assertEquals(timestamp, stringifier.reverse().convert(str));
}
use of com.google.protobuf.Timestamp in project core-java by SpineEventEngine.
the class MessagesShould method pack_to_Any.
@Test
public void pack_to_Any() {
final Timestamp timestamp = Time.getCurrentTime();
assertEquals(timestamp, unpack(Messages.toAny(timestamp)));
}
use of com.google.protobuf.Timestamp in project core-java by SpineEventEngine.
the class Timestamps2Should method calculate_timestamp_of_moment_seconds_ago.
@Test
public void calculate_timestamp_of_moment_seconds_ago() {
final Timestamp currentTime = getCurrentTime();
final Timestamp expected = subtract(currentTime, TEN_SECONDS);
final Timestamp actual = TimeTests.Past.secondsAgo(TEN_SECONDS.getSeconds());
assertEquals(expected.getSeconds(), actual.getSeconds());
}
use of com.google.protobuf.Timestamp in project core-java by SpineEventEngine.
the class Timestamps2Should method convert_timestamp_to_date_to_nearest_second.
@Test
public void convert_timestamp_to_date_to_nearest_second() {
final Timestamp expectedTime = getCurrentTime();
final Date actualDate = toDate(expectedTime);
final long actualSeconds = actualDate.getTime() / MILLIS_PER_SECOND;
assertEquals(expectedTime.getSeconds(), actualSeconds);
}
Aggregations