MessageHeadersBuilder extends AbstractDittoHeadersBuilder<MessageHeadersBuilder, MessageHeaders> { @Deprecated public static MessageHeadersBuilder newInstance(final MessageDirection direction, final CharSequence thingId, final CharSequence subject) { return newInstance(direction, ThingId.of(thingId), subject); } private  MessageHeadersBuilder(final Map<String, String> headers); private  MessageHeadersBuilder(final MessageHeaders dittoHeaders); @Deprecated static MessageHeadersBuilder newInstance(final MessageDirection direction, final CharSequence thingId,
            final CharSequence subject); static MessageHeadersBuilder newInstance(final MessageDirection direction, final ThingId thingId,
            final CharSequence subject); static MessageHeadersBuilder of(final Map<String, String> headers); static MessageHeadersBuilder of(final JsonObject jsonObject); MessageHeadersBuilder featureId(@Nullable final CharSequence featureId); @Override MessageHeadersBuilder contentType(@Nullable final CharSequence contentType); @Override MessageHeadersBuilder timeout(final Duration timeout); @Deprecated MessageHeadersBuilder timeout(final long timeoutInSeconds); MessageHeadersBuilder timestamp(@Nullable final OffsetDateTime timestamp); @Override MessageHeadersBuilder removeHeader(final CharSequence key); MessageHeadersBuilder timestamp(@Nullable final CharSequence timestampISO8601); MessageHeadersBuilder statusCode(@Nullable final HttpStatusCode statusCode); MessageHeadersBuilder statusCode(final int statusCode);  }
@Test public void tryToCreateInstanceWithNullDirection() { assertThatExceptionOfType(NullPointerException.class) .isThrownBy(() -> MessageHeadersBuilder.newInstance(null, THING_ID, SUBJECT)) .withMessage("The %s must not be null!", "direction") .withNoCause(); }
@Test public void tryToCreateInstanceWithNullThingId() { assertThatExceptionOfType(NullPointerException.class) .isThrownBy(() -> MessageHeadersBuilder.newInstance(DIRECTION, null, SUBJECT)) .withMessage("The %s must not be null!", "thing-id") .withNoCause(); }
@Test public void tryToCreateInstanceWithNullSubject() { assertThatExceptionOfType(NullPointerException.class) .isThrownBy(() -> MessageHeadersBuilder.newInstance(DIRECTION, THING_ID, null)) .withMessage("The %s must not be null!", "subject") .withNoCause(); }
@Test public void tryToCreateInstanceWithEmptySubject() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> MessageHeadersBuilder.newInstance(DIRECTION, THING_ID, "")) .withMessage("The argument '%s' must not be empty!", "subject") .withNoCause(); }
@Test public void tryToCreateInstanceWithInvalidSubject() { final String invalidSubject = "§foo"; assertThatExceptionOfType(DittoHeaderInvalidException.class) .isThrownBy(() -> MessageHeadersBuilder.newInstance(DIRECTION, THING_ID, invalidSubject)) .withMessageContaining(invalidSubject) .withMessageEndingWith("is not a valid message subject.") .withNoCause(); }