Repository: apache/kafka
File: clients/src/test/java/org/apache/kafka/clients/admin/internals/DescribeConsumerGroupsHandlerTest.java (Java)

Code before:
        assertThrows(IllegalArgumentException.class, () -> handler.buildRequest(1, singleton(CoordinatorKey.byTransactionalId("tId"))));
    }

    @Test
    public void testSuccessfulHandleConsumerGroupResponse() {
        DescribeConsumerGroupsHandler handler = new DescribeConsumerGroupsHandler(false, logContext);
        Collection<MemberDescription> members = List.of(
            new MemberDescription(
                "memberId",
                Optional.of("instanceId"),
                Optional.of("rackid"),
                "clientId",
                "host",
                new MemberAssignment(Set.of(
                    new TopicPartition("foo", 0)
                )),
                Optional.of(new MemberAssignment(Set.of(
                    new TopicPartition("foo", 1)
                ))),
                Optional.of(10),
                Optional.of(true)
            ),
            new MemberDescription(
                "memberId-classic",
                Optional.of("instanceId-classic"),
                Optional.of("rackid"),
                "clientId-classic",
                "host",
                new MemberAssignment(Set.of(
                    new TopicPartition("bar", 0)
                )),
                Optional.of(new MemberAssignment(Set.of(
                    new TopicPartition("bar", 1)
                ))),
                Optional.of(9),
                Optional.of(false)
            ));
        ConsumerGroupDescription expected = new ConsumerGroupDescription(
            groupId1,
            false,
            members,
            "range",
            GroupType.CONSUMER,
            GroupState.STABLE,
            coordinator,
            Collections.emptySet(),
            Optional.of(10),
            Optional.of(10)
        );
        AdminApiHandler.ApiResult<CoordinatorKey, ConsumerGroupDescription> result = handler.handleResponse(
            coordinator,

Review comment (suggestion):
Let's have `Optional.empty()` too to increase the variety of the parameters being used.

Code after:
        assertThrows(IllegalArgumentException.class, () -> handler.buildRequest(1, singleton(CoordinatorKey.byTransactionalId("tId"))));
    }

    @Test
    public void testSuccessfulHandleConsumerGroupResponse() {
        DescribeConsumerGroupsHandler handler = new DescribeConsumerGroupsHandler(false, logContext);
        Collection<MemberDescription> members = List.of(
            new MemberDescription(
                "memberId",
                Optional.of("instanceId"),
                Optional.of("rackId"),
                "clientId",
                "host",
                new MemberAssignment(Set.of(
                    new TopicPartition("foo", 0)
                )),
                Optional.of(new MemberAssignment(Set.of(
                    new TopicPartition("foo", 1)
                ))),
                Optional.of(10),
                Optional.of(true)
            ),
            new MemberDescription(
                "memberId-classic",
                Optional.of("instanceId-classic"),
                Optional.empty(),
                "clientId-classic",
                "host",
                new MemberAssignment(Set.of(
                    new TopicPartition("bar", 0)
                )),
                Optional.of(new MemberAssignment(Set.of(
                    new TopicPartition("bar", 1)
                ))),
                Optional.of(9),
                Optional.of(false)
            ));
        ConsumerGroupDescription expected = new ConsumerGroupDescription(
            groupId1,
            false,
            members,
            "range",
            GroupType.CONSUMER,
            GroupState.STABLE,
            coordinator,
            Collections.emptySet(),
            Optional.of(10),
            Optional.of(10)
        );
        AdminApiHandler.ApiResult<CoordinatorKey, ConsumerGroupDescription> result = handler.handleResponse(
            coordinator,