@Override
    public GroupAssignment assign(
        GroupSpec groupSpec,
        SubscribedTopicDescriber subscribedTopicDescriber
    ) throws PartitionAssignorException {
        if (groupSpec.memberIds().isEmpty()) {
            return new GroupAssignment(Collections.emptyMap());
        } else if (groupSpec.subscriptionType() == SubscriptionType.HOMOGENEOUS) {
            return assignHomogeneousGroup(groupSpec, subscribedTopicDescriber);
        } else {
            return assignHeterogeneousGroup(groupSpec, subscribedTopicDescriber);
        }
    }
@Test
    public void testMixedStaticMembership() throws PartitionAssignorException {
        SubscribedTopicDescriber subscribedTopicMetadata = new SubscribedTopicDescriberImpl(
            Collections.singletonMap(
                topic1Uuid,
                new TopicMetadata(
                    topic1Uuid,
                    topic1Name,
                    5,
                    Collections.emptyMap()
                )
            )
        );

        // Initialize members with instance Ids.
        Map<String, MemberSubscriptionAndAssignmentImpl> members = new TreeMap<>();
        members.put(memberA, new MemberSubscriptionAndAssignmentImpl(
            Optional.empty(),
            Optional.of("instanceA"),
            Collections.singleton(topic1Uuid),
            Assignment.EMPTY
        ));
        members.put(memberC, new MemberSubscriptionAndAssignmentImpl(
            Optional.empty(),
            Optional.of("instanceC"),
            Collections.singleton(topic1Uuid),
            Assignment.EMPTY
        ));

        // Initialize member without an instance Id.
        members.put(memberB, new MemberSubscriptionAndAssignmentImpl(
            Optional.empty(),
            Optional.empty(),
            Collections.singleton(topic1Uuid),
            Assignment.EMPTY
        ));

        GroupSpec groupSpec = new GroupSpecImpl(
            members,
            SubscriptionType.HOMOGENEOUS,
            invertedTargetAssignment(members)
        );

        GroupAssignment initialAssignment = assignor.assign(
            groupSpec,
            subscribedTopicMetadata
        );

        // Remove memberA and add it back with a different member Id but same instance Id.
        members.remove(memberA);
        members.put("memberA1", new MemberSubscriptionAndAssignmentImpl(
            Optional.empty(),
            Optional.of("instanceA"),
            Collections.singleton(topic1Uuid),
            Assignment.EMPTY
        ));

        groupSpec = new GroupSpecImpl(
            members,
            SubscriptionType.HOMOGENEOUS,
            invertedTargetAssignment(members)
        );

        GroupAssignment reassignedAssignment = assignor.assign(
            groupSpec,
            subscribedTopicMetadata
        );

        // Assert that the assignments did not change.
        assertEquals(
            initialAssignment.members().get(memberA).partitions(),
            reassignedAssignment.members().get("memberA1").partitions()
        );

        assertEquals(
            initialAssignment.members().get(memberB).partitions(),
            reassignedAssignment.members().get(memberB).partitions()
        );

        assertEquals(
            initialAssignment.members().get(memberC).partitions(),
            reassignedAssignment.members().get(memberC).partitions()
        );
    }