MessageBuilder { public V timestamp(Date timestamp) { if (timestamp == null) { throw new NullPointerException("Null timestamp"); } this.timestamp = timestamp; return self(); } MessageBuilder(Message.Type type);   MessageBuilder(Message message); V messageId(UUID messageId); V messageId(String messageId); V timestamp(Date timestamp); V context(Map<String, ?> context); V anonymousId(UUID anonymousId); V anonymousId(String anonymousId); V userId(String userId); V enableIntegration(String key, boolean enable); V integrationOptions(String key, Map<String, ? super Object> options); T build(); Message.Type type();  }
@Test public void nullTimestampThrowsError(TestUtils.MessageBuilderFactory builder) { try { builder.get().timestamp(null); fail(); } catch (NullPointerException e) { assertThat(e).hasMessage("Null timestamp"); } }
@Test public void timestamp(TestUtils.MessageBuilderFactory builder) { Date date = newDate(1985, 4, 12, 23, 20, 50, 520, 0); Message message = builder.get().userId("userId").timestamp(date).build(); assertThat(message.timestamp()).isEqualTo(date); }