Search in sources :

Example 1 with ReportProductExecutionService

use of com.mercedesbenz.sechub.domain.scan.product.ReportProductExecutionService in project sechub by mercedes-benz.

the class ReportServiceTest method before.

@Before
public void before() throws Exception {
    serviceToTest = new CreateScanReportService();
    secHubJobUUID = UUID.randomUUID();
    context = mock(SecHubExecutionContext.class);
    configuration = mock(SecHubConfiguration.class);
    when(context.getConfiguration()).thenReturn(configuration);
    when(context.getSechubJobUUID()).thenReturn(secHubJobUUID);
    when(configuration.getProjectId()).thenReturn("project1");
    reportRepository = mock(ScanReportRepository.class);
    /* just return report as given to save method... */
    when(reportRepository.save(any(ScanReport.class))).thenAnswer(new Answer<ScanReport>() {

        @Override
        public ScanReport answer(InvocationOnMock invocation) throws Throwable {
            return (ScanReport) invocation.getArguments()[0];
        }
    });
    scanReportTransactionService = mock(ScanReportTransactionService.class);
    reportProductExecutionService = mock(ReportProductExecutionService.class);
    reportTransformationResult = mock(ReportTransformationResult.class);
    SecHubResult sechubResult = mock(SecHubResult.class);
    when(reportTransformationResult.getResult()).thenReturn(sechubResult);
    secHubResultService = mock(SecHubReportProductTransformerService.class);
    when(secHubResultService.createResult(context)).thenReturn(reportTransformationResult);
    trafficLightCalculator = mock(ScanReportTrafficLightCalculator.class);
    serviceToTest.reportProductExecutionService = reportProductExecutionService;
    serviceToTest.reportTransformerService = secHubResultService;
    serviceToTest.trafficLightCalculator = trafficLightCalculator;
    serviceToTest.reportRepository = reportRepository;
    serviceToTest.scanReportTransactionService = scanReportTransactionService;
}
Also used : ReportTransformationResult(com.mercedesbenz.sechub.domain.scan.ReportTransformationResult) SecHubExecutionContext(com.mercedesbenz.sechub.sharedkernel.execution.SecHubExecutionContext) SecHubConfiguration(com.mercedesbenz.sechub.sharedkernel.configuration.SecHubConfiguration) InvocationOnMock(org.mockito.invocation.InvocationOnMock) SecHubResult(com.mercedesbenz.sechub.commons.model.SecHubResult) ReportProductExecutionService(com.mercedesbenz.sechub.domain.scan.product.ReportProductExecutionService) SecHubReportProductTransformerService(com.mercedesbenz.sechub.domain.scan.SecHubReportProductTransformerService) Before(org.junit.Before)

Aggregations

SecHubResult (com.mercedesbenz.sechub.commons.model.SecHubResult)1 ReportTransformationResult (com.mercedesbenz.sechub.domain.scan.ReportTransformationResult)1 SecHubReportProductTransformerService (com.mercedesbenz.sechub.domain.scan.SecHubReportProductTransformerService)1 ReportProductExecutionService (com.mercedesbenz.sechub.domain.scan.product.ReportProductExecutionService)1 SecHubConfiguration (com.mercedesbenz.sechub.sharedkernel.configuration.SecHubConfiguration)1 SecHubExecutionContext (com.mercedesbenz.sechub.sharedkernel.execution.SecHubExecutionContext)1 Before (org.junit.Before)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1