CalvalusExecuteResponseConverter { public ExecuteResponse getFailedResponse(String exceptionMessage) { StatusType statusType = new StatusType(); GregorianCalendar gregorianCalendar = new GregorianCalendar(); XMLGregorianCalendar currentTime = getXmlGregorianCalendar(gregorianCalendar); statusType.setCreationTime(currentTime); ProcessFailedType processFailedType = new ProcessFailedType(); ExceptionReport exceptionReport = new ExceptionReport(); exceptionReport.setVersion("1.0.0"); ExceptionType exceptionType = new ExceptionType(); exceptionType.getExceptionText().add(exceptionMessage); exceptionType.setExceptionCode("NoApplicableCode"); exceptionReport.getException().add(exceptionType); processFailedType.setExceptionReport(exceptionReport); statusType.setProcessFailed(processFailedType); executeResponse.setStatus(statusType); return executeResponse; } CalvalusExecuteResponseConverter(); ExecuteResponse getAcceptedResponse(String jobId, WpsServerContext context); ExecuteResponse getAcceptedWithLineageResponse(String jobId,
                                                          DataInputsType dataInputs,
                                                          List<DocumentOutputDefinitionType> rawDataOutput,
                                                          WpsServerContext context); ExecuteResponse getSuccessfulResponse(List<String> resultUrls, Date stopTime); ExecuteResponse getSuccessfulWithLineageResponse(List<String> resultUrls,
                                                            DataInputsType dataInputs,
                                                            List<DocumentOutputDefinitionType> outputType); ExecuteResponse getFailedResponse(String exceptionMessage); ExecuteResponse getStartedResponse(String state, float progress); ExecuteResponse getQuotationResponse(String username, String remoteRef, DataInputsType dataInputs);  }
@Test public void canGetFailedResponse() throws Exception { Calendar calendar = Calendar.getInstance(); ExecuteResponse executeResponse = calvalusExecuteResponse.getFailedResponse("Unable to process the request"); 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().getProcessFailed().getExceptionReport().getVersion(), equalTo("1.0.0")); assertThat(executeResponse.getStatus().getProcessFailed().getExceptionReport().getException().get(0).getExceptionCode(), equalTo("NoApplicableCode")); assertThat(executeResponse.getStatus().getProcessFailed().getExceptionReport().getException().get(0).getExceptionText().get(0), equalTo("Unable to process the request")); }