ConsumerGroupOffsets { public static Builder newBuilder() { return new Builder(); } ConsumerGroupOffsets(final String consumerId, final Map<String, ConsumerGroupTopicOffsets> topics); String getConsumerId(); Collection<String> getTopicNames(); List<ConsumerGroupTopicOffsets> getTopics(); ConsumerGroupTopicOffsets getOffsetsForTopic(final String topicName); static Builder newBuilder();  }
@Test public void testSerialization() throws JsonProcessingException { final String expectedResult = "{\"consumerId\":\"MyConsumerId\",\"topics\":[{\"topic\":\"topic-a\",\"partitions\":[0,1],\"offsets\":[{\"partition\":0,\"offset\":0},{\"partition\":1,\"offset\":1}]},{\"topic\":\"topic-b\",\"partitions\":[0,1],\"offsets\":[{\"partition\":0,\"offset\":2},{\"partition\":1,\"offset\":3}]}],\"topicNames\":[\"topic-a\",\"topic-b\"]}"; final ConsumerGroupOffsets offsets = ConsumerGroupOffsets.newBuilder() .withConsumerId("MyConsumerId") .withOffset("topic-a", 0, 0) .withOffset("topic-a", 1, 1) .withOffset("topic-b", 0, 2) .withOffset("topic-b", 1, 3) .build(); assertTrue("Should be able to serialize", objectMapper.canSerialize(ConsumerGroupOffsets.class)); final String result = objectMapper.writeValueAsString(offsets); assertEquals("Should have expected serialized value", expectedResult, result); }