CalvalusStaging { void stageProduction(String jobid) throws WpsStagingException { LOG.info("Staging results..."); try { ProductionService productionService = CalvalusProductionService.getServiceContainerSingleton().getProductionService(); productionService.stageProductions(jobid); } catch (ProductionException | IOException exception) { throw new WpsStagingException(exception); } } CalvalusStaging(WpsServerContext wpsServerContext);   }
@Test public void canStageProduction() throws Exception { mockProductionService = mock(ProductionService.class); ServiceContainer mockServiceContainer = mock(ServiceContainer.class); PowerMockito.when(mockServiceContainer.getProductionService()).thenReturn(mockProductionService); PowerMockito.when(CalvalusProductionService.getServiceContainerSingleton()).thenReturn(mockServiceContainer); ArgumentCaptor<String> productId = ArgumentCaptor.forClass(String.class); calvalusStaging = new CalvalusStaging(mockServerContext); calvalusStaging.stageProduction("productId"); verify(mockProductionService).stageProductions(productId.capture()); assertThat(productId.getValue(), equalTo("productId")); }
@Test(expected = WpsStagingException.class) public void canCatchExceptionWhenStageProduction() throws Exception { mockProductionService = mock(ProductionService.class); doThrow(new ProductionException("error when staging")).when(mockProductionService).stageProductions(anyString()); ServiceContainer mockServiceContainer = mock(ServiceContainer.class); PowerMockito.when(mockServiceContainer.getProductionService()).thenReturn(mockProductionService); PowerMockito.when(CalvalusProductionService.getServiceContainerSingleton()).thenReturn(mockServiceContainer); ArgumentCaptor<String> productId = ArgumentCaptor.forClass(String.class); calvalusStaging = new CalvalusStaging(mockServerContext); calvalusStaging.stageProduction("productId"); verify(mockProductionService).stageProductions(productId.capture()); assertThat(productId.getValue(), equalTo("productId")); }