Search in sources :

Example 1 with DescribeAclsResponseData

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);
    }
}
Also used : DescribeAclsResponse(org.apache.kafka.common.requests.DescribeAclsResponse) DescribeAclsResponseData(org.apache.kafka.common.message.DescribeAclsResponseData) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Test(org.junit.jupiter.api.Test)

Example 2 with DescribeAclsResponseData

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());
}
Also used : DescribeAclsResponseData(org.apache.kafka.common.message.DescribeAclsResponseData)

Aggregations

DescribeAclsResponseData (org.apache.kafka.common.message.DescribeAclsResponseData)2 DescribeAclsResponse (org.apache.kafka.common.requests.DescribeAclsResponse)1 Test (org.junit.jupiter.api.Test)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1