TenantObject extends JsonBackedValueObject { @JsonIgnore public Set<TrustAnchor> getTrustAnchors() { if (trustAnchors == null) { trustAnchors = getProperty(TenantConstants.FIELD_PAYLOAD_TRUSTED_CA, JsonArray.class, new JsonArray()) .stream() .filter(obj -> obj instanceof JsonObject) .map(ca -> getTrustAnchorForPublicKey((JsonObject) ca)) .filter(anchor -> anchor != null) .collect(Collectors.toSet()); } return trustAnchors; }  @JsonAnySetter TenantObject setProperty(final String name, final Object value); @JsonIgnore String getTenantId(); @JsonIgnore TenantObject setTenantId(final String tenantId); @JsonIgnore boolean isEnabled(); @JsonIgnore TenantObject setEnabled(final boolean flag); @JsonIgnore TenantObject setTrustAnchor(final PublicKey publicKey, final X500Principal subjectDn); @JsonIgnore TenantObject addTrustAnchor(final PublicKey publicKey, final X500Principal subjectDn,
            final Boolean autoProvisioningEnabled); @JsonIgnore TenantObject addTrustAnchor(final byte[] publicKey,
                                       final String publicKeyAlgorithm,
                                       final X500Principal subjectDn,
                                       final Boolean autoProvisioningEnabled); @JsonIgnore Set<TrustAnchor> getTrustAnchors(); @JsonIgnore boolean isAutoProvisioningEnabled(final String subjectDn); @JsonProperty(TenantConstants.FIELD_ADAPTERS) List<Adapter> getAdapters(); @JsonProperty(TenantConstants.FIELD_ADAPTERS) TenantObject setAdapters(final List<Adapter> adapters); @JsonIgnore Adapter getAdapter(final String type); TenantObject addAdapter(final Adapter adapter); @JsonIgnore boolean isAdapterEnabled(final String typeName); @JsonIgnore int getMaxTimeUntilDisconnect(final String typeName); static TenantObject from(final String tenantId, final Boolean enabled); static TenantObject from(final Boolean enabled); @JsonGetter(TenantConstants.FIELD_RESOURCE_LIMITS) ResourceLimits getResourceLimits(); @JsonIgnore TenantObject setResourceLimits(final JsonObject resourceLimits); @JsonSetter(TenantConstants.FIELD_RESOURCE_LIMITS) TenantObject setResourceLimits(final ResourceLimits resourceLimits); @JsonIgnore int getMinimumMessageSize(); TenantObject setMinimumMessageSize(final int payloadSize); @JsonIgnore JsonObject getDefaults(); @JsonIgnore TenantObject setDefaults(final JsonObject defaultProperties); @JsonProperty(value = TenantConstants.FIELD_TRACING) TenantTracingConfig getTracingConfig(); @JsonProperty(value = TenantConstants.FIELD_TRACING) TenantObject setTracingConfig(final TenantTracingConfig tracing);  }
@Test public void testDeserializationOfEmptyTrustedAuthoritiesArray() { final JsonObject config = new JsonObject() .put(TenantConstants.FIELD_PAYLOAD_TENANT_ID, "my-tenant") .put(TenantConstants.FIELD_PAYLOAD_TRUSTED_CA, new JsonArray()); final TenantObject tenant = config.mapTo(TenantObject.class); assertThat(tenant.getTrustAnchors()).isNotNull(); assertThat(tenant.getTrustAnchors()).isEmpty(); }