use of org.eclipse.hono.adapter.http.HttpAdapterMetrics in project hono by eclipse.
the class LoraProtocolAdapterTest method setUp.
/**
* Sets up the fixture.
*/
@BeforeEach
public void setUp() {
vertx = mock(Vertx.class);
final Context context = VertxMockSupport.mockContext(vertx);
webClient = mock(WebClient.class);
this.properties = givenDefaultConfigurationProperties();
createClients();
prepareClients();
processMessageSpan = mock(Span.class);
when(processMessageSpan.context()).thenReturn(mock(SpanContext.class));
final Span otherSpan = mock(Span.class);
when(otherSpan.context()).thenReturn(mock(SpanContext.class));
final SpanBuilder processMessageSpanBuilder = mock(SpanBuilder.class, withSettings().defaultAnswer(RETURNS_SELF));
when(processMessageSpanBuilder.start()).thenReturn(processMessageSpan);
final SpanBuilder otherSpanBuilder = mock(SpanBuilder.class, withSettings().defaultAnswer(RETURNS_SELF));
when(otherSpanBuilder.start()).thenReturn(otherSpan);
final Tracer tracer = mock(Tracer.class);
when(tracer.buildSpan(eq(LoraProtocolAdapter.SPAN_NAME_PROCESS_MESSAGE))).thenReturn(processMessageSpanBuilder);
when(tracer.buildSpan(argThat(opName -> !opName.equals(LoraProtocolAdapter.SPAN_NAME_PROCESS_MESSAGE)))).thenReturn(otherSpanBuilder);
final HttpAdapterMetrics metrics = mock(HttpAdapterMetrics.class);
when(metrics.startTimer()).thenReturn(mock(Sample.class));
adapter = new LoraProtocolAdapter(webClient);
adapter.setConfig(properties);
adapter.setTracer(tracer);
adapter.init(vertx, context);
adapter.setMetrics(metrics);
setServiceClients(adapter);
}
use of org.eclipse.hono.adapter.http.HttpAdapterMetrics in project hono by eclipse.
the class VertxBasedHttpProtocolAdapterTest method deployAdapter.
/**
* Creates and deploys the adapter instance under test.
* <p>
* The service clients' behavior is newly configured per test case
* in {@link VertxBasedHttpProtocolAdapterTest#configureServiceClients(TestInfo)}.
*
* @param ctx The vert.x test context.
*/
@SuppressWarnings("unchecked")
@BeforeAll
public void deployAdapter(final VertxTestContext ctx) {
vertx = Vertx.vertx();
usernamePasswordAuthProvider = mock(DeviceCredentialsAuthProvider.class);
final HttpAdapterMetrics metrics = mock(HttpAdapterMetrics.class);
when(metrics.startTimer()).thenReturn(Timer.start());
this.properties = givenDefaultConfigurationProperties();
createClients();
adapter = new VertxBasedHttpProtocolAdapter();
adapter.setConfig(properties);
adapter.setUsernamePasswordAuthProvider(usernamePasswordAuthProvider);
adapter.setMetrics(metrics);
setServiceClients(adapter);
vertx.deployVerticle(adapter, ctx.succeeding(deploymentId -> {
final WebClientOptions options = new WebClientOptions().setDefaultHost(HOST).setDefaultPort(adapter.getInsecurePort());
httpClient = WebClient.create(vertx, options);
ctx.completeNow();
}));
}
Aggregations