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);
}
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());
}
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));
}
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());
}
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));
}
Aggregations