Browse Source

[Test-4124][service] Add the testCreateCommand test of ProcessService Class (#5257)

* [uint test] Improve code test coverage of ProcessService class

* [Test-4124][service] Add the testCreateCommand test of ProcessService Class

Co-authored-by: liuziying <liuziying@longfor.com>
Bruce Lau 4 years ago
parent
commit
3e64f43138

+ 13 - 0
dolphinscheduler-service/src/test/java/org/apache/dolphinscheduler/service/process/ProcessServiceTest.java

@@ -464,4 +464,17 @@ public class ProcessServiceTest {
         processService.changeOutParam(result,taskInstance);
     }
 
+    @Test
+    public void testCreateCommand() {
+        Command command = new Command();
+        command.setProcessDefinitionId(123);
+        command.setCommandParam("{\"ProcessInstanceId\":222}");
+        command.setCommandType(CommandType.START_PROCESS);
+        int mockResult = 1;
+        Mockito.when(commandMapper.insert(command)).thenReturn(mockResult);
+        int exeMethodResult = processService.createCommand(command);
+        Assert.assertEquals(mockResult, exeMethodResult);
+        Mockito.verify(commandMapper, Mockito.times(1)).insert(command);
+    }
+
 }