@ -73,28 +73,27 @@ public class ProcessDefinitionControllerTest {
@Test
public void testCreateProcessDefinition ( ) throws Exception {
String json = "[{\"name\":\"\",\"pre_task_code\":0,\"pre_task_version\":0,\"post_task_code\":123456789,\"post_task_version\":1,"
+ "\"condition_type\":0,\"condition_params\":{}},{\"name\":\"\",\"pre_task_code\":123456789,\"pre_task_version\":1,"
+ "\"post_task_code\":123451234,\"post_task_version\":1,\"condition_type\":0,\"condition_params\":{}}]" ;
String json = "{\"globalParams\":[],\"tasks\":[{\"type\":\"SHELL\",\"id\":\"tasks-36196\",\"name\""
+ ":\"ssh_test1\",\"params\":{\"resourceList\":[],\"localParams\":[],\"rawScript\":\"aa=\\\"1234\\\"\\"
+ "necho ${aa}\"},\"desc\":\"\",\"runFlag\":\"NORMAL\",\"dependence\":{},\"maxRetryTimes\":\"0\""
+ ",\"retryInterval\":\"1\",\"timeout\":{\"strategy\":\"\",\"interval\":null,\"enable\":false},"
+ "\"taskInstancePriority\":\"MEDIUM\",\"workerGroupId\":-1,\"preTasks\":[]}],\"tenantId\":-1,\"timeout\":0}" ;
String locations = "{\"tasks-36196\":{\"name\":\"ssh_test1\",\"targetarr\":\"\",\"x\":141,\"y\":70}}" ;
String projectName = "test" ;
String name = "dag_test" ;
String description = "desc test" ;
String globalParams = "[]" ;
String connects = "[]" ;
String locations = "[]" ;
int timeout = 0 ;
String tenantCode = "root" ;
Map < String , Object > result = new HashMap < > ( ) ;
putMsg ( result , Status . SUCCESS ) ;
result . put ( Constants . DATA_LIST , 1 ) ;
Mockito . when ( processDefinitionService . createProcessDefinition ( user , projectName , name , description , globalParams ,
connects , locations , timeout , tenantCode , json ) ) . thenReturn ( result ) ;
Mockito . when ( processDefinitionService . createProcessDefinition ( user , projectName , name , json ,
des cripti on, locations , connects ) ) . thenReturn ( result ) ;
Result response = processDefinitionController . createProcessDefinition ( user , projectName , name , description , globalParams ,
connects , locations , timeout , tenantCode , js on) ;
Assert . assertEquals ( Status . SUCCESS . getCode ( ) , response . getCode ( ) . intValue ( ) ) ;
Result response = processDefinitionController . createProcessDefinition ( user , projectName , name , json ,
locations , connects , descripti on) ;
Assert . assertTrue ( response . isSuccess ( ) ) ;
}
private void putMsg ( Map < String , Object > result , Status status , Object . . . statusParams ) {
@ -117,35 +116,34 @@ public class ProcessDefinitionControllerTest {
Mockito . when ( processDefinitionService . verifyProcessDefinitionName ( user , projectName , name ) ) . thenReturn ( result ) ;
Result response = processDefinitionController . verifyProcessDefinitionName ( user , projectName , name ) ;
Assert . assertEquals ( Status . PROCESS_DEFINITION_NAME_EXIST . getCode ( ) , response . getCode ( ) . intValue ( ) ) ;
Assert . assertTrue ( response . isStatus ( Status . PROCESS_DEFINITION_NAME_EXIST ) ) ;
}
@Test
public void updateProcessDefinition ( ) {
String json = "[{\"name\":\"\",\"pre_task_code\":0,\"pre_task_version\":0,\"post_task_code\":123456789,\"post_task_version\":1,"
+ "\"condition_type\":0,\"condition_params\":{}},{\"name\":\"\",\"pre_task_code\":123456789,\"pre_task_version\":1,"
+ "\"post_task_code\":123451234,\"post_task_version\":1,\"condition_type\":0,\"condition_params\":{}}]" ;
public void updateProcessDefinition ( ) throws Exception {
String json = "{\"globalParams\":[],\"tasks\":[{\"type\":\"SHELL\",\"id\":\"tasks-36196\",\"name\":\"ssh_test1\""
+ ",\"params\":{\"resourceList\":[],\"localParams\":[],\"rawScript\":\"aa=\\\"1234\\\"\\necho ${aa}\"}"
+ ",\"desc\":\"\",\"runFlag\":\"NORMAL\",\"dependence\":{},\"maxRetryTimes\":\"0\",\"retryInterval\""
+ ":\"1\",\"timeout\":{\"strategy\":\"\",\"interval\":null,\"enable\":false},\"taskInstancePriority\""
+ ":\"MEDIUM\",\"workerGroupId\":-1,\"preTasks\":[]}],\"tenantId\":-1,\"timeout\":0}" ;
String locations = "{\"tasks-36196\":{\"name\":\"ssh_test1\",\"targetarr\":\"\",\"x\":141,\"y\":70}}" ;
String projectName = "test" ;
String name = "dag_test" ;
String description = "desc test" ;
String connects = "[]" ;
String globalParams = "[]" ;
int timeout = 0 ;
String tenantCode = "root" ;
long code = 123L ;
int id = 1 ;
Map < String , Object > result = new HashMap < > ( ) ;
putMsg ( result , Status . SUCCESS ) ;
result . put ( "processDefinitionId" , 1 ) ;
Mockito . when ( processDefinitionService . updateProcessDefinition ( user , projectName , name , code , description , globalParams ,
connects , locations , timeout , tenantCode , json ) ) . thenReturn ( result ) ;
Mockito . when ( processDefinitionService . updateProcessDefinition ( user , projectName , id , name , json ,
des cripti on, locations , connects ) ) . thenReturn ( result ) ;
Result response = processDefinitionController . updateProcessDefinition ( user , projectName , name , code , description , globalParams ,
connects , locations , timeout , tenantCode , json , ReleaseState . OFFLINE ) ;
Assert . assertEquals ( Status . SUCCESS . getCode ( ) , response . getCode ( ) . intValue ( ) ) ;
}
Result response = processDefinitionController . updateProcessDefinition ( user , projectName , name , id , json ,
locations , connects , description , ReleaseState . OFFLINE ) ;
Assert . assertTrue ( response ! = null & & response . isSuccess ( ) ) ; }
@Test
public void testReleaseProcessDefinition ( ) throws Exception {
@ -156,7 +154,7 @@ public class ProcessDefinitionControllerTest {
Mockito . when ( processDefinitionService . releaseProcessDefinition ( user , projectName , id , ReleaseState . OFFLINE ) ) . thenReturn ( result ) ;
Result response = processDefinitionController . releaseProcessDefinition ( user , projectName , id , ReleaseState . OFFLINE ) ;
Assert . assertEquals ( Status . SUCCESS . getCode ( ) , response . getCode ( ) . intValue ( ) ) ;
Assert . assertTrue ( response ! = null & & response . isSuccess ( ) ) ;
}
@Test
@ -189,7 +187,7 @@ public class ProcessDefinitionControllerTest {
Mockito . when ( processDefinitionService . queryProcessDefinitionById ( user , projectName , id ) ) . thenReturn ( result ) ;
Result response = processDefinitionController . queryProcessDefinitionById ( user , projectName , id ) ;
Assert . assertEquals ( Status . SUCCESS . getCode ( ) , response . getCode ( ) . intValue ( ) ) ;
Assert . assertTrue ( response ! = null & & response . isSuccess ( ) ) ;
}
@Test
@ -205,7 +203,7 @@ public class ProcessDefinitionControllerTest {
Mockito . when ( processDefinitionService . batchCopyProcessDefinition ( user , projectName , id , targetProjectId ) ) . thenReturn ( result ) ;
Result response = processDefinitionController . copyProcessDefinition ( user , projectName , id , targetProjectId ) ;
Assert . assertEquals ( Status . SUCCESS . getCode ( ) , response . getCode ( ) . intValue ( ) ) ;
Assert . assertTrue ( response ! = null & & response . isSuccess ( ) ) ;
}
@Test
@ -221,7 +219,7 @@ public class ProcessDefinitionControllerTest {
Mockito . when ( processDefinitionService . batchMoveProcessDefinition ( user , projectName , id , targetProjectId ) ) . thenReturn ( result ) ;
Result response = processDefinitionController . moveProcessDefinition ( user , projectName , id , targetProjectId ) ;
Assert . assertEquals ( Status . SUCCESS . getCode ( ) , response . getCode ( ) . intValue ( ) ) ;
Assert . assertTrue ( response ! = null & & response . isSuccess ( ) ) ;
}
@Test
@ -237,7 +235,7 @@ public class ProcessDefinitionControllerTest {
Mockito . when ( processDefinitionService . queryProcessDefinitionList ( user , projectName ) ) . thenReturn ( result ) ;
Result response = processDefinitionController . queryProcessDefinitionList ( user , projectName ) ;
Assert . assertEquals ( Status . SUCCESS . getCode ( ) , response . getCode ( ) . intValue ( ) ) ;
Assert . assertTrue ( response ! = null & & response . isSuccess ( ) ) ;
}
public List < ProcessDefinition > getDefinitionList ( ) {
@ -292,7 +290,7 @@ public class ProcessDefinitionControllerTest {
Mockito . when ( processDefinitionService . deleteProcessDefinitionById ( user , projectName , id ) ) . thenReturn ( result ) ;
Result response = processDefinitionController . deleteProcessDefinitionById ( user , projectName , id ) ;
Assert . assertEquals ( Status . SUCCESS . getCode ( ) , response . getCode ( ) . intValue ( ) ) ;
Assert . assertTrue ( response ! = null & & response . isSuccess ( ) ) ;
}
@Test
@ -306,7 +304,7 @@ public class ProcessDefinitionControllerTest {
Mockito . when ( processDefinitionService . getTaskNodeListByDefinitionCode ( code ) ) . thenReturn ( result ) ;
Result response = processDefinitionController . getNodeListByDefinitionCode ( user , projectName , code ) ;
Assert . assertEquals ( Status . SUCCESS . getCode ( ) , response . getCode ( ) . intValue ( ) ) ;
Assert . assertTrue ( response ! = null & & response . isSuccess ( ) ) ;
}
@Test
@ -320,7 +318,7 @@ public class ProcessDefinitionControllerTest {
Mockito . when ( processDefinitionService . getTaskNodeListByDefinitionCodeList ( codeList ) ) . thenReturn ( result ) ;
Result response = processDefinitionController . getNodeListByDefinitionCodeList ( user , projectName , codeList ) ;
Assert . assertEquals ( Status . SUCCESS . getCode ( ) , response . getCode ( ) . intValue ( ) ) ;
Assert . assertTrue ( response ! = null & & response . isSuccess ( ) ) ;
}
@Test
@ -332,7 +330,7 @@ public class ProcessDefinitionControllerTest {
Mockito . when ( processDefinitionService . queryProcessDefinitionAllByProjectId ( projectId ) ) . thenReturn ( result ) ;
Result response = processDefinitionController . queryProcessDefinitionAllByProjectId ( user , projectId ) ;
Assert . assertEquals ( Status . SUCCESS . getCode ( ) , response . getCode ( ) . intValue ( ) ) ;
Assert . assertTrue ( response ! = null & & response . isSuccess ( ) ) ;
}
@Test
@ -346,7 +344,7 @@ public class ProcessDefinitionControllerTest {
Mockito . when ( processDefinitionService . viewTree ( processId , limit ) ) . thenReturn ( result ) ;
Result response = processDefinitionController . viewTree ( user , projectName , processId , limit ) ;
Assert . assertEquals ( Status . SUCCESS . getCode ( ) , response . getCode ( ) . intValue ( ) ) ;
Assert . assertTrue ( response ! = null & & response . isSuccess ( ) ) ;
}
@Test
@ -364,7 +362,7 @@ public class ProcessDefinitionControllerTest {
Mockito . when ( processDefinitionService . queryProcessDefinitionListPaging ( user , projectName , searchVal , pageNo , pageSize , userId ) ) . thenReturn ( result ) ;
Result response = processDefinitionController . queryProcessDefinitionListPaging ( user , projectName , pageNo , searchVal , userId , pageSize ) ;
Assert . assertEquals ( Status . SUCCESS . getCode ( ) , response . getCode ( ) . intValue ( ) ) ;
Assert . assertTrue ( response ! = null & & response . isSuccess ( ) ) ;
}
@Test