FileBasedTenantService implements TenantService, TenantManagementService, Lifecycle { private void addTenant(final JsonObject tenantToAdd) { Optional.ofNullable(tenantToAdd.getValue(TenantConstants.FIELD_PAYLOAD_TRUSTED_CA)) .filter(JsonObject.class::isInstance) .map(JsonObject.class::cast) .ifPresent(trustedCas -> tenantToAdd.put(TenantConstants.FIELD_PAYLOAD_TRUSTED_CA, new JsonArray().add(trustedCas))); final String tenantId = Optional.ofNullable(tenantToAdd.remove(TenantConstants.FIELD_PAYLOAD_TENANT_ID)) .filter(String.class::isInstance) .map(String.class::cast) .orElseThrow(() -> new IllegalArgumentException("tenant has no " + TenantConstants.FIELD_PAYLOAD_TENANT_ID + " property")); final Versioned<Tenant> tenant = new Versioned<>(tenantToAdd.mapTo(Tenant.class)); LOG.debug("loading tenant [{}]", tenantId); tenants.put(tenantId, tenant); } @Autowired  FileBasedTenantService(final Vertx vertx); @Autowired void setConfig(final FileBasedTenantsConfigProperties configuration); @Override Future<Void> start(); @Override Future<Void> stop(); @Override Future<TenantResult<JsonObject>> get(final String tenantId); @Override Future<TenantResult<JsonObject>> get(final String tenantId, final Span span); @Override Future<TenantResult<JsonObject>> get(final X500Principal subjectDn); @Override Future<OperationResult<Tenant>> readTenant(final String tenantId, final Span span); @Override Future<TenantResult<JsonObject>> get(final X500Principal subjectDn, final Span span); @Override Future<Result<Void>> deleteTenant(final String tenantId, final Optional<String> resourceVersion,
            final Span span); @Override Future<OperationResult<Id>> createTenant(final Optional<String> tenantId, final Tenant tenantSpec,
            final Span span); @Override Future<OperationResult<Void>> updateTenant(final String tenantId, final Tenant tenantSpec,
            final Optional<String> expectedResourceVersion,
            final Span span); OperationResult<Void> update(
            final String tenantId,
            final Tenant tenantSpec,
            final Optional<String> expectedResourceVersion,
            final Span span); void clear(); @Override String toString();  }
@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; }); }