Skip to content

Commit

Permalink
issue #522 simplify test
Browse files Browse the repository at this point in the history
The NoopTracer doesn't need its span to be activated.
  • Loading branch information
ePaul committed Apr 13, 2021
1 parent 684251e commit 035b658
Showing 1 changed file with 4 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
package org.zalando.opentracing.flowid;

import io.opentracing.Scope;
import io.opentracing.Span;
import io.opentracing.mock.MockSpan;
import io.opentracing.noop.NoopTracer;
import io.opentracing.noop.NoopTracerFactory;
import org.junit.jupiter.api.Test;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

Expand All @@ -16,8 +11,7 @@
import static org.junit.jupiter.api.Assertions.assertThrows;

class DefaultFlowNoopTracerTest {
NoopTracer tracer = NoopTracerFactory.create();
private final Flow unit = Flow.create(tracer);
private final Flow unit = Flow.create(NoopTracerFactory.create());

@Test
void shouldThrowNoActiveSpanFoundException() {
Expand All @@ -26,14 +20,8 @@ void shouldThrowNoActiveSpanFoundException() {

@Test
void writeToShouldNotThrow() {
final Span span = tracer.buildSpan("test").start();

try (final Scope ignored = tracer.activateSpan(span)) {
final Map<String, String> target = new HashMap<>();

unit.writeTo(target::put);

assertEquals(emptyMap(), target);
}
final Map<String, String> target = new HashMap<>();
unit.writeTo(target::put);
assertEquals(emptyMap(), target);
}
}

0 comments on commit 035b658

Please sign in to comment.