Attribute { public void setType(Optional<String> type) { this.type = type; } Attribute();  Attribute(Object value); Object getValue(); void setValue(Object value); Optional<String> getType(); void setType(Optional<String> type); Map<String, Metadata> getMetadata(); void setMetadata(Map<String, Metadata> metadata); @JsonIgnore void addMetadata(String key, Metadata metadata);  }
@Test public void serializationAttributeWithNullMetadataTest() throws JsonProcessingException { Attribute attribute = new Attribute(23.5); attribute.setType(Optional.of("float")); String json = Utils.objectMapper.writeValueAsString(attribute); assertTrue(json.contains("value")); assertTrue(json.contains("type")); assertTrue(json.contains("metadata")); }