use of com.blackducksoftware.integration.hub.alert.datasource.entity.CommonDistributionConfigEntity in project hub-alert by blackducksoftware.
the class CommonConfigHandlerTest method validateConfigTest.
@Test
public void validateConfigTest() {
final CommonDistributionConfigActions configActions = Mockito.mock(CommonDistributionConfigActions.class);
final CommonConfigHandler<CommonDistributionConfigEntity, CommonDistributionConfigRestModel, CommonDistributionRepositoryWrapper> handler = new CommonConfigHandler<>(CommonDistributionConfigEntity.class, CommonDistributionConfigRestModel.class, configActions, objectTransformer);
final CommonDistributionConfigRestModel restModel = mockCommonDistributionRestModel.createRestModel();
final ResponseEntity<String> response = handler.validateConfig(restModel);
assertEquals(HttpStatus.OK, response.getStatusCode());
}
use of com.blackducksoftware.integration.hub.alert.datasource.entity.CommonDistributionConfigEntity in project hub-alert by blackducksoftware.
the class NotificationPostProcessorTestIT method doNotificationTypesMatchWithNoneConfiguredTest.
@Test
public void doNotificationTypesMatchWithNoneConfiguredTest() {
final DistributionNotificationTypeRepositoryWrapper distributionNotificationTypeRepository = Mockito.mock(DistributionNotificationTypeRepositoryWrapper.class);
final NotificationPostProcessor postProcessor = new NotificationPostProcessor(distributionProjectRepository, configuredProjectsRepository, distributionNotificationTypeRepository, notificationTypeRepository);
Mockito.when(distributionNotificationTypeRepository.findByCommonDistributionConfigId(Mockito.anyLong())).thenReturn(Collections.emptyList());
final ProjectData projectData = new ProjectData(null, null, null, null, null);
final CommonDistributionConfigEntity config = new CommonDistributionConfigEntity(13L, SupportedChannels.EMAIL_GROUP, "Config 1", DigestTypeEnum.DAILY, true);
config.setId(13L);
assertFalse(postProcessor.doNotificationTypesMatch(config, projectData));
}
use of com.blackducksoftware.integration.hub.alert.datasource.entity.CommonDistributionConfigEntity in project hub-alert by blackducksoftware.
the class CommonConfigHandlerTest method putConfigTest.
@Test
public void putConfigTest() throws IntegrationException {
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(true);
Mockito.when(configActions.validateConfig(Mockito.any())).thenReturn("");
Mockito.when(configActions.saveNewConfigUpdateFromSavedConfig(Mockito.any())).thenReturn(new CommonDistributionConfigEntity());
final CommonDistributionConfigRestModel restModel = mockCommonDistributionRestModel.createRestModel();
final ResponseEntity<String> response = handler.putConfig(restModel);
assertEquals(HttpStatus.ACCEPTED, response.getStatusCode());
}
use of com.blackducksoftware.integration.hub.alert.datasource.entity.CommonDistributionConfigEntity in project hub-alert by blackducksoftware.
the class CommonConfigHandlerTest method validateConfigWithInvalidConfigTest.
@Test
public void validateConfigWithInvalidConfigTest() throws AlertFieldException {
final CommonDistributionConfigActions configActions = Mockito.mock(CommonDistributionConfigActions.class);
final CommonConfigHandler<CommonDistributionConfigEntity, CommonDistributionConfigRestModel, CommonDistributionRepositoryWrapper> handler = new CommonConfigHandler<>(CommonDistributionConfigEntity.class, CommonDistributionConfigRestModel.class, configActions, objectTransformer);
Mockito.when(configActions.validateConfig(Mockito.any())).thenThrow(new AlertFieldException(Collections.emptyMap()));
Mockito.when(configActions.getObjectTransformer()).thenReturn(objectTransformer);
final CommonDistributionConfigRestModel restModel = mockCommonDistributionRestModel.createRestModel();
final ResponseEntity<String> response = handler.validateConfig(restModel);
assertEquals(HttpStatus.BAD_REQUEST, response.getStatusCode());
}
Aggregations