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());
}
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());
}
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());
}
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;
}
}
}
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);
}
Aggregations