use of com.google.cloud.Timestamp in project google-cloud-java by GoogleCloudPlatform.
the class KeyTest method equalsAndHashCode.
@Test
public void equalsAndHashCode() {
EqualsTester tester = new EqualsTester();
tester.addEqualityGroup(Key.of(), Key.newBuilder().build());
// All types of null are considered equal.
tester.addEqualityGroup(Key.of((Object) null), Key.newBuilder().append((Boolean) null).build(), Key.newBuilder().append((Long) null).build(), Key.newBuilder().append((Double) null).build(), Key.newBuilder().append((String) null).build(), Key.newBuilder().append((ByteArray) null).build(), Key.newBuilder().append((Timestamp) null).build(), Key.newBuilder().append((Date) null).build(), Key.newBuilder().appendObject(null).build());
tester.addEqualityGroup(Key.of(true), Key.newBuilder().append(true).build());
tester.addEqualityGroup(Key.of(false), Key.newBuilder().append(false).build());
tester.addEqualityGroup(Key.of(1), Key.of(1L), Key.newBuilder().append(1).build());
tester.addEqualityGroup(Key.of(2), Key.of(2L), Key.newBuilder().append(2).build());
tester.addEqualityGroup(Key.of(1, 2));
tester.addEqualityGroup(Key.of(1.0f), Key.of(1.0d), Key.newBuilder().append(1.0).build());
tester.addEqualityGroup(Key.of(2.0f), Key.of(2.0d), Key.newBuilder().append(2.0).build());
tester.addEqualityGroup(Key.of("a"), Key.newBuilder().append("a").build());
tester.addEqualityGroup(Key.of("a", "b", "c"));
tester.addEqualityGroup(Key.of(ByteArray.copyFrom("a")), Key.newBuilder().append(ByteArray.copyFrom("a")).build());
Timestamp t = Timestamp.parseTimestamp("2015-09-15T00:00:00Z");
tester.addEqualityGroup(Key.of(t), Key.newBuilder().append(t).build());
Date d = Date.parseDate("2016-09-15");
tester.addEqualityGroup(Key.of(d), Key.newBuilder().append(d).build());
tester.addEqualityGroup(Key.of("a", 2, null));
tester.testEquals();
}
use of com.google.cloud.Timestamp in project beam by apache.
the class MutationSizeEstimatorTest method dates.
@Test
public void dates() throws Exception {
Mutation timestamp = Mutation.newInsertOrUpdateBuilder("test").set("one").to(Timestamp.now()).build();
Mutation nullTimestamp = Mutation.newInsertOrUpdateBuilder("test").set("one").to((Timestamp) null).build();
Mutation date = Mutation.newInsertOrUpdateBuilder("test").set("one").to(Date.fromYearMonthDay(2017, 10, 10)).build();
Mutation nullDate = Mutation.newInsertOrUpdateBuilder("test").set("one").to((Date) null).build();
Mutation timestampArray = Mutation.newInsertOrUpdateBuilder("test").set("one").toTimestampArray(Arrays.asList(Timestamp.now(), null)).build();
Mutation dateArray = Mutation.newInsertOrUpdateBuilder("test").set("one").toDateArray(Arrays.asList(null, Date.fromYearMonthDay(2017, 1, 1), null, Date.fromYearMonthDay(2017, 1, 2))).build();
assertThat(MutationSizeEstimator.sizeOf(timestamp), is(12L));
assertThat(MutationSizeEstimator.sizeOf(date), is(12L));
assertThat(MutationSizeEstimator.sizeOf(nullTimestamp), is(12L));
assertThat(MutationSizeEstimator.sizeOf(nullDate), is(12L));
assertThat(MutationSizeEstimator.sizeOf(timestampArray), is(24L));
assertThat(MutationSizeEstimator.sizeOf(dateArray), is(48L));
}
Aggregations