use of org.apache.kafka.clients.admin.DescribeProducersResult in project kafka by apache.
the class TransactionsCommandTest method testDescribeProducers.
private void testDescribeProducers(TopicPartition topicPartition, String[] args, DescribeProducersOptions expectedOptions) throws Exception {
DescribeProducersResult describeResult = Mockito.mock(DescribeProducersResult.class);
KafkaFuture<PartitionProducerState> describeFuture = completedFuture(new PartitionProducerState(asList(new ProducerState(12345L, 15, 1300, 1599509565L, OptionalInt.of(20), OptionalLong.of(990)), new ProducerState(98765L, 30, 2300, 1599509599L, OptionalInt.empty(), OptionalLong.empty()))));
Mockito.when(describeResult.partitionResult(topicPartition)).thenReturn(describeFuture);
Mockito.when(admin.describeProducers(singleton(topicPartition), expectedOptions)).thenReturn(describeResult);
execute(args);
assertNormalExit();
List<List<String>> table = readOutputAsTable();
assertEquals(3, table.size());
List<String> expectedHeaders = asList(TransactionsCommand.DescribeProducersCommand.HEADERS);
assertEquals(expectedHeaders, table.get(0));
Set<List<String>> expectedRows = Utils.mkSet(asList("12345", "15", "20", "1300", "1599509565", "990"), asList("98765", "30", "-1", "2300", "1599509599", "None"));
assertEquals(expectedRows, new HashSet<>(table.subList(1, table.size())));
}
Aggregations