use of com.synopsys.integration.alert.common.persistence.model.mutable.ConfigurationModelMutable in project hub-alert by blackducksoftware.
the class ConfigurationModelTest method createMutableCopyTest.
@Test
public void createMutableCopyTest() {
ConfigurationModel configurationModel = createConfigurationModel();
ConfigurationModelMutable configurationModelMutable = configurationModel.createMutableCopy();
assertEquals(configurationModel, configurationModelMutable);
assertNotSame(configurationModel, configurationModelMutable);
}
use of com.synopsys.integration.alert.common.persistence.model.mutable.ConfigurationModelMutable in project hub-alert by blackducksoftware.
the class DefaultNotificationAccessorTest method createConfigurationModel.
private ConfigurationModelMutable createConfigurationModel() {
ConfigurationModelMutable configurationModel = new ConfigurationModelMutable(1L, 1L, "createdAt-test", "lastUpdate-test", ConfigContextEnum.DISTRIBUTION);
ConfigurationFieldModel configurationFieldModel = ConfigurationFieldModel.create(KEY_PROVIDER_CONFIG_NAME);
configurationFieldModel.setFieldValue(fieldValue);
configurationModel.put(configurationFieldModel);
return configurationModel;
}
use of com.synopsys.integration.alert.common.persistence.model.mutable.ConfigurationModelMutable in project hub-alert by blackducksoftware.
the class DefaultConfigurationModelConfigurationAccessor method createConfigModel.
private ConfigurationModelMutable createConfigModel(Long descriptorId, Long configId, OffsetDateTime createdAt, OffsetDateTime lastUpdated, Long contextId) {
String configContext = getContextById(contextId);
String createdAtFormatted = DateUtils.formatDate(createdAt, DateUtils.UTC_DATE_FORMAT_TO_MINUTE);
String lastUpdatedFormatted = DateUtils.formatDate(lastUpdated, DateUtils.UTC_DATE_FORMAT_TO_MINUTE);
ConfigurationModelMutable newModel = new ConfigurationModelMutable(descriptorId, configId, createdAtFormatted, lastUpdatedFormatted, configContext);
List<FieldValueEntity> fieldValueEntities = fieldValueRepository.findByConfigId(configId);
for (FieldValueEntity fieldValueEntity : fieldValueEntities) {
DefinedFieldEntity definedFieldEntity = definedFieldRepository.findById(fieldValueEntity.getFieldId()).orElseThrow(() -> new AlertRuntimeException("Field Id missing from the database"));
String fieldKey = definedFieldEntity.getKey();
ConfigurationFieldModel fieldModel = BooleanUtils.isTrue(definedFieldEntity.getSensitive()) ? ConfigurationFieldModel.createSensitive(fieldKey) : ConfigurationFieldModel.create(fieldKey);
String decryptedValue = decrypt(fieldValueEntity.getValue(), fieldModel.isSensitive());
fieldModel.setFieldValue(decryptedValue);
newModel.put(fieldModel);
}
return newModel;
}
use of com.synopsys.integration.alert.common.persistence.model.mutable.ConfigurationModelMutable in project hub-alert by blackducksoftware.
the class PurgeTaskTest method cronExpressionNotDefault.
@Test
public void cronExpressionNotDefault() {
final String notDefaultValue = "44";
ConfigurationModelConfigurationAccessor configurationModelConfigurationAccessor = Mockito.mock(ConfigurationModelConfigurationAccessor.class);
ConfigurationModelMutable configurationModel = new ConfigurationModelMutable(1L, 1L, null, null, ConfigContextEnum.GLOBAL);
ConfigurationFieldModel configurationFieldModel = ConfigurationFieldModel.create(SchedulingDescriptor.KEY_PURGE_DATA_FREQUENCY_DAYS);
configurationFieldModel.setFieldValue(notDefaultValue);
configurationModel.put(configurationFieldModel);
Mockito.when(configurationModelConfigurationAccessor.getConfigurationsByDescriptorKey(Mockito.any(DescriptorKey.class))).thenReturn(List.of(configurationModel));
PurgeTask task = new PurgeTask(new SchedulingDescriptorKey(), null, null, null, null, configurationModelConfigurationAccessor);
String cronWithNotDefault = task.scheduleCronExpression();
String expectedCron = String.format(PurgeTask.CRON_FORMAT, notDefaultValue);
assertEquals(expectedCron, cronWithNotDefault);
}
use of com.synopsys.integration.alert.common.persistence.model.mutable.ConfigurationModelMutable in project hub-alert by blackducksoftware.
the class LdapManagerTest method createConfigurationModel.
private ConfigurationModel createConfigurationModel() {
ConfigurationModelMutable configurationModel = new ConfigurationModelMutable(1L, 1L, null, null, ConfigContextEnum.GLOBAL);
ConfigurationFieldModel enabledField = ConfigurationFieldModel.create(AuthenticationDescriptor.KEY_LDAP_ENABLED);
ConfigurationFieldModel serverField = ConfigurationFieldModel.create(AuthenticationDescriptor.KEY_LDAP_SERVER);
ConfigurationFieldModel managerDNField = ConfigurationFieldModel.create(AuthenticationDescriptor.KEY_LDAP_MANAGER_DN);
ConfigurationFieldModel managerPasswordField = ConfigurationFieldModel.createSensitive(AuthenticationDescriptor.KEY_LDAP_MANAGER_PWD);
ConfigurationFieldModel authenticationTypeField = ConfigurationFieldModel.create(AuthenticationDescriptor.KEY_LDAP_AUTHENTICATION_TYPE);
ConfigurationFieldModel referralField = ConfigurationFieldModel.create(AuthenticationDescriptor.KEY_LDAP_REFERRAL);
ConfigurationFieldModel userSearchBaseField = ConfigurationFieldModel.create(AuthenticationDescriptor.KEY_LDAP_USER_SEARCH_BASE);
ConfigurationFieldModel userSearchFilterField = ConfigurationFieldModel.create(AuthenticationDescriptor.KEY_LDAP_USER_SEARCH_FILTER);
ConfigurationFieldModel userDNPatternsField = ConfigurationFieldModel.create(AuthenticationDescriptor.KEY_LDAP_USER_DN_PATTERNS);
ConfigurationFieldModel userAttributesField = ConfigurationFieldModel.create(AuthenticationDescriptor.KEY_LDAP_USER_ATTRIBUTES);
ConfigurationFieldModel groupSearchBaseField = ConfigurationFieldModel.create(AuthenticationDescriptor.KEY_LDAP_GROUP_SEARCH_BASE);
ConfigurationFieldModel groupSearchFilterField = ConfigurationFieldModel.create(AuthenticationDescriptor.KEY_LDAP_GROUP_SEARCH_FILTER);
ConfigurationFieldModel groupRoleAttributeField = ConfigurationFieldModel.create(AuthenticationDescriptor.KEY_LDAP_GROUP_ROLE_ATTRIBUTE);
enabledField.setFieldValue(DEFAULT_ENABLED);
serverField.setFieldValue(DEFAULT_SERVER);
managerDNField.setFieldValue(DEFAULT_MANAGER_DN);
managerPasswordField.setFieldValue(DEFAULT_MANAGER_PASSWORD);
authenticationTypeField.setFieldValue(DEFAULT_AUTHENTICATION_TYPE);
referralField.setFieldValue(DEFAULT_REFERRAL);
userSearchBaseField.setFieldValue(DEFAULT_USER_SEARCH_BASE);
userSearchFilterField.setFieldValue(DEFAULT_USER_SEARCH_FILTER);
userDNPatternsField.setFieldValue(DEFAULT_USER_DN_PATTERNS);
userAttributesField.setFieldValue(DEFAULT_USER_ATTRIBUTES);
groupSearchBaseField.setFieldValue(DEFAULT_GROUP_SEARCH_BASE);
groupSearchFilterField.setFieldValue(DEFAULT_GROUP_SEARCH_FILTER);
groupRoleAttributeField.setFieldValue(DEFAULT_GROUP_ROLE_ATTRIBUTE);
configurationModel.put(enabledField);
configurationModel.put(serverField);
configurationModel.put(managerDNField);
configurationModel.put(managerPasswordField);
configurationModel.put(authenticationTypeField);
configurationModel.put(referralField);
configurationModel.put(userSearchBaseField);
configurationModel.put(userSearchFilterField);
configurationModel.put(userDNPatternsField);
configurationModel.put(userAttributesField);
configurationModel.put(groupSearchBaseField);
configurationModel.put(groupSearchFilterField);
configurationModel.put(groupRoleAttributeField);
return configurationModel;
}
Aggregations