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