Skip to content

Commit c0288d3

Browse files
committed
Fix ErrorCommand loss some fields in Command
1 parent 5ad7b15 commit c0288d3

File tree

2 files changed

+95
-4
lines changed

2 files changed

+95
-4
lines changed

dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ErrorCommand.java

+13-4
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ public class ErrorCommand {
5252
*/
5353
private long processDefinitionCode;
5454

55+
private int processDefinitionVersion;
56+
57+
private int processInstanceId;
58+
5559
/**
5660
* executor id
5761
*/
@@ -73,7 +77,7 @@ public class ErrorCommand {
7377
private FailureStrategy failureStrategy;
7478

7579
/**
76-
* warning type
80+
* warning type
7781
*/
7882
private WarningType warningType;
7983

@@ -135,21 +139,26 @@ public class ErrorCommand {
135139

136140
public ErrorCommand() {
137141
}
142+
138143
public ErrorCommand(Command command, String message) {
139144
this.id = command.getId();
140145
this.commandType = command.getCommandType();
141146
this.executorId = command.getExecutorId();
142147
this.processDefinitionCode = command.getProcessDefinitionCode();
148+
this.processDefinitionVersion = command.getProcessDefinitionVersion();
149+
this.processInstanceId = command.getProcessInstanceId();
143150
this.commandParam = command.getCommandParam();
151+
this.taskDependType = command.getTaskDependType();
152+
this.failureStrategy = command.getFailureStrategy();
144153
this.warningType = command.getWarningType();
145154
this.warningGroupId = command.getWarningGroupId();
146155
this.scheduleTime = command.getScheduleTime();
147-
this.taskDependType = command.getTaskDependType();
148-
this.failureStrategy = command.getFailureStrategy();
149156
this.startTime = command.getStartTime();
150157
this.updateTime = command.getUpdateTime();
151-
this.environmentCode = command.getEnvironmentCode();
152158
this.processInstancePriority = command.getProcessInstancePriority();
159+
this.workerGroup = command.getWorkerGroup();
160+
this.tenantCode = command.getTenantCode();
161+
this.environmentCode = command.getEnvironmentCode();
153162
this.message = message;
154163
this.dryRun = command.getDryRun();
155164
this.testFlag = command.getTestFlag();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.dolphinscheduler.dao.entity;
19+
20+
import static org.junit.jupiter.api.Assertions.assertEquals;
21+
22+
import org.apache.dolphinscheduler.common.enums.CommandType;
23+
import org.apache.dolphinscheduler.common.enums.FailureStrategy;
24+
import org.apache.dolphinscheduler.common.enums.Flag;
25+
import org.apache.dolphinscheduler.common.enums.Priority;
26+
import org.apache.dolphinscheduler.common.enums.TaskDependType;
27+
import org.apache.dolphinscheduler.common.enums.WarningType;
28+
29+
import java.util.Date;
30+
31+
import org.junit.jupiter.api.Test;
32+
33+
class ErrorCommandTest {
34+
35+
@Test
36+
void testConstructor() {
37+
Command command = new Command();
38+
command.setId(1);
39+
command.setCommandType(CommandType.PAUSE);
40+
command.setExecutorId(1);
41+
command.setProcessDefinitionCode(123);
42+
command.setProcessDefinitionVersion(1);
43+
command.setProcessInstanceId(1);
44+
command.setCommandParam("param");
45+
command.setTaskDependType(TaskDependType.TASK_POST);
46+
command.setFailureStrategy(FailureStrategy.CONTINUE);
47+
command.setWarningType(WarningType.ALL);
48+
command.setWarningGroupId(1);
49+
command.setScheduleTime(new Date());
50+
command.setStartTime(new Date());
51+
command.setUpdateTime(new Date());
52+
command.setProcessInstancePriority(Priority.HIGHEST);
53+
command.setWorkerGroup("default");
54+
command.setTenantCode("root");
55+
command.setEnvironmentCode(1L);
56+
command.setDryRun(1);
57+
command.setTestFlag(Flag.NO.getCode());
58+
59+
ErrorCommand errorCommand = new ErrorCommand(command, "test");
60+
assertEquals(command.getCommandType(), errorCommand.getCommandType());
61+
assertEquals(command.getExecutorId(), errorCommand.getExecutorId());
62+
assertEquals(command.getProcessDefinitionCode(), errorCommand.getProcessDefinitionCode());
63+
assertEquals(command.getProcessDefinitionVersion(), errorCommand.getProcessDefinitionVersion());
64+
assertEquals(command.getProcessInstanceId(), errorCommand.getProcessInstanceId());
65+
assertEquals(command.getCommandParam(), errorCommand.getCommandParam());
66+
assertEquals(command.getTaskDependType(), errorCommand.getTaskDependType());
67+
assertEquals(command.getFailureStrategy(), errorCommand.getFailureStrategy());
68+
assertEquals(command.getWarningType(), errorCommand.getWarningType());
69+
assertEquals(command.getWarningGroupId(), errorCommand.getWarningGroupId());
70+
assertEquals(command.getScheduleTime(), errorCommand.getScheduleTime());
71+
assertEquals(command.getStartTime(), errorCommand.getStartTime());
72+
assertEquals(command.getUpdateTime(), errorCommand.getUpdateTime());
73+
assertEquals(command.getProcessInstancePriority(), errorCommand.getProcessInstancePriority());
74+
assertEquals(command.getWorkerGroup(), errorCommand.getWorkerGroup());
75+
assertEquals(command.getTenantCode(), errorCommand.getTenantCode());
76+
assertEquals(command.getEnvironmentCode(), errorCommand.getEnvironmentCode());
77+
assertEquals(command.getDryRun(), errorCommand.getDryRun());
78+
assertEquals(command.getTestFlag(), errorCommand.getTestFlag());
79+
assertEquals("test", errorCommand.getMessage());
80+
}
81+
82+
}

0 commit comments

Comments
 (0)