use of org.eclipse.hono.client.TenantClient in project hono by eclipse.
the class TenantAmqpIT method prepareDeviceRegistry.
/**
* Starts the device registry, connects a client and provides a tenant API client.
*
* @param ctx The vert.x test context.
*/
@BeforeClass
public static void prepareDeviceRegistry(final TestContext ctx) {
client = DeviceRegistryAmqpTestSupport.prepareDeviceRegistryClient(vertx);
client.connect(new ProtonClientOptions()).compose(c -> c.getOrCreateTenantClient()).setHandler(ctx.asyncAssertSuccess(r -> {
tenantClient = r;
}));
}
use of org.eclipse.hono.client.TenantClient in project hono by eclipse.
the class AbstractVertxBasedHttpProtocolAdapterTest method setup.
/**
* Sets up common fixture.
*/
@SuppressWarnings("unchecked")
@Before
public void setup() {
config = new HttpProtocolAdapterProperties();
config.setInsecurePortEnabled(true);
regClient = mock(RegistrationClient.class);
final JsonObject result = new JsonObject().put(RegistrationConstants.FIELD_ASSERTION, "token");
when(regClient.assertRegistration(anyString(), any())).thenReturn(Future.succeededFuture(result));
tenantClient = mock(TenantClient.class);
when(tenantClient.get(anyString())).thenAnswer(invocation -> {
return Future.succeededFuture(TenantObject.from(invocation.getArgument(0), true));
});
tenantServiceClient = mock(HonoClient.class);
when(tenantServiceClient.connect(any(Handler.class))).thenReturn(Future.succeededFuture(tenantServiceClient));
when(tenantServiceClient.getOrCreateTenantClient()).thenReturn(Future.succeededFuture(tenantClient));
messagingClient = mock(HonoClient.class);
when(messagingClient.connect(any(Handler.class))).thenReturn(Future.succeededFuture(messagingClient));
registrationServiceClient = mock(HonoClient.class);
when(registrationServiceClient.connect(any(Handler.class))).thenReturn(Future.succeededFuture(registrationServiceClient));
when(registrationServiceClient.getOrCreateRegistrationClient(anyString())).thenReturn(Future.succeededFuture(regClient));
credentialsAuthProvider = mock(HonoClientBasedAuthProvider.class);
when(credentialsAuthProvider.start()).thenReturn(Future.succeededFuture());
}
use of org.eclipse.hono.client.TenantClient in project hono by eclipse.
the class AbstractVertxBasedMqttProtocolAdapterTest method setup.
/**
* Creates clients for the needed micro services and sets the configuration to enable the insecure port.
*/
@Before
@SuppressWarnings("unchecked")
public void setup() {
config = new ProtocolAdapterProperties();
config.setInsecurePortEnabled(true);
regClient = mock(RegistrationClient.class);
final JsonObject result = new JsonObject().put(RegistrationConstants.FIELD_ASSERTION, "token");
when(regClient.assertRegistration(anyString(), any())).thenReturn(Future.succeededFuture(result));
tenantClient = mock(TenantClient.class);
when(tenantClient.get(anyString())).thenAnswer(invocation -> {
return Future.succeededFuture(TenantObject.from(invocation.getArgument(0), true));
});
tenantServiceClient = mock(HonoClient.class);
when(tenantServiceClient.connect(any(Handler.class))).thenReturn(Future.succeededFuture(tenantServiceClient));
when(tenantServiceClient.getOrCreateTenantClient()).thenReturn(Future.succeededFuture(tenantClient));
messagingClient = mock(HonoClient.class);
when(messagingClient.connect(any(Handler.class))).thenReturn(Future.succeededFuture(messagingClient));
deviceRegistrationServiceClient = mock(HonoClient.class);
when(deviceRegistrationServiceClient.connect(any(Handler.class))).thenReturn(Future.succeededFuture(deviceRegistrationServiceClient));
when(deviceRegistrationServiceClient.getOrCreateRegistrationClient(anyString())).thenReturn(Future.succeededFuture(regClient));
credentialsAuthProvider = mock(HonoClientBasedAuthProvider.class);
when(credentialsAuthProvider.start()).thenReturn(Future.succeededFuture());
}
Aggregations