From 3ae00c76e2cc7b8ae53a41685e28a7b46d4a0625 Mon Sep 17 00:00:00 2001 From: Zhan Su Date: Fri, 13 Sep 2019 11:54:01 -0700 Subject: [PATCH] Unit test for null endpoint serviceName --- .../stackdriver/AttributesExtractorTest.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/translation-stackdriver/src/test/java/zipkin2/translation/stackdriver/AttributesExtractorTest.java b/translation-stackdriver/src/test/java/zipkin2/translation/stackdriver/AttributesExtractorTest.java index 66aa9fa7..93ce3fb3 100644 --- a/translation-stackdriver/src/test/java/zipkin2/translation/stackdriver/AttributesExtractorTest.java +++ b/translation-stackdriver/src/test/java/zipkin2/translation/stackdriver/AttributesExtractorTest.java @@ -148,6 +148,25 @@ public void testEndpointIsSetIpv6() { assertThat(clientLabels).doesNotContainKeys("endpoint.ipv4", "endpoint.ipv6"); } + @Test + public void testEndpointWithNullServiceName() { + Endpoint.Builder serverEndpointBuilder = Endpoint.newBuilder().port(80); + Endpoint serverEndpoint = serverEndpointBuilder.build(); + assertThat(serverEndpoint.serviceName()).isNull(); + Span serverSpan = + Span.newBuilder() + .kind(Kind.SERVER) + .traceId("4") + .name("test-span") + .id("5") + .localEndpoint(serverEndpoint) + .build(); + + AttributesExtractor extractor = new AttributesExtractor(Collections.emptyMap()); + Map serverLabels = extractor.extract(serverSpan).getAttributeMapMap(); + assertThat(serverLabels).doesNotContainKey("endpoint.serviceName"); + } + @Test public void testComponentLabelIsSet() { AttributesExtractor extractor = new AttributesExtractor(Collections.emptyMap());