use of com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfig in project sechub by mercedes-benz.
the class InfrastructureScanProductExecutionServiceImplTest method before.
@Before
public void before() throws Exception {
infraScanProductExecutorConfigInfo = new WithoutProductExecutorConfigInfo(INFRASCANNER1_PRODUCT_IDENTIFIER);
uri = new URI("https://www.example.org");
configuration = mock(SecHubConfiguration.class);
when(configuration.getProjectId()).thenReturn(PROJECT_ID1);
productExecutorContext = mock(ProductExecutorContext.class);
infraconfig = mock(SecHubInfrastructureScanConfiguration.class);
context = mock(SecHubExecutionContext.class);
ProductResultRepository productResultRepository = mock(ProductResultRepository.class);
infrascanner1 = mock(InfrastructureScanProductExecutor.class, "infrascanner1");
when(infrascanner1.getIdentifier()).thenReturn(INFRASCANNER1_PRODUCT_IDENTIFIER);
when(infrascanner1.getVersion()).thenReturn(1);
infrascanner2 = mock(InfrastructureScanProductExecutor.class, "infrascanner2");
when(infrascanner2.getIdentifier()).thenReturn(INFRASCANNER2_PRODUCT_IDENTIFIER);
when(infrascanner2.getVersion()).thenReturn(2);
when(infraconfig.getUris()).thenReturn(Collections.singletonList(uri));
when(context.getConfiguration()).thenReturn(configuration);
List<InfrastructureScanProductExecutor> executors = new ArrayList<>();
executors.add(infrascanner1);
executors.add(infrascanner2);
productExecutorConfigRepository = mock(ProductExecutorConfigRepository.class);
/* simulate default profile1 */
when(productExecutorConfigRepository.findExecutableConfigurationsForProject(eq(PROJECT_ID1), eq(INFRASCANNER1_PRODUCT_IDENTIFIER), eq(1))).thenReturn(Arrays.asList(new ProductExecutorConfig(INFRASCANNER1_PRODUCT_IDENTIFIER, 1, new ProductExecutorConfigSetup())));
when(productExecutorConfigRepository.findExecutableConfigurationsForProject(eq(PROJECT_ID1), eq(INFRASCANNER2_PRODUCT_IDENTIFIER), eq(2))).thenReturn(Arrays.asList(new ProductExecutorConfig(INFRASCANNER2_PRODUCT_IDENTIFIER, 2, new ProductExecutorConfigSetup())));
serviceToTest = new InfrastructureScanProductExecutionServiceImpl(executors);
serviceToTest.productResultRepository = productResultRepository;
productExecutorContextFactory = mock(ProductExecutorContextFactory.class);
serviceToTest.productExecutorContextFactory = productExecutorContextFactory;
serviceToTest.productExecutorConfigRepository = productExecutorConfigRepository;
when(productExecutorContextFactory.create(any(), any(), any(), any())).thenReturn(productExecutorContext);
}
Aggregations