Search in sources :

Example 6 with DescribeTransactionsResponseData

use of org.apache.kafka.common.message.DescribeTransactionsResponseData in project kafka by apache.

the class DescribeTransactionsHandlerTest method testHandleSuccessfulResponse.

@Test
public void testHandleSuccessfulResponse() {
    String transactionalId1 = "foo";
    String transactionalId2 = "bar";
    Set<String> transactionalIds = mkSet(transactionalId1, transactionalId2);
    DescribeTransactionsHandler handler = new DescribeTransactionsHandler(logContext);
    DescribeTransactionsResponseData.TransactionState transactionState1 = sampleTransactionState1(transactionalId1);
    DescribeTransactionsResponseData.TransactionState transactionState2 = sampleTransactionState2(transactionalId2);
    Set<CoordinatorKey> keys = coordinatorKeys(transactionalIds);
    DescribeTransactionsResponse response = new DescribeTransactionsResponse(new DescribeTransactionsResponseData().setTransactionStates(asList(transactionState1, transactionState2)));
    ApiResult<CoordinatorKey, TransactionDescription> result = handler.handleResponse(node, keys, response);
    assertEquals(keys, result.completedKeys.keySet());
    assertMatchingTransactionState(node.id(), transactionState1, result.completedKeys.get(CoordinatorKey.byTransactionalId(transactionalId1)));
    assertMatchingTransactionState(node.id(), transactionState2, result.completedKeys.get(CoordinatorKey.byTransactionalId(transactionalId2)));
}
Also used : DescribeTransactionsResponse(org.apache.kafka.common.requests.DescribeTransactionsResponse) TransactionDescription(org.apache.kafka.clients.admin.TransactionDescription) DescribeTransactionsResponseData(org.apache.kafka.common.message.DescribeTransactionsResponseData) Test(org.junit.jupiter.api.Test)

Aggregations

DescribeTransactionsResponseData (org.apache.kafka.common.message.DescribeTransactionsResponseData)6 DescribeTransactionsResponse (org.apache.kafka.common.requests.DescribeTransactionsResponse)4 Test (org.junit.jupiter.api.Test)3 TransactionDescription (org.apache.kafka.clients.admin.TransactionDescription)2 Node (org.apache.kafka.common.Node)2 DescribeTransactionsRequest (org.apache.kafka.common.requests.DescribeTransactionsRequest)2 FindCoordinatorRequest (org.apache.kafka.common.requests.FindCoordinatorRequest)2 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2 Cluster (org.apache.kafka.common.Cluster)1 FindCoordinatorResponseData (org.apache.kafka.common.message.FindCoordinatorResponseData)1 Errors (org.apache.kafka.common.protocol.Errors)1 FindCoordinatorResponse (org.apache.kafka.common.requests.FindCoordinatorResponse)1 MockTime (org.apache.kafka.common.utils.MockTime)1