Search in sources :

Example 16 with TestGlobalProperties

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

the class AccumulatorProcessorTestIT method init.

@Before
public void init() throws Exception {
    globalProperties = new TestGlobalProperties();
    final HubServicesFactory hubServicesFactory = globalProperties.createHubServicesFactoryWithCredential(new PrintStreamIntLogger(System.out, LogLevel.TRACE));
    projectService = hubServicesFactory.createProjectService();
    notificationDataService = hubServicesFactory.createNotificationService();
    codeLocationService = hubServicesFactory.createCodeLocationService();
    hubService = hubServicesFactory.createHubService();
}
Also used : PrintStreamIntLogger(com.blackducksoftware.integration.log.PrintStreamIntLogger) HubServicesFactory(com.blackducksoftware.integration.hub.service.HubServicesFactory) TestGlobalProperties(com.blackducksoftware.integration.hub.alert.TestGlobalProperties) Before(org.junit.Before)

Example 17 with TestGlobalProperties

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

the class SlackChannelTestIT method sendMessageTestIT.

@Test
@Category(ExternalConnectionTest.class)
public void sendMessageTestIT() throws IOException, IntegrationException {
    final AuditEntryRepositoryWrapper auditEntryRepository = Mockito.mock(AuditEntryRepositoryWrapper.class);
    final GlobalHubRepositoryWrapper mockedGlobalRepository = Mockito.mock(GlobalHubRepositoryWrapper.class);
    final TestGlobalProperties globalProperties = new TestGlobalProperties(mockedGlobalRepository, null);
    final ChannelRestConnectionFactory channelRestConnectionFactory = new ChannelRestConnectionFactory(globalProperties);
    final SlackChannel slackChannel = new SlackChannel(gson, auditEntryRepository, null, null, channelRestConnectionFactory);
    final String roomName = properties.getProperty(TestPropertyKey.TEST_SLACK_CHANNEL_NAME);
    final String username = properties.getProperty(TestPropertyKey.TEST_SLACK_USERNAME);
    final String webHook = properties.getProperty(TestPropertyKey.TEST_SLACK_WEBHOOK);
    final SlackDistributionConfigEntity config = new SlackDistributionConfigEntity(webHook, username, roomName);
    final ProjectData projectData = createProjectData("Slack test project");
    final SlackEvent event = new SlackEvent(projectData, new Long(0));
    slackChannel.sendAuditedMessage(event, config);
    final boolean actual = outputLogger.isLineContainingText("Successfully sent a slack_channel message!");
    assertTrue(actual);
}
Also used : ChannelRestConnectionFactory(com.blackducksoftware.integration.hub.alert.channel.rest.ChannelRestConnectionFactory) AuditEntryRepositoryWrapper(com.blackducksoftware.integration.hub.alert.audit.repository.AuditEntryRepositoryWrapper) SlackDistributionConfigEntity(com.blackducksoftware.integration.hub.alert.channel.slack.repository.distribution.SlackDistributionConfigEntity) GlobalHubRepositoryWrapper(com.blackducksoftware.integration.hub.alert.datasource.entity.repository.global.GlobalHubRepositoryWrapper) TestGlobalProperties(com.blackducksoftware.integration.hub.alert.TestGlobalProperties) ProjectData(com.blackducksoftware.integration.hub.alert.digest.model.ProjectData) Category(org.junit.experimental.categories.Category) ExternalConnectionTest(com.blackducksoftware.integration.test.annotation.ExternalConnectionTest) Test(org.junit.Test) ChannelTest(com.blackducksoftware.integration.hub.alert.channel.ChannelTest)

Example 18 with TestGlobalProperties

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

the class CommonConfigTest method init.

@Before
public void init() throws IOException {
    outputLogger = new OutputLogger();
    globalProperties = new TestGlobalProperties();
}
Also used : OutputLogger(com.blackducksoftware.integration.hub.alert.OutputLogger) TestGlobalProperties(com.blackducksoftware.integration.hub.alert.TestGlobalProperties) Before(org.junit.Before)

Example 19 with TestGlobalProperties

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

the class EmailChannelTestIT method sendEmailTest.

@Test
@Category(ExternalConnectionTest.class)
public void sendEmailTest() throws Exception {
    final AuditEntryRepositoryWrapper auditEntryRepository = Mockito.mock(AuditEntryRepositoryWrapper.class);
    final GlobalHubRepositoryWrapper globalRepository = Mockito.mock(GlobalHubRepositoryWrapper.class);
    final GlobalHubConfigEntity globalConfig = new GlobalHubConfigEntity(300, properties.getProperty(TestPropertyKey.TEST_HUB_API_KEY));
    Mockito.when(globalRepository.findAll()).thenReturn(Arrays.asList(globalConfig));
    final TestGlobalProperties globalProperties = new TestGlobalProperties(globalRepository);
    globalProperties.setHubUrl(properties.getProperty(TestPropertyKey.TEST_HUB_SERVER_URL));
    final String trustCert = properties.getProperty(TestPropertyKey.TEST_TRUST_HTTPS_CERT);
    if (trustCert != null) {
        globalProperties.setHubTrustCertificate(Boolean.valueOf(trustCert));
    }
    EmailGroupChannel emailChannel = new EmailGroupChannel(globalProperties, gson, auditEntryRepository, null, null, null);
    final ProjectData projectData = createProjectData("Manual test project");
    final EmailGroupEvent event = new EmailGroupEvent(projectData, 1L);
    final String smtpHost = properties.getProperty(TestPropertyKey.TEST_EMAIL_SMTP_HOST);
    final String smtpFrom = properties.getProperty(TestPropertyKey.TEST_EMAIL_SMTP_FROM);
    final GlobalEmailConfigEntity emailGlobalConfigEntity = new GlobalEmailConfigEntity(smtpHost, null, null, null, null, null, smtpFrom, null, null, null, null, null, null, null);
    emailChannel = Mockito.spy(emailChannel);
    Mockito.doReturn(emailGlobalConfigEntity).when(emailChannel).getGlobalConfigEntity();
    final MockEmailEntity mockEmailEntity = new MockEmailEntity();
    mockEmailEntity.setGroupName("IntegrationTest");
    emailChannel.sendAuditedMessage(event, mockEmailEntity.createEntity());
}
Also used : GlobalEmailConfigEntity(com.blackducksoftware.integration.hub.alert.channel.email.repository.global.GlobalEmailConfigEntity) AuditEntryRepositoryWrapper(com.blackducksoftware.integration.hub.alert.audit.repository.AuditEntryRepositoryWrapper) GlobalHubRepositoryWrapper(com.blackducksoftware.integration.hub.alert.datasource.entity.repository.global.GlobalHubRepositoryWrapper) TestGlobalProperties(com.blackducksoftware.integration.hub.alert.TestGlobalProperties) ProjectData(com.blackducksoftware.integration.hub.alert.digest.model.ProjectData) MockEmailEntity(com.blackducksoftware.integration.hub.alert.channel.email.mock.MockEmailEntity) GlobalHubConfigEntity(com.blackducksoftware.integration.hub.alert.datasource.entity.global.GlobalHubConfigEntity) Category(org.junit.experimental.categories.Category) Test(org.junit.Test) ExternalConnectionTest(com.blackducksoftware.integration.test.annotation.ExternalConnectionTest) ChannelTest(com.blackducksoftware.integration.hub.alert.channel.ChannelTest)

Example 20 with TestGlobalProperties

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

the class LoginActionsTestIT method testAuthenticateUserRoleFailIT.

@Test
public void testAuthenticateUserRoleFailIT() throws IntegrationException, IOException {
    mockLoginRestModel.setHubUsername(properties.getProperty(TestPropertyKey.TEST_ACTIVE_USER));
    final LoginActions loginActions = new LoginActions(new TestGlobalProperties());
    final boolean userAuthenticated = loginActions.authenticateUser(mockLoginRestModel.createRestModel(), new Slf4jIntLogger(logger));
    assertFalse(userAuthenticated);
    assertTrue(outputLogger.isLineContainingText("User role not authenticated"));
}
Also used : Slf4jIntLogger(com.blackducksoftware.integration.log.Slf4jIntLogger) TestGlobalProperties(com.blackducksoftware.integration.hub.alert.TestGlobalProperties) Test(org.junit.Test) HubConnectionTest(com.blackducksoftware.integration.test.annotation.HubConnectionTest)

Aggregations

TestGlobalProperties (com.blackducksoftware.integration.hub.alert.TestGlobalProperties)24 Test (org.junit.Test)20 GlobalProperties (com.blackducksoftware.integration.hub.alert.config.GlobalProperties)8 GlobalHubRepositoryWrapper (com.blackducksoftware.integration.hub.alert.datasource.entity.repository.global.GlobalHubRepositoryWrapper)8 ChannelTest (com.blackducksoftware.integration.hub.alert.channel.ChannelTest)6 ChannelRestConnectionFactory (com.blackducksoftware.integration.hub.alert.channel.rest.ChannelRestConnectionFactory)6 GlobalHubConfigActions (com.blackducksoftware.integration.hub.alert.hub.controller.global.GlobalHubConfigActions)5 RestConnection (com.blackducksoftware.integration.hub.rest.RestConnection)5 Slf4jIntLogger (com.blackducksoftware.integration.log.Slf4jIntLogger)5 ExternalConnectionTest (com.blackducksoftware.integration.test.annotation.ExternalConnectionTest)5 HubConnectionTest (com.blackducksoftware.integration.test.annotation.HubConnectionTest)5 AuditEntryRepositoryWrapper (com.blackducksoftware.integration.hub.alert.audit.repository.AuditEntryRepositoryWrapper)4 ProjectData (com.blackducksoftware.integration.hub.alert.digest.model.ProjectData)4 ObjectTransformer (com.blackducksoftware.integration.hub.alert.web.ObjectTransformer)4 IntegrationException (com.blackducksoftware.integration.exception.IntegrationException)3 GlobalHipChatConfigEntity (com.blackducksoftware.integration.hub.alert.channel.hipchat.repository.global.GlobalHipChatConfigEntity)3 GlobalHubConfigEntity (com.blackducksoftware.integration.hub.alert.datasource.entity.global.GlobalHubConfigEntity)3 GlobalHubConfigRestModel (com.blackducksoftware.integration.hub.alert.hub.controller.global.GlobalHubConfigRestModel)3 GlobalActionsTest (com.blackducksoftware.integration.hub.alert.web.actions.global.GlobalActionsTest)3 HubServerConfigBuilder (com.blackducksoftware.integration.hub.configuration.HubServerConfigBuilder)3