ActionUtil { public static String generateWorkItemName( final Map<String, Serializable> params ) { if ( params == null ) { return generateWorkItemName( null, null ); } final String userName = Optional.ofNullable( (String) params.get( INVOKER_ACTIONUSER ) ).orElse( (String) params .get( QUARTZ_ACTIONUSER ) ); String inputFilePath = Optional.ofNullable( (String) params.get( INVOKER_STREAMPROVIDER_INPUT_FILE ) ) .orElse( (String) params.get( QUARTZ_STREAMPROVIDER_INPUT_FILE ) ); if ( StringUtil.isEmpty( inputFilePath ) && isInlinePassingOfInputOnStreamProvider( params ) ) { inputFilePath = getInlineInputFileOnStreamProvider( params ); } return generateWorkItemName( inputFilePath, userName ); }  static void removeKeyFromMap( final Map<String, ?> params, final String key ); static void prepareMap( final Map<String, Serializable> params ); static String extractName( final Map<String, Serializable> params ); static String generateWorkItemName( final Map<String, Serializable> params ); static boolean isInlinePassingOfInputOnStreamProvider( final Map<String, Serializable> params ); static String getInlineInputFileOnStreamProvider( final Map<String, Serializable> params ); static String getStreamProviderContent( final Map<String, Serializable> params ); static String generateWorkItemName( final String inputFilePath,
                                            final String userName ); static IAction createActionBean( final String actionClassName, final String actionId ); static IAction createActionBean( final String actionClassName, final String actionId, final boolean retryBeanInstantiationIfFailed ); static void sendEmail( Map<String, Object> actionParams, Map<String, Serializable> params, String filePath ); static final String QUARTZ_ACTIONCLASS; static final String QUARTZ_ACTIONUSER; static final String QUARTZ_ACTIONID; static final String QUARTZ_STREAMPROVIDER; static final String QUARTZ_STREAMPROVIDER_INPUT_FILE; static final String QUARTZ_STREAMPROVIDER_INLINE_INPUT_FILE; static final String QUARTZ_STREAMPROVIDER_INLINE_OUTPUT_FILE; static final String QUARTZ_UIPASSPARAM; static final String QUARTZ_LINEAGE_ID; static final String QUARTZ_RESTART_FLAG; static final String QUARTZ_AUTO_CREATE_UNIQUE_FILENAME; static final String QUARTZ_APPEND_DATE_FORMAT; static final String INVOKER_ACTIONPARAMS; static final String INVOKER_ACTIONCLASS; static final String INVOKER_ACTIONUSER; static final String INVOKER_ACTIONID; static final String INVOKER_UUID; static final String INVOKER_CONTENT_TYPE; static final String INVOKER_STATUS; static final String INVOKER_STREAMPROVIDER; static final String INVOKER_STREAMPROVIDER_INPUT_FILE; static final String INVOKER_STREAMPROVIDER_OUTPUT_FILE_PATTERN; static final String INVOKER_STREAMPROVIDER_UNIQUE_FILE_NAME; static final String INVOKER_UIPASSPARAM; static final String INVOKER_RESTART_FLAG; static final String INVOKER_SESSION; static final String INVOKER_ASYNC_EXEC; static final String INVOKER_DEFAULT_ASYNC_EXEC_VALUE; static final String INVOKER_SYNC_VALUE; static final String WORK_ITEM_UID; static final String WORK_ITEM_NAME; }
@Test public void testGenerateWorkItemNameWithMap() throws NoSuchFieldException, IllegalAccessException { final long currentTime = freezeTime(); Map map = null; String result; result = ActionUtil.generateWorkItemName( map ); assertEquals( "[]", result ); map = new HashMap(); result = ActionUtil.generateWorkItemName( map ); assertEquals( "[]", result ); map = new HashMap(); map.put( ActionUtil.QUARTZ_ACTIONUSER, "quartzAdmin" ); result = ActionUtil.generateWorkItemName( map ); assertEquals( "[quartzAdmin]", result ); map = new HashMap(); map.put( ActionUtil.INVOKER_ACTIONUSER, "actionAdmin" ); result = ActionUtil.generateWorkItemName( map ); assertEquals( "[actionAdmin]", result ); map = new HashMap(); map.put( ActionUtil.QUARTZ_ACTIONUSER, "quartzAdmin" ); map.put( ActionUtil.INVOKER_ACTIONUSER, "actionAdmin" ); result = ActionUtil.generateWorkItemName( map ); assertEquals( "[actionAdmin]", result ); map = new HashMap(); map.put( ActionUtil.QUARTZ_STREAMPROVIDER_INPUT_FILE, "quartzInputFile" ); result = ActionUtil.generateWorkItemName( map ); assertEquals( "quartzInputFile[]", result ); map = new HashMap(); map.put( ActionUtil.INVOKER_STREAMPROVIDER_INPUT_FILE, "adminInputFile" ); result = ActionUtil.generateWorkItemName( map ); assertEquals( "adminInputFile[]", result ); map = new HashMap(); map.put( ActionUtil.QUARTZ_STREAMPROVIDER_INPUT_FILE, "quartzInputFile" ); map.put( ActionUtil.INVOKER_STREAMPROVIDER_INPUT_FILE, "adminInputFile" ); result = ActionUtil.generateWorkItemName( map ); assertEquals( "adminInputFile[]", result ); map = new HashMap(); map.put( ActionUtil.QUARTZ_STREAMPROVIDER_INPUT_FILE, "quartzInputFile" ); map.put( ActionUtil.INVOKER_STREAMPROVIDER_INPUT_FILE, "adminInputFile" ); map.put( ActionUtil.QUARTZ_ACTIONUSER, "quartzAdmin" ); map.put( ActionUtil.INVOKER_ACTIONUSER, "actionAdmin" ); result = ActionUtil.generateWorkItemName( map ); assertEquals( "adminInputFile[actionAdmin]", result ); }
@Test public void testGenerateWorkItemName() throws NoSuchFieldException, IllegalAccessException { final long currentTime = freezeTime(); String result; result = ActionUtil.generateWorkItemName( "Test.prpt", "admin" ); assertEquals( "Test.prpt[admin]", result ); result = ActionUtil.generateWorkItemName( "!@#$%^&*.prpt", "adm&*&in" ); assertEquals( "!@#$%^&*.prpt[adm&*&in]", result ); result = ActionUtil.generateWorkItemName( "!@#$%^&*.prpt", "&*&(*&" ); assertEquals( "!@#$%^&*.prpt[&*&(*&]", result ); result = ActionUtil.generateWorkItemName( "folder/Test File.prpt", "adm&*&in" ); assertEquals( "folder/Test File.prpt[adm&*&in]", result ); result = ActionUtil.generateWorkItemName( "", "" ); assertEquals( "[]", result ); result = ActionUtil.generateWorkItemName( null, null ); assertEquals( "[]", result ); }