Search in sources :

Example 1 with SimplePathResolver

use of com.synopsys.integration.configuration.property.types.path.SimplePathResolver in project synopsys-detect by blackducksoftware.

the class DetectConfigurationTest method testDeprecated.

@Test
public void testDeprecated() throws DetectUserFriendlyException {
    HashMap<String, String> values = new HashMap<>();
    values.put(DetectProperties.DETECT_BDIO2_ENABLED.getKey(), "false");
    List<PropertySource> propertySources = new ArrayList<>();
    propertySources.add(new MapPropertySource("test", values));
    PropertyConfiguration propertyConfiguration = new PropertyConfiguration(propertySources);
    DetectPropertyConfiguration detectPropertyConfiguration = new DetectPropertyConfiguration(propertyConfiguration, new SimplePathResolver());
    DetectConfigurationFactory detectConfigurationFactory = new DetectConfigurationFactory(detectPropertyConfiguration, new Gson());
    BdioOptions bdioOptions = detectConfigurationFactory.createBdioOptions();
    Assertions.assertFalse(bdioOptions.isBdio2Enabled());
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Gson(com.google.gson.Gson) SimplePathResolver(com.synopsys.integration.configuration.property.types.path.SimplePathResolver) MapPropertySource(com.synopsys.integration.configuration.source.MapPropertySource) PropertySource(com.synopsys.integration.configuration.source.PropertySource) BdioOptions(com.synopsys.integration.detect.workflow.bdio.BdioOptions) MapPropertySource(com.synopsys.integration.configuration.source.MapPropertySource) PropertyConfiguration(com.synopsys.integration.configuration.config.PropertyConfiguration) Test(org.junit.jupiter.api.Test)

Example 2 with SimplePathResolver

use of com.synopsys.integration.configuration.property.types.path.SimplePathResolver in project synopsys-detect by blackducksoftware.

the class DetectConfigurationFactoryTestUtils method factoryOf.

@SafeVarargs
public static DetectConfigurationFactory factoryOf(Pair<Property, String>... properties) {
    Map<String, String> propertyMap = Bds.of(properties).toMap(pair -> pair.getLeft().getKey(), Pair::getRight);
    PropertySource inMemoryPropertySource = new MapPropertySource("test", propertyMap);
    PropertyConfiguration propertyConfiguration = new PropertyConfiguration(Collections.singletonList(inMemoryPropertySource));
    DetectPropertyConfiguration detectPropertyConfiguration = new DetectPropertyConfiguration(propertyConfiguration, new SimplePathResolver());
    return new DetectConfigurationFactory(detectPropertyConfiguration, new Gson());
}
Also used : MapPropertySource(com.synopsys.integration.configuration.source.MapPropertySource) Gson(com.google.gson.Gson) SimplePathResolver(com.synopsys.integration.configuration.property.types.path.SimplePathResolver) PropertyConfiguration(com.synopsys.integration.configuration.config.PropertyConfiguration) Pair(org.apache.commons.lang3.tuple.Pair) MapPropertySource(com.synopsys.integration.configuration.source.MapPropertySource) PropertySource(com.synopsys.integration.configuration.source.PropertySource)

Example 3 with SimplePathResolver

use of com.synopsys.integration.configuration.property.types.path.SimplePathResolver in project synopsys-detect by blackducksoftware.

the class DetectConfigurationTest method testGenericProperty.

@Test
public void testGenericProperty() {
    HashMap<String, String> values = new HashMap<>();
    values.put(DetectProperties.DETECT_PROJECT_CODELOCATION_PREFIX.getKey(), "some_prefix");
    List<PropertySource> propertySources = new ArrayList<>();
    propertySources.add(new MapPropertySource("test", values));
    PropertyConfiguration propertyConfiguration = new PropertyConfiguration(propertySources);
    DetectPropertyConfiguration detectPropertyConfiguration = new DetectPropertyConfiguration(propertyConfiguration, new SimplePathResolver());
    DetectConfigurationFactory detectConfigurationFactory = new DetectConfigurationFactory(detectPropertyConfiguration, new Gson());
    BdioOptions bdioOptions = detectConfigurationFactory.createBdioOptions();
    assertTrue(bdioOptions.getProjectCodeLocationPrefix().isPresent());
    assertEquals("some_prefix", bdioOptions.getProjectCodeLocationPrefix().get());
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Gson(com.google.gson.Gson) SimplePathResolver(com.synopsys.integration.configuration.property.types.path.SimplePathResolver) MapPropertySource(com.synopsys.integration.configuration.source.MapPropertySource) PropertySource(com.synopsys.integration.configuration.source.PropertySource) BdioOptions(com.synopsys.integration.detect.workflow.bdio.BdioOptions) MapPropertySource(com.synopsys.integration.configuration.source.MapPropertySource) PropertyConfiguration(com.synopsys.integration.configuration.config.PropertyConfiguration) Test(org.junit.jupiter.api.Test)

Example 4 with SimplePathResolver

use of com.synopsys.integration.configuration.property.types.path.SimplePathResolver in project synopsys-detect by blackducksoftware.

the class BlackDuckConnectionDecisionBranch method traverse.

@Override
public void traverse(InteractivePropertySourceBuilder propertySourceBuilder, InteractiveWriter writer) {
    boolean shouldReconfigureServer = true;
    BlackDuckConnectivityResult blackDuckConnectivityResult = BlackDuckConnectivityResult.failure("Connection has yet to be attempted.");
    BlackDuckServerDecisionBranch blackDuckServerDecisionBranch = new BlackDuckServerDecisionBranch();
    while (!blackDuckConnectivityResult.isSuccessfullyConnected() && shouldReconfigureServer) {
        blackDuckServerDecisionBranch.traverse(propertySourceBuilder, writer);
        Boolean testConnection = writer.askYesOrNo(SHOULD_TEST_CONNECTION);
        if (testConnection) {
            try {
                MapPropertySource interactivePropertySource = propertySourceBuilder.build();
                List<PropertySource> propertySources = new ArrayList<>(this.existingPropertySources);
                propertySources.add(0, interactivePropertySource);
                PropertyConfiguration propertyConfiguration = new PropertyConfiguration(propertySources);
                DetectPropertyConfiguration detectConfiguration = new DetectPropertyConfiguration(propertyConfiguration, new SimplePathResolver());
                DetectConfigurationFactory detectConfigurationFactory = new DetectConfigurationFactory(detectConfiguration, gson);
                BlackDuckConfigFactory blackDuckConfigFactory = new BlackDuckConfigFactory(detectInfo, detectConfigurationFactory.createBlackDuckConnectionDetails());
                BlackDuckServerConfig blackDuckServerConfig = blackDuckConfigFactory.createServerConfig(new SilentIntLogger());
                blackDuckConnectivityResult = blackDuckConnectivityChecker.determineConnectivity(blackDuckServerConfig);
            } catch (Exception e) {
                blackDuckConnectivityResult = BlackDuckConnectivityResult.failure("Failed to test connection. " + System.lineSeparator() + e);
            }
            if (!blackDuckConnectivityResult.isSuccessfullyConnected()) {
                writer.println(blackDuckConnectivityResult.getFailureReason());
                shouldReconfigureServer = writer.askYesOrNo(SHOULD_RETRY_CONNECTION);
            }
        } else {
            shouldReconfigureServer = false;
        }
    }
}
Also used : BlackDuckConnectivityResult(com.synopsys.integration.detect.lifecycle.boot.product.BlackDuckConnectivityResult) ArrayList(java.util.ArrayList) SimplePathResolver(com.synopsys.integration.configuration.property.types.path.SimplePathResolver) MapPropertySource(com.synopsys.integration.configuration.source.MapPropertySource) PropertySource(com.synopsys.integration.configuration.source.PropertySource) BlackDuckServerConfig(com.synopsys.integration.blackduck.configuration.BlackDuckServerConfig) SilentIntLogger(com.synopsys.integration.log.SilentIntLogger) DetectPropertyConfiguration(com.synopsys.integration.detect.configuration.DetectPropertyConfiguration) MapPropertySource(com.synopsys.integration.configuration.source.MapPropertySource) DetectConfigurationFactory(com.synopsys.integration.detect.configuration.DetectConfigurationFactory) DetectPropertyConfiguration(com.synopsys.integration.detect.configuration.DetectPropertyConfiguration) PropertyConfiguration(com.synopsys.integration.configuration.config.PropertyConfiguration) BlackDuckConfigFactory(com.synopsys.integration.detect.configuration.connection.BlackDuckConfigFactory)

Example 5 with SimplePathResolver

use of com.synopsys.integration.configuration.property.types.path.SimplePathResolver 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)

Aggregations

SimplePathResolver (com.synopsys.integration.configuration.property.types.path.SimplePathResolver)8 PropertyConfiguration (com.synopsys.integration.configuration.config.PropertyConfiguration)7 Gson (com.google.gson.Gson)5 MapPropertySource (com.synopsys.integration.configuration.source.MapPropertySource)5 PropertySource (com.synopsys.integration.configuration.source.PropertySource)4 DetectConfigurationFactory (com.synopsys.integration.detect.configuration.DetectConfigurationFactory)4 DetectPropertyConfiguration (com.synopsys.integration.detect.configuration.DetectPropertyConfiguration)4 InstalledToolLocator (com.synopsys.integration.detect.tool.cache.InstalledToolLocator)3 PathResolver (com.synopsys.integration.configuration.property.types.path.PathResolver)2 ConnectionFactory (com.synopsys.integration.detect.configuration.connection.ConnectionFactory)2 InstalledToolManager (com.synopsys.integration.detect.tool.cache.InstalledToolManager)2 ArtifactResolver (com.synopsys.integration.detect.workflow.ArtifactResolver)2 BdioOptions (com.synopsys.integration.detect.workflow.bdio.BdioOptions)2 DirectoryManager (com.synopsys.integration.detect.workflow.file.DirectoryManager)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Test (org.junit.jupiter.api.Test)2 BlackDuckServerConfig (com.synopsys.integration.blackduck.configuration.BlackDuckServerConfig)1 TildeInPathResolver (com.synopsys.integration.configuration.property.types.path.TildeInPathResolver)1 DetectUserFriendlyException (com.synopsys.integration.detect.configuration.DetectUserFriendlyException)1