@Test
    public void testGroupMismatchAndRematch() {
        final Pair<String, String> groupStream = saveSource("group1,group3");
        bindGroup(true, "group1");

        agent.pullTask();
        agent.pullTask(); // report last success status

        final int sourceId = sourceService.listSource(groupStream.getLeft(), groupStream.getRight()).stream()
                .filter(source -> source.getTaskMapId() != null)
                .findAny()
                .get()
                .getId();
        // unbind group and mismatch
        bindGroup(false, "group1");
        TaskResult t1 = agent.pullTask();
        Assertions.assertEquals(1, t1.getDataConfigs().size());
        Assertions.assertEquals(1, t1.getDataConfigs().stream()
                .filter(dataConfig -> Integer.valueOf(dataConfig.getOp()) == ManagerOpEnum.FROZEN.getType())
                .collect(Collectors.toSet())
                .size());
        DataConfig d1 = t1.getDataConfigs().get(0);
        Assertions.assertEquals(sourceId, d1.getTaskId());

        // bind group and rematch
        bindGroup(true, "group1");
        TaskResult t2 = agent.pullTask();
        Assertions.assertEquals(0, t2.getDataConfigs().size());
        Assertions.assertEquals(0, t2.getDataConfigs().stream()
                .filter(dataConfig -> Integer.valueOf(dataConfig.getOp()) == ManagerOpEnum.ACTIVE.getType())
                .collect(Collectors.toSet())
                .size());

        // update group to config success
        final String groupId = sourceService.listSource(groupStream.getLeft(), groupStream.getRight()).stream()
                .filter(source -> source.getTaskMapId() != null)
                .findAny()
                .get()
                .getInlongGroupId();
        groupMapper.updateStatus(groupId, GroupStatus.CONFIG_SUCCESSFUL.getCode(), GLOBAL_OPERATOR);
        TaskResult t3 = agent.pullTask();
        Assertions.assertEquals(1, t3.getDataConfigs().size());
        Assertions.assertEquals(1, t3.getDataConfigs().stream()
                .filter(dataConfig -> Integer.valueOf(dataConfig.getOp()) == ManagerOpEnum.ACTIVE.getType())
                .collect(Collectors.toSet())
                .size());
        DataConfig d3 = t3.getDataConfigs().get(0);
        Assertions.assertEquals(sourceId, d3.getTaskId());
    }
Test node group mismatch source task and next time rematch source task.
inlong-manager/manager-service/src/test/java/org/apache/inlong/manager/service/core/impl/AgentServiceTest.java