Search in sources :

Example 1 with DeviceServiceProperties

use of org.eclipse.hono.deviceregistry.jdbc.config.DeviceServiceProperties in project hono by eclipse.

the class AbstractJdbcRegistryTest method startDevices.

@BeforeEach
void startDevices(final Vertx vertx) throws IOException, SQLException {
    final var jdbc = resolveJdbcProperties();
    try (var connection = DriverManager.getConnection(jdbc.getUrl(), jdbc.getUsername(), jdbc.getPassword());
        var script = Files.newBufferedReader(EXAMPLE_SQL_BASE.resolve("02-create.devices.sql"))) {
        // pre-create database
        RunScript.execute(connection, script);
    }
    properties = new DeviceServiceProperties();
    this.credentialsAdapter = new CredentialsServiceImpl(DeviceStores.adapterStoreFactory().createTable(vertx, TRACER, jdbc, Optional.empty(), Optional.empty(), Optional.empty()), properties);
    this.registrationAdapter = new RegistrationServiceImpl(DeviceStores.adapterStoreFactory().createTable(vertx, TRACER, jdbc, Optional.empty(), Optional.empty(), Optional.empty()), new NoOpSchemaCreator());
    this.credentialsManagement = new CredentialsManagementServiceImpl(vertx, new SpringBasedHonoPasswordEncoder(properties.getMaxBcryptCostfactor()), DeviceStores.managementStoreFactory().createTable(vertx, TRACER, jdbc, Optional.empty(), Optional.empty(), Optional.empty()), properties);
    this.registrationManagement = new DeviceManagementServiceImpl(vertx, DeviceStores.managementStoreFactory().createTable(vertx, TRACER, jdbc, Optional.empty(), Optional.empty(), Optional.empty()), properties);
    tenantInformationService = mock(TenantInformationService.class);
    when(tenantInformationService.getTenant(anyString(), any())).thenReturn(Future.succeededFuture(new Tenant()));
    when(tenantInformationService.tenantExists(anyString(), any())).thenAnswer(invocation -> {
        return Future.succeededFuture(OperationResult.ok(HttpURLConnection.HTTP_OK, TenantKey.from(invocation.getArgument(0)), Optional.empty(), Optional.empty()));
    });
    registrationManagement.setTenantInformationService(tenantInformationService);
    credentialsManagement.setTenantInformationService(tenantInformationService);
}
Also used : Tenant(org.eclipse.hono.service.management.tenant.Tenant) SpringBasedHonoPasswordEncoder(org.eclipse.hono.auth.SpringBasedHonoPasswordEncoder) TenantInformationService(org.eclipse.hono.deviceregistry.service.tenant.TenantInformationService) DeviceServiceProperties(org.eclipse.hono.deviceregistry.jdbc.config.DeviceServiceProperties) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

SpringBasedHonoPasswordEncoder (org.eclipse.hono.auth.SpringBasedHonoPasswordEncoder)1 DeviceServiceProperties (org.eclipse.hono.deviceregistry.jdbc.config.DeviceServiceProperties)1 TenantInformationService (org.eclipse.hono.deviceregistry.service.tenant.TenantInformationService)1 Tenant (org.eclipse.hono.service.management.tenant.Tenant)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1