@Test
public void createBuilderFromMapContainingInvalidMetadataValue() {

    final String invalidValue = String.valueOf(Instant.now());
    final Map<String, String> headerMap = new HashMap<>();
    headerMap.put("foo", "bar");
    headerMap.put(DittoHeaderDefinition.PUT_METADATA.getKey(), invalidValue);
    headerMap.put(DittoHeaderDefinition.CORRELATION_ID.getKey(), String.valueOf(UUID.randomUUID()));
    assertThatExceptionOfType(DittoHeaderInvalidException.class)
            .isThrownBy(() -> DefaultDittoHeadersBuilder.of(headerMap))
            .withMessage("The value '%s' of the header '%s' is not a valid MetadataHeaders.", invalidValue,
                    DittoHeaderDefinition.PUT_METADATA.getKey())
            .satisfies(dittoHeaderInvalidException -> assertThat(dittoHeaderInvalidException.getDescription())
                    .hasValueSatisfying(description -> assertThat(description)
                            .startsWith("Failed to parse JSON string '" + invalidValue + "'!")))
            .withCauseInstanceOf(JsonParseException.class);
}