welsh-wen commented on code in PR #10670:
URL: https://github.com/apache/dolphinscheduler/pull/10670#discussion_r912455889


##########
dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api.test/pages/project/WorkFlowDefinitionPage.java:
##########
@@ -0,0 +1,165 @@
+/*
+ * Licensed to Apache Software Foundation (ASF) under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Apache Software Foundation (ASF) licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.dolphinscheduler.api.test.pages.project;
+
+
+import org.apache.dolphinscheduler.api.test.cases.ProjectAPITest;
+import org.apache.dolphinscheduler.api.test.core.Constants;
+import org.apache.dolphinscheduler.api.test.entity.WorkFlowCreateRequestData;
+import org.apache.dolphinscheduler.api.test.entity.WorkFlowResponseTotalList;
+import org.apache.dolphinscheduler.api.test.entity.WorkFlowResponseData;
+import org.apache.dolphinscheduler.api.test.entity.WorkFlowRunRequestData;
+import org.apache.dolphinscheduler.api.test.entity.HttpResponse;
+import org.apache.dolphinscheduler.api.test.utils.JSONUtils;
+import org.apache.dolphinscheduler.api.test.utils.RequestClient;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+
+
+public final class WorkFlowDefinitionPage {
+    private static String genNumId = null;
+    private static String workFlowCode = null;
+    private static final Logger logger = 
LoggerFactory.getLogger(ProjectAPITest.class);
+
+    public void getGenNumId(String sessionId, String projectName) {
+
+        Map<String, Object> params = new HashMap<>();
+        Map<String, String> headers = new HashMap<>();
+        params.put("genNum", 1);
+        headers.put(Constants.SESSION_ID_KEY, sessionId);
+        ProjectPage project = new ProjectPage();
+        String projectCode = project.getProjectCode(sessionId, projectName);
+        RequestClient requestClient = new RequestClient();
+        HttpResponse res = 
requestClient.get("/projects/"+projectCode+"/task-definition/gen-task-codes", 
headers, params);
+        ArrayList list = (ArrayList) res.body().data();
+        genNumId = list.get(0).toString();
+
+
+    }
+
+
+    public HttpResponse createWorkflow(String sessionId, String projectName, 
String workFlowName) {
+        Map<String, Object> params = new HashMap<>();
+        Map<String, String> headers = new HashMap<>();
+
+        WorkFlowCreateRequestData workFlowCreateRequestData = new 
WorkFlowCreateRequestData();
+
+        String taskDefinitionJson = "[{\"code\":" + genNumId + 
",\"delayTime\":\"0\",\"description\":\"\",\"environmentCode\":-1,\"failRetryInterval\":\"1\",\"failRetryTimes\":\"0\",\"flag\":\"YES\",\"name\":\"echo_123\",\"taskParams\":{\"localParams\":[],\"rawScript\":\"echo
 
123\",\"resourceList\":[]},\"taskPriority\":\"MEDIUM\",\"taskType\":\"SHELL\",\"timeout\":0,\"timeoutFlag\":\"CLOSE\",\"timeoutNotifyStrategy\":\"\",\"workerGroup\":\"default\"}]";
+        String taskRelationJson = 
"[{\"name\":\"\",\"preTaskCode\":0,\"preTaskVersion\":0,\"postTaskCode\":"+ 
genNumId + 
",\"postTaskVersion\":0,\"conditionType\":\"NONE\",\"conditionParams\":{}}]";
+        String locations = "[{\"taskCode\":" + genNumId 
+",\"x\":33.5,\"y\":38.5}]";
+        workFlowCreateRequestData.setTaskDefinitionJson(taskDefinitionJson);
+        workFlowCreateRequestData.setTaskRelationJson(taskRelationJson);
+        workFlowCreateRequestData.setLocations(locations);
+        workFlowCreateRequestData.setName(workFlowName);
+        workFlowCreateRequestData.setTenantCode("admin");
+        workFlowCreateRequestData.setExecutionType("PARALLEL");
+        workFlowCreateRequestData.setDescription("");
+        workFlowCreateRequestData.setGlobalParams("[]");
+        workFlowCreateRequestData.setTimeout(0);
+        headers.put(Constants.SESSION_ID_KEY, sessionId);
+        RequestClient requestClient = new RequestClient();
+        ProjectPage project = new ProjectPage();
+        String projectCode = project.getProjectCode(sessionId, projectName);
+
+        HttpResponse res = 
requestClient.post("/projects/"+projectCode+"/process-definition", headers, 
JSONUtils.convertValue(workFlowCreateRequestData, Map.class));
+        logger.info("创建工作流结果:%s", res);

Review Comment:
   Thanks for the reminder, it has been fixed



##########
dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api.test/entity/TaskInstanceResponseData.java:
##########
@@ -0,0 +1,46 @@
+/*
+ * Licensed to Apache Software Foundation (ASF) under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Apache Software Foundation (ASF) licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.dolphinscheduler.api.test.entity;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.util.List;
+
+@AllArgsConstructor
+@NoArgsConstructor
+@Data
+public class TaskInstanceResponseData {
+
+    private Integer currentPage;
+
+    private Integer pageSize;
+
+    private Integer start;
+
+    private Integer total;
+
+    private List<TaskInstanceResponseTotalList> totalList;
+
+    private Integer totalPage;
+
+

Review Comment:
   Thanks for the reminder, it has been fixed



##########
dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api.test/entity/ProjectListResponseData.java:
##########
@@ -0,0 +1,45 @@
+/*
+ * Licensed to Apache Software Foundation (ASF) under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Apache Software Foundation (ASF) licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.dolphinscheduler.api.test.entity;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.util.List;
+
+@AllArgsConstructor
+@NoArgsConstructor
+@Data
+public class ProjectListResponseData {
+
+

Review Comment:
   Thanks for the reminder, it has been fixed



##########
dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api.test/cases/WorkFlowAPITest.java:
##########
@@ -0,0 +1,109 @@
+/*
+ * Licensed to Apache Software Foundation (ASF) under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Apache Software Foundation (ASF) licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.dolphinscheduler.api.test.cases;
+
+import lombok.extern.slf4j.Slf4j;
+import org.apache.dolphinscheduler.api.test.core.DolphinScheduler;
+import org.apache.dolphinscheduler.api.test.entity.HttpResponse;
+import org.apache.dolphinscheduler.api.test.entity.LoginResponseData;
+import org.apache.dolphinscheduler.api.test.pages.LoginPage;
+import 
org.apache.dolphinscheduler.api.test.pages.project.WorkFlowDefinitionPage;
+import org.apache.dolphinscheduler.api.test.utils.JSONUtils;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Order;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Assertions;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+@DolphinScheduler(composeFiles = "docker/basic/docker-compose.yaml")
+@Slf4j
+public class WorkFlowAPITest {
+    private static final Logger logger = 
LoggerFactory.getLogger(ProjectAPITest.class);
+
+    private static final String projectName = "wen";
+
+    private static final String workFlowName = "shell123";
+
+    private static final String user = "admin";
+
+    private static final String password = "dolphinscheduler123";
+
+    private static String sessionId = null;
+
+    private static String genNumId = null;
+
+    @BeforeAll
+    public static void setup() {
+        LoginPage loginPage = new LoginPage();
+        HttpResponse loginHttpResponse = loginPage.login(user, password);
+
+        sessionId = JSONUtils.convertValue(loginHttpResponse.body().data(), 
LoginResponseData.class).sessionId();
+    }
+
+    @Test
+    @Order(99)
+    public void testCreateWorkflow() {
+        WorkFlowDefinitionPage flow = new WorkFlowDefinitionPage();
+        flow.getGenNumId(sessionId,"wen");
+        HttpResponse res = flow.createWorkflow(sessionId, projectName, 
workFlowName);
+        System.out.println(res);
+        System.out.println(res.body());
+        Assertions.assertTrue(res.body().success());
+    }
+
+    @Test
+    @Order(1)
+    public void testQueryWorkflow() {
+        WorkFlowDefinitionPage flow = new WorkFlowDefinitionPage();
+        flow.getGenNumId(sessionId,"wen");
+        HttpResponse res = flow.queryWorkflow(sessionId, projectName, 
workFlowName);
+        System.out.println(res);
+        System.out.println(res.body());
+        Assertions.assertTrue(res.body().success());
+    }
+
+    @Test
+    @Order(98)
+    public void testOnlineWorkflow() {
+        WorkFlowDefinitionPage flow = new WorkFlowDefinitionPage();
+        HttpResponse res = flow.onLineWorkflow(sessionId, projectName, 
workFlowName);
+        System.out.println(res);
+        System.out.println(res.body());
+        Assertions.assertTrue(res.body().success());
+
+    }
+
+
+    @Test
+    @Order(97)
+    public void testRunWorkflow() {
+        WorkFlowDefinitionPage flow = new WorkFlowDefinitionPage();
+        HttpResponse res = flow.runWorkflow(sessionId, projectName, 
workFlowName);
+        System.out.println(res);
+        System.out.println(res.body());
+        Assertions.assertTrue(res.body().success());
+
+    }
+
+

Review Comment:
   Thanks for the reminder, it has been fixed



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to