use of org.apache.kafka.common.requests.UpdateFeaturesRequest in project kafka by apache.
the class KafkaAdminClientTest method testUpdateFeatures.
private void testUpdateFeatures(Map<String, FeatureUpdate> featureUpdates, ApiError topLevelError, Map<String, ApiError> featureUpdateErrors) throws Exception {
try (final AdminClientUnitTestEnv env = mockClientEnv()) {
env.kafkaClient().prepareResponse(body -> body instanceof UpdateFeaturesRequest, UpdateFeaturesResponse.createWithErrors(topLevelError, featureUpdateErrors, 0));
final Map<String, KafkaFuture<Void>> futures = env.adminClient().updateFeatures(featureUpdates, new UpdateFeaturesOptions().timeoutMs(10000)).values();
for (final Map.Entry<String, KafkaFuture<Void>> entry : futures.entrySet()) {
final KafkaFuture<Void> future = entry.getValue();
final ApiError error = featureUpdateErrors.get(entry.getKey());
if (topLevelError.error() == Errors.NONE) {
assertNotNull(error);
if (error.error() == Errors.NONE) {
future.get();
} else {
final ExecutionException e = assertThrows(ExecutionException.class, future::get);
assertEquals(e.getCause().getClass(), error.exception().getClass());
}
} else {
final ExecutionException e = assertThrows(ExecutionException.class, future::get);
assertEquals(e.getCause().getClass(), topLevelError.exception().getClass());
}
}
}
}
Aggregations