Skip to content

Commit

Permalink
Fix ErrorCommand loss some fields in Command
Browse files Browse the repository at this point in the history
  • Loading branch information
ruanwenjun committed Apr 15, 2024
1 parent efbffac commit fe4dd1c
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ public class ErrorCommand {
*/
private long processDefinitionCode;

private int processDefinitionVersion;

private int processInstanceId;

/**
* executor id
*/
Expand All @@ -73,7 +77,7 @@ public class ErrorCommand {
private FailureStrategy failureStrategy;

/**
* warning type
* warning type
*/
private WarningType warningType;

Expand Down Expand Up @@ -135,21 +139,26 @@ public class ErrorCommand {

public ErrorCommand() {
}

public ErrorCommand(Command command, String message) {
this.id = command.getId();
this.commandType = command.getCommandType();
this.executorId = command.getExecutorId();
this.processDefinitionCode = command.getProcessDefinitionCode();
this.processDefinitionVersion = command.getProcessDefinitionVersion();
this.processInstanceId = command.getProcessInstanceId();
this.commandParam = command.getCommandParam();
this.taskDependType = command.getTaskDependType();
this.failureStrategy = command.getFailureStrategy();
this.warningType = command.getWarningType();
this.warningGroupId = command.getWarningGroupId();
this.scheduleTime = command.getScheduleTime();
this.taskDependType = command.getTaskDependType();
this.failureStrategy = command.getFailureStrategy();
this.startTime = command.getStartTime();
this.updateTime = command.getUpdateTime();
this.environmentCode = command.getEnvironmentCode();
this.processInstancePriority = command.getProcessInstancePriority();
this.workerGroup = command.getWorkerGroup();
this.tenantCode = command.getTenantCode();
this.environmentCode = command.getEnvironmentCode();
this.message = message;
this.dryRun = command.getDryRun();
this.testFlag = command.getTestFlag();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package org.apache.dolphinscheduler.dao.entity;

import static org.junit.jupiter.api.Assertions.assertEquals;

import org.apache.dolphinscheduler.common.enums.CommandType;
import org.apache.dolphinscheduler.common.enums.FailureStrategy;
import org.apache.dolphinscheduler.common.enums.Flag;
import org.apache.dolphinscheduler.common.enums.Priority;
import org.apache.dolphinscheduler.common.enums.TaskDependType;
import org.apache.dolphinscheduler.common.enums.WarningType;

import java.util.Date;

import org.junit.jupiter.api.Test;

public class ErrorCommandTest {

@Test
public void testConstructor() {
Command command = new Command();
command.setId(1);
command.setCommandType(CommandType.PAUSE);
command.setExecutorId(1);
command.setProcessDefinitionCode(123);
command.setProcessDefinitionVersion(1);
command.setProcessInstanceId(1);
command.setCommandParam("param");
command.setTaskDependType(TaskDependType.TASK_POST);
command.setFailureStrategy(FailureStrategy.CONTINUE);
command.setWarningType(WarningType.ALL);
command.setWarningGroupId(1);
command.setScheduleTime(new Date());
command.setStartTime(new Date());
command.setUpdateTime(new Date());
command.setProcessInstancePriority(Priority.HIGHEST);
command.setWorkerGroup("default");
command.setTenantCode("root");
command.setEnvironmentCode(1L);
command.setDryRun(1);
command.setTestFlag(Flag.NO.getCode());

ErrorCommand errorCommand = new ErrorCommand(command, "test");
assertEquals(command.getCommandType(), errorCommand.getCommandType());
assertEquals(command.getExecutorId(), errorCommand.getExecutorId());
assertEquals(command.getProcessDefinitionCode(), errorCommand.getProcessDefinitionCode());
assertEquals(command.getProcessDefinitionVersion(), errorCommand.getProcessDefinitionVersion());
assertEquals(command.getProcessInstanceId(), errorCommand.getProcessInstanceId());
assertEquals(command.getCommandParam(), errorCommand.getCommandParam());
assertEquals(command.getTaskDependType(), errorCommand.getTaskDependType());
assertEquals(command.getFailureStrategy(), errorCommand.getFailureStrategy());
assertEquals(command.getWarningType(), errorCommand.getWarningType());
assertEquals(command.getWarningGroupId(), errorCommand.getWarningGroupId());
assertEquals(command.getScheduleTime(), errorCommand.getScheduleTime());
assertEquals(command.getStartTime(), errorCommand.getStartTime());
assertEquals(command.getUpdateTime(), errorCommand.getUpdateTime());
assertEquals(command.getProcessInstancePriority(), errorCommand.getProcessInstancePriority());
assertEquals(command.getWorkerGroup(), errorCommand.getWorkerGroup());
assertEquals(command.getTenantCode(), errorCommand.getTenantCode());
assertEquals(command.getEnvironmentCode(), errorCommand.getEnvironmentCode());
assertEquals(command.getDryRun(), errorCommand.getDryRun());
assertEquals(command.getTestFlag(), errorCommand.getTestFlag());
assertEquals("test", errorCommand.getMessage());
}

}

0 comments on commit fe4dd1c

Please sign in to comment.