use of com.google.common.testing.EqualsTester in project instrumentation-java by census-instrumentation.
the class TraceOptionsTest method traceOptions_EqualsAndHashCode.
@Test
public void traceOptions_EqualsAndHashCode() {
EqualsTester tester = new EqualsTester();
tester.addEqualityGroup(TraceOptions.DEFAULT);
tester.addEqualityGroup(TraceOptions.fromBytes(secondBytes), TraceOptions.builder().setIsSampled().build());
tester.addEqualityGroup(TraceOptions.fromBytes(firstBytes));
tester.testEquals();
}
use of com.google.common.testing.EqualsTester in project instrumentation-java by census-instrumentation.
the class SpanDataTest method spanDataEquals.
@Test
public void spanDataEquals() {
SpanData allSpanData1 = SpanData.create(spanContext, parentSpanId, false, DISPLAY_NAME, startTimestamp, attributes, annotations, networkEvents, links, status, endTimestamp);
SpanData allSpanData2 = SpanData.create(spanContext, parentSpanId, false, DISPLAY_NAME, startTimestamp, attributes, annotations, networkEvents, links, status, endTimestamp);
SpanData emptySpanData = SpanData.create(spanContext, parentSpanId, false, DISPLAY_NAME, startTimestamp, Attributes.create(Collections.<String, AttributeValue>emptyMap(), 0), TimedEvents.create(Collections.<SpanData.TimedEvent<Annotation>>emptyList(), 0), TimedEvents.create(Collections.<SpanData.TimedEvent<NetworkEvent>>emptyList(), 0), Links.create(Collections.<Link>emptyList(), 0), status, endTimestamp);
new EqualsTester().addEqualityGroup(allSpanData1, allSpanData2).addEqualityGroup(emptySpanData).testEquals();
}
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();
}
Aggregations