Batch { public static Batch create(Map<String, ?> context, List<Message> batch) { return new AutoValue_Batch(batch, new Date(), context, SEQUENCE_GENERATOR.incrementAndGet()); }  static Batch create(Map<String, ?> context, List<Message> batch); abstract List<Message> batch(); abstract Date sentAt(); abstract Map<String, ?> context(); abstract int sequence();  }
@Test public void create(TestUtils.MessageBuilderFactory factory) { Message message = factory.get().userId("userId").build(); Map<String, String> context = ImmutableMap.of("foo", "bar"); List<Message> messages = ImmutableList.of(message); Batch batch = Batch.create(context, messages); assertThat(batch.batch()).isEqualTo(messages); assertThat(batch.context()).isEqualTo(context); }