5656import org .springframework .cloud .dataflow .server .service .SchedulerService ;
5757import org .springframework .cloud .dataflow .server .service .SchedulerServiceProperties ;
5858import org .springframework .cloud .deployer .resource .docker .DockerResource ;
59+ import org .springframework .cloud .deployer .spi .core .AppDefinition ;
5960import org .springframework .cloud .deployer .spi .scheduler .CreateScheduleException ;
6061import org .springframework .cloud .deployer .spi .scheduler .ScheduleInfo ;
6162import org .springframework .cloud .deployer .spi .scheduler .ScheduleRequest ;
@@ -371,7 +372,18 @@ public void testScheduleWithoutCommandLineArguments() throws Exception {
371372 assertEquals ("Invalid number of command line arguments" , 0 , commandLineArguments .size ());
372373 }
373374
375+ @ Test
376+ public void testGetDefaultCTR () {
377+ ScheduleRequest request = getScheduleRequest (new ArrayList <>(), "springcloudtask/composed-task-runner:latest" , "1: timestamp && 2: timestamp" );
378+ AppDefinition definition = request .getDefinition ();
379+ assertEquals ("Docker Resource [docker:springcloudtask/composed-task-runner:latest]" , request .getResource ().toString ());
380+ }
381+
374382 private List <String > getCommandLineArguments (List <String > commandLineArguments ) {
383+ return getScheduleRequest (commandLineArguments ,"springcloudtask/timestamp-task:latest" , "timestamp" ).getCommandlineArguments ();
384+ }
385+
386+ private ScheduleRequest getScheduleRequest (List <String > commandLineArguments , String resourceToReturn , String definition ) {
375387 Scheduler mockScheduler = mock (SimpleTestScheduler .class );
376388 TaskDefinitionRepository mockTaskDefinitionRepository = mock (TaskDefinitionRepository .class );
377389 AppRegistryService mockAppRegistryService = mock (AppRegistryService .class );
@@ -386,19 +398,18 @@ this.taskConfigurationProperties, mock(DataSourceProperties.class), "uri",
386398 mock (ApplicationConfigurationMetadataResolver .class ), mock (SchedulerServiceProperties .class ),
387399 mock (AuditRecordService .class ));
388400
389- TaskDefinition taskDefinition = new TaskDefinition (BASE_DEFINITION_NAME , "timestamp" );
401+ TaskDefinition taskDefinition = new TaskDefinition (BASE_DEFINITION_NAME , definition );
390402
391403 when (mockTaskDefinitionRepository .findById (BASE_DEFINITION_NAME )).thenReturn (Optional .of (taskDefinition ));
392- when (mockAppRegistryService .getAppResource (any ())).thenReturn (new DockerResource ("springcloudtask/timestamp-task:latest" ));
404+ when (mockAppRegistryService .getAppResource (any ())).thenReturn (new DockerResource (resourceToReturn ));
393405 when (mockAppRegistryService .find (taskDefinition .getRegisteredAppName (), ApplicationType .task ))
394406 .thenReturn (new AppRegistration ());
395407 mockSchedulerService .schedule (BASE_SCHEDULE_NAME , BASE_DEFINITION_NAME , this .testProperties ,
396408 commandLineArguments , null );
397409
398410 ArgumentCaptor <ScheduleRequest > scheduleRequestArgumentCaptor = ArgumentCaptor .forClass (ScheduleRequest .class );
399411 verify (mockScheduler ).schedule (scheduleRequestArgumentCaptor .capture ());
400-
401- return scheduleRequestArgumentCaptor .getValue ().getCommandlineArguments ();
412+ return scheduleRequestArgumentCaptor .getValue ();
402413 }
403414
404415 private void verifyScheduleExistsInScheduler (ScheduleInfo scheduleInfo ) {
0 commit comments