MessageBuilder { public V enableIntegration(String key, boolean enable) { if (isNullOrEmpty(key)) { throw new IllegalArgumentException("Key cannot be null or empty."); } if (integrations == null) { integrations = new LinkedHashMap<>(); } integrations.put(key, enable); 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 invalidIntegrationKeyThrowsWhenEnabling(TestUtils.MessageBuilderFactory builder) { try { builder.get().enableIntegration(null, false); fail(); } catch (IllegalArgumentException e) { assertThat(e).hasMessage("Key cannot be null or empty."); } }
@Test public void enableIntegration(TestUtils.MessageBuilderFactory builder) { Message message = builder.get().userId("foo").enableIntegration("foo", false).build(); assertThat(message.integrations()).hasSize(1).containsEntry("foo", false); }