use of com.google.common.testing.EqualsTester in project google-cloud-java by GoogleCloudPlatform.
the class MutationTest method equalsAndHashCode.
@Test
public void equalsAndHashCode() {
EqualsTester tester = new EqualsTester();
// Equality, not identity.
tester.addEqualityGroup(Mutation.newInsertBuilder("T1").build(), Mutation.newInsertBuilder("T1").build());
// Operation types are distinguished.
tester.addEqualityGroup(Mutation.newInsertOrUpdateBuilder("T1").build());
tester.addEqualityGroup(Mutation.newUpdateBuilder("T1").build());
tester.addEqualityGroup(Mutation.newReplaceBuilder("T1").build());
// Table is distinguished.
tester.addEqualityGroup(Mutation.newInsertBuilder("T2").build());
// Columns/values are distinguished (but by equality, not identity).
tester.addEqualityGroup(Mutation.newInsertBuilder("T1").set("C").to("V").build(), Mutation.newInsertBuilder("T1").set("C").to("V").build());
// Deletes consider the key set.
tester.addEqualityGroup(Mutation.delete("T1", KeySet.all()));
tester.addEqualityGroup(Mutation.delete("T1", KeySet.singleKey(Key.of("k"))), Mutation.delete("T1", Key.of("k")));
tester.testEquals();
}
use of com.google.common.testing.EqualsTester in project google-cloud-java by GoogleCloudPlatform.
the class InstanceTest method equality.
@Test
public void equality() {
InstanceId id = new InstanceId("test-project", "test-instance");
InstanceConfigId configId = new InstanceConfigId("test-project", "test-instance-config");
Instance instance = new Instance.Builder(instanceClient, dbClient, id).setInstanceConfigId(configId).setDisplayName("test instance").setNodeCount(1).setState(InstanceInfo.State.READY).addLabel("env", "prod").addLabel("region", "us").build();
Instance instance2 = new Instance.Builder(instanceClient, dbClient, id).setInstanceConfigId(configId).setDisplayName("test instance").setNodeCount(1).setState(InstanceInfo.State.READY).addLabel("region", "us").addLabel("env", "prod").build();
Instance instance3 = new Instance.Builder(instanceClient, dbClient, id).setInstanceConfigId(configId).setDisplayName("test instance").setNodeCount(1).setState(InstanceInfo.State.READY).addLabel("env", "prod").build();
EqualsTester tester = new EqualsTester();
tester.addEqualityGroup(instance, instance2);
tester.addEqualityGroup(instance3);
tester.testEquals();
}
use of com.google.common.testing.EqualsTester in project google-cloud-java by GoogleCloudPlatform.
the class KeyRangeTest method equalsAndHashCode.
@Test
public void equalsAndHashCode() {
EqualsTester tester = new EqualsTester();
// Test factory method vs builder with defaults vs builder with all parts explicit.
tester.addEqualityGroup(KeyRange.closedOpen(Key.of(1), Key.of(2)), KeyRange.newBuilder().setStart(Key.of(1)).setEnd(Key.of(2)).build(), KeyRange.newBuilder().setStart(Key.of(1)).setStartType(CLOSED).setEnd(Key.of(2)).setEndType(OPEN).build());
// Differing endpoint types.
tester.addEqualityGroup(KeyRange.closedClosed(Key.of(1), Key.of(2)));
tester.addEqualityGroup(KeyRange.openOpen(Key.of(1), Key.of(2)));
tester.addEqualityGroup(KeyRange.openClosed(Key.of(1), Key.of(2)));
// Differing start/end keys.
tester.addEqualityGroup(KeyRange.closedOpen(Key.of(2), Key.of(1)));
tester.addEqualityGroup(KeyRange.closedClosed(Key.of(), Key.of()));
// Prefix range.
tester.addEqualityGroup(KeyRange.prefix(Key.of(1, 2)), KeyRange.closedClosed(Key.of(1, 2), Key.of(1, 2)));
tester.testEquals();
}
use of com.google.common.testing.EqualsTester in project google-cloud-java by GoogleCloudPlatform.
the class TimestampTest method equalsAndHashCode.
@Test
public void equalsAndHashCode() {
EqualsTester tester = new EqualsTester();
tester.addEqualityGroup(Timestamp.ofTimeSecondsAndNanos(TEST_TIME_SECONDS, 0), Timestamp.ofTimeSecondsAndNanos(TEST_TIME_SECONDS, 0), Timestamp.of(new java.sql.Timestamp(TEST_TIME_SECONDS * 1000)));
tester.addEqualityGroup(Timestamp.ofTimeSecondsAndNanos(TEST_TIME_SECONDS + 1, 0));
tester.addEqualityGroup(Timestamp.ofTimeSecondsAndNanos(TEST_TIME_SECONDS, 1));
tester.testEquals();
}
use of com.google.common.testing.EqualsTester in project core-java by SpineEventEngine.
the class MessageEnvelopeShould method support_equality.
@Test
public void support_equality() {
final O oneMessage = outerObject();
final O anotherMessage = outerObject();
final E oneEnvelope = toEnvelope(oneMessage);
final E anotherEnvelope = toEnvelope(anotherMessage);
new EqualsTester().addEqualityGroup(oneEnvelope).addEqualityGroup(anotherEnvelope).testEquals();
}
Aggregations