CalvalusWpsProvider implements WpsServiceInstance { @Override public ExecuteResponse doExecute(WpsRequestContext wpsRequestContext, Execute executeRequest) throws WpsServiceException { try { String processId = executeRequest.getIdentifier().getValue(); CalvalusExecuteOperation executeOperation = new CalvalusExecuteOperation(processId, wpsRequestContext); return executeOperation.execute(executeRequest); } catch (IOException | ProductionException | WpsProductionException | WpsResultProductException | InvalidProcessorIdException exception) { logger.log(Level.SEVERE, "Unable to perform Execute operation successfully", exception); throw new WpsServiceException(exception); } }  @Override Capabilities getCapabilities(WpsRequestContext wpsRequestContext); @Override List<ProcessDescriptionType> describeProcess(WpsRequestContext wpsRequestContext, String processId); @Override ExecuteResponse doExecute(WpsRequestContext wpsRequestContext, Execute executeRequest); @Override ExecuteResponse getStatus(WpsRequestContext wpsRequestContext, String jobId); @Override void dispose();  }
@Test public void canDoExecute() throws Exception { CalvalusExecuteOperation mockExecute = mock(CalvalusExecuteOperation.class); Execute mockExecuteRequest = mock(Execute.class); CodeType mockProcessorId = new CodeType(); mockProcessorId.setValue(MOCK_PROCESSOR_ID); when(mockExecuteRequest.getIdentifier()).thenReturn(mockProcessorId); PowerMockito.whenNew(CalvalusExecuteOperation.class).withArguments(MOCK_PROCESSOR_ID, mockRequestContext).thenReturn(mockExecute); calvalusProvider.doExecute(mockRequestContext, mockExecuteRequest); verify(mockExecute, times(1)).execute(mockExecuteRequest); }
@Test(expected = WpsServiceException.class) public void canThrowExceptionDoExecute() throws Exception { Execute mockExecuteRequest = mock(Execute.class); CodeType mockProcessorId = new CodeType(); mockProcessorId.setValue(MOCK_PROCESSOR_ID); when(mockExecuteRequest.getIdentifier()).thenReturn(mockProcessorId); CalvalusExecuteOperation mockExecute = mock(CalvalusExecuteOperation.class); when(mockExecute.execute(mockExecuteRequest)).thenThrow(new IOException()); PowerMockito.whenNew(CalvalusExecuteOperation.class).withArguments(MOCK_PROCESSOR_ID, mockRequestContext).thenReturn(mockExecute); calvalusProvider.doExecute(mockRequestContext, mockExecuteRequest); }