MessageBuilder { public V context(Map<String, ?> context) { if (context == null) { throw new NullPointerException("Null context"); } this.context = ImmutableMap.copyOf(context); 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 invalidContextThrows(TestUtils.MessageBuilderFactory builder) { try { builder.get().context(null); fail(); } catch (NullPointerException e) { assertThat(e).hasMessage("Null context"); } }
@Test public void context(TestUtils.MessageBuilderFactory builder) { Map<String, String> context = ImmutableMap.of("foo", "bar"); Message message = builder.get().userId("foo").context(context).build(); assertThat(message.context()).isEqualTo(context); }