Search in sources :

Example 1 with BlackDuckConnectivityResult

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);
}
Also used : BlackDuckConnectivityResult(com.synopsys.integration.detect.lifecycle.boot.product.BlackDuckConnectivityResult) ProductBootOptions(com.synopsys.integration.detect.lifecycle.boot.product.ProductBootOptions) BlackDuckServicesFactory(com.synopsys.integration.blackduck.service.BlackDuckServicesFactory) ProductRunData(com.synopsys.integration.detect.lifecycle.run.data.ProductRunData) BlackDuckServerConfig(com.synopsys.integration.blackduck.configuration.BlackDuckServerConfig) Test(org.junit.jupiter.api.Test)

Example 2 with BlackDuckConnectivityResult

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;
        }
    }
}
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 3 with BlackDuckConnectivityResult

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());
}
Also used : BlackDuckConnectivityResult(com.synopsys.integration.detect.lifecycle.boot.product.BlackDuckConnectivityResult) ProductBootOptions(com.synopsys.integration.detect.lifecycle.boot.product.ProductBootOptions) ProductRunData(com.synopsys.integration.detect.lifecycle.run.data.ProductRunData) Test(org.junit.jupiter.api.Test)

Example 4 with BlackDuckConnectivityResult

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());
}
Also used : BlackDuckConnectivityResult(com.synopsys.integration.detect.lifecycle.boot.product.BlackDuckConnectivityResult) ProductBootOptions(com.synopsys.integration.detect.lifecycle.boot.product.ProductBootOptions) BlackDuckServicesFactory(com.synopsys.integration.blackduck.service.BlackDuckServicesFactory) ProductRunData(com.synopsys.integration.detect.lifecycle.run.data.ProductRunData) BlackDuckServerConfig(com.synopsys.integration.blackduck.configuration.BlackDuckServerConfig) Test(org.junit.jupiter.api.Test)

Example 5 with BlackDuckConnectivityResult

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));
}
Also used : BlackDuckConnectivityResult(com.synopsys.integration.detect.lifecycle.boot.product.BlackDuckConnectivityResult) ProductBootOptions(com.synopsys.integration.detect.lifecycle.boot.product.ProductBootOptions) Test(org.junit.jupiter.api.Test)

Aggregations

BlackDuckConnectivityResult (com.synopsys.integration.detect.lifecycle.boot.product.BlackDuckConnectivityResult)6 ProductBootOptions (com.synopsys.integration.detect.lifecycle.boot.product.ProductBootOptions)5 Test (org.junit.jupiter.api.Test)5 BlackDuckServerConfig (com.synopsys.integration.blackduck.configuration.BlackDuckServerConfig)3 ProductRunData (com.synopsys.integration.detect.lifecycle.run.data.ProductRunData)3 BlackDuckServicesFactory (com.synopsys.integration.blackduck.service.BlackDuckServicesFactory)2 PropertyConfiguration (com.synopsys.integration.configuration.config.PropertyConfiguration)1 SimplePathResolver (com.synopsys.integration.configuration.property.types.path.SimplePathResolver)1 MapPropertySource (com.synopsys.integration.configuration.source.MapPropertySource)1 PropertySource (com.synopsys.integration.configuration.source.PropertySource)1 DetectConfigurationFactory (com.synopsys.integration.detect.configuration.DetectConfigurationFactory)1 DetectPropertyConfiguration (com.synopsys.integration.detect.configuration.DetectPropertyConfiguration)1 BlackDuckConfigFactory (com.synopsys.integration.detect.configuration.connection.BlackDuckConfigFactory)1 SilentIntLogger (com.synopsys.integration.log.SilentIntLogger)1 ArrayList (java.util.ArrayList)1