### Question:
ConsumerOffsetClient implements Closeable { public void commitOffsets(Map<TopicPartition, Long> offsets){ if(offsets == null) throw new IllegalArgumentException("offsets cannot be null"); Map<TopicPartition, OffsetAndMetadata> offsetsToWrite = offsets.entrySet().stream() .collect(Collectors.toMap(Map.Entry::getKey, e -> new OffsetAndMetadata(e.getValue()))); consumer.commitSync(offsetsToWrite); } ConsumerOffsetClient(Properties properties);  ConsumerOffsetClient(Consumer<Object, Object> consumer);   ConsumerOffsetClient(Consumer<Object, Object> consumer, boolean providedByUser); Map<TopicPartition, Long> getEndOffsets(Collection<String> topics); Map<TopicPartition, Long> getBeginningOffsets(Collection<String> topics); Map<TopicPartition, Long> getOffsetsForTimes(Collection<String> topics, long time); Map<TopicPartition, Long> getCommittedOffsets(Collection<String> topics); void commitOffsets(Map<TopicPartition, Long> offsets); long getCommittedOffset(TopicPartition topicPartition); Collection<TopicPartition> getPartitionsFor(Collection<String> topics); @Override void close();  }### Answer:
@Test(expected=IllegalArgumentException.class) public void commitOffsets_null() { client.commitOffsets(null); }
@Test public void commitOffsets(){ Map<TopicPartition, Long> offsets = new HashMap<>(); offsets.put(new TopicPartition("topic1", 0), 123L); offsets.put(new TopicPartition("topic1", 1), 234L); offsets.put(new TopicPartition("topic2", 0), 0L); offsets.put(new TopicPartition("topic2", 1), 0L); client.commitOffsets(offsets); verify(consumer).commitSync(commitRequest.capture()); Map<TopicPartition, OffsetAndMetadata> request = commitRequest.getValue(); request.forEach((k, v) -> assertThat(v.offset(), is(offsets.get(k)))); }
@Test(expected=IllegalArgumentException.class) public void commitOffsets_negativeValue(){ client.commitOffsets(Collections.singletonMap(new TopicPartition("topic1", 0), -1L)); }
@Test(expected=NullPointerException.class) public void commitOffsets_nullValue(){ client.commitOffsets(Collections.singletonMap(new TopicPartition("topic1", 0), null)); }