private static String renderAnnotation(Annotation annotation) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append(annotation.getDescription()); if (!annotation.getAttributes().isEmpty()) { stringBuilder.append(" "); stringBuilder.append(renderAttributes(annotation.getAttributes())); } return stringBuilder.toString(); }
@Test public void fromDescriptionAndAttributes_EmptyAttributes() { Annotation annotation = Annotation.fromDescriptionAndAttributes( "MyAnnotationText", Collections.<String, AttributeValue>emptyMap()); assertThat(annotation.getDescription()).isEqualTo("MyAnnotationText"); assertThat(annotation.getAttributes().size()).isEqualTo(0); }
@Test public void fromDescription() { Annotation annotation = Annotation.fromDescription("MyAnnotationText"); assertThat(annotation.getDescription()).isEqualTo("MyAnnotationText"); assertThat(annotation.getAttributes().size()).isEqualTo(0); }
@Test public void fromDescriptionAndAttributes() { Map<String, AttributeValue> attributes = new HashMap<String, AttributeValue>(); attributes.put( "MyStringAttributeKey", AttributeValue.stringAttributeValue("MyStringAttributeValue")); Annotation annotation = Annotation.fromDescriptionAndAttributes("MyAnnotationText", attributes); assertThat(annotation.getDescription()).isEqualTo("MyAnnotationText"); assertThat(annotation.getAttributes()).isEqualTo(attributes); }
timestampsInMicros, attributesToTags( event.getEvent().getAttributes(), descriptionToTag(event.getEvent().getDescription()))));
private static TimeEvent toTimeAnnotationProto(TimedEvent<Annotation> timedEvent) { TimeEvent.Builder timeEventBuilder = TimeEvent.newBuilder().setTime(toTimestampProto(timedEvent.getTimestamp())); Annotation annotation = timedEvent.getEvent(); timeEventBuilder.setAnnotation( TimeEvent.Annotation.newBuilder() .setDescription(toTruncatableStringProto(annotation.getDescription())) .setAttributes(toAttributesBuilderProto(annotation.getAttributes(), 0)) .build()); return timeEventBuilder.build(); }
private static TimeEvent toTimeAnnotationProto(TimedEvent<Annotation> timedEvent) { TimeEvent.Builder timeEventBuilder = TimeEvent.newBuilder().setTime(toTimestampProto(timedEvent.getTimestamp())); Annotation annotation = timedEvent.getEvent(); timeEventBuilder.setAnnotation( TimeEvent.Annotation.newBuilder() .setDescription(toTruncatableStringProto(annotation.getDescription())) .setAttributes(toAttributesBuilderProto(annotation.getAttributes(), 0)) .build()); return timeEventBuilder.build(); }
private static TimeEvent toTimeAnnotationProto(TimedEvent<Annotation> timedEvent) { TimeEvent.Builder timeEventBuilder = TimeEvent.newBuilder().setTime(toTimestampProto(timedEvent.getTimestamp())); Annotation annotation = timedEvent.getEvent(); timeEventBuilder.setAnnotation( TimeEvent.Annotation.newBuilder() .setDescription(toTruncatableStringProto(annotation.getDescription())) .setAttributes(toAttributesBuilderProto(annotation.getAttributes(), 0)) .build()); return timeEventBuilder.build(); }