Search in sources :

Example 21 with CommonDistributionConfigEntity

use of com.blackducksoftware.integration.hub.alert.datasource.entity.CommonDistributionConfigEntity 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 22 with CommonDistributionConfigEntity

use of com.blackducksoftware.integration.hub.alert.datasource.entity.CommonDistributionConfigEntity 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 23 with CommonDistributionConfigEntity

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

the class ActionsTest method testConstructRestModel.

@Test
public void testConstructRestModel() throws AlertException {
    Mockito.when(configActions.getConfiguredProjectsActions().getConfiguredProjectsRepository().findOne(1L)).thenReturn(projectMockUtils.getProjectOneEntity());
    Mockito.when(configActions.getConfiguredProjectsActions().getConfiguredProjectsRepository().findOne(2L)).thenReturn(projectMockUtils.getProjectTwoEntity());
    Mockito.when(configActions.getConfiguredProjectsActions().getConfiguredProjectsRepository().findOne(3L)).thenReturn(projectMockUtils.getProjectThreeEntity());
    Mockito.when(configActions.getConfiguredProjectsActions().getConfiguredProjectsRepository().findOne(4L)).thenReturn(projectMockUtils.getProjectFourEntity());
    Mockito.when(configActions.getConfiguredProjectsActions().getDistributionProjectRepository().findByCommonDistributionConfigId(Mockito.anyLong())).thenReturn(projectMockUtils.getProjectRelations());
    final CommonDistributionConfigEntity commonEntity = distributionMockUtils.createEntity();
    final R actualRestModel = configActions.constructRestModel(commonEntity, getEntityMockUtil().createEntity());
    final R expectedRestModel = getRestMockUtil().createRestModel();
    expectedRestModel.setConfiguredProjects(null);
    expectedRestModel.setNotificationTypes(null);
    assertEquals(expectedRestModel, actualRestModel);
}
Also used : CommonDistributionConfigEntity(com.blackducksoftware.integration.hub.alert.datasource.entity.CommonDistributionConfigEntity) Test(org.junit.Test)

Example 24 with CommonDistributionConfigEntity

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

the class DistributionConfigActions method cleanUpStaleChannelConfigurations.

private void cleanUpStaleChannelConfigurations() {
    final String distributionName = getDistributionName();
    if (distributionName != null) {
        final List<D> channelDistributionConfigEntities = getRepository().findAll();
        channelDistributionConfigEntities.forEach(entity -> {
            final CommonDistributionConfigEntity commonEntity = commonDistributionRepository.findByDistributionConfigIdAndDistributionType(entity.getId(), distributionName);
            if (commonEntity == null) {
                getRepository().delete(entity);
            }
        });
    }
}
Also used : CommonDistributionConfigEntity(com.blackducksoftware.integration.hub.alert.datasource.entity.CommonDistributionConfigEntity)

Example 25 with CommonDistributionConfigEntity

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

the class CommonDistributionRepositoryWrapperTest method testFindByDistributionConfigIdAndDistributionType.

@Test
public void testFindByDistributionConfigIdAndDistributionType() throws EncryptionException, IOException {
    final CommonDistributionRepositoryWrapper wrapper = getExceptionThrowingRepositoryWrapper();
    final CommonDistributionConfigEntity entity = wrapper.findByDistributionConfigIdAndDistributionType(1L, "any");
    assertExceptionThrown(entity);
}
Also used : CommonDistributionConfigEntity(com.blackducksoftware.integration.hub.alert.datasource.entity.CommonDistributionConfigEntity) Test(org.junit.Test)

Aggregations

CommonDistributionConfigEntity (com.blackducksoftware.integration.hub.alert.datasource.entity.CommonDistributionConfigEntity)49 Test (org.junit.Test)38 CommonDistributionConfigRestModel (com.blackducksoftware.integration.hub.alert.web.model.distribution.CommonDistributionConfigRestModel)24 CommonDistributionRepositoryWrapper (com.blackducksoftware.integration.hub.alert.datasource.entity.repository.CommonDistributionRepositoryWrapper)22 CommonDistributionConfigActions (com.blackducksoftware.integration.hub.alert.web.actions.distribution.CommonDistributionConfigActions)18 DatabaseConnectionTest (com.blackducksoftware.integration.test.annotation.DatabaseConnectionTest)14 AlertException (com.blackducksoftware.integration.hub.alert.exception.AlertException)7 AlertFieldException (com.blackducksoftware.integration.hub.alert.exception.AlertFieldException)7 AuditEntryEntity (com.blackducksoftware.integration.hub.alert.audit.repository.AuditEntryEntity)6 NotificationEntity (com.blackducksoftware.integration.hub.alert.datasource.entity.NotificationEntity)6 ProjectData (com.blackducksoftware.integration.hub.alert.digest.model.ProjectData)6 DigestTypeEnum (com.blackducksoftware.integration.hub.alert.enumeration.DigestTypeEnum)6 IntegrationException (com.blackducksoftware.integration.exception.IntegrationException)5 AuditNotificationRelation (com.blackducksoftware.integration.hub.alert.audit.repository.relation.AuditNotificationRelation)5 AbstractChannelEvent (com.blackducksoftware.integration.hub.alert.event.AbstractChannelEvent)5 NotificationModel (com.blackducksoftware.integration.hub.alert.hub.model.NotificationModel)5 ConfiguredProjectEntity (com.blackducksoftware.integration.hub.alert.datasource.entity.ConfiguredProjectEntity)4 DistributionProjectRelation (com.blackducksoftware.integration.hub.alert.datasource.relation.DistributionProjectRelation)4 ArrayList (java.util.ArrayList)4 AuditEntryRepositoryWrapper (com.blackducksoftware.integration.hub.alert.audit.repository.AuditEntryRepositoryWrapper)3