@ -341,7 +341,7 @@ public class ProcessDefinitionServiceTest {
Mockito . when ( processDefineMapper . selectById ( 1 ) ) . thenReturn ( null ) ;
Mockito . when ( processDefineMapper . selectById ( 1 ) ) . thenReturn ( null ) ;
Map < String , Object > instanceNotexitRes = processDefinitionService . queryProcessDefinitionById ( loginUser ,
Map < String , Object > instanceNotexitRes = processDefinitionService . queryProcessDefinitionById ( loginUser ,
"project_test1" , 1 ) ;
"project_test1" , 1 ) ;
Assert . assertEquals ( Status . PROCESS_INSTANC E_NOT_EXIST , instanceNotexitRes . get ( Constants . STATUS ) ) ;
Assert . assertEquals ( Status . PROCESS_DEF INE_NOT_EXIST , instanceNotexitRes . get ( Constants . STATUS ) ) ;
//instance exit
//instance exit
Mockito . when ( processDefineMapper . selectById ( 46 ) ) . thenReturn ( getProcessDefinition ( ) ) ;
Mockito . when ( processDefineMapper . selectById ( 46 ) ) . thenReturn ( getProcessDefinition ( ) ) ;
@ -350,6 +350,41 @@ public class ProcessDefinitionServiceTest {
Assert . assertEquals ( Status . SUCCESS , successRes . get ( Constants . STATUS ) ) ;
Assert . assertEquals ( Status . SUCCESS , successRes . get ( Constants . STATUS ) ) ;
}
}
@Test
public void testQueryProcessDefinitionByName ( ) {
String projectName = "project_test1" ;
Mockito . when ( projectMapper . queryByName ( projectName ) ) . thenReturn ( getProject ( projectName ) ) ;
Project project = getProject ( projectName ) ;
User loginUser = new User ( ) ;
loginUser . setId ( - 1 ) ;
loginUser . setUserType ( UserType . GENERAL_USER ) ;
Map < String , Object > result = new HashMap < > ( ) ;
putMsg ( result , Status . PROJECT_NOT_FOUNT , projectName ) ;
//project check auth fail
Mockito . when ( projectService . checkProjectAndAuth ( loginUser , project , projectName ) ) . thenReturn ( result ) ;
Map < String , Object > map = processDefinitionService . queryProcessDefinitionByName ( loginUser ,
"project_test1" , "test_def" ) ;
Assert . assertEquals ( Status . PROJECT_NOT_FOUNT , map . get ( Constants . STATUS ) ) ;
//project check auth success, instance not exist
putMsg ( result , Status . SUCCESS , projectName ) ;
Mockito . when ( projectService . checkProjectAndAuth ( loginUser , project , projectName ) ) . thenReturn ( result ) ;
Mockito . when ( processDefineMapper . queryByDefineName ( project . getId ( ) , "test_def" ) ) . thenReturn ( null ) ;
Map < String , Object > instanceNotexitRes = processDefinitionService . queryProcessDefinitionByName ( loginUser ,
"project_test1" , "test_def" ) ;
Assert . assertEquals ( Status . PROCESS_DEFINE_NOT_EXIST , instanceNotexitRes . get ( Constants . STATUS ) ) ;
//instance exit
Mockito . when ( processDefineMapper . queryByDefineName ( project . getId ( ) , "test" ) ) . thenReturn ( getProcessDefinition ( ) ) ;
Map < String , Object > successRes = processDefinitionService . queryProcessDefinitionByName ( loginUser ,
"project_test1" , "test" ) ;
Assert . assertEquals ( Status . SUCCESS , successRes . get ( Constants . STATUS ) ) ;
}
@Test
@Test
public void testBatchCopyProcessDefinition ( ) {
public void testBatchCopyProcessDefinition ( ) {