@Test(expectedExceptions = ScheduleExecutionException.class) public void testExecuteScheduleException() { when(restTemplate.postForObject(eq(SCHEDULE_EXECUTIONS_URI), any(ScheduleExecution.class), eq(ScheduleExecution.class))) .thenThrow(new RestClientException("")); final Schedule schedule = mock(Schedule.class); when(schedule.getExecutionsUri()).thenReturn(SCHEDULE_EXECUTIONS_URI); processService.executeSchedule(schedule); }
public FutureResult<ScheduleExecution> executeSchedule(final Schedule schedule) { notNull(schedule, "schedule"); notNull(schedule.getExecutionsUri(), "schedule.executionsUri"); ScheduleExecution scheduleExecution; try { scheduleExecution = restTemplate.postForObject(schedule.getExecutionsUri(), new ScheduleExecution(), ScheduleExecution.class); } catch (GoodDataException | RestClientException e) { throw new ScheduleExecutionException("Cannot execute schedule", e); } return new PollResult<>(this, new AbstractPollHandler<ScheduleExecution, ScheduleExecution>( notNullState(scheduleExecution, "created schedule execution").getUri(), ScheduleExecution.class, ScheduleExecution.class) { @Override public boolean isFinished(ClientHttpResponse response) throws IOException { final ScheduleExecution pollResult = extractData(response, ScheduleExecution.class); return pollResult.isFinished(); } @Override public void handlePollResult(final ScheduleExecution pollResult) { setResult(pollResult); } @Override public void handlePollException(final GoodDataRestException e) { throw new ScheduleExecutionException("Cannot execute schedule", e); } }); }
ProcessService extends AbstractService { public FutureResult<ScheduleExecution> executeSchedule(final Schedule schedule) { notNull(schedule, "schedule"); notNull(schedule.getExecutionsUri(), "schedule.executionsUri"); ScheduleExecution scheduleExecution; try { scheduleExecution = restTemplate.postForObject(schedule.getExecutionsUri(), new ScheduleExecution(), ScheduleExecution.class); } catch (GoodDataException | RestClientException e) { throw new ScheduleExecutionException("Cannot execute schedule", e); } return new PollResult<>(this, new AbstractPollHandler<ScheduleExecution, ScheduleExecution>( notNullState(scheduleExecution, "created schedule execution").getUri(), ScheduleExecution.class, ScheduleExecution.class) { @Override public boolean isFinished(ClientHttpResponse response) throws IOException { final ScheduleExecution pollResult = extractData(response, ScheduleExecution.class); return pollResult.isFinished(); } @Override public void handlePollResult(final ScheduleExecution pollResult) { setResult(pollResult); } @Override public void handlePollException(final GoodDataRestException e) { throw new ScheduleExecutionException("Cannot execute schedule", e); } }); } }
ProcessService extends AbstractService { public FutureResult<ScheduleExecution> executeSchedule(final Schedule schedule) { notNull(schedule, "schedule"); notNull(schedule.getExecutionsUri(), "schedule.executionsUri"); ScheduleExecution scheduleExecution; try { scheduleExecution = restTemplate.postForObject(schedule.getExecutionsUri(), new ScheduleExecution(), ScheduleExecution.class); } catch (GoodDataException | RestClientException e) { throw new ScheduleExecutionException("Cannot execute schedule", e); } return new PollResult<>(this, new AbstractPollHandler<ScheduleExecution, ScheduleExecution>( notNullState(scheduleExecution, "created schedule execution").getUri(), ScheduleExecution.class, ScheduleExecution.class) { @Override public boolean isFinished(ClientHttpResponse response) throws IOException { final ScheduleExecution pollResult = extractData(response, ScheduleExecution.class); return pollResult.isFinished(); } @Override public void handlePollResult(final ScheduleExecution pollResult) { setResult(pollResult); } @Override public void handlePollException(final GoodDataRestException e) { throw new ScheduleExecutionException("Cannot execute schedule", e); } }); } ProcessService(final RestTemplate restTemplate, final AccountService accountService,
                          final DataStoreService dataStoreService, final GoodDataSettings settings); }
ProcessService extends AbstractService { public FutureResult<ScheduleExecution> executeSchedule(final Schedule schedule) { notNull(schedule, "schedule"); notNull(schedule.getExecutionsUri(), "schedule.executionsUri"); ScheduleExecution scheduleExecution; try { scheduleExecution = restTemplate.postForObject(schedule.getExecutionsUri(), new ScheduleExecution(), ScheduleExecution.class); } catch (GoodDataException | RestClientException e) { throw new ScheduleExecutionException("Cannot execute schedule", e); } return new PollResult<>(this, new AbstractPollHandler<ScheduleExecution, ScheduleExecution>( notNullState(scheduleExecution, "created schedule execution").getUri(), ScheduleExecution.class, ScheduleExecution.class) { @Override public boolean isFinished(ClientHttpResponse response) throws IOException { final ScheduleExecution pollResult = extractData(response, ScheduleExecution.class); return pollResult.isFinished(); } @Override public void handlePollResult(final ScheduleExecution pollResult) { setResult(pollResult); } @Override public void handlePollException(final GoodDataRestException e) { throw new ScheduleExecutionException("Cannot execute schedule", e); } }); } ProcessService(final RestTemplate restTemplate, final AccountService accountService,
                          final DataStoreService dataStoreService, final GoodDataSettings settings); DataloadProcess createProcess(Project project, DataloadProcess process, File processData); DataloadProcess createProcess(Project project, DataloadProcess process); FutureResult<DataloadProcess> createProcessFromAppstore(Project project, DataloadProcess process); DataloadProcess updateProcess(DataloadProcess process, File processData); FutureResult<DataloadProcess> updateProcessFromAppstore(DataloadProcess process); DataloadProcess getProcessByUri(String uri); DataloadProcess getProcessById(Project project, String id); Collection<DataloadProcess> listProcesses(Project project); Collection<DataloadProcess> listUserProcesses(); void removeProcess(DataloadProcess process); void getProcessSource(DataloadProcess process, OutputStream outputStream); void getExecutionLog(ProcessExecutionDetail executionDetail, OutputStream outputStream); FutureResult<ProcessExecutionDetail> executeProcess(ProcessExecution execution); Schedule createSchedule(Project project, Schedule schedule); Schedule updateSchedule(Schedule schedule); Schedule getScheduleByUri(String uri); Schedule getScheduleById(Project project, String id); PageBrowser<Schedule> listSchedules(final Project project); PageBrowser<Schedule> listSchedules(final Project project,
                                                final PageRequest startPage); void removeSchedule(final Schedule schedule); FutureResult<ScheduleExecution> executeSchedule(final Schedule schedule); }
ProcessService extends AbstractService { public FutureResult<ScheduleExecution> executeSchedule(final Schedule schedule) { notNull(schedule, "schedule"); notNull(schedule.getExecutionsUri(), "schedule.executionsUri"); ScheduleExecution scheduleExecution; try { scheduleExecution = restTemplate.postForObject(schedule.getExecutionsUri(), new ScheduleExecution(), ScheduleExecution.class); } catch (GoodDataException | RestClientException e) { throw new ScheduleExecutionException("Cannot execute schedule", e); } return new PollResult<>(this, new AbstractPollHandler<ScheduleExecution, ScheduleExecution>( notNullState(scheduleExecution, "created schedule execution").getUri(), ScheduleExecution.class, ScheduleExecution.class) { @Override public boolean isFinished(ClientHttpResponse response) throws IOException { final ScheduleExecution pollResult = extractData(response, ScheduleExecution.class); return pollResult.isFinished(); } @Override public void handlePollResult(final ScheduleExecution pollResult) { setResult(pollResult); } @Override public void handlePollException(final GoodDataRestException e) { throw new ScheduleExecutionException("Cannot execute schedule", e); } }); } ProcessService(final RestTemplate restTemplate, final AccountService accountService,
                          final DataStoreService dataStoreService, final GoodDataSettings settings); DataloadProcess createProcess(Project project, DataloadProcess process, File processData); DataloadProcess createProcess(Project project, DataloadProcess process); FutureResult<DataloadProcess> createProcessFromAppstore(Project project, DataloadProcess process); DataloadProcess updateProcess(DataloadProcess process, File processData); FutureResult<DataloadProcess> updateProcessFromAppstore(DataloadProcess process); DataloadProcess getProcessByUri(String uri); DataloadProcess getProcessById(Project project, String id); Collection<DataloadProcess> listProcesses(Project project); Collection<DataloadProcess> listUserProcesses(); void removeProcess(DataloadProcess process); void getProcessSource(DataloadProcess process, OutputStream outputStream); void getExecutionLog(ProcessExecutionDetail executionDetail, OutputStream outputStream); FutureResult<ProcessExecutionDetail> executeProcess(ProcessExecution execution); Schedule createSchedule(Project project, Schedule schedule); Schedule updateSchedule(Schedule schedule); Schedule getScheduleByUri(String uri); Schedule getScheduleById(Project project, String id); PageBrowser<Schedule> listSchedules(final Project project); PageBrowser<Schedule> listSchedules(final Project project,
                                                final PageRequest startPage); void removeSchedule(final Schedule schedule); FutureResult<ScheduleExecution> executeSchedule(final Schedule schedule); static final UriTemplate SCHEDULE_TEMPLATE; static final UriTemplate PROCESS_TEMPLATE; static final UriTemplate SCHEDULES_TEMPLATE; static final UriTemplate PROCESSES_TEMPLATE; static final UriTemplate USER_PROCESSES_TEMPLATE; }