Search in sources :

Example 11 with CommonDistributionRepositoryWrapper

use of com.blackducksoftware.integration.hub.alert.datasource.entity.repository.CommonDistributionRepositoryWrapper in project hub-alert by blackducksoftware.

the class CommonConfigHandlerTest method postConfigTest.

@Test
public void postConfigTest() throws AlertException {
    final CommonDistributionConfigActions configActions = Mockito.mock(CommonDistributionConfigActions.class);
    final CommonConfigHandler<CommonDistributionConfigEntity, CommonDistributionConfigRestModel, CommonDistributionRepositoryWrapper> handler = new CommonConfigHandler<>(CommonDistributionConfigEntity.class, CommonDistributionConfigRestModel.class, configActions, objectTransformer);
    Mockito.when(configActions.doesConfigExist(Mockito.anyString())).thenReturn(false);
    Mockito.when(configActions.saveConfig(Mockito.any())).thenReturn(new CommonDistributionConfigEntity());
    final CommonDistributionConfigRestModel restModel = mockCommonDistributionRestModel.createRestModel();
    final ResponseEntity<String> response = handler.postConfig(restModel);
    assertEquals(HttpStatus.CREATED, response.getStatusCode());
}
Also used : CommonDistributionConfigActions(com.blackducksoftware.integration.hub.alert.web.actions.distribution.CommonDistributionConfigActions) CommonDistributionRepositoryWrapper(com.blackducksoftware.integration.hub.alert.datasource.entity.repository.CommonDistributionRepositoryWrapper) CommonDistributionConfigRestModel(com.blackducksoftware.integration.hub.alert.web.model.distribution.CommonDistributionConfigRestModel) CommonDistributionConfigEntity(com.blackducksoftware.integration.hub.alert.datasource.entity.CommonDistributionConfigEntity) Test(org.junit.Test)

Example 12 with CommonDistributionRepositoryWrapper

use of com.blackducksoftware.integration.hub.alert.datasource.entity.repository.CommonDistributionRepositoryWrapper in project hub-alert by blackducksoftware.

the class CommonConfigHandlerTest method putConfigWithInvalidIdTest.

@Test
public void putConfigWithInvalidIdTest() {
    final CommonDistributionConfigActions configActions = Mockito.mock(CommonDistributionConfigActions.class);
    final CommonConfigHandler<CommonDistributionConfigEntity, CommonDistributionConfigRestModel, CommonDistributionRepositoryWrapper> handler = new CommonConfigHandler<>(CommonDistributionConfigEntity.class, CommonDistributionConfigRestModel.class, configActions, objectTransformer);
    Mockito.when(configActions.doesConfigExist(Mockito.anyString())).thenReturn(false);
    final CommonDistributionConfigRestModel restModel = mockCommonDistributionRestModel.createRestModel();
    final ResponseEntity<String> response = handler.putConfig(restModel);
    assertEquals(HttpStatus.BAD_REQUEST, response.getStatusCode());
}
Also used : CommonDistributionConfigActions(com.blackducksoftware.integration.hub.alert.web.actions.distribution.CommonDistributionConfigActions) CommonDistributionRepositoryWrapper(com.blackducksoftware.integration.hub.alert.datasource.entity.repository.CommonDistributionRepositoryWrapper) CommonDistributionConfigRestModel(com.blackducksoftware.integration.hub.alert.web.model.distribution.CommonDistributionConfigRestModel) CommonDistributionConfigEntity(com.blackducksoftware.integration.hub.alert.datasource.entity.CommonDistributionConfigEntity) Test(org.junit.Test)

Example 13 with CommonDistributionRepositoryWrapper

use of com.blackducksoftware.integration.hub.alert.datasource.entity.repository.CommonDistributionRepositoryWrapper in project hub-alert by blackducksoftware.

the class DistributionChannelTest method handleEventWrongTypeTest.

@Test
public void handleEventWrongTypeTest() {
    final GlobalProperties globalProperties = new TestGlobalProperties();
    final Gson gson = new Gson();
    final CommonDistributionRepositoryWrapper commonRepositoryWrapper = Mockito.mock(CommonDistributionRepositoryWrapper.class);
    final EmailGroupChannel channel = new EmailGroupChannel(globalProperties, gson, null, null, null, commonRepositoryWrapper);
    final Long commonId = 1L;
    final EmailGroupEvent event = new EmailGroupEvent(createProjectData("Distribution Channel Test"), commonId);
    final CommonDistributionConfigEntity commonEntity = new CommonDistributionConfigEntity(commonId, SupportedChannels.SLACK, "Other Config", DigestTypeEnum.REAL_TIME, false);
    Mockito.when(commonRepositoryWrapper.findOne(Mockito.anyLong())).thenReturn(commonEntity);
    channel.handleEvent(event);
}
Also used : CommonDistributionRepositoryWrapper(com.blackducksoftware.integration.hub.alert.datasource.entity.repository.CommonDistributionRepositoryWrapper) EmailGroupEvent(com.blackducksoftware.integration.hub.alert.channel.email.EmailGroupEvent) TestGlobalProperties(com.blackducksoftware.integration.hub.alert.TestGlobalProperties) GlobalProperties(com.blackducksoftware.integration.hub.alert.config.GlobalProperties) CommonDistributionConfigEntity(com.blackducksoftware.integration.hub.alert.datasource.entity.CommonDistributionConfigEntity) EmailGroupChannel(com.blackducksoftware.integration.hub.alert.channel.email.EmailGroupChannel) Gson(com.google.gson.Gson) TestGlobalProperties(com.blackducksoftware.integration.hub.alert.TestGlobalProperties) Test(org.junit.Test)

Example 14 with CommonDistributionRepositoryWrapper

use of com.blackducksoftware.integration.hub.alert.datasource.entity.repository.CommonDistributionRepositoryWrapper in project hub-alert by blackducksoftware.

the class HipChatConfigActionsTest method createMockedConfigActionsUsingObjectTransformer.

@Override
public HipChatDistributionConfigActions createMockedConfigActionsUsingObjectTransformer(final ObjectTransformer objectTransformer) {
    final HipChatManager hipChatManager = Mockito.mock(HipChatManager.class);
    final HipChatDistributionRepositoryWrapper mockedHipChatRepository = Mockito.mock(HipChatDistributionRepositoryWrapper.class);
    final CommonDistributionRepositoryWrapper commonRepository = Mockito.mock(CommonDistributionRepositoryWrapper.class);
    final ConfiguredProjectsRepositoryWrapper projectsRepository = Mockito.mock(ConfiguredProjectsRepositoryWrapper.class);
    final DistributionProjectRepositoryWrapper distributionProjectRepository = Mockito.mock(DistributionProjectRepositoryWrapper.class);
    final ConfiguredProjectsActions<HipChatDistributionRestModel> projectsAction = new ConfiguredProjectsActions<>(projectsRepository, distributionProjectRepository);
    final NotificationTypeRepositoryWrapper notificationRepository = Mockito.mock(NotificationTypeRepositoryWrapper.class);
    final DistributionNotificationTypeRepositoryWrapper notificationDistributionRepository = Mockito.mock(DistributionNotificationTypeRepositoryWrapper.class);
    final NotificationTypesActions<HipChatDistributionRestModel> notificationAction = new NotificationTypesActions<>(notificationRepository, notificationDistributionRepository);
    final HipChatDistributionConfigActions configActions = new HipChatDistributionConfigActions(commonRepository, mockedHipChatRepository, projectsAction, notificationAction, objectTransformer, hipChatManager);
    return configActions;
}
Also used : NotificationTypeRepositoryWrapper(com.blackducksoftware.integration.hub.alert.datasource.entity.repository.NotificationTypeRepositoryWrapper) DistributionNotificationTypeRepositoryWrapper(com.blackducksoftware.integration.hub.alert.datasource.relation.repository.DistributionNotificationTypeRepositoryWrapper) HipChatDistributionRepositoryWrapper(com.blackducksoftware.integration.hub.alert.channel.hipchat.repository.distribution.HipChatDistributionRepositoryWrapper) NotificationTypesActions(com.blackducksoftware.integration.hub.alert.web.actions.NotificationTypesActions) ConfiguredProjectsRepositoryWrapper(com.blackducksoftware.integration.hub.alert.datasource.entity.repository.ConfiguredProjectsRepositoryWrapper) DistributionNotificationTypeRepositoryWrapper(com.blackducksoftware.integration.hub.alert.datasource.relation.repository.DistributionNotificationTypeRepositoryWrapper) ConfiguredProjectsActions(com.blackducksoftware.integration.hub.alert.web.actions.ConfiguredProjectsActions) CommonDistributionRepositoryWrapper(com.blackducksoftware.integration.hub.alert.datasource.entity.repository.CommonDistributionRepositoryWrapper) DistributionProjectRepositoryWrapper(com.blackducksoftware.integration.hub.alert.datasource.relation.repository.DistributionProjectRepositoryWrapper) HipChatManager(com.blackducksoftware.integration.hub.alert.channel.hipchat.HipChatManager)

Example 15 with CommonDistributionRepositoryWrapper

use of com.blackducksoftware.integration.hub.alert.datasource.entity.repository.CommonDistributionRepositoryWrapper in project hub-alert by blackducksoftware.

the class SlackConfigActionsTest method createMockedConfigActionsUsingObjectTransformer.

@Override
public SlackDistributionConfigActions createMockedConfigActionsUsingObjectTransformer(final ObjectTransformer objectTransformer) {
    final SlackManager slackManager = Mockito.mock(SlackManager.class);
    final SlackDistributionRepositoryWrapper mockedSlackRepository = Mockito.mock(SlackDistributionRepositoryWrapper.class);
    final CommonDistributionRepositoryWrapper commonRepository = Mockito.mock(CommonDistributionRepositoryWrapper.class);
    final ConfiguredProjectsRepositoryWrapper projectsRepository = Mockito.mock(ConfiguredProjectsRepositoryWrapper.class);
    final DistributionProjectRepositoryWrapper distributionProjectRepository = Mockito.mock(DistributionProjectRepositoryWrapper.class);
    final ConfiguredProjectsActions<SlackDistributionRestModel> projectsAction = new ConfiguredProjectsActions<>(projectsRepository, distributionProjectRepository);
    final NotificationTypeRepositoryWrapper notificationRepository = Mockito.mock(NotificationTypeRepositoryWrapper.class);
    final DistributionNotificationTypeRepositoryWrapper notificationDistributionRepository = Mockito.mock(DistributionNotificationTypeRepositoryWrapper.class);
    final NotificationTypesActions<SlackDistributionRestModel> notificationAction = new NotificationTypesActions<>(notificationRepository, notificationDistributionRepository);
    final SlackDistributionConfigActions configActions = new SlackDistributionConfigActions(commonRepository, mockedSlackRepository, projectsAction, notificationAction, objectTransformer, slackManager);
    return configActions;
}
Also used : SlackManager(com.blackducksoftware.integration.hub.alert.channel.slack.SlackManager) NotificationTypeRepositoryWrapper(com.blackducksoftware.integration.hub.alert.datasource.entity.repository.NotificationTypeRepositoryWrapper) DistributionNotificationTypeRepositoryWrapper(com.blackducksoftware.integration.hub.alert.datasource.relation.repository.DistributionNotificationTypeRepositoryWrapper) NotificationTypesActions(com.blackducksoftware.integration.hub.alert.web.actions.NotificationTypesActions) ConfiguredProjectsRepositoryWrapper(com.blackducksoftware.integration.hub.alert.datasource.entity.repository.ConfiguredProjectsRepositoryWrapper) DistributionNotificationTypeRepositoryWrapper(com.blackducksoftware.integration.hub.alert.datasource.relation.repository.DistributionNotificationTypeRepositoryWrapper) ConfiguredProjectsActions(com.blackducksoftware.integration.hub.alert.web.actions.ConfiguredProjectsActions) CommonDistributionRepositoryWrapper(com.blackducksoftware.integration.hub.alert.datasource.entity.repository.CommonDistributionRepositoryWrapper) DistributionProjectRepositoryWrapper(com.blackducksoftware.integration.hub.alert.datasource.relation.repository.DistributionProjectRepositoryWrapper) SlackDistributionRepositoryWrapper(com.blackducksoftware.integration.hub.alert.channel.slack.repository.distribution.SlackDistributionRepositoryWrapper)

Aggregations

CommonDistributionRepositoryWrapper (com.blackducksoftware.integration.hub.alert.datasource.entity.repository.CommonDistributionRepositoryWrapper)25 Test (org.junit.Test)22 CommonDistributionConfigEntity (com.blackducksoftware.integration.hub.alert.datasource.entity.CommonDistributionConfigEntity)20 CommonDistributionConfigActions (com.blackducksoftware.integration.hub.alert.web.actions.distribution.CommonDistributionConfigActions)18 CommonDistributionConfigRestModel (com.blackducksoftware.integration.hub.alert.web.model.distribution.CommonDistributionConfigRestModel)18 AlertFieldException (com.blackducksoftware.integration.hub.alert.exception.AlertFieldException)5 AlertException (com.blackducksoftware.integration.hub.alert.exception.AlertException)4 AuditEntryRepositoryWrapper (com.blackducksoftware.integration.hub.alert.audit.repository.AuditEntryRepositoryWrapper)3 ConfiguredProjectsRepositoryWrapper (com.blackducksoftware.integration.hub.alert.datasource.entity.repository.ConfiguredProjectsRepositoryWrapper)3 NotificationTypeRepositoryWrapper (com.blackducksoftware.integration.hub.alert.datasource.entity.repository.NotificationTypeRepositoryWrapper)3 DistributionNotificationTypeRepositoryWrapper (com.blackducksoftware.integration.hub.alert.datasource.relation.repository.DistributionNotificationTypeRepositoryWrapper)3 DistributionProjectRepositoryWrapper (com.blackducksoftware.integration.hub.alert.datasource.relation.repository.DistributionProjectRepositoryWrapper)3 ConfiguredProjectsActions (com.blackducksoftware.integration.hub.alert.web.actions.ConfiguredProjectsActions)3 NotificationTypesActions (com.blackducksoftware.integration.hub.alert.web.actions.NotificationTypesActions)3 IntegrationException (com.blackducksoftware.integration.exception.IntegrationException)2 NotificationManager (com.blackducksoftware.integration.hub.alert.NotificationManager)2 TestGlobalProperties (com.blackducksoftware.integration.hub.alert.TestGlobalProperties)2 MockAuditEntryEntity (com.blackducksoftware.integration.hub.alert.audit.mock.MockAuditEntryEntity)2 AuditNotificationRepositoryWrapper (com.blackducksoftware.integration.hub.alert.audit.repository.AuditNotificationRepositoryWrapper)2 EmailGroupChannel (com.blackducksoftware.integration.hub.alert.channel.email.EmailGroupChannel)2