Search in sources :

Example 26 with JiraServerGlobalConfigModel

use of com.synopsys.integration.alert.channel.jira.server.model.JiraServerGlobalConfigModel in project hub-alert by blackducksoftware.

the class JiraServerGlobalCrudActionsTest method getOneTest.

@Test
void getOneTest() {
    JiraServerGlobalConfigModel jiraServerGlobalConfigModel = createJiraServerGlobalConfigModel(id);
    JiraServerGlobalConfigAccessor configAccessor = Mockito.mock(JiraServerGlobalConfigAccessor.class);
    Mockito.when(configAccessor.getConfiguration(id)).thenReturn(Optional.of(jiraServerGlobalConfigModel));
    JiraServerGlobalCrudActions crudActions = new JiraServerGlobalCrudActions(authorizationManager, configAccessor, validator);
    ActionResponse<JiraServerGlobalConfigModel> actionResponse = crudActions.getOne(id);
    assertTrue(actionResponse.isSuccessful());
    assertTrue(actionResponse.hasContent());
    assertEquals(HttpStatus.OK, actionResponse.getHttpStatus());
    assertModelObfuscated(actionResponse);
}
Also used : JiraServerGlobalConfigModel(com.synopsys.integration.alert.channel.jira.server.model.JiraServerGlobalConfigModel) JiraServerGlobalConfigAccessor(com.synopsys.integration.alert.channel.jira.server.database.accessor.JiraServerGlobalConfigAccessor) Test(org.junit.jupiter.api.Test)

Example 27 with JiraServerGlobalConfigModel

use of com.synopsys.integration.alert.channel.jira.server.model.JiraServerGlobalConfigModel in project hub-alert by blackducksoftware.

the class JiraServerGlobalConfigurationModelConverterTest method invalidPropertyKeysTest.

@Test
void invalidPropertyKeysTest() {
    String invalidFieldKey = "invalid.jira.field";
    ConfigurationFieldModel invalidField = ConfigurationFieldModel.create(invalidFieldKey);
    Map<String, ConfigurationFieldModel> fieldValues = Map.of(invalidFieldKey, invalidField);
    ConfigurationModel configurationModel = new ConfigurationModel(1L, 1L, "", "", ConfigContextEnum.GLOBAL, fieldValues);
    JiraServerGlobalConfigurationModelConverter converter = new JiraServerGlobalConfigurationModelConverter();
    Optional<JiraServerGlobalConfigModel> model = converter.convert(configurationModel);
    assertTrue(model.isEmpty());
}
Also used : ConfigurationModel(com.synopsys.integration.alert.common.persistence.model.ConfigurationModel) ConfigurationFieldModel(com.synopsys.integration.alert.common.persistence.model.ConfigurationFieldModel) JiraServerGlobalConfigModel(com.synopsys.integration.alert.channel.jira.server.model.JiraServerGlobalConfigModel) Test(org.junit.jupiter.api.Test)

Example 28 with JiraServerGlobalConfigModel

use of com.synopsys.integration.alert.channel.jira.server.model.JiraServerGlobalConfigModel in project hub-alert by blackducksoftware.

the class JiraServerGlobalConfigurationModelConverterTest method validConversionTest.

@Test
void validConversionTest() {
    ConfigurationModel configurationModel = createDefaultConfigurationModel();
    JiraServerGlobalConfigurationModelConverter converter = new JiraServerGlobalConfigurationModelConverter();
    Optional<JiraServerGlobalConfigModel> model = converter.convert(configurationModel);
    assertTrue(model.isPresent());
    JiraServerGlobalConfigModel jiraModel = model.get();
    assertNull(jiraModel.getId());
    assertEquals(TEST_URL, jiraModel.getUrl());
    assertEquals(TEST_USERNAME, jiraModel.getUserName());
    assertEquals(TEST_PASSWORD, jiraModel.getPassword().orElse("Password value is missing"));
    assertTrue(jiraModel.getDisablePluginCheck().orElse(Boolean.FALSE));
}
Also used : ConfigurationModel(com.synopsys.integration.alert.common.persistence.model.ConfigurationModel) JiraServerGlobalConfigModel(com.synopsys.integration.alert.channel.jira.server.model.JiraServerGlobalConfigModel) Test(org.junit.jupiter.api.Test)

Example 29 with JiraServerGlobalConfigModel

use of com.synopsys.integration.alert.channel.jira.server.model.JiraServerGlobalConfigModel in project hub-alert by blackducksoftware.

the class JiraServerGlobalConfigurationModelConverterTest method validConversionMissingOptionalFieldsTest.

@Test
void validConversionMissingOptionalFieldsTest() {
    ConfigurationModel configurationModel = createDefaultConfigurationModel();
    Map<String, ConfigurationFieldModel> fields = configurationModel.getCopyOfKeyToFieldMap();
    fields.remove(JiraServerGlobalConfigurationModelConverter.PASSWORD_KEY);
    fields.remove(JiraServerGlobalConfigurationModelConverter.DISABLE_PLUGIN_CHECK_KEY);
    configurationModel = new ConfigurationModel(1L, 1L, "", "", ConfigContextEnum.GLOBAL, fields);
    JiraServerGlobalConfigurationModelConverter converter = new JiraServerGlobalConfigurationModelConverter();
    Optional<JiraServerGlobalConfigModel> model = converter.convert(configurationModel);
    assertTrue(model.isPresent());
    JiraServerGlobalConfigModel jiraModel = model.get();
    assertNull(jiraModel.getId());
    assertEquals(TEST_URL, jiraModel.getUrl());
    assertEquals(TEST_USERNAME, jiraModel.getUserName());
    assertTrue(jiraModel.getPassword().isEmpty());
    assertTrue(jiraModel.getDisablePluginCheck().isEmpty());
}
Also used : ConfigurationModel(com.synopsys.integration.alert.common.persistence.model.ConfigurationModel) ConfigurationFieldModel(com.synopsys.integration.alert.common.persistence.model.ConfigurationFieldModel) JiraServerGlobalConfigModel(com.synopsys.integration.alert.channel.jira.server.model.JiraServerGlobalConfigModel) Test(org.junit.jupiter.api.Test)

Example 30 with JiraServerGlobalConfigModel

use of com.synopsys.integration.alert.channel.jira.server.model.JiraServerGlobalConfigModel in project hub-alert by blackducksoftware.

the class JiraServerGlobalConfigAccessorTest method getByConfigurationNameTest.

@Test
void getByConfigurationNameTest() throws AlertConfigurationException {
    UUID id = UUID.randomUUID();
    JiraServerConfigurationEntity entity = createEntity(id);
    Mockito.when(jiraServerConfigurationRepository.findByName(AlertRestConstants.DEFAULT_CONFIGURATION_NAME)).thenReturn(Optional.of(entity));
    JiraServerGlobalConfigModel configModel = jiraServerGlobalConfigAccessor.getConfigurationByName(AlertRestConstants.DEFAULT_CONFIGURATION_NAME).orElseThrow(() -> new AlertConfigurationException("Cannot find expected configuration"));
    assertEquals(id.toString(), configModel.getId());
    assertEquals(TEST_URL, configModel.getUrl());
    assertEquals(TEST_USERNAME, configModel.getUserName());
    assertTrue(configModel.getIsPasswordSet().orElse(Boolean.FALSE));
    assertEquals(TEST_PASSWORD, configModel.getPassword().orElse(null));
    assertTrue(configModel.getDisablePluginCheck().orElse(Boolean.FALSE));
}
Also used : JiraServerGlobalConfigModel(com.synopsys.integration.alert.channel.jira.server.model.JiraServerGlobalConfigModel) JiraServerConfigurationEntity(com.synopsys.integration.alert.channel.jira.server.database.configuration.JiraServerConfigurationEntity) UUID(java.util.UUID) AlertConfigurationException(com.synopsys.integration.alert.api.common.model.exception.AlertConfigurationException) Test(org.junit.jupiter.api.Test)

Aggregations

JiraServerGlobalConfigModel (com.synopsys.integration.alert.channel.jira.server.model.JiraServerGlobalConfigModel)44 Test (org.junit.jupiter.api.Test)40 UUID (java.util.UUID)17 AlertIntegrationTest (com.synopsys.integration.alert.util.AlertIntegrationTest)14 JiraServerConfigurationEntity (com.synopsys.integration.alert.channel.jira.server.database.configuration.JiraServerConfigurationEntity)10 WithMockUser (org.springframework.security.test.context.support.WithMockUser)7 MockHttpServletRequestBuilder (org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder)7 JiraServerGlobalConfigAccessor (com.synopsys.integration.alert.channel.jira.server.database.accessor.JiraServerGlobalConfigAccessor)6 AlertFieldStatus (com.synopsys.integration.alert.common.descriptor.config.field.errors.AlertFieldStatus)5 ValidationResponseModel (com.synopsys.integration.alert.common.rest.model.ValidationResponseModel)5 AlertConfigurationException (com.synopsys.integration.alert.api.common.model.exception.AlertConfigurationException)4 ConfigurationModel (com.synopsys.integration.alert.common.persistence.model.ConfigurationModel)4 ConfigurationFieldModel (com.synopsys.integration.alert.common.persistence.model.ConfigurationFieldModel)3 EnvironmentProcessingResult (com.synopsys.integration.alert.environment.EnvironmentProcessingResult)2 PageImpl (org.springframework.data.domain.PageImpl)2 PageRequest (org.springframework.data.domain.PageRequest)2 JiraServerEnvironmentVariableHandlerFactory (com.synopsys.integration.alert.channel.jira.server.environment.JiraServerEnvironmentVariableHandlerFactory)1 JiraServerGlobalConfigurationValidator (com.synopsys.integration.alert.channel.jira.server.validator.JiraServerGlobalConfigurationValidator)1 IssueTrackerException (com.synopsys.integration.alert.common.channel.issuetracker.exception.IssueTrackerException)1 ConfigurationTestResult (com.synopsys.integration.alert.common.message.model.ConfigurationTestResult)1