CalvalusWpsProvider implements WpsServiceInstance { @Override public Capabilities getCapabilities(WpsRequestContext wpsRequestContext) throws WpsServiceException { try { CalvalusGetCapabilitiesOperation getCapabilitiesOperation = new CalvalusGetCapabilitiesOperation(wpsRequestContext); return getCapabilitiesOperation.getCapabilities(); } catch (WpsProcessorNotFoundException | IOException | URISyntaxException | BindingException exception) { logger.log(Level.SEVERE, "Unable to perform GetCapabilities 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 canGetCapabilities() throws Exception { CalvalusGetCapabilitiesOperation mockGetCapabilities = mock(CalvalusGetCapabilitiesOperation.class); PowerMockito.whenNew(CalvalusGetCapabilitiesOperation.class).withArguments(mockRequestContext).thenReturn(mockGetCapabilities); calvalusProvider.getCapabilities(mockRequestContext); verify(mockGetCapabilities, times(1)).getCapabilities(); }
@Test(expected = WpsServiceException.class) public void canThrowExceptionGetCapabilities() throws Exception { CalvalusGetCapabilitiesOperation mockGetCapabilities = mock(CalvalusGetCapabilitiesOperation.class); when(mockGetCapabilities.getCapabilities()).thenThrow(new WpsProcessorNotFoundException("process not available")); PowerMockito.whenNew(CalvalusGetCapabilitiesOperation.class).withArguments(mockRequestContext).thenReturn(mockGetCapabilities); calvalusProvider.getCapabilities(mockRequestContext); }