### Question:
KafkaAdminClient implements Closeable { public Map<Resource, Set<Acl>> getAcls() { LOG.debug("Fetching all ACLs"); try { return convertKafkaAclMap(getAuthorizer().getAcls()); } catch (ZkException | ZooKeeperClientException e) { throw new AdminOperationException("Unable to retrieve all ACLs", e); } } KafkaAdminClient(Properties properties); Set<String> getTopics(); Set<TopicAndPartition> getPartitions(); Set<TopicAndPartition> getPartitions(String topic); Authorizer getAuthorizer(); Map<Resource, Set<Acl>> getAcls(); Map<Resource, Set<Acl>> getAcls(KafkaPrincipal principal); Set<Acl> getAcls(Resource resource); void addAcls(Set<Acl> acls, Resource resource); void removeAcls(Set<Acl> acls, Resource resource); void createTopic(String topic, int partitions, int replicationFactor); void createTopic(String topic, int partitions, int replicationFactor, Properties topicConfig); void deleteTopic(String topic); Properties getTopicConfig(String topic); void updateTopicConfig(String topic, Properties properties); int getTopicReplicationFactor(String topic); int getTopicPartitions(String topic); void addTopicPartitions(String topic, int partitions); AdminClient.ConsumerGroupSummary getConsumerGroupSummary(String consumerGroup); Collection<AdminClient.ConsumerSummary> getConsumerGroupSummaries(String consumerGroup); Map<TopicPartition, String> getConsumerGroupAssignments(String consumerGroup); @Override void close(); static final String ZOOKEEPER_SECURE; static final String DEFAULT_ZOOKEEPER_SECURE; static final String OPERATION_TIMEOUT_MS; static final String DEFAULT_OPERATION_TIMEOUT_MS; static final String OPERATION_SLEEP_MS; static final String DEFAULT_OPERATION_SLEEP_MS; }### Answer:
@Test public void getAcls() { KafkaPrincipal user = new KafkaPrincipal(KafkaPrincipal.USER_TYPE, "my_user"); Resource topic1 = Resource.fromString(Topic.name() + Resource.Separator() + "topic1"); Resource topic2 = Resource.fromString(Topic.name() + Resource.Separator() + "topic2"); Set<Acl> readAcl = Collections.singleton(new Acl(user, Allow$.MODULE$, Acl.WildCardHost(), Read$.MODULE$)); client.addAcls(readAcl, topic1); client.addAcls(readAcl, topic2); Map<Resource, Set<Acl>> allAcls = new HashMap<>(); allAcls.put(topic1, readAcl); allAcls.put(topic2, readAcl); assertThat(client.getAcls(), is(allAcls)); }
@Test(expected = AdminOperationException.class) public void getAcls_zkException() { failureClient.getAcls(); }
@Test (expected = IllegalArgumentException.class) public void getAcls_withKafkaPrincipal_principalIsNull() { client.getAcls((KafkaPrincipal) null); }
@Test(expected = AdminOperationException.class) public void getAcls_withKafkaPrincipal_zkException() { KafkaPrincipal user = new KafkaPrincipal(KafkaPrincipal.USER_TYPE, "user"); failureClient.getAcls(user); }
@Test (expected = IllegalArgumentException.class) public void getAcls_withResource_resourceIsNull() { client.getAcls((Resource) null); }
@Test(expected = AdminOperationException.class) public void getAcls_withResource_zkException() { Resource resource = Resource.fromString(Topic.name() + Resource.Separator() + "topic"); failureClient.getAcls(resource); }