### Question:
ProcessService extends AbstractService { public DataloadProcess createProcess(Project project, DataloadProcess process, File processData) { notNull(process, "process"); notNull(processData, "processData"); notNull(project, "project"); isTrue(process.getPath() == null, "Process path has to be null, use processData argument. If you want to create process from appstore, use method createProcessFromAppstore()"); return postProcess(process, processData, getProcessesUri(project)); } 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; }### Answer:
@Test public void shouldDeploySmallProcessUsingAPI() throws Exception { final DataloadProcess process = new DataloadProcess("test", ProcessType.GRAPH); final ArgumentCaptor<HttpEntity> entityCaptor = ArgumentCaptor.forClass(HttpEntity.class); when(restTemplate.exchange(any(URI.class), eq(HttpMethod.POST), entityCaptor.capture(), eq(DataloadProcess.class))) .thenReturn(new ResponseEntity<>(process, HttpStatus.CREATED)); processService.createProcess(project, process, createProcessOfSize(1)); assertNotNull(entityCaptor.getValue()); assertNotNull(entityCaptor.getValue().getBody()); assertTrue(entityCaptor.getValue().getBody() instanceof MultiValueMap); verifyZeroInteractions(dataStoreService); }
@Test public void shouldDeployLargeProcessUsingWebDAV() throws Exception { final DataloadProcess process = new DataloadProcess("test", ProcessType.GRAPH); when(dataStoreService.getUri(anyString())).thenReturn(create("URI")); when(restTemplate.exchange(any(URI.class), eq(HttpMethod.POST), eq(new HttpEntity<>(process)), eq(DataloadProcess.class))) .thenReturn(new ResponseEntity<>(process, HttpStatus.CREATED)); processService.createProcess(project, process, createProcessOfSize(2048)); verify(dataStoreService).upload(anyString(), notNull(InputStream.class)); }