Search in sources :

Example 1 with DirectoryOptions

use of com.synopsys.integration.detect.workflow.file.DirectoryOptions in project synopsys-detect by blackducksoftware.

the class DetectConfigurationFactory method createDirectoryOptions.

public DirectoryOptions createDirectoryOptions() throws IOException {
    Path sourcePath = detectConfiguration.getPathOrNull(DetectProperties.DETECT_SOURCE_PATH);
    Path outputPath = detectConfiguration.getPathOrNull(DetectProperties.DETECT_OUTPUT_PATH);
    Path bdioPath = detectConfiguration.getPathOrNull(DetectProperties.DETECT_BDIO_OUTPUT_PATH);
    Path scanPath = detectConfiguration.getPathOrNull(DetectProperties.DETECT_SCAN_OUTPUT_PATH);
    Path toolsOutputPath = detectConfiguration.getPathOrNull(DetectProperties.DETECT_TOOLS_OUTPUT_PATH);
    Path impactOutputPath = detectConfiguration.getPathOrNull(DetectProperties.DETECT_IMPACT_ANALYSIS_OUTPUT_PATH);
    return new DirectoryOptions(sourcePath, outputPath, bdioPath, scanPath, toolsOutputPath, impactOutputPath);
}
Also used : Path(java.nio.file.Path) DirectoryOptions(com.synopsys.integration.detect.workflow.file.DirectoryOptions)

Example 2 with DirectoryOptions

use of com.synopsys.integration.detect.workflow.file.DirectoryOptions in project synopsys-detect by blackducksoftware.

the class FontLoaderTestIT method createTempDirectory.

@BeforeEach
public void createTempDirectory() throws Exception {
    fontDirectory = Files.createTempDirectory("junit_test_font_loader").toFile();
    PropertyConfiguration propertyConfiguration = new PropertyConfiguration(Collections.emptyList());
    Gson gson = new Gson();
    DetectConfigurationFactory detectConfigurationFactory = new DetectConfigurationFactory(new DetectPropertyConfiguration(propertyConfiguration, new SimplePathResolver()), gson);
    ConnectionFactory connectionFactory = new ConnectionFactory(detectConfigurationFactory.createConnectionDetails());
    ArtifactResolver artifactResolver = new ArtifactResolver(connectionFactory, gson);
    InstalledToolManager installedToolManager = new InstalledToolManager();
    InstalledToolLocator installedToolLocator = new InstalledToolLocator(Paths.get(""), new Gson());
    DetectFontInstaller installer = new DetectFontInstaller(artifactResolver, installedToolManager, installedToolLocator);
    DirectoryOptions directoryOptions = new DirectoryOptions(null, null, null, null, fontDirectory.toPath(), null);
    DirectoryManager directoryManager = new DirectoryManager(directoryOptions, DetectRunId.createDefault());
    detectFontLocator = new OnlineDetectFontLocator(installer, directoryManager);
}
Also used : InstalledToolLocator(com.synopsys.integration.detect.tool.cache.InstalledToolLocator) DirectoryManager(com.synopsys.integration.detect.workflow.file.DirectoryManager) Gson(com.google.gson.Gson) SimplePathResolver(com.synopsys.integration.configuration.property.types.path.SimplePathResolver) ArtifactResolver(com.synopsys.integration.detect.workflow.ArtifactResolver) ConnectionFactory(com.synopsys.integration.detect.configuration.connection.ConnectionFactory) InstalledToolManager(com.synopsys.integration.detect.tool.cache.InstalledToolManager) DetectFontInstaller(com.synopsys.integration.detect.workflow.blackduck.font.DetectFontInstaller) DirectoryOptions(com.synopsys.integration.detect.workflow.file.DirectoryOptions) DetectPropertyConfiguration(com.synopsys.integration.detect.configuration.DetectPropertyConfiguration) DetectConfigurationFactory(com.synopsys.integration.detect.configuration.DetectConfigurationFactory) OnlineDetectFontLocator(com.synopsys.integration.detect.workflow.blackduck.font.OnlineDetectFontLocator) PropertyConfiguration(com.synopsys.integration.configuration.config.PropertyConfiguration) DetectPropertyConfiguration(com.synopsys.integration.detect.configuration.DetectPropertyConfiguration) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 3 with DirectoryOptions

use of com.synopsys.integration.detect.workflow.file.DirectoryOptions in project synopsys-detect by blackducksoftware.

the class RapidModeGenerateJsonOperationTest method test.

@Test
void test(@TempDir Path tempPath) throws IOException, DetectUserFriendlyException {
    Gson gson = Mockito.mock(Gson.class);
    File tempDir = tempPath.toFile();
    File scanDir = new File(tempDir, "scan");
    DirectoryOptions directoryOptions = new DirectoryOptions(null, null, null, scanDir.toPath(), null, null);
    DetectRunId detectRunId = new DetectRunId("testId");
    DirectoryManager directoryManager = new DirectoryManager(directoryOptions, detectRunId);
    RapidModeGenerateJsonOperation op = new RapidModeGenerateJsonOperation(gson, directoryManager);
    NameVersion projectNameVersion = new NameVersion("testName", "testVersion");
    List<DeveloperScanComponentResultView> results = new LinkedList<>();
    DeveloperScanComponentResultView resultView = Mockito.mock(DeveloperScanComponentResultView.class);
    results.add(resultView);
    String mockedResultsJsonString = "mocked json string for results";
    Mockito.when(gson.toJson(results)).thenReturn(mockedResultsJsonString);
    File generatedFile = op.generateJsonFile(projectNameVersion, results);
    String expectedFilename = String.format("%s_%s_BlackDuck_DeveloperMode_Result.json", projectNameVersion.getName(), projectNameVersion.getVersion());
    String expectedPath = new File(scanDir, expectedFilename).getAbsolutePath();
    assertEquals(expectedPath, generatedFile.getAbsolutePath());
    String generatedString = FileUtils.readFileToString(generatedFile);
    assertEquals(mockedResultsJsonString, generatedString);
}
Also used : DeveloperScanComponentResultView(com.synopsys.integration.blackduck.api.manual.view.DeveloperScanComponentResultView) DirectoryOptions(com.synopsys.integration.detect.workflow.file.DirectoryOptions) DetectRunId(com.synopsys.integration.detect.workflow.DetectRunId) NameVersion(com.synopsys.integration.util.NameVersion) DirectoryManager(com.synopsys.integration.detect.workflow.file.DirectoryManager) Gson(com.google.gson.Gson) File(java.io.File) LinkedList(java.util.LinkedList) Test(org.junit.jupiter.api.Test)

Aggregations

DirectoryOptions (com.synopsys.integration.detect.workflow.file.DirectoryOptions)3 Gson (com.google.gson.Gson)2 DirectoryManager (com.synopsys.integration.detect.workflow.file.DirectoryManager)2 DeveloperScanComponentResultView (com.synopsys.integration.blackduck.api.manual.view.DeveloperScanComponentResultView)1 PropertyConfiguration (com.synopsys.integration.configuration.config.PropertyConfiguration)1 SimplePathResolver (com.synopsys.integration.configuration.property.types.path.SimplePathResolver)1 DetectConfigurationFactory (com.synopsys.integration.detect.configuration.DetectConfigurationFactory)1 DetectPropertyConfiguration (com.synopsys.integration.detect.configuration.DetectPropertyConfiguration)1 ConnectionFactory (com.synopsys.integration.detect.configuration.connection.ConnectionFactory)1 InstalledToolLocator (com.synopsys.integration.detect.tool.cache.InstalledToolLocator)1 InstalledToolManager (com.synopsys.integration.detect.tool.cache.InstalledToolManager)1 ArtifactResolver (com.synopsys.integration.detect.workflow.ArtifactResolver)1 DetectRunId (com.synopsys.integration.detect.workflow.DetectRunId)1 DetectFontInstaller (com.synopsys.integration.detect.workflow.blackduck.font.DetectFontInstaller)1 OnlineDetectFontLocator (com.synopsys.integration.detect.workflow.blackduck.font.OnlineDetectFontLocator)1 NameVersion (com.synopsys.integration.util.NameVersion)1 File (java.io.File)1 Path (java.nio.file.Path)1 LinkedList (java.util.LinkedList)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1