@Override
    public ListTransactionsRequest.Builder buildBatchedRequest(
        int brokerId,
        Set<AllBrokersStrategy.BrokerKey> keys
    ) {
        ListTransactionsRequestData request = new ListTransactionsRequestData();
        request.setProducerIdFilters(new ArrayList<>(options.filteredProducerIds()));
        request.setStateFilters(options.filteredStates().stream()
            .map(TransactionState::toString)
            .collect(Collectors.toList()));
        request.setDurationFilter(options.filteredDuration());
        return new ListTransactionsRequest.Builder(request);
    }
@Test
    public void testBuildRequestWithDurationFilter() {
        int brokerId = 1;
        BrokerKey brokerKey = new BrokerKey(OptionalInt.of(brokerId));
        ListTransactionsOptions options = new ListTransactionsOptions();
        ListTransactionsHandler handler = new ListTransactionsHandler(options, logContext);
        // case 1: check the default value (-1L) for durationFilter
        ListTransactionsRequest request = handler.buildBatchedRequest(brokerId, singleton(brokerKey)).build((short) 1);
        assertEquals(-1L, request.data().durationFilter());
        request = handler.buildBatchedRequest(brokerId, singleton(brokerKey)).build((short) 0);
        assertEquals(-1L, request.data().durationFilter());
        // case 2: able to set a valid duration filter when using API version 1
        options.filterOnDuration(10L);
        request = handler.buildBatchedRequest(brokerId, singleton(brokerKey)).build((short) 1);
        assertEquals(10L, request.data().durationFilter());
        assertEquals(Collections.emptyList(), request.data().producerIdFilters());
        // case 3: unable to set a valid duration filter when using API version 0
        assertThrows(UnsupportedVersionException.class, () -> handler.buildBatchedRequest(brokerId, singleton(brokerKey)).build((short) 0));
        // case 4: able to set duration filter to -1L when using API version 0
        options.filterOnDuration(-1L);
        ListTransactionsRequest request1 = handler.buildBatchedRequest(brokerId, singleton(brokerKey)).build((short) 0);
        assertEquals(-1L, request1.data().durationFilter());
    }