ImmutableLogEntry implements LogEntry { public static LogEntryBuilder getBuilder(final String correlationId, final Instant timestamp, final LogCategory logCategory, final LogType logType, final LogLevel logLevel, final String message) { return getBuilder(correlationId, timestamp, logCategory, logType, logLevel, message, null, null); } private  ImmutableLogEntry(final Builder builder); static LogEntryBuilder getBuilder(final String correlationId, final Instant timestamp, final LogCategory logCategory,
            final LogType logType, final LogLevel logLevel, final String message); static LogEntryBuilder getBuilder(final String correlationId, final Instant timestamp, final LogCategory logCategory,
            final LogType logType, final LogLevel logLevel, final String message,
            @Nullable final String address, @Nullable final ThingId thingId); static LogEntry fromJson(final JsonObject jsonObject); @Override String getCorrelationId(); @Override Instant getTimestamp(); @Override LogCategory getLogCategory(); @Override LogType getLogType(); @Override LogLevel getLogLevel(); @Override String getMessage(); @Override Optional<String> getAddress(); @Override Optional<ThingId> getThingId(); @Override JsonObject toJson(final JsonSchemaVersion schemaVersion, final Predicate<JsonField> predicate); @Override boolean equals(@Nullable final Object o); @Override int hashCode(); @Override String toString();  }
@Test public void createInstanceWithNullCorrelationId() { assertThatExceptionOfType(NullPointerException.class) .isThrownBy(() -> ImmutableLogEntry.getBuilder(null, TIMESTAMP, CATEGORY, TYPE, LEVEL, MESSAGE, ADDRESS, THING_ID)); }
@Test public void createInstanceWithNullTimestamp() { assertThatExceptionOfType(NullPointerException.class) .isThrownBy(() -> ImmutableLogEntry.getBuilder(CORRELATION_ID, null, CATEGORY, TYPE, LEVEL, MESSAGE, ADDRESS, THING_ID)); }
@Test public void createInstanceWithNullLogCategory() { assertThatExceptionOfType(NullPointerException.class) .isThrownBy(() -> ImmutableLogEntry.getBuilder(CORRELATION_ID, TIMESTAMP, null, TYPE, LEVEL, MESSAGE, ADDRESS, THING_ID)); }
@Test public void createInstanceWithNullLogType() { assertThatExceptionOfType(NullPointerException.class) .isThrownBy(() -> ImmutableLogEntry.getBuilder(CORRELATION_ID, TIMESTAMP, CATEGORY, null, LEVEL, MESSAGE, ADDRESS, THING_ID)); }
@Test public void createInstanceWithNullMessage() { assertThatExceptionOfType(NullPointerException.class) .isThrownBy(() -> ImmutableLogEntry.getBuilder(CORRELATION_ID, TIMESTAMP, CATEGORY, TYPE, LEVEL, null, ADDRESS, THING_ID)); }
@Test public void createInstanceWithNullLogLevel() { assertThatExceptionOfType(NullPointerException.class) .isThrownBy(() -> ImmutableLogEntry.getBuilder(CORRELATION_ID, TIMESTAMP, CATEGORY, TYPE, null, MESSAGE, ADDRESS, THING_ID)); }
@Test public void verifyBuilder() { final LogEntryBuilder builder = ImmutableLogEntry.getBuilder("any", Instant.now().minusSeconds(123), LogCategory.RESPONSE, LogType.DISPATCHED, LogLevel.FAILURE, "other message"); final LogEntry builtEntry = builder .correlationId(CORRELATION_ID) .timestamp(TIMESTAMP) .logCategory(CATEGORY) .logType(TYPE) .logLevel(LEVEL) .message(MESSAGE) .address(ADDRESS) .thingId(THING_ID) .build(); assertThat(builtEntry).isEqualTo(LOG_ENTRY); }