@Test
    void testGetAndReportSubSourceTask() {
        // create template source for cluster agents and approve
        final Integer templateId = this.saveTemplateSource();
        sourceService.updateStatus(GLOBAL_GROUP_ID, GLOBAL_STREAM_ID, SourceStatus.TO_BE_ISSUED_ADD.getCode(),
                GLOBAL_OPERATOR);

        // get sub-source task
        TaskRequest getRequest = new TaskRequest();
        getRequest.setAgentIp("127.0.0.1");
        getRequest.setClusterName(GLOBAL_CLUSTER_NAME);
        getRequest.setPullJobType(PullJobTypeEnum.NEW.getType());
        TaskResult result = agentService.getTaskResult(getRequest);
        Assertions.assertEquals(1, result.getDataConfigs().size());
        DataConfig subSourceTask = result.getDataConfigs().get(0);
        // new sub-source version must be 1
        Assertions.assertEquals(2, subSourceTask.getVersion());
        // sub-source's id must be different from its template source
        Assertions.assertNotEquals(templateId, subSourceTask.getTaskId());
        // operation is to add new task
        Assertions.assertEquals(SourceStatus.BEEN_ISSUED_ADD.getCode() % 100,
                Integer.valueOf(subSourceTask.getOp()));

        // report sub-source status
        CommandEntity reportTask = new CommandEntity();
        reportTask.setTaskId(subSourceTask.getTaskId());
        reportTask.setVersion(subSourceTask.getVersion());
        reportTask.setCommandResult(Constants.RESULT_SUCCESS);
        TaskRequest reportRequest = new TaskRequest();
        reportRequest.setAgentIp("127.0.0.1");
        reportRequest.setCommandInfo(Lists.newArrayList(reportTask));
        agentService.report(reportRequest);

        // check sub-source task status
        StreamSource subSource = sourceService.get(subSourceTask.getTaskId());
        Assertions.assertEquals(SourceStatus.SOURCE_NORMAL.getCode(), subSource.getStatus());

        sourceService.delete(templateId, GLOBAL_OPERATOR);
        sourceService.delete(subSource.getId(), GLOBAL_OPERATOR);
    }
Test sub-source task status manipulation.
inlong-manager/manager-service/src/test/java/org/apache/inlong/manager/service/core/impl/AgentServiceTest.java