synchronized boolean groupSubscribe(Collection<String> topics) {
        if (!hasAutoAssignedPartitions())
            throw new IllegalStateException(SUBSCRIPTION_EXCEPTION_MESSAGE);
        groupSubscription = new HashSet<>(topics);
        return !subscription.containsAll(groupSubscription);
    }
@Test
    public void testGroupSubscribe() {
        state.subscribe(singleton(topic1), Optional.of(rebalanceListener));
        assertEquals(singleton(topic1), state.metadataTopics());

        assertFalse(state.groupSubscribe(singleton(topic1)));
        assertEquals(singleton(topic1), state.metadataTopics());

        assertTrue(state.groupSubscribe(Utils.mkSet(topic, topic1)));
        assertEquals(Utils.mkSet(topic, topic1), state.metadataTopics());

        // `groupSubscribe` does not accumulate
        assertFalse(state.groupSubscribe(singleton(topic1)));
        assertEquals(singleton(topic1), state.metadataTopics());

        state.subscribe(singleton("anotherTopic"), Optional.of(rebalanceListener));
        assertEquals(Utils.mkSet(topic1, "anotherTopic"), state.metadataTopics());

        assertFalse(state.groupSubscribe(singleton("anotherTopic")));
        assertEquals(singleton("anotherTopic"), state.metadataTopics());
    }