"Firestore.Query: Start", ImmutableMap.of( "transactional", AttributeValue.booleanAttributeValue(transactionId != null)));
@Test public void putAttributeCallsAddAttributesByDefault() { Span span = Mockito.spy(new NoopSpan(spanContext, spanOptions)); span.putAttribute("MyKey", AttributeValue.booleanAttributeValue(true)); span.end(); verify(span) .putAttributes( eq(Collections.singletonMap("MyKey", AttributeValue.booleanAttributeValue(true)))); }
private static ImmutableMap<String, AttributeValue> sampleAttributes() { return ImmutableMap.of( "BOOL", AttributeValue.booleanAttributeValue(false), "LONG", AttributeValue.longAttributeValue(Long.MAX_VALUE), "STRING", AttributeValue.stringAttributeValue( "Judge of a man by his questions rather than by his answers. -- Voltaire")); }
@Before public void setUp() { MockitoAnnotations.initMocks(this); attributes.put( "MyStringAttributeKey", AttributeValue.stringAttributeValue("MyStringAttributeValue")); attributes.put("MyLongAttributeKey", AttributeValue.longAttributeValue(123L)); attributes.put("MyBooleanAttributeKey", AttributeValue.booleanAttributeValue(false)); expectedAttributes.putAll(attributes); expectedAttributes.put( "MySingleStringAttributeKey", AttributeValue.stringAttributeValue("MySingleStringAttributeValue")); }
@Before public void setUp() { attributesMap.put("MyAttributeKey0", AttributeValue.stringAttributeValue("MyStringAttribute")); attributesMap.put("MyAttributeKey1", AttributeValue.longAttributeValue(10)); attributesMap.put("MyAttributeKey2", AttributeValue.booleanAttributeValue(true)); }
@Test public void attributeValue_ToString() { AttributeValue attribute = AttributeValue.stringAttributeValue("MyStringAttributeValue"); assertThat(attribute.toString()).contains("MyStringAttributeValue"); attribute = AttributeValue.booleanAttributeValue(true); assertThat(attribute.toString()).contains("true"); attribute = AttributeValue.longAttributeValue(123456L); assertThat(attribute.toString()).contains("123456"); attribute = AttributeValue.doubleAttributeValue(1.23456); assertThat(attribute.toString()).contains("1.23456"); } }
private static SpanData.TimedEvent<Annotation> sampleAnnotation() { return SpanData.TimedEvent.create( Timestamp.create(1519629872L, 987654321), Annotation.fromDescriptionAndAttributes( "annotation #1", ImmutableMap.of( "bool", AttributeValue.booleanAttributeValue(true), "long", AttributeValue.longAttributeValue(1337L), "string", AttributeValue.stringAttributeValue( "Kind words do not cost much. Yet they accomplish much. -- Pascal")))); }
@Before public void setUp() { attributesMap.put("MyAttributeKey1", AttributeValue.longAttributeValue(10)); attributesMap.put("MyAttributeKey2", AttributeValue.booleanAttributeValue(true)); attributes = Attributes.create(attributesMap, 1); annotationsList.add(SpanData.TimedEvent.create(eventTimestamp1, annotation)); annotationsList.add(SpanData.TimedEvent.create(eventTimestamp3, annotation)); annotations = TimedEvents.create(annotationsList, 2); networkEventsList.add(SpanData.TimedEvent.create(eventTimestamp1, recvNetworkEvent)); networkEventsList.add(SpanData.TimedEvent.create(eventTimestamp2, sentNetworkEvent)); networkEvents = TimedEvents.create(networkEventsList, 3); messageEventsList.add(SpanData.TimedEvent.create(eventTimestamp1, recvMessageEvent)); messageEventsList.add(SpanData.TimedEvent.create(eventTimestamp2, sentMessageEvent)); messageEvents = TimedEvents.create(messageEventsList, 3); linksList.add(Link.fromSpanContext(spanContext, Type.CHILD_LINKED_SPAN)); links = Links.create(linksList, 0); }
@Test public void booleanAttributeValue() { AttributeValue attribute = AttributeValue.booleanAttributeValue(true); attribute.match( new Function<String, Object>() { @Override @Nullable public Object apply(String stringValue) { fail("Expected a Boolean"); return null; } }, new Function<Boolean, Object>() { @Override @Nullable public Object apply(Boolean booleanValue) { assertThat(booleanValue).isTrue(); return null; } }, new Function<Long, Object>() { @Override @Nullable public Object apply(Long longValue) { fail("Expected a Boolean"); return null; } }, Functions.throwIllegalArgumentException()); }
"Firestore.Query: Start", ImmutableMap.of( "transactional", AttributeValue.booleanAttributeValue(transactionId != null)));
private static List<Link> sampleLinks() { return Lists.newArrayList( Link.fromSpanContext( SpanContext.create( TraceId.fromBytes( new byte[] {FF, FF, FF, FF, FF, FF, FF, FF, FF, FF, FF, FF, FF, FF, FF, 0}), SpanId.fromBytes(new byte[] {0, 0, 0, 0, 0, 0, 2, 0}), TraceOptions.builder().setIsSampled(false).build(), Tracestate.builder().build()), Link.Type.CHILD_LINKED_SPAN, ImmutableMap.of( "Bool", AttributeValue.booleanAttributeValue(true), "Long", AttributeValue.longAttributeValue(299792458L), "String", AttributeValue.stringAttributeValue( "Man is condemned to be free; because once thrown into the world, " + "he is responsible for everything he does. -- Sartre")))); } }
@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(); }
@Test public void doNotCrash() { Map<String, AttributeValue> attributes = new HashMap<String, AttributeValue>(); attributes.put( "MyStringAttributeKey", AttributeValue.stringAttributeValue("MyStringAttributeValue")); Map<String, AttributeValue> multipleAttributes = new HashMap<String, AttributeValue>(); multipleAttributes.put( "MyStringAttributeKey", AttributeValue.stringAttributeValue("MyStringAttributeValue")); multipleAttributes.put("MyBooleanAttributeKey", AttributeValue.booleanAttributeValue(true)); multipleAttributes.put("MyLongAttributeKey", AttributeValue.longAttributeValue(123)); // Tests only that all the methods are not crashing/throwing errors. BlankSpan.INSTANCE.putAttribute( "MyStringAttributeKey2", AttributeValue.stringAttributeValue("MyStringAttributeValue2")); BlankSpan.INSTANCE.addAttributes(attributes); BlankSpan.INSTANCE.addAttributes(multipleAttributes); BlankSpan.INSTANCE.addAnnotation("MyAnnotation"); BlankSpan.INSTANCE.addAnnotation("MyAnnotation", attributes); BlankSpan.INSTANCE.addAnnotation("MyAnnotation", multipleAttributes); BlankSpan.INSTANCE.addAnnotation(Annotation.fromDescription("MyAnnotation")); BlankSpan.INSTANCE.addNetworkEvent(NetworkEvent.builder(NetworkEvent.Type.SENT, 1L).build()); BlankSpan.INSTANCE.addMessageEvent(MessageEvent.builder(MessageEvent.Type.SENT, 1L).build()); BlankSpan.INSTANCE.addLink( Link.fromSpanContext(SpanContext.INVALID, Link.Type.CHILD_LINKED_SPAN)); BlankSpan.INSTANCE.setStatus(Status.OK); BlankSpan.INSTANCE.end(EndSpanOptions.DEFAULT); BlankSpan.INSTANCE.end(); }
@Test public void doNotCrash() { Map<String, AttributeValue> attributes = new HashMap<String, AttributeValue>(); attributes.put( "MyStringAttributeKey", AttributeValue.stringAttributeValue("MyStringAttributeValue")); Map<String, AttributeValue> multipleAttributes = new HashMap<String, AttributeValue>(); multipleAttributes.put( "MyStringAttributeKey", AttributeValue.stringAttributeValue("MyStringAttributeValue")); multipleAttributes.put("MyBooleanAttributeKey", AttributeValue.booleanAttributeValue(true)); multipleAttributes.put("MyLongAttributeKey", AttributeValue.longAttributeValue(123)); // Tests only that all the methods are not crashing/throwing errors. noRecordEventsSpan.putAttribute( "MyStringAttributeKey2", AttributeValue.stringAttributeValue("MyStringAttributeValue2")); noRecordEventsSpan.addAttributes(attributes); noRecordEventsSpan.addAttributes(multipleAttributes); noRecordEventsSpan.addAnnotation("MyAnnotation"); noRecordEventsSpan.addAnnotation("MyAnnotation", attributes); noRecordEventsSpan.addAnnotation("MyAnnotation", multipleAttributes); noRecordEventsSpan.addAnnotation(Annotation.fromDescription("MyAnnotation")); noRecordEventsSpan.addNetworkEvent(NetworkEvent.builder(NetworkEvent.Type.SENT, 1L).build()); noRecordEventsSpan.addMessageEvent(MessageEvent.builder(MessageEvent.Type.SENT, 1L).build()); noRecordEventsSpan.addLink( Link.fromSpanContext(SpanContext.INVALID, Link.Type.CHILD_LINKED_SPAN)); noRecordEventsSpan.setStatus(Status.OK); noRecordEventsSpan.end(EndSpanOptions.DEFAULT); noRecordEventsSpan.end(); } }
Map<String, AttributeValue> attributeMap = new HashMap<String, AttributeValue>(); attributeMap.put("string", AttributeValue.stringAttributeValue("string value")); attributeMap.put("boolean", AttributeValue.booleanAttributeValue(false)); attributeMap.put("long", AttributeValue.longAttributeValue(9999L)); SpanData data =