MessageBuilder { public V integrationOptions(String key, Map<String, ? super Object> options) { if (isNullOrEmpty(key)) { throw new IllegalArgumentException("Key cannot be null or empty."); } if (integrations == null) { integrations = new LinkedHashMap<>(); } integrations.put(key, ImmutableMap.copyOf(options)); 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 invalidIntegrationKeyThrowsWhenSettingOptions( TestUtils.MessageBuilderFactory builder) { try { builder.get().integrationOptions(null, null); fail(); } catch (IllegalArgumentException e) { assertThat(e).hasMessage("Key cannot be null or empty."); } }
@Test public void integrationOptions(TestUtils.MessageBuilderFactory builder) { Message message = builder .get() .userId("foo") .integrationOptions("bar", ImmutableMap.of("qaz", "qux")) .build(); assertThat(message.integrations()) .hasSize(1) .containsEntry("bar", ImmutableMap.of("qaz", "qux")); }