use of com.blackducksoftware.integration.hub.alert.enumeration.StatusEnum in project hub-alert by blackducksoftware.
the class CommonDistributionConfigActionsTestIT method saveAndGetTestIT.
@Test
public void saveAndGetTestIT() throws AlertException {
final String distributionType = null;
final String name = "My Config";
final String frequency = "DAILY";
final String filterByProject = "true";
final List<String> projectList = Arrays.asList("Project 1", "Project 2", "Project 3");
final List<String> notificationTypeList = Arrays.asList("POLICY_VIOLATION", "VULNERABILITY");
final Date lastRan = new Date(System.currentTimeMillis());
final StatusEnum status = StatusEnum.SUCCESS;
auditEntryRepository.save(new AuditEntryEntity(new Long(-1), lastRan, lastRan, status, "", ""));
final CommonDistributionConfigRestModel commonDistributionConfigRestModel = new CommonDistributionConfigRestModel(null, null, distributionType, name, frequency, filterByProject, projectList, notificationTypeList);
final CommonDistributionConfigActions commonDistributionConfigActions = new CommonDistributionConfigActions(commonDistributionRepository, auditEntryRepository, configuredProjectsActions, notificationTypesActions, objectTransformer);
final CommonDistributionConfigEntity savedEntity = commonDistributionConfigActions.saveConfig(commonDistributionConfigRestModel);
assertEquals(distributionType, savedEntity.getDistributionType());
assertEquals(name, savedEntity.getName());
assertEquals(frequency, savedEntity.getFrequency().name());
assertEquals(filterByProject, savedEntity.getFilterByProject().toString());
assertEquals(projectList.size(), configuredProjectsActions.getDistributionProjectRepository().count());
assertEquals(projectList.size(), configuredProjectsActions.getConfiguredProjectsRepository().count());
assertEquals(notificationTypeList.size(), notificationTypesActions.getDistributionNotificationTypeRepository().count());
assertEquals(notificationTypeList.size(), notificationTypesActions.getNotificationTypeRepository().count());
final CommonDistributionConfigRestModel updatedRestModel = objectTransformer.databaseEntityToConfigRestModel(savedEntity, CommonDistributionConfigRestModel.class);
commonDistributionConfigActions.saveConfig(updatedRestModel);
assertEquals(projectList.size(), configuredProjectsActions.getDistributionProjectRepository().count());
assertEquals(projectList.size(), configuredProjectsActions.getConfiguredProjectsRepository().count());
assertEquals(notificationTypeList.size(), notificationTypesActions.getDistributionNotificationTypeRepository().count());
assertEquals(notificationTypeList.size(), notificationTypesActions.getNotificationTypeRepository().count());
final List<CommonDistributionConfigRestModel> foundRestModels = commonDistributionConfigActions.getConfig(savedEntity.getId());
assertEquals(1, foundRestModels.size());
final CommonDistributionConfigRestModel foundRestModel = foundRestModels.get(0);
assertEquals(savedEntity.getId(), objectTransformer.stringToLong(foundRestModel.getId()));
assertEquals(savedEntity.getDistributionConfigId(), objectTransformer.stringToLong(foundRestModel.getDistributionConfigId()));
assertEquals(savedEntity.getDistributionType(), foundRestModel.getDistributionType());
assertEquals(savedEntity.getFilterByProject(), objectTransformer.stringToBoolean(foundRestModel.getFilterByProject()));
assertEquals(projectList, foundRestModel.getConfiguredProjects());
}
Aggregations