CalvalusFacade extends ProcessFacade { @Override public LocalProductionStatus orderProductionSynchronous(Execute executeRequest) throws WpsProductionException { return calvalusProduction.orderProductionSynchronous(executeRequest, remoteUserName, this); } CalvalusFacade(WpsRequestContext wpsRequestContext); @Override LocalProductionStatus orderProductionAsynchronous(Execute executeRequest); @Override LocalProductionStatus orderProductionSynchronous(Execute executeRequest); @Override List<String> getProductResultUrls(String jobId); @Override void stageProduction(String jobId); @Override void observeStagingStatus(String jobId); @Override void generateProductMetadata(String jobId); @Override List<WpsProcess> getProcessors(); @Override WpsProcess getProcessor(ProcessorNameConverter parser); ProductSet[] getProductSets(); Production getProduction(String jobId); String[] getRegionFiles(); String[][] loadRegionDataInfo(String url);  }
@Test public void testOrderProductionSynchronous() throws Exception { Execute mockExecuteRequest = mock(Execute.class); CalvalusProcessor mockProcessor = mock(CalvalusProcessor.class); LocalProductionStatus mockStatus = mock(LocalProductionStatus.class); CodeType mockIdentifier = new CodeType(); mockIdentifier.setValue(MOCK_PROCESS_ID); when(mockExecuteRequest.getIdentifier()).thenReturn(mockIdentifier); ExecuteRequestExtractor mockRequestExtractor = mock(ExecuteRequestExtractor.class); ProcessorNameConverter mockNameConverter = mock(ProcessorNameConverter.class); CalvalusDataInputs mockCalvalusDataInput = mock(CalvalusDataInputs.class); Map<String, String> mockParameterMap = new HashMap<>(); ProductionRequest mockProductionRequest = mock(ProductionRequest.class); when(mockCalvalusProcessorExtractor.getProcessor(any(ProcessorNameConverter.class), anyString())) .thenReturn(mockProcessor); when(mockCalvalusDataInput.getValue("productionType")).thenReturn("L2"); when(mockCalvalusDataInput.getInputMapFormatted()).thenReturn(mockParameterMap); when(mockStatus.getJobId()).thenReturn(MOCK_PROCESS_ID); when(mockCalvalusProduction.orderProductionSynchronous(any(Execute.class), anyString(), any(CalvalusFacade.class))).thenReturn(mockStatus); whenNew(ExecuteRequestExtractor.class).withArguments(Execute.class).thenReturn(mockRequestExtractor); whenNew(ProcessorNameConverter.class).withArguments(anyString()).thenReturn(mockNameConverter); whenNew(CalvalusProcessorExtractor.class).withNoArguments().thenReturn(mockCalvalusProcessorExtractor); whenNew(CalvalusDataInputs.class).withAnyArguments().thenReturn(mockCalvalusDataInput); whenNew(ProductionRequest.class).withAnyArguments().thenReturn(mockProductionRequest); whenNew(CalvalusProduction.class).withNoArguments().thenReturn(mockCalvalusProduction); whenNew(CalvalusStaging.class).withArguments(any(WpsServerContext.class)).thenReturn(mockCalvalusStaging); ArgumentCaptor<Execute> requestArgumentCaptor = ArgumentCaptor.forClass(Execute.class); ArgumentCaptor<String> userNameArgumentCaptor = ArgumentCaptor.forClass(String.class); calvalusFacade = new CalvalusFacade(mockRequestContext); calvalusFacade.orderProductionSynchronous(mockExecuteRequest); verify(mockCalvalusProduction).orderProductionSynchronous(requestArgumentCaptor.capture(), userNameArgumentCaptor.capture(), any(CalvalusFacade.class)); assertThat(requestArgumentCaptor.getValue(), equalTo(mockExecuteRequest)); }