use of org.eclipse.hono.service.auth.device.HonoClientBasedAuthProvider in project hono by eclipse.
the class AbstractProtocolAdapterBaseTest method testStartInternalConnectsToServices.
/**
* Verifies that the adapter connects to required services during
* startup and invokes the <em>doStart</em> method.
*
* @param ctx The vert.x test context.
*/
@SuppressWarnings("unchecked")
@Test
public void testStartInternalConnectsToServices(final TestContext ctx) {
// GIVEN an adapter configured with service clients
final Handler<Void> startupHandler = mock(Handler.class);
adapter = newProtocolAdapter(properties, "test", startupHandler);
final HonoClient tenantService = mock(HonoClient.class);
when(tenantService.connect(any(Handler.class))).thenReturn(Future.succeededFuture(tenantService));
adapter.setTenantServiceClient(tenantService);
final HonoClient registrationService = mock(HonoClient.class);
when(registrationService.connect(any(Handler.class))).thenReturn(Future.succeededFuture(registrationService));
adapter.setRegistrationServiceClient(registrationService);
final HonoClient messagingService = mock(HonoClient.class);
when(messagingService.connect(any(Handler.class))).thenReturn(Future.succeededFuture(messagingService));
adapter.setHonoMessagingClient(messagingService);
final HonoClientBasedAuthProvider authProvider = mock(HonoClientBasedAuthProvider.class);
when(authProvider.start()).thenReturn(Future.succeededFuture());
adapter.setCredentialsAuthProvider(authProvider);
// WHEN starting the adapter
adapter.startInternal().setHandler(ctx.asyncAssertSuccess(ok -> {
// THEN the service clients have connected
verify(tenantService).connect(any(Handler.class));
verify(registrationService).connect(any(Handler.class));
verify(messagingService).connect(any(Handler.class));
verify(authProvider).start();
// and the startup handler has been invoked
verify(startupHandler).handle(null);
}));
}
Aggregations