Search in sources :

Example 1 with NoThreadExecutorService

use of com.synopsys.integration.util.NoThreadExecutorService in project blackduck-common by blackducksoftware.

the class BlackDuckServerConfigBuilderTest method testPopulatingExecutorService.

@Test
public void testPopulatingExecutorService() throws Exception {
    ExecutorService executorService = null;
    try {
        executorService = Executors.newSingleThreadExecutor();
        BlackDuckServerConfigBuilder blackDuckServerConfigBuilder = BlackDuckServerConfig.newApiTokenBuilder();
        blackDuckServerConfigBuilder.setUrl(GOOD_URL);
        blackDuckServerConfigBuilder.setApiToken(API_TOKEN);
        BlackDuckServerConfig blackDuckServerConfig = blackDuckServerConfigBuilder.build();
        Field executorServiceField = BlackDuckServerConfig.class.getDeclaredField("executorService");
        executorServiceField.setAccessible(true);
        assertTrue(executorServiceField.get(blackDuckServerConfig) instanceof NoThreadExecutorService);
        assertNotNull(blackDuckServerConfigBuilder.getExecutorService());
        blackDuckServerConfigBuilder.setExecutorService(executorService);
        assertEquals(executorService, blackDuckServerConfigBuilder.getExecutorService().orElse(null));
        blackDuckServerConfig = blackDuckServerConfigBuilder.build();
        assertNotNull(executorServiceField.get(blackDuckServerConfig));
    } finally {
        assert executorService != null;
        executorService.shutdownNow();
    }
}
Also used : NoThreadExecutorService(com.synopsys.integration.util.NoThreadExecutorService) Field(java.lang.reflect.Field) ExecutorService(java.util.concurrent.ExecutorService) NoThreadExecutorService(com.synopsys.integration.util.NoThreadExecutorService) Test(org.junit.jupiter.api.Test)

Example 2 with NoThreadExecutorService

use of com.synopsys.integration.util.NoThreadExecutorService in project synopsys-detect by blackducksoftware.

the class ImpactAnalysisTestIT method testImpactAnalysisForDetect.

@Test
public void testImpactAnalysisForDetect() throws IOException, IntegrationException {
    BlackDuckTestConnection blackDuckTestConnection = BlackDuckTestConnection.fromEnvironment();
    NameVersion projectNameVersion = new NameVersion("synopsys-detect-junit", "impact-analysis");
    BlackDuckServicesFactory blackDuckServicesFactory = blackDuckTestConnection.getBlackDuckServicesFactory();
    File toScan = new File("./");
    Path outputDirectory = outputDirAsPath.toPath();
    ImpactAnalysisNamingOperation impactAnalysisNamingOperation = new ImpactAnalysisNamingOperation(codeLocationNameManager);
    String impactAnalysisCodeLocationName = impactAnalysisNamingOperation.createCodeLocationName(toScan, projectNameVersion);
    GenerateImpactAnalysisOperation generateImpactAnalysisOperation = new GenerateImpactAnalysisOperation();
    Path impactAnalysisFile = generateImpactAnalysisOperation.generateImpactAnalysis(toScan, impactAnalysisCodeLocationName, outputDirectory);
    ImpactAnalysisBatchRunner impactAnalysisBatchRunner = new ImpactAnalysisBatchRunner(logger, blackDuckServicesFactory.getBlackDuckApiClient(), blackDuckServicesFactory.getApiDiscovery(), new NoThreadExecutorService(), blackDuckServicesFactory.getGson());
    ImpactAnalysisUploadService impactAnalysisUploadService = new ImpactAnalysisUploadService(impactAnalysisBatchRunner, blackDuckServicesFactory.createCodeLocationCreationService());
    ImpactAnalysisUploadOperation impactAnalysisUploadOperation = new ImpactAnalysisUploadOperation(impactAnalysisUploadService);
    CodeLocationCreationData<ImpactAnalysisBatchOutput> creationData = impactAnalysisUploadOperation.uploadImpactAnalysis(impactAnalysisFile, projectNameVersion, impactAnalysisCodeLocationName);
    assertEquals(1, creationData.getOutput().getOutputs().size());
    assertEquals(Result.SUCCESS, creationData.getOutput().getOutputs().get(0).getResult());
}
Also used : Path(java.nio.file.Path) NameVersion(com.synopsys.integration.util.NameVersion) BlackDuckServicesFactory(com.synopsys.integration.blackduck.service.BlackDuckServicesFactory) ImpactAnalysisUploadService(com.synopsys.integration.detect.tool.impactanalysis.service.ImpactAnalysisUploadService) NoThreadExecutorService(com.synopsys.integration.util.NoThreadExecutorService) ImpactAnalysisBatchRunner(com.synopsys.integration.detect.tool.impactanalysis.service.ImpactAnalysisBatchRunner) ImpactAnalysisBatchOutput(com.synopsys.integration.detect.tool.impactanalysis.service.ImpactAnalysisBatchOutput) BlackDuckTestConnection(com.synopsys.integration.detect.battery.docker.integration.BlackDuckTestConnection) File(java.io.File) Test(org.junit.jupiter.api.Test)

Example 3 with NoThreadExecutorService

use of com.synopsys.integration.util.NoThreadExecutorService in project blackduck-docker-inspector by blackducksoftware.

the class BlackDuckClient method createBlackDuckServicesFactory.

private BlackDuckServicesFactory createBlackDuckServicesFactory(IntLogger intLogger, BlackDuckHttpClient httpConnection) {
    IntEnvironmentVariables intEnvironmentVariables = IntEnvironmentVariables.empty();
    ExecutorService executorService = new NoThreadExecutorService();
    BlackDuckRequestFactory blackDuckRequestFactory = new BlackDuckRequestFactory();
    return new BlackDuckServicesFactory(intEnvironmentVariables, new Gson(), BlackDuckServicesFactory.createDefaultObjectMapper(), executorService, httpConnection, intLogger, blackDuckRequestFactory);
}
Also used : NoThreadExecutorService(com.synopsys.integration.util.NoThreadExecutorService) IntEnvironmentVariables(com.synopsys.integration.util.IntEnvironmentVariables) BlackDuckRequestFactory(com.synopsys.integration.blackduck.http.BlackDuckRequestFactory) ExecutorService(java.util.concurrent.ExecutorService) NoThreadExecutorService(com.synopsys.integration.util.NoThreadExecutorService) Gson(com.google.gson.Gson) BlackDuckServicesFactory(com.synopsys.integration.blackduck.service.BlackDuckServicesFactory)

Aggregations

NoThreadExecutorService (com.synopsys.integration.util.NoThreadExecutorService)3 BlackDuckServicesFactory (com.synopsys.integration.blackduck.service.BlackDuckServicesFactory)2 ExecutorService (java.util.concurrent.ExecutorService)2 Test (org.junit.jupiter.api.Test)2 Gson (com.google.gson.Gson)1 BlackDuckRequestFactory (com.synopsys.integration.blackduck.http.BlackDuckRequestFactory)1 BlackDuckTestConnection (com.synopsys.integration.detect.battery.docker.integration.BlackDuckTestConnection)1 ImpactAnalysisBatchOutput (com.synopsys.integration.detect.tool.impactanalysis.service.ImpactAnalysisBatchOutput)1 ImpactAnalysisBatchRunner (com.synopsys.integration.detect.tool.impactanalysis.service.ImpactAnalysisBatchRunner)1 ImpactAnalysisUploadService (com.synopsys.integration.detect.tool.impactanalysis.service.ImpactAnalysisUploadService)1 IntEnvironmentVariables (com.synopsys.integration.util.IntEnvironmentVariables)1 NameVersion (com.synopsys.integration.util.NameVersion)1 File (java.io.File)1 Field (java.lang.reflect.Field)1 Path (java.nio.file.Path)1