Skip to content

Commit

Permalink
Remove unused autowired tenant information service class
Browse files Browse the repository at this point in the history
* A test that used AutowiredTenantInformationService has been
  refactored to use DefaultTenantInformationService.
* Unused AutowiredTenantInformationService class has been removed.

Signed-off-by: Kartheeswaran Kalidass <kartheeswaran.kalidass@bosch.io>
  • Loading branch information
kaniyan committed May 20, 2021
1 parent 6c5f3cc commit 27d841a
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 113 deletions.

This file was deleted.

Expand Up @@ -23,10 +23,12 @@
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.UUID;

import javax.security.auth.x500.X500Principal;

import org.eclipse.hono.client.StatusCodeMapper;
import org.eclipse.hono.deviceregistry.service.tenant.DefaultTenantInformationService;
import org.eclipse.hono.deviceregistry.util.DeviceRegistryUtils;
import org.eclipse.hono.service.management.Id;
import org.eclipse.hono.service.management.OperationResult;
Expand Down Expand Up @@ -563,6 +565,34 @@ default void testUpdateTenantFailsForDuplicateCa(final VertxTestContext ctx) {
}));
}

/**
* Verifies that {@link org.eclipse.hono.deviceregistry.service.tenant.DefaultTenantInformationService} works
* correctly.
*
* @param ctx The vert.x test context.
*/
@Test
default void testTenantInformationService(final VertxTestContext ctx) {
final DefaultTenantInformationService informationService = new DefaultTenantInformationService(
getTenantManagementService());
final String tenantId = UUID.randomUUID().toString();

informationService.tenantExists(tenantId, NoopSpan.INSTANCE)
.onComplete(ctx.succeeding(t -> {
ctx.verify(() -> assertThat(t.getStatus()).isEqualTo(HttpURLConnection.HTTP_NOT_FOUND));
}));

addTenant(tenantId)
.map(ok -> {
informationService.tenantExists(tenantId, NoopSpan.INSTANCE)
.onComplete(ctx.succeeding(s -> ctx.verify(() -> {
assertThat(s.getPayload().getTenantId()).isEqualTo(tenantId);
ctx.completeNow();
})));
return null;
});
}

/**
* Verifies that a tenant is registered.
*
Expand Down
Expand Up @@ -33,7 +33,6 @@
import java.util.concurrent.TimeUnit;

import org.eclipse.hono.deviceregistry.DeviceRegistryTestUtils;
import org.eclipse.hono.deviceregistry.service.tenant.AutowiredTenantInformationService;
import org.eclipse.hono.deviceregistry.util.DeviceRegistryUtils;
import org.eclipse.hono.service.management.tenant.Tenant;
import org.eclipse.hono.service.management.tenant.TenantManagementService;
Expand Down Expand Up @@ -458,33 +457,4 @@ public void testConversion() {
assertThat(expectedAuthorities.getJsonObject(0)
.containsKey(RegistryManagementConstants.FIELD_AUTO_PROVISION_AS_GATEWAY)).isFalse();
}

/**
* Verifies that autowired {@link org.eclipse.hono.deviceregistry.service.tenant.TenantInformationService} works correctly.
*
* @param ctx The vert.x test context.
*/
@Test
public void testTenantInformationService(final VertxTestContext ctx) {
final AutowiredTenantInformationService informationService = new AutowiredTenantInformationService();
informationService.setService(svc);

informationService.tenantExists(Constants.DEFAULT_TENANT, NoopSpan.INSTANCE)
.onComplete(ctx.succeeding(t -> {
ctx.verify(() -> assertThat(t.getStatus()).isEqualTo(HttpURLConnection.HTTP_NOT_FOUND));
}));

addTenant(Constants.DEFAULT_TENANT)
.map(ok -> {
informationService.tenantExists(Constants.DEFAULT_TENANT, NoopSpan.INSTANCE)
.onComplete(ctx.succeeding(s -> {
ctx.verify(() -> {
assertThat(s.getPayload().getTenantId()).isEqualTo(Constants.DEFAULT_TENANT);
ctx.completeNow();
});
}));
return null;
});
}

}

0 comments on commit 27d841a

Please sign in to comment.