use of com.synopsys.integration.alert.common.persistence.accessor.FieldUtility in project hub-alert by blackducksoftware.
the class JiraCloudPropertiesFactory method createJiraProperties.
public JiraCloudProperties createJiraProperties() throws AlertConfigurationException {
ConfigurationModel jiraServerGlobalConfig = configurationModelConfigurationAccessor.getConfigurationsByDescriptorKeyAndContext(channelKey, ConfigContextEnum.GLOBAL).stream().findAny().orElseThrow(() -> new AlertConfigurationException("Missing Jira Cloud global configuration"));
FieldUtility fieldUtility = new FieldUtility(jiraServerGlobalConfig.getCopyOfKeyToFieldMap());
return createJiraProperties(fieldUtility);
}
use of com.synopsys.integration.alert.common.persistence.accessor.FieldUtility in project hub-alert by blackducksoftware.
the class BlackDuckDistributionFieldModelTestActionTest method verifyProjectNameVersionPatternCheckIsFasterWithMatchingProjectNamePatternTest.
@Disabled
@Test
@Tag(TestTags.DEFAULT_PERFORMANCE)
public void verifyProjectNameVersionPatternCheckIsFasterWithMatchingProjectNamePatternTest() throws IntegrationException {
FieldUtility fieldUtility = createFieldUtilityData(null, "0.0.*");
FieldUtility fasterFieldUtility = createFieldUtilityData("project 2*", "0.0.*");
BlackDuckDistributionFieldModelTestAction testAction = createTestAction();
long startTest1 = System.nanoTime();
MessageResult messageResult = testAction.testConfig(null, null, fieldUtility);
long endTest1 = System.nanoTime();
long slowTime = endTest1 - startTest1;
long startTest2 = System.nanoTime();
MessageResult fasterResult = testAction.testConfig(null, null, fasterFieldUtility);
long endTest2 = System.nanoTime();
long fastTime = endTest2 - startTest2;
assertEquals(messageResult, fasterResult);
assertTrue(fastTime < slowTime, "config with project name pattern should be faster: Fast time " + fastTime + " Slow time " + slowTime);
}
use of com.synopsys.integration.alert.common.persistence.accessor.FieldUtility in project hub-alert by blackducksoftware.
the class BlackDuckDistributionFieldModelTestActionTest method testConfigWithProjectVersionNamePatternNotMatchingTest.
@Test
public void testConfigWithProjectVersionNamePatternNotMatchingTest() throws IntegrationException {
FieldUtility fieldUtility = createFieldUtilityData(null, "wrong");
BlackDuckDistributionFieldModelTestAction testAction = createTestAction();
MessageResult messageResult = testAction.testConfig(null, null, fieldUtility);
assertNotNull(messageResult);
assertFalse(messageResult.hasErrors(), messageResult.getFieldStatusesBySeverity(FieldStatusSeverity.ERROR).toString());
assertTrue(messageResult.hasWarnings(), messageResult.getFieldStatusesBySeverity(FieldStatusSeverity.WARNING).toString());
assertEquals(1, messageResult.getFieldStatuses().size(), messageResult.getFieldStatuses().toString());
}
use of com.synopsys.integration.alert.common.persistence.accessor.FieldUtility in project hub-alert by blackducksoftware.
the class BlackDuckDistributionFieldModelTestActionTest method testConfigWithProjectNamePatternNotMatchingTest.
@Test
public void testConfigWithProjectNamePatternNotMatchingTest() throws IntegrationException {
FieldUtility fieldUtility = createFieldUtilityData("fake*", null);
BlackDuckDistributionFieldModelTestAction testAction = createTestAction();
MessageResult messageResult = testAction.testConfig(null, null, fieldUtility);
assertNotNull(messageResult);
assertFalse(messageResult.hasErrors(), messageResult.getFieldStatusesBySeverity(FieldStatusSeverity.ERROR).toString());
assertTrue(messageResult.hasWarnings(), messageResult.getFieldStatusesBySeverity(FieldStatusSeverity.WARNING).toString());
assertEquals(1, messageResult.getFieldStatuses().size(), messageResult.getFieldStatuses().toString());
}
use of com.synopsys.integration.alert.common.persistence.accessor.FieldUtility in project hub-alert by blackducksoftware.
the class LdapManagerTest method testUpdate.
@Test
public void testUpdate() throws Exception {
ConfigurationModel configurationModel = createConfigurationModel();
DefaultConfigurationModelConfigurationAccessor configurationModelConfigurationAccessor = Mockito.mock(DefaultConfigurationModelConfigurationAccessor.class);
UserManagementAuthoritiesPopulator authoritiesPopulator = Mockito.mock(UserManagementAuthoritiesPopulator.class);
Mockito.when(configurationModelConfigurationAccessor.getConfigurationsByDescriptorKey(Mockito.any(DescriptorKey.class))).thenReturn(List.of(configurationModel));
LdapManager ldapManager = new LdapManager(AUTHENTICATION_DESCRIPTOR_KEY, configurationModelConfigurationAccessor, authoritiesPopulator, LDAP_USER_CONTEXT_MAPPER);
FieldUtility updatedProperties = ldapManager.getCurrentConfiguration();
assertEquals(DEFAULT_ENABLED, updatedProperties.getField(AuthenticationDescriptor.KEY_LDAP_ENABLED).flatMap(field -> field.getFieldValue()).orElse(null));
assertEquals(DEFAULT_SERVER, updatedProperties.getField(AuthenticationDescriptor.KEY_LDAP_SERVER).flatMap(field -> field.getFieldValue()).orElse(null));
assertEquals(DEFAULT_MANAGER_DN, updatedProperties.getField(AuthenticationDescriptor.KEY_LDAP_MANAGER_DN).flatMap(field -> field.getFieldValue()).orElse(null));
assertEquals(DEFAULT_MANAGER_PASSWORD, updatedProperties.getField(AuthenticationDescriptor.KEY_LDAP_MANAGER_PWD).flatMap(field -> field.getFieldValue()).orElse(null));
assertEquals(DEFAULT_AUTHENTICATION_TYPE, updatedProperties.getField(AuthenticationDescriptor.KEY_LDAP_AUTHENTICATION_TYPE).flatMap(field -> field.getFieldValue()).orElse(null));
assertEquals(DEFAULT_REFERRAL, updatedProperties.getField(AuthenticationDescriptor.KEY_LDAP_REFERRAL).flatMap(field -> field.getFieldValue()).orElse(null));
assertEquals(DEFAULT_USER_SEARCH_BASE, updatedProperties.getField(AuthenticationDescriptor.KEY_LDAP_USER_SEARCH_BASE).flatMap(field -> field.getFieldValue()).orElse(null));
assertEquals(DEFAULT_USER_SEARCH_FILTER, updatedProperties.getField(AuthenticationDescriptor.KEY_LDAP_USER_SEARCH_FILTER).flatMap(field -> field.getFieldValue()).orElse(null));
assertEquals(DEFAULT_USER_DN_PATTERNS, updatedProperties.getField(AuthenticationDescriptor.KEY_LDAP_USER_DN_PATTERNS).flatMap(field -> field.getFieldValue()).orElse(null));
assertEquals(DEFAULT_USER_ATTRIBUTES, updatedProperties.getField(AuthenticationDescriptor.KEY_LDAP_USER_ATTRIBUTES).flatMap(field -> field.getFieldValue()).orElse(null));
assertEquals(DEFAULT_GROUP_SEARCH_BASE, updatedProperties.getField(AuthenticationDescriptor.KEY_LDAP_GROUP_SEARCH_BASE).flatMap(field -> field.getFieldValue()).orElse(null));
assertEquals(DEFAULT_GROUP_SEARCH_FILTER, updatedProperties.getField(AuthenticationDescriptor.KEY_LDAP_GROUP_SEARCH_FILTER).flatMap(field -> field.getFieldValue()).orElse(null));
assertEquals(DEFAULT_GROUP_ROLE_ATTRIBUTE, updatedProperties.getField(AuthenticationDescriptor.KEY_LDAP_GROUP_ROLE_ATTRIBUTE).flatMap(field -> field.getFieldValue()).orElse(null));
}
Aggregations