use of org.apache.kafka.common.message.CreateAclsResponseData in project kafka by apache.
the class KafkaAdminClientTest method testCreateAcls.
@Test
public void testCreateAcls() throws Exception {
try (AdminClientUnitTestEnv env = mockClientEnv()) {
env.kafkaClient().setNodeApiVersions(NodeApiVersions.create());
// Test a call where we successfully create two ACLs.
env.kafkaClient().prepareResponse(new CreateAclsResponse(new CreateAclsResponseData().setResults(asList(new CreateAclsResponseData.AclCreationResult(), new CreateAclsResponseData.AclCreationResult()))));
CreateAclsResult results = env.adminClient().createAcls(asList(ACL1, ACL2));
assertCollectionIs(results.values().keySet(), ACL1, ACL2);
for (KafkaFuture<Void> future : results.values().values()) future.get();
results.all().get();
// Test a call where we fail to create one ACL.
env.kafkaClient().prepareResponse(new CreateAclsResponse(new CreateAclsResponseData().setResults(asList(new CreateAclsResponseData.AclCreationResult().setErrorCode(Errors.SECURITY_DISABLED.code()).setErrorMessage("Security is disabled"), new CreateAclsResponseData.AclCreationResult()))));
results = env.adminClient().createAcls(asList(ACL1, ACL2));
assertCollectionIs(results.values().keySet(), ACL1, ACL2);
TestUtils.assertFutureError(results.values().get(ACL1), SecurityDisabledException.class);
results.values().get(ACL2).get();
TestUtils.assertFutureError(results.all(), SecurityDisabledException.class);
}
}
use of org.apache.kafka.common.message.CreateAclsResponseData in project kafka by apache.
the class CreateAclsRequest method getErrorResponse.
@Override
public AbstractResponse getErrorResponse(int throttleTimeMs, Throwable throwable) {
CreateAclsResponseData.AclCreationResult result = CreateAclsRequest.aclResult(throwable);
List<CreateAclsResponseData.AclCreationResult> results = Collections.nCopies(data.creations().size(), result);
return new CreateAclsResponse(new CreateAclsResponseData().setThrottleTimeMs(throttleTimeMs).setResults(results));
}
Aggregations