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());
}
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());
}
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);
}
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;
}
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;
}
Aggregations