use of com.synopsys.integration.detect.lifecycle.boot.product.BlackDuckConnectivityResult in project synopsys-detect by blackducksoftware.
the class ProductBootTest method blackDuckConnectionSuccessWithTestReturnsNull.
@Test
public void blackDuckConnectionSuccessWithTestReturnsNull() throws DetectUserFriendlyException, IOException, IntegrationException {
BlackDuckConnectivityResult connectivityResult = BlackDuckConnectivityResult.success(Mockito.mock(BlackDuckServicesFactory.class), Mockito.mock(BlackDuckServerConfig.class));
ProductRunData productRunData = testBoot(BlackDuckDecision.runOnline(BlackduckScanMode.INTELLIGENT), new ProductBootOptions(false, true), connectivityResult);
Assertions.assertNull(productRunData);
}
use of com.synopsys.integration.detect.lifecycle.boot.product.BlackDuckConnectivityResult 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.detect.lifecycle.boot.product.BlackDuckConnectivityResult in project synopsys-detect by blackducksoftware.
the class ProductBootTest method blackDuckFailureWithIgnoreReturnsFalse.
@Test
public void blackDuckFailureWithIgnoreReturnsFalse() throws DetectUserFriendlyException, IOException, IntegrationException {
BlackDuckConnectivityResult connectivityResult = BlackDuckConnectivityResult.failure("Failed to connect");
ProductRunData productRunData = testBoot(BlackDuckDecision.runOnline(BlackduckScanMode.INTELLIGENT), new ProductBootOptions(true, false), connectivityResult);
Assertions.assertFalse(productRunData.shouldUseBlackDuckProduct());
}
use of com.synopsys.integration.detect.lifecycle.boot.product.BlackDuckConnectivityResult in project synopsys-detect by blackducksoftware.
the class ProductBootTest method blackDuckOnlyWorks.
@Test
public void blackDuckOnlyWorks() throws DetectUserFriendlyException, IOException, IntegrationException {
BlackDuckConnectivityResult connectivityResult = BlackDuckConnectivityResult.success(Mockito.mock(BlackDuckServicesFactory.class), Mockito.mock(BlackDuckServerConfig.class));
ProductRunData productRunData = testBoot(BlackDuckDecision.runOnline(BlackduckScanMode.INTELLIGENT), new ProductBootOptions(false, false), connectivityResult);
Assertions.assertTrue(productRunData.shouldUseBlackDuckProduct());
}
use of com.synopsys.integration.detect.lifecycle.boot.product.BlackDuckConnectivityResult in project synopsys-detect by blackducksoftware.
the class ProductBootTest method blackDuckConnectionFailureWithTestThrows.
@Test
public void blackDuckConnectionFailureWithTestThrows() {
BlackDuckConnectivityResult connectivityResult = BlackDuckConnectivityResult.failure("Failed to connect");
Assertions.assertThrows(DetectUserFriendlyException.class, () -> testBoot(BlackDuckDecision.runOnline(BlackduckScanMode.INTELLIGENT), new ProductBootOptions(false, true), connectivityResult));
}
Aggregations