MessageBuilder { public V userId(String userId) { if (isNullOrEmpty(userId)) { throw new IllegalArgumentException("userId cannot be null or empty."); } this.userId = userId; 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 invalidUserIdThrows(TestUtils.MessageBuilderFactory builder) { try { builder.get().userId(null); fail(); } catch (IllegalArgumentException e) { assertThat(e).hasMessage("userId cannot be null or empty."); } }