Search in sources :

Example 1 with HubServerConfig

use of com.blackducksoftware.integration.hub.configuration.HubServerConfig in project hub-alert by blackducksoftware.

the class TestGlobalProperties method createHubServicesFactoryWithCredential.

public HubServicesFactory createHubServicesFactoryWithCredential(final IntLogger logger) throws Exception {
    setHubUrl(testProperties.getProperty(TestPropertyKey.TEST_HUB_SERVER_URL));
    setHubTrustCertificate(true);
    final HubServerConfig hubServerConfig = createHubServerConfigWithCredentials(logger);
    final RestConnection restConnection = hubServerConfig.createCredentialsRestConnection(logger);
    return new HubServicesFactory(restConnection);
}
Also used : RestConnection(com.blackducksoftware.integration.hub.rest.RestConnection) HubServerConfig(com.blackducksoftware.integration.hub.configuration.HubServerConfig) HubServicesFactory(com.blackducksoftware.integration.hub.service.HubServicesFactory)

Example 2 with HubServerConfig

use of com.blackducksoftware.integration.hub.configuration.HubServerConfig in project hub-alert by blackducksoftware.

the class GlobalHubConfigActionsTest method testCreateRestConnection.

@Test
public void testCreateRestConnection() throws Exception {
    final GlobalHubConfigActions configActions = new GlobalHubConfigActions(null, null, null);
    final String url = "https://www.google.com/";
    final String apiToken = "User";
    HubServerConfigBuilder serverConfigBuilder = new HubServerConfigBuilder();
    serverConfigBuilder.setHubUrl(url);
    serverConfigBuilder.setApiToken(apiToken);
    // we create this spy to skip the server validation that happens in the build method
    serverConfigBuilder = Mockito.spy(serverConfigBuilder);
    Mockito.doAnswer(new Answer<HubServerConfig>() {

        @Override
        public HubServerConfig answer(final InvocationOnMock invocation) throws Throwable {
            final HubServerConfig hubServerConfig = new HubServerConfig(new URL(url), 0, apiToken, new ProxyInfo(null, 0, null, null, null, null), false, new UriCombiner());
            return hubServerConfig;
        }
    }).when(serverConfigBuilder).build();
    final RestConnection restConnection = configActions.createRestConnection(serverConfigBuilder);
    assertNotNull(restConnection);
}
Also used : ProxyInfo(com.blackducksoftware.integration.hub.proxy.ProxyInfo) UriCombiner(com.blackducksoftware.integration.hub.rest.UriCombiner) RestConnection(com.blackducksoftware.integration.hub.rest.RestConnection) HubServerConfig(com.blackducksoftware.integration.hub.configuration.HubServerConfig) InvocationOnMock(org.mockito.invocation.InvocationOnMock) HubServerConfigBuilder(com.blackducksoftware.integration.hub.configuration.HubServerConfigBuilder) GlobalHubConfigActions(com.blackducksoftware.integration.hub.alert.hub.controller.global.GlobalHubConfigActions) URL(java.net.URL) Test(org.junit.Test) GlobalActionsTest(com.blackducksoftware.integration.hub.alert.web.actions.global.GlobalActionsTest)

Aggregations

HubServerConfig (com.blackducksoftware.integration.hub.configuration.HubServerConfig)2 RestConnection (com.blackducksoftware.integration.hub.rest.RestConnection)2 GlobalHubConfigActions (com.blackducksoftware.integration.hub.alert.hub.controller.global.GlobalHubConfigActions)1 GlobalActionsTest (com.blackducksoftware.integration.hub.alert.web.actions.global.GlobalActionsTest)1 HubServerConfigBuilder (com.blackducksoftware.integration.hub.configuration.HubServerConfigBuilder)1 ProxyInfo (com.blackducksoftware.integration.hub.proxy.ProxyInfo)1 UriCombiner (com.blackducksoftware.integration.hub.rest.UriCombiner)1 HubServicesFactory (com.blackducksoftware.integration.hub.service.HubServicesFactory)1 URL (java.net.URL)1 Test (org.junit.Test)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1