Search in sources :

Example 21 with CommonDistributionRepositoryWrapper

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

the class CommonConfigHandlerTest method putWithInvalidConfigTest.

@Test
public void putWithInvalidConfigTest() 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.doesConfigExist(Mockito.anyString())).thenReturn(true);
    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.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) AlertFieldException(com.blackducksoftware.integration.hub.alert.exception.AlertFieldException) Test(org.junit.Test)

Example 22 with CommonDistributionRepositoryWrapper

use of com.blackducksoftware.integration.hub.alert.datasource.entity.repository.CommonDistributionRepositoryWrapper 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());
}
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 23 with CommonDistributionRepositoryWrapper

use of com.blackducksoftware.integration.hub.alert.datasource.entity.repository.CommonDistributionRepositoryWrapper 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());
}
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 24 with CommonDistributionRepositoryWrapper

use of com.blackducksoftware.integration.hub.alert.datasource.entity.repository.CommonDistributionRepositoryWrapper 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());
}
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) AlertFieldException(com.blackducksoftware.integration.hub.alert.exception.AlertFieldException) Test(org.junit.Test)

Example 25 with CommonDistributionRepositoryWrapper

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

the class AuditEntryActionsTest method testResendNotificationException.

@Test
public void testResendNotificationException() {
    final AuditEntryRepositoryWrapper auditEntryRepository = Mockito.mock(AuditEntryRepositoryWrapper.class);
    final NotificationRepositoryWrapper notificationRepository = Mockito.mock(NotificationRepositoryWrapper.class);
    final VulnerabilityRepositoryWrapper vulnerabilityRepository = Mockito.mock(VulnerabilityRepositoryWrapper.class);
    final AuditNotificationRepositoryWrapper auditNotificationRepository = Mockito.mock(AuditNotificationRepositoryWrapper.class);
    final CommonDistributionRepositoryWrapper commonDistributionRepositoryWrapper = Mockito.mock(CommonDistributionRepositoryWrapper.class);
    final MockAuditEntryEntity mockAuditEntryEntity = new MockAuditEntryEntity();
    final MockNotificationEntity mockNotificationEntity = new MockNotificationEntity();
    Mockito.when(auditEntryRepository.findOne(Mockito.anyLong())).thenReturn(mockAuditEntryEntity.createEmptyEntity());
    Mockito.when(commonDistributionRepositoryWrapper.findOne(Mockito.anyLong())).thenReturn(null);
    Mockito.when(notificationRepository.findAll(Mockito.any())).thenReturn(Arrays.asList(mockNotificationEntity.createEntity()));
    final AuditEntryActions auditEntryActions = new AuditEntryActions(auditEntryRepository, new NotificationManager(notificationRepository, vulnerabilityRepository, auditEntryRepository, auditNotificationRepository), auditNotificationRepository, commonDistributionRepositoryWrapper, null, null, null, null);
    List<AuditEntryRestModel> restModel = null;
    try {
        restModel = auditEntryActions.resendNotification(1L);
        fail();
    } catch (final IllegalArgumentException e) {
        assertTrue(true);
    } catch (final IntegrationException e) {
        fail();
    }
    assertNull(restModel);
}
Also used : AuditNotificationRepositoryWrapper(com.blackducksoftware.integration.hub.alert.audit.repository.AuditNotificationRepositoryWrapper) NotificationRepositoryWrapper(com.blackducksoftware.integration.hub.alert.datasource.entity.repository.NotificationRepositoryWrapper) NotificationManager(com.blackducksoftware.integration.hub.alert.NotificationManager) IntegrationException(com.blackducksoftware.integration.exception.IntegrationException) AuditEntryRepositoryWrapper(com.blackducksoftware.integration.hub.alert.audit.repository.AuditEntryRepositoryWrapper) CommonDistributionRepositoryWrapper(com.blackducksoftware.integration.hub.alert.datasource.entity.repository.CommonDistributionRepositoryWrapper) MockNotificationEntity(com.blackducksoftware.integration.hub.alert.mock.entity.MockNotificationEntity) AuditNotificationRepositoryWrapper(com.blackducksoftware.integration.hub.alert.audit.repository.AuditNotificationRepositoryWrapper) VulnerabilityRepositoryWrapper(com.blackducksoftware.integration.hub.alert.datasource.entity.repository.VulnerabilityRepositoryWrapper) MockAuditEntryEntity(com.blackducksoftware.integration.hub.alert.audit.mock.MockAuditEntryEntity) Test(org.junit.Test)

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