use of com.synopsys.integration.configuration.source.PropertySource 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.source.PropertySource in project synopsys-detect by blackducksoftware.
the class DetectConfigurationTest method testPhoneHomePassthroughProperties.
@Test
public void testPhoneHomePassthroughProperties() {
final String givenKeyPhoneHomePart = "x.y.z";
final String givenKeyFull = "detect.phone.home.passthrough." + givenKeyPhoneHomePart;
final String givenValue = "testValue";
HashMap<String, String> values = new HashMap<>();
values.put(givenKeyFull, givenValue);
List<PropertySource> propertySources = new ArrayList<>();
propertySources.add(new MapPropertySource("test", values));
PropertyConfiguration propertyConfiguration = new PropertyConfiguration(propertySources);
Map<String, String> phoneHomePropertiesMap = propertyConfiguration.getRaw(DetectProperties.PHONEHOME_PASSTHROUGH);
assertEquals(givenValue, phoneHomePropertiesMap.get(givenKeyPhoneHomePart));
}
use of com.synopsys.integration.configuration.source.PropertySource in project synopsys-detect by blackducksoftware.
the class MultiplePropertySourceTests method valueFromSecondaryWhenNotInPrimary.
@Test
public void valueFromSecondaryWhenNotInPrimary() throws InvalidPropertyException {
NullableAlikeProperty<String> property = new NullableStringProperty("any.key");
PropertySource secondarySource = propertySourceOf("secondaryName", Pair.of(property.getKey(), "secondaryValue"));
PropertySource primarySource = propertySourceOf("primaryName");
PropertyConfiguration config = configOf(primarySource, secondarySource);
Assertions.assertEquals(Optional.of("secondaryValue"), config.getValue(property));
Assertions.assertEquals(Optional.of("secondaryName"), config.getPropertySource(property));
}
use of com.synopsys.integration.configuration.source.PropertySource in project synopsys-detect by blackducksoftware.
the class MultiplePropertySourceTests method containsKeysFromBothSources.
@Test
public void containsKeysFromBothSources() {
NullableAlikeProperty<String> primaryProperty = new NullableStringProperty("primary.key");
PropertySource primarySource = propertySourceOf("primaryName", Pair.of(primaryProperty.getKey(), "primaryValue"));
NullableAlikeProperty<String> secondaryProperty = new NullableStringProperty("secondary.key");
PropertySource secondarySource = propertySourceOf("secondaryName", Pair.of(secondaryProperty.getKey(), "secondaryValue"));
PropertyConfiguration config = configOf(primarySource, secondarySource);
Assertions.assertEquals(Bds.setOf(primaryProperty.getKey(), secondaryProperty.getKey()), config.getKeys());
}
use of com.synopsys.integration.configuration.source.PropertySource in project synopsys-detect by blackducksoftware.
the class PropertyConfigurationTest method getRawPassthroughPrimary.
@Test
public void getRawPassthroughPrimary() {
PassthroughProperty passthrough = new PassthroughProperty("pass");
PropertySource secondarySource = propertySourceOf("secondary", Pair.of("pass.shared", "secondaryValue"));
PropertySource primarySource = propertySourceOf("primary", Pair.of("pass.shared", "primaryValue"));
PropertyConfiguration configuration = configOf(primarySource, secondarySource);
Map<String, String> properties = Bds.mapOf(Pair.of("shared", "primaryValue"));
Assertions.assertEquals(properties, configuration.getRaw(passthrough));
}
Aggregations