use of org.apache.kafka.clients.admin.internals.AllBrokersStrategy.BrokerKey in project kafka by apache.
the class ListTransactionsHandlerTest method assertFatalError.
private void assertFatalError(Errors error) {
int brokerId = 1;
BrokerKey brokerKey = new BrokerKey(OptionalInt.of(brokerId));
ApiResult<BrokerKey, Collection<TransactionListing>> result = handleResponseWithError(brokerId, error);
assertEquals(Collections.emptyMap(), result.completedKeys);
assertEquals(Collections.emptyList(), result.unmappedKeys);
assertEquals(Collections.singleton(brokerKey), result.failedKeys.keySet());
Throwable throwable = result.failedKeys.get(brokerKey);
assertEquals(error, Errors.forException(throwable));
}
use of org.apache.kafka.clients.admin.internals.AllBrokersStrategy.BrokerKey in project kafka by apache.
the class ListTransactionsHandlerTest method testBuildRequestWithFilteredState.
@Test
public void testBuildRequestWithFilteredState() {
int brokerId = 1;
BrokerKey brokerKey = new BrokerKey(OptionalInt.of(brokerId));
TransactionState filteredState = TransactionState.ONGOING;
ListTransactionsOptions options = new ListTransactionsOptions().filterStates(singleton(filteredState));
ListTransactionsHandler handler = new ListTransactionsHandler(options, logContext);
ListTransactionsRequest request = handler.buildRequest(brokerId, singleton(brokerKey)).build();
assertEquals(Collections.singletonList(filteredState.toString()), request.data().stateFilters());
assertEquals(Collections.emptyList(), request.data().producerIdFilters());
}
use of org.apache.kafka.clients.admin.internals.AllBrokersStrategy.BrokerKey in project kafka by apache.
the class ListTransactionsHandlerTest method testHandleSuccessfulResponse.
@Test
public void testHandleSuccessfulResponse() {
int brokerId = 1;
BrokerKey brokerKey = new BrokerKey(OptionalInt.of(brokerId));
ListTransactionsOptions options = new ListTransactionsOptions();
ListTransactionsHandler handler = new ListTransactionsHandler(options, logContext);
ListTransactionsResponse response = sampleListTransactionsResponse1();
ApiResult<BrokerKey, Collection<TransactionListing>> result = handler.handleResponse(node, singleton(brokerKey), response);
assertEquals(singleton(brokerKey), result.completedKeys.keySet());
assertExpectedTransactions(response.data().transactionStates(), result.completedKeys.get(brokerKey));
}
use of org.apache.kafka.clients.admin.internals.AllBrokersStrategy.BrokerKey in project kafka by apache.
the class ListTransactionsHandlerTest method handleResponseWithError.
private ApiResult<BrokerKey, Collection<TransactionListing>> handleResponseWithError(int brokerId, Errors error) {
BrokerKey brokerKey = new BrokerKey(OptionalInt.of(brokerId));
ListTransactionsOptions options = new ListTransactionsOptions();
ListTransactionsHandler handler = new ListTransactionsHandler(options, logContext);
ListTransactionsResponse response = new ListTransactionsResponse(new ListTransactionsResponseData().setErrorCode(error.code()));
return handler.handleResponse(node, singleton(brokerKey), response);
}
use of org.apache.kafka.clients.admin.internals.AllBrokersStrategy.BrokerKey in project kafka by apache.
the class ListTransactionsHandlerTest method testBuildRequestWithFilteredProducerId.
@Test
public void testBuildRequestWithFilteredProducerId() {
int brokerId = 1;
BrokerKey brokerKey = new BrokerKey(OptionalInt.of(brokerId));
long filteredProducerId = 23423L;
ListTransactionsOptions options = new ListTransactionsOptions().filterProducerIds(singleton(filteredProducerId));
ListTransactionsHandler handler = new ListTransactionsHandler(options, logContext);
ListTransactionsRequest request = handler.buildRequest(brokerId, singleton(brokerKey)).build();
assertEquals(Collections.singletonList(filteredProducerId), request.data().producerIdFilters());
assertEquals(Collections.emptyList(), request.data().stateFilters());
}
Aggregations