Search in sources :

Example 21 with FieldUtility

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);
}
Also used : ConfigurationModel(com.synopsys.integration.alert.common.persistence.model.ConfigurationModel) FieldUtility(com.synopsys.integration.alert.common.persistence.accessor.FieldUtility) AlertConfigurationException(com.synopsys.integration.alert.api.common.model.exception.AlertConfigurationException)

Example 22 with 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);
}
Also used : MessageResult(com.synopsys.integration.alert.common.message.model.MessageResult) FieldUtility(com.synopsys.integration.alert.common.persistence.accessor.FieldUtility) Test(org.junit.jupiter.api.Test) Tag(org.junit.jupiter.api.Tag) Disabled(org.junit.jupiter.api.Disabled)

Example 23 with FieldUtility

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());
}
Also used : MessageResult(com.synopsys.integration.alert.common.message.model.MessageResult) FieldUtility(com.synopsys.integration.alert.common.persistence.accessor.FieldUtility) Test(org.junit.jupiter.api.Test)

Example 24 with FieldUtility

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());
}
Also used : MessageResult(com.synopsys.integration.alert.common.message.model.MessageResult) FieldUtility(com.synopsys.integration.alert.common.persistence.accessor.FieldUtility) Test(org.junit.jupiter.api.Test)

Example 25 with FieldUtility

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));
}
Also used : ConfigurationModel(com.synopsys.integration.alert.common.persistence.model.ConfigurationModel) UserManagementAuthoritiesPopulator(com.synopsys.integration.alert.component.authentication.security.UserManagementAuthoritiesPopulator) DescriptorKey(com.synopsys.integration.alert.descriptor.api.model.DescriptorKey) AuthenticationDescriptorKey(com.synopsys.integration.alert.component.authentication.descriptor.AuthenticationDescriptorKey) FieldUtility(com.synopsys.integration.alert.common.persistence.accessor.FieldUtility) DefaultConfigurationModelConfigurationAccessor(com.synopsys.integration.alert.database.api.DefaultConfigurationModelConfigurationAccessor) Test(org.junit.jupiter.api.Test)

Aggregations

FieldUtility (com.synopsys.integration.alert.common.persistence.accessor.FieldUtility)25 Test (org.junit.jupiter.api.Test)15 ConfigurationFieldModel (com.synopsys.integration.alert.common.persistence.model.ConfigurationFieldModel)13 MessageResult (com.synopsys.integration.alert.common.message.model.MessageResult)11 FieldModel (com.synopsys.integration.alert.common.rest.model.FieldModel)10 AlertException (com.synopsys.integration.alert.api.common.model.exception.AlertException)8 ConfigurationModel (com.synopsys.integration.alert.common.persistence.model.ConfigurationModel)7 DescriptorKey (com.synopsys.integration.alert.descriptor.api.model.DescriptorKey)6 FieldModelTestAction (com.synopsys.integration.alert.common.action.FieldModelTestAction)4 EmailChannelMessagingService (com.synopsys.integration.alert.channel.email.distribution.EmailChannelMessagingService)3 ActionResponse (com.synopsys.integration.alert.common.action.ActionResponse)3 ValidationActionResponse (com.synopsys.integration.alert.common.action.ValidationActionResponse)3 AlertFieldStatus (com.synopsys.integration.alert.common.descriptor.config.field.errors.AlertFieldStatus)3 AlertFieldException (com.synopsys.integration.alert.common.exception.AlertFieldException)3 ConfigurationModelConfigurationAccessor (com.synopsys.integration.alert.common.persistence.accessor.ConfigurationModelConfigurationAccessor)3 DescriptorAccessor (com.synopsys.integration.alert.common.persistence.accessor.DescriptorAccessor)3 IntegrationException (com.synopsys.integration.exception.IntegrationException)3 ProviderProjectExistencePopulator (com.synopsys.integration.alert.api.provider.ProviderProjectExistencePopulator)2 AbstractJobResourceActions (com.synopsys.integration.alert.common.action.api.AbstractJobResourceActions)2 ConfigurationFieldModelConverter (com.synopsys.integration.alert.common.persistence.util.ConfigurationFieldModelConverter)2