use of org.apache.kafka.common.message.DescribeAclsResponseData in project kafka by apache.
the class KafkaAdminClientTest method testDescribeAcls.
@Test
public void testDescribeAcls() throws Exception {
try (AdminClientUnitTestEnv env = mockClientEnv()) {
env.kafkaClient().setNodeApiVersions(NodeApiVersions.create());
// Test a call where we get back ACL1 and ACL2.
env.kafkaClient().prepareResponse(new DescribeAclsResponse(new DescribeAclsResponseData().setResources(DescribeAclsResponse.aclsResources(asList(ACL1, ACL2))), ApiKeys.DESCRIBE_ACLS.latestVersion()));
assertCollectionIs(env.adminClient().describeAcls(FILTER1).values().get(), ACL1, ACL2);
// Test a call where we get back no results.
env.kafkaClient().prepareResponse(new DescribeAclsResponse(new DescribeAclsResponseData(), ApiKeys.DESCRIBE_ACLS.latestVersion()));
assertTrue(env.adminClient().describeAcls(FILTER2).values().get().isEmpty());
// Test a call where we get back an error.
env.kafkaClient().prepareResponse(new DescribeAclsResponse(new DescribeAclsResponseData().setErrorCode(Errors.SECURITY_DISABLED.code()).setErrorMessage("Security is disabled"), ApiKeys.DESCRIBE_ACLS.latestVersion()));
TestUtils.assertFutureError(env.adminClient().describeAcls(FILTER2).values(), SecurityDisabledException.class);
// Test a call where we supply an invalid filter.
TestUtils.assertFutureError(env.adminClient().describeAcls(UNKNOWN_FILTER).values(), InvalidRequestException.class);
}
}
use of org.apache.kafka.common.message.DescribeAclsResponseData in project kafka by apache.
the class DescribeAclsRequest method getErrorResponse.
@Override
public AbstractResponse getErrorResponse(int throttleTimeMs, Throwable throwable) {
ApiError error = ApiError.fromThrowable(throwable);
DescribeAclsResponseData response = new DescribeAclsResponseData().setThrottleTimeMs(throttleTimeMs).setErrorCode(error.error().code()).setErrorMessage(error.message());
return new DescribeAclsResponse(response, version());
}
Aggregations