@Test @SuppressWarnings( "ResultOfMethodCallIgnored" ) public void testBuildSchedulerRequestEntity() throws UnknownParamException, UnsupportedEncodingException { AbstractMeta meta = mock( JobMeta.class ); RepositoryDirectoryInterface repositoryDirectory = mock( RepositoryDirectoryInterface.class ); doReturn( repositoryDirectory ).when( meta ).getRepositoryDirectory(); doReturn( TEST_REPOSITORY_DIRECTORY ).when( repositoryDirectory ).getPath(); doReturn( TEST_JOB_NAME ).when( meta ).getName(); doReturn( JOB_EXTENSION ).when( meta ).getDefaultExtension(); doReturn( LogLevel.getLogLevelForCode( TEST_LOG_LEVEL_PARAM_VALUE ) ).when( meta ).getLogLevel(); doReturn( Boolean.valueOf( TEST_CLEAR_LOG_PARAM_VALUE ) ).when( meta ).isClearingLog(); doReturn( Boolean.valueOf( TEST_RUN_SAFE_MODE_PARAM_VALUE ) ).when( meta ).isSafeModeEnabled(); doReturn( Boolean.valueOf( TEST_GATHERING_METRICS_PARAM_VALUE ) ).when( meta ).isGatheringMetrics(); doReturn( TEST_START_COPY_NAME_PARAM_VALUE ).when( (JobMeta) meta ).getStartCopyName(); doReturn( Boolean.valueOf( TEST_EXPANDING_REMOTE_JOB_PARAM_VALUE ) ).when( (JobMeta) meta ).isExpandingRemoteJob(); doReturn( ARRAY_WITH_TEST_PDI_PARAM_NAME ).when( meta ).listParameters(); doReturn( TEST_PDI_PARAM_VALUE ).when( meta ).getParameterValue( TEST_PDI_PARAM_NAME ); doCallRealMethod().when( schedulerRequest ).buildSchedulerRequestEntity( meta ); assertTrue( compareContentOfStringEntities( schedulerRequest.buildSchedulerRequestEntity( meta ), new StringEntity( REFERENCE_TEST_REQUEST ) ) ); }
StringEntity buildSchedulerRequestEntity( AbstractMeta meta ) throws UnsupportedEncodingException, UnknownParamException { String filename = getFullPath( meta ); StringBuilder sb = new StringBuilder(); sb.append( "<jobScheduleRequest>\n" ); sb.append( "<inputFile>" ).append( filename ).append( "</inputFile>\n" ); if ( meta.getLogLevel() != null ) { sb.append( "<jobParameters>\n" ); sb.append( "<name>" ).append( "logLevel" ).append( "</name>\n" ); sb.append( "<type>" ).append( "string" ).append( "</type>\n" ); sb.append( "<stringValue>" ).append( meta.getLogLevel().getCode() ).append( "</stringValue>\n" ); sb.append( "</jobParameters>\n" ); } sb.append( "<jobParameters>\n" ); sb.append( "<name>" ).append( "clearLog" ).append( "</name>\n" ); sb.append( "<type>" ).append( "string" ).append( "</type>\n" ); sb.append( "<stringValue>" ).append( meta.isClearingLog() ).append( "</stringValue>\n" ); sb.append( "</jobParameters>\n" ); sb.append( "<jobParameters>\n" ); sb.append( "<name>" ).append( "runSafeMode" ).append( "</name>\n" ); sb.append( "<type>" ).append( "string" ).append( "</type>\n" ); sb.append( "<stringValue>" ).append( meta.isSafeModeEnabled() ).append( "</stringValue>\n" ); sb.append( "</jobParameters>\n" ); sb.append( "<jobParameters>\n" ); sb.append( "<name>" ).append( "gatheringMetrics" ).append( "</name>\n" ); sb.append( "<type>" ).append( "string" ).append( "</type>\n" ); sb.append( "<stringValue>" ).append( meta.isGatheringMetrics() ).append( "</stringValue>\n" ); sb.append( "</jobParameters>\n" ); if ( meta instanceof JobMeta ) { JobMeta jobMeta = (JobMeta) meta; if ( jobMeta.getStartCopyName() != null ) { sb.append( "<jobParameters>\n" ); sb.append( "<name>" ).append( "startCopyName" ).append( "</name>\n" ); sb.append( "<type>" ).append( "string" ).append( "</type>\n" ); sb.append( "<stringValue>" ).append( jobMeta.getStartCopyName() ).append( "</stringValue>\n" ); sb.append( "</jobParameters>\n" ); } sb.append( "<jobParameters>\n" ); sb.append( "<name>" ).append( "expandingRemoteJob" ).append( "</name>\n" ); sb.append( "<type>" ).append( "string" ).append( "</type>\n" ); sb.append( "<stringValue>" ).append( jobMeta.isExpandingRemoteJob() ).append( "</stringValue>\n" ); sb.append( "</jobParameters>\n" ); } if ( meta.listParameters() != null ) { sb.append( "<pdiParameters>\n" ); for ( String param : meta.listParameters() ) { sb.append( "<entry>\n" ); sb.append( "<key>" ).append( param ).append( "</key>\n" ); sb.append( "<value>" ).append( meta.getParameterValue( param ) ).append( "</value>\n" ); sb.append( "</entry>\n" ); } sb.append( "</pdiParameters>\n" ); } sb.append( "</jobScheduleRequest>" ); return new StringEntity( sb.toString() ); }
SchedulerRequest { StringEntity buildSchedulerRequestEntity( AbstractMeta meta ) throws UnsupportedEncodingException, UnknownParamException { String filename = getFullPath( meta ); StringBuilder sb = new StringBuilder(); sb.append( "<jobScheduleRequest>\n" ); sb.append( "<inputFile>" ).append( filename ).append( "</inputFile>\n" ); if ( meta.getLogLevel() != null ) { sb.append( "<jobParameters>\n" ); sb.append( "<name>" ).append( "logLevel" ).append( "</name>\n" ); sb.append( "<type>" ).append( "string" ).append( "</type>\n" ); sb.append( "<stringValue>" ).append( meta.getLogLevel().getCode() ).append( "</stringValue>\n" ); sb.append( "</jobParameters>\n" ); } sb.append( "<jobParameters>\n" ); sb.append( "<name>" ).append( "clearLog" ).append( "</name>\n" ); sb.append( "<type>" ).append( "string" ).append( "</type>\n" ); sb.append( "<stringValue>" ).append( meta.isClearingLog() ).append( "</stringValue>\n" ); sb.append( "</jobParameters>\n" ); sb.append( "<jobParameters>\n" ); sb.append( "<name>" ).append( "runSafeMode" ).append( "</name>\n" ); sb.append( "<type>" ).append( "string" ).append( "</type>\n" ); sb.append( "<stringValue>" ).append( meta.isSafeModeEnabled() ).append( "</stringValue>\n" ); sb.append( "</jobParameters>\n" ); sb.append( "<jobParameters>\n" ); sb.append( "<name>" ).append( "gatheringMetrics" ).append( "</name>\n" ); sb.append( "<type>" ).append( "string" ).append( "</type>\n" ); sb.append( "<stringValue>" ).append( meta.isGatheringMetrics() ).append( "</stringValue>\n" ); sb.append( "</jobParameters>\n" ); if ( meta instanceof JobMeta ) { JobMeta jobMeta = (JobMeta) meta; if ( jobMeta.getStartCopyName() != null ) { sb.append( "<jobParameters>\n" ); sb.append( "<name>" ).append( "startCopyName" ).append( "</name>\n" ); sb.append( "<type>" ).append( "string" ).append( "</type>\n" ); sb.append( "<stringValue>" ).append( jobMeta.getStartCopyName() ).append( "</stringValue>\n" ); sb.append( "</jobParameters>\n" ); } sb.append( "<jobParameters>\n" ); sb.append( "<name>" ).append( "expandingRemoteJob" ).append( "</name>\n" ); sb.append( "<type>" ).append( "string" ).append( "</type>\n" ); sb.append( "<stringValue>" ).append( jobMeta.isExpandingRemoteJob() ).append( "</stringValue>\n" ); sb.append( "</jobParameters>\n" ); } if ( meta.listParameters() != null ) { sb.append( "<pdiParameters>\n" ); for ( String param : meta.listParameters() ) { sb.append( "<entry>\n" ); sb.append( "<key>" ).append( param ).append( "</key>\n" ); sb.append( "<value>" ).append( meta.getParameterValue( param ) ).append( "</value>\n" ); sb.append( "</entry>\n" ); } sb.append( "</pdiParameters>\n" ); } sb.append( "</jobScheduleRequest>" ); return new StringEntity( sb.toString() ); } }
SchedulerRequest { StringEntity buildSchedulerRequestEntity( AbstractMeta meta ) throws UnsupportedEncodingException, UnknownParamException { String filename = getFullPath( meta ); StringBuilder sb = new StringBuilder(); sb.append( "<jobScheduleRequest>\n" ); sb.append( "<inputFile>" ).append( filename ).append( "</inputFile>\n" ); if ( meta.getLogLevel() != null ) { sb.append( "<jobParameters>\n" ); sb.append( "<name>" ).append( "logLevel" ).append( "</name>\n" ); sb.append( "<type>" ).append( "string" ).append( "</type>\n" ); sb.append( "<stringValue>" ).append( meta.getLogLevel().getCode() ).append( "</stringValue>\n" ); sb.append( "</jobParameters>\n" ); } sb.append( "<jobParameters>\n" ); sb.append( "<name>" ).append( "clearLog" ).append( "</name>\n" ); sb.append( "<type>" ).append( "string" ).append( "</type>\n" ); sb.append( "<stringValue>" ).append( meta.isClearingLog() ).append( "</stringValue>\n" ); sb.append( "</jobParameters>\n" ); sb.append( "<jobParameters>\n" ); sb.append( "<name>" ).append( "runSafeMode" ).append( "</name>\n" ); sb.append( "<type>" ).append( "string" ).append( "</type>\n" ); sb.append( "<stringValue>" ).append( meta.isSafeModeEnabled() ).append( "</stringValue>\n" ); sb.append( "</jobParameters>\n" ); sb.append( "<jobParameters>\n" ); sb.append( "<name>" ).append( "gatheringMetrics" ).append( "</name>\n" ); sb.append( "<type>" ).append( "string" ).append( "</type>\n" ); sb.append( "<stringValue>" ).append( meta.isGatheringMetrics() ).append( "</stringValue>\n" ); sb.append( "</jobParameters>\n" ); if ( meta instanceof JobMeta ) { JobMeta jobMeta = (JobMeta) meta; if ( jobMeta.getStartCopyName() != null ) { sb.append( "<jobParameters>\n" ); sb.append( "<name>" ).append( "startCopyName" ).append( "</name>\n" ); sb.append( "<type>" ).append( "string" ).append( "</type>\n" ); sb.append( "<stringValue>" ).append( jobMeta.getStartCopyName() ).append( "</stringValue>\n" ); sb.append( "</jobParameters>\n" ); } sb.append( "<jobParameters>\n" ); sb.append( "<name>" ).append( "expandingRemoteJob" ).append( "</name>\n" ); sb.append( "<type>" ).append( "string" ).append( "</type>\n" ); sb.append( "<stringValue>" ).append( jobMeta.isExpandingRemoteJob() ).append( "</stringValue>\n" ); sb.append( "</jobParameters>\n" ); } if ( meta.listParameters() != null ) { sb.append( "<pdiParameters>\n" ); for ( String param : meta.listParameters() ) { sb.append( "<entry>\n" ); sb.append( "<key>" ).append( param ).append( "</key>\n" ); sb.append( "<value>" ).append( meta.getParameterValue( param ) ).append( "</value>\n" ); sb.append( "</entry>\n" ); } sb.append( "</pdiParameters>\n" ); } sb.append( "</jobScheduleRequest>" ); return new StringEntity( sb.toString() ); } SchedulerRequest( Builder builder ); }
SchedulerRequest { StringEntity buildSchedulerRequestEntity( AbstractMeta meta ) throws UnsupportedEncodingException, UnknownParamException { String filename = getFullPath( meta ); StringBuilder sb = new StringBuilder(); sb.append( "<jobScheduleRequest>\n" ); sb.append( "<inputFile>" ).append( filename ).append( "</inputFile>\n" ); if ( meta.getLogLevel() != null ) { sb.append( "<jobParameters>\n" ); sb.append( "<name>" ).append( "logLevel" ).append( "</name>\n" ); sb.append( "<type>" ).append( "string" ).append( "</type>\n" ); sb.append( "<stringValue>" ).append( meta.getLogLevel().getCode() ).append( "</stringValue>\n" ); sb.append( "</jobParameters>\n" ); } sb.append( "<jobParameters>\n" ); sb.append( "<name>" ).append( "clearLog" ).append( "</name>\n" ); sb.append( "<type>" ).append( "string" ).append( "</type>\n" ); sb.append( "<stringValue>" ).append( meta.isClearingLog() ).append( "</stringValue>\n" ); sb.append( "</jobParameters>\n" ); sb.append( "<jobParameters>\n" ); sb.append( "<name>" ).append( "runSafeMode" ).append( "</name>\n" ); sb.append( "<type>" ).append( "string" ).append( "</type>\n" ); sb.append( "<stringValue>" ).append( meta.isSafeModeEnabled() ).append( "</stringValue>\n" ); sb.append( "</jobParameters>\n" ); sb.append( "<jobParameters>\n" ); sb.append( "<name>" ).append( "gatheringMetrics" ).append( "</name>\n" ); sb.append( "<type>" ).append( "string" ).append( "</type>\n" ); sb.append( "<stringValue>" ).append( meta.isGatheringMetrics() ).append( "</stringValue>\n" ); sb.append( "</jobParameters>\n" ); if ( meta instanceof JobMeta ) { JobMeta jobMeta = (JobMeta) meta; if ( jobMeta.getStartCopyName() != null ) { sb.append( "<jobParameters>\n" ); sb.append( "<name>" ).append( "startCopyName" ).append( "</name>\n" ); sb.append( "<type>" ).append( "string" ).append( "</type>\n" ); sb.append( "<stringValue>" ).append( jobMeta.getStartCopyName() ).append( "</stringValue>\n" ); sb.append( "</jobParameters>\n" ); } sb.append( "<jobParameters>\n" ); sb.append( "<name>" ).append( "expandingRemoteJob" ).append( "</name>\n" ); sb.append( "<type>" ).append( "string" ).append( "</type>\n" ); sb.append( "<stringValue>" ).append( jobMeta.isExpandingRemoteJob() ).append( "</stringValue>\n" ); sb.append( "</jobParameters>\n" ); } if ( meta.listParameters() != null ) { sb.append( "<pdiParameters>\n" ); for ( String param : meta.listParameters() ) { sb.append( "<entry>\n" ); sb.append( "<key>" ).append( param ).append( "</key>\n" ); sb.append( "<value>" ).append( meta.getParameterValue( param ) ).append( "</value>\n" ); sb.append( "</entry>\n" ); } sb.append( "</pdiParameters>\n" ); } sb.append( "</jobScheduleRequest>" ); return new StringEntity( sb.toString() ); } SchedulerRequest( Builder builder ); void submit( AbstractMeta meta ); }
SchedulerRequest { StringEntity buildSchedulerRequestEntity( AbstractMeta meta ) throws UnsupportedEncodingException, UnknownParamException { String filename = getFullPath( meta ); StringBuilder sb = new StringBuilder(); sb.append( "<jobScheduleRequest>\n" ); sb.append( "<inputFile>" ).append( filename ).append( "</inputFile>\n" ); if ( meta.getLogLevel() != null ) { sb.append( "<jobParameters>\n" ); sb.append( "<name>" ).append( "logLevel" ).append( "</name>\n" ); sb.append( "<type>" ).append( "string" ).append( "</type>\n" ); sb.append( "<stringValue>" ).append( meta.getLogLevel().getCode() ).append( "</stringValue>\n" ); sb.append( "</jobParameters>\n" ); } sb.append( "<jobParameters>\n" ); sb.append( "<name>" ).append( "clearLog" ).append( "</name>\n" ); sb.append( "<type>" ).append( "string" ).append( "</type>\n" ); sb.append( "<stringValue>" ).append( meta.isClearingLog() ).append( "</stringValue>\n" ); sb.append( "</jobParameters>\n" ); sb.append( "<jobParameters>\n" ); sb.append( "<name>" ).append( "runSafeMode" ).append( "</name>\n" ); sb.append( "<type>" ).append( "string" ).append( "</type>\n" ); sb.append( "<stringValue>" ).append( meta.isSafeModeEnabled() ).append( "</stringValue>\n" ); sb.append( "</jobParameters>\n" ); sb.append( "<jobParameters>\n" ); sb.append( "<name>" ).append( "gatheringMetrics" ).append( "</name>\n" ); sb.append( "<type>" ).append( "string" ).append( "</type>\n" ); sb.append( "<stringValue>" ).append( meta.isGatheringMetrics() ).append( "</stringValue>\n" ); sb.append( "</jobParameters>\n" ); if ( meta instanceof JobMeta ) { JobMeta jobMeta = (JobMeta) meta; if ( jobMeta.getStartCopyName() != null ) { sb.append( "<jobParameters>\n" ); sb.append( "<name>" ).append( "startCopyName" ).append( "</name>\n" ); sb.append( "<type>" ).append( "string" ).append( "</type>\n" ); sb.append( "<stringValue>" ).append( jobMeta.getStartCopyName() ).append( "</stringValue>\n" ); sb.append( "</jobParameters>\n" ); } sb.append( "<jobParameters>\n" ); sb.append( "<name>" ).append( "expandingRemoteJob" ).append( "</name>\n" ); sb.append( "<type>" ).append( "string" ).append( "</type>\n" ); sb.append( "<stringValue>" ).append( jobMeta.isExpandingRemoteJob() ).append( "</stringValue>\n" ); sb.append( "</jobParameters>\n" ); } if ( meta.listParameters() != null ) { sb.append( "<pdiParameters>\n" ); for ( String param : meta.listParameters() ) { sb.append( "<entry>\n" ); sb.append( "<key>" ).append( param ).append( "</key>\n" ); sb.append( "<value>" ).append( meta.getParameterValue( param ) ).append( "</value>\n" ); sb.append( "</entry>\n" ); } sb.append( "</pdiParameters>\n" ); } sb.append( "</jobScheduleRequest>" ); return new StringEntity( sb.toString() ); } SchedulerRequest( Builder builder ); void submit( AbstractMeta meta ); static final String API_SCHEDULER_JOB; static final String CONTENT_TYPE; static final String APPLICATION_XML; static final String UTF_8; static final String AUTHORIZATION; }