@Test public void canGetInProgressStatus() throws Exception { ProductionRequest mockProductionRequest = getMockProductionRequest(); when(mockProduction.getProductionRequest()).thenReturn(mockProductionRequest); when(mockCalvalusFacade.getProduction(anyString())).thenReturn(mockProduction); ArrayList<String> dummyList = new ArrayList<>(); when(mockCalvalusFacade.getProductResultUrls("job-01")).thenReturn(dummyList); CalvalusWpsProcessStatus mockStatus = getInProgressProcessStatus(); PowerMockito.whenNew(CalvalusWpsProcessStatus.class).withArguments(mockProduction, dummyList).thenReturn(mockStatus); PowerMockito.whenNew(CalvalusFacade.class).withArguments(any(WpsRequestContext.class)).thenReturn(mockCalvalusFacade); Calendar calendar = Calendar.getInstance(); getStatusOperation = new CalvalusGetStatusOperation(mockRequestContext); ExecuteResponse executeResponse = getStatusOperation.getStatus("job-01"); assertThat(executeResponse.getProcess().getIdentifier().getValue(), equalTo("mockBundle~1.0~mockProcessor")); assertThat(executeResponse.getProcess().getProcessVersion(), equalTo("1.0")); assertThat(executeResponse.getStatus().getCreationTime().getDay(), equalTo(calendar.get(Calendar.DAY_OF_MONTH))); assertThat(executeResponse.getStatus().getCreationTime().getMonth(), equalTo(calendar.get(Calendar.MONTH) + 1)); assertThat(executeResponse.getStatus().getCreationTime().getYear(), equalTo(calendar.get(Calendar.YEAR))); assertThat(executeResponse.getStatus().getProcessStarted().getPercentCompleted(), equalTo(40)); assertThat(executeResponse.getStatus().getProcessStarted().getValue(), equalTo("RUNNING")); }
public ExecuteResponse getStatus(String jobId) throws JobNotFoundException, InvalidProcessorIdException, SqlStoreException { String localJobIdRegex = ".*-((\\d{4}((0[13578]|1[02])(0[1-9]|[12]\\d|3[01])|(0[13456789]|1[012])(0[1-9]|" + "[12]\\d|30)|02(0[1-9]|1\\d|2[0-8])))|(\\d{2}[02468][048]|\\d{2}[13579][26])0229){0,8}_.*"; if (jobId.matches(localJobIdRegex)) { try { return getLocalProcessExecuteResponse(jobId); } catch (JobNotFoundException _) {} } return getCalvalusExecuteResponse(jobId); }
CalvalusGetStatusOperation extends WpsOperation { public ExecuteResponse getStatus(String jobId) throws JobNotFoundException, InvalidProcessorIdException, SqlStoreException { String localJobIdRegex = ".*-((\\d{4}((0[13578]|1[02])(0[1-9]|[12]\\d|3[01])|(0[13456789]|1[012])(0[1-9]|" + "[12]\\d|30)|02(0[1-9]|1\\d|2[0-8])))|(\\d{2}[02468][048]|\\d{2}[13579][26])0229){0,8}_.*"; if (jobId.matches(localJobIdRegex)) { try { return getLocalProcessExecuteResponse(jobId); } catch (JobNotFoundException _) {} } return getCalvalusExecuteResponse(jobId); } }
CalvalusGetStatusOperation extends WpsOperation { public ExecuteResponse getStatus(String jobId) throws JobNotFoundException, InvalidProcessorIdException, SqlStoreException { String localJobIdRegex = ".*-((\\d{4}((0[13578]|1[02])(0[1-9]|[12]\\d|3[01])|(0[13456789]|1[012])(0[1-9]|" + "[12]\\d|30)|02(0[1-9]|1\\d|2[0-8])))|(\\d{2}[02468][048]|\\d{2}[13579][26])0229){0,8}_.*"; if (jobId.matches(localJobIdRegex)) { try { return getLocalProcessExecuteResponse(jobId); } catch (JobNotFoundException _) {} } return getCalvalusExecuteResponse(jobId); } CalvalusGetStatusOperation(WpsRequestContext context); }
CalvalusGetStatusOperation extends WpsOperation { public ExecuteResponse getStatus(String jobId) throws JobNotFoundException, InvalidProcessorIdException, SqlStoreException { String localJobIdRegex = ".*-((\\d{4}((0[13578]|1[02])(0[1-9]|[12]\\d|3[01])|(0[13456789]|1[012])(0[1-9]|" + "[12]\\d|30)|02(0[1-9]|1\\d|2[0-8])))|(\\d{2}[02468][048]|\\d{2}[13579][26])0229){0,8}_.*"; if (jobId.matches(localJobIdRegex)) { try { return getLocalProcessExecuteResponse(jobId); } catch (JobNotFoundException _) {} } return getCalvalusExecuteResponse(jobId); } CalvalusGetStatusOperation(WpsRequestContext context); ExecuteResponse getStatus(String jobId); }
CalvalusGetStatusOperation extends WpsOperation { public ExecuteResponse getStatus(String jobId) throws JobNotFoundException, InvalidProcessorIdException, SqlStoreException { String localJobIdRegex = ".*-((\\d{4}((0[13578]|1[02])(0[1-9]|[12]\\d|3[01])|(0[13456789]|1[012])(0[1-9]|" + "[12]\\d|30)|02(0[1-9]|1\\d|2[0-8])))|(\\d{2}[02468][048]|\\d{2}[13579][26])0229){0,8}_.*"; if (jobId.matches(localJobIdRegex)) { try { return getLocalProcessExecuteResponse(jobId); } catch (JobNotFoundException _) {} } return getCalvalusExecuteResponse(jobId); } CalvalusGetStatusOperation(WpsRequestContext context); ExecuteResponse getStatus(String jobId);  }