Search in sources :

Example 41 with EqualsTester

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, SPAN_NAME, Kind.CLIENT, startTimestamp, attributes, annotations, messageEvents, links, CHILD_SPAN_COUNT, status, endTimestamp);
    SpanData allSpanData2 = SpanData.create(spanContext, parentSpanId, false, SPAN_NAME, Kind.CLIENT, startTimestamp, attributes, annotations, messageEvents, links, CHILD_SPAN_COUNT, status, endTimestamp);
    SpanData emptySpanData = SpanData.create(spanContext, parentSpanId, false, SPAN_NAME, null, startTimestamp, Attributes.create(Collections.<String, AttributeValue>emptyMap(), 0), TimedEvents.create(Collections.<SpanData.TimedEvent<Annotation>>emptyList(), 0), TimedEvents.create(Collections.<SpanData.TimedEvent<MessageEvent>>emptyList(), 0), Links.create(Collections.<Link>emptyList(), 0), 0, status, endTimestamp);
    new EqualsTester().addEqualityGroup(allSpanData1, allSpanData2).addEqualityGroup(emptySpanData).testEquals();
}
Also used : AttributeValue(io.opencensus.trace.AttributeValue) EqualsTester(com.google.common.testing.EqualsTester) TimedEvent(io.opencensus.trace.export.SpanData.TimedEvent) Link(io.opencensus.trace.Link) Test(org.junit.Test)

Example 42 with EqualsTester

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.fromByte(SECOND_BYTE), TraceOptions.builder().setIsSampled(true).build());
    tester.addEqualityGroup(TraceOptions.fromByte(FIRST_BYTE));
    tester.testEquals();
}
Also used : EqualsTester(com.google.common.testing.EqualsTester) Test(org.junit.Test)

Example 43 with EqualsTester

use of com.google.common.testing.EqualsTester in project instrumentation-java by census-instrumentation.

the class AnnotationTest method annotation_EqualsAndHashCode.

@Test
public void annotation_EqualsAndHashCode() {
    EqualsTester tester = new EqualsTester();
    Map<String, AttributeValue> attributes = new HashMap<String, AttributeValue>();
    attributes.put("MyStringAttributeKey", AttributeValue.stringAttributeValue("MyStringAttributeValue"));
    tester.addEqualityGroup(Annotation.fromDescription("MyAnnotationText"), Annotation.fromDescriptionAndAttributes("MyAnnotationText", Collections.<String, AttributeValue>emptyMap())).addEqualityGroup(Annotation.fromDescriptionAndAttributes("MyAnnotationText", attributes), Annotation.fromDescriptionAndAttributes("MyAnnotationText", attributes)).addEqualityGroup(Annotation.fromDescription("MyAnnotationText2"));
    tester.testEquals();
}
Also used : EqualsTester(com.google.common.testing.EqualsTester) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 44 with EqualsTester

use of com.google.common.testing.EqualsTester in project instrumentation-java by census-instrumentation.

the class LinkTest method link_EqualsAndHashCode.

@Test
public void link_EqualsAndHashCode() {
    EqualsTester tester = new EqualsTester();
    tester.addEqualityGroup(Link.fromSpanContext(spanContext, Type.PARENT_LINKED_SPAN), Link.fromSpanContext(spanContext, Type.PARENT_LINKED_SPAN)).addEqualityGroup(Link.fromSpanContext(spanContext, Type.CHILD_LINKED_SPAN), Link.fromSpanContext(spanContext, Type.CHILD_LINKED_SPAN)).addEqualityGroup(Link.fromSpanContext(SpanContext.INVALID, Type.CHILD_LINKED_SPAN)).addEqualityGroup(Link.fromSpanContext(SpanContext.INVALID, Type.PARENT_LINKED_SPAN)).addEqualityGroup(Link.fromSpanContext(spanContext, Type.PARENT_LINKED_SPAN, attributesMap), Link.fromSpanContext(spanContext, Type.PARENT_LINKED_SPAN, attributesMap));
    tester.testEquals();
}
Also used : EqualsTester(com.google.common.testing.EqualsTester) Test(org.junit.Test)

Example 45 with EqualsTester

use of com.google.common.testing.EqualsTester in project instrumentation-java by census-instrumentation.

the class AttributeValueTest method attributeValue_EqualsAndHashCode.

@Test
public void attributeValue_EqualsAndHashCode() {
    EqualsTester tester = new EqualsTester();
    tester.addEqualityGroup(AttributeValue.stringAttributeValue("MyStringAttributeValue"), AttributeValue.stringAttributeValue("MyStringAttributeValue"));
    tester.addEqualityGroup(AttributeValue.stringAttributeValue("MyStringAttributeDiffValue"));
    tester.addEqualityGroup(AttributeValue.booleanAttributeValue(true), AttributeValue.booleanAttributeValue(true));
    tester.addEqualityGroup(AttributeValue.booleanAttributeValue(false));
    tester.addEqualityGroup(AttributeValue.longAttributeValue(123456L), AttributeValue.longAttributeValue(123456L));
    tester.addEqualityGroup(AttributeValue.longAttributeValue(1234567L));
    tester.addEqualityGroup(AttributeValue.doubleAttributeValue(1.23456), AttributeValue.doubleAttributeValue(1.23456));
    tester.addEqualityGroup(AttributeValue.doubleAttributeValue(1.234567));
    tester.testEquals();
}
Also used : EqualsTester(com.google.common.testing.EqualsTester) Test(org.junit.Test)

Aggregations

EqualsTester (com.google.common.testing.EqualsTester)225 Test (org.junit.Test)118 GwtIncompatible (com.google.common.annotations.GwtIncompatible)10 ParameterizedType (java.lang.reflect.ParameterizedType)10 Test (org.junit.jupiter.api.Test)9 WildcardType (java.lang.reflect.WildcardType)8 Method (java.lang.reflect.Method)7 Entry (java.util.Map.Entry)7 GenericArrayType (java.lang.reflect.GenericArrayType)6 Type (java.lang.reflect.Type)6 HashMap (java.util.HashMap)6 ImmutableList (com.google.common.collect.ImmutableList)5 Path (com.google.devtools.build.lib.vfs.Path)5 List (java.util.List)5 DisplayName (org.junit.jupiter.api.DisplayName)5 RootedPath (com.google.devtools.build.lib.vfs.RootedPath)4 HashSet (java.util.HashSet)4 Set (java.util.Set)4 ImmutableSet (com.google.common.collect.ImmutableSet)3 Label (com.google.devtools.build.lib.cmdline.Label)3