use of com.synopsys.integration.alert.channel.jira.server.model.JiraServerGlobalConfigModel in project hub-alert by blackducksoftware.
the class JiraServerGlobalConfigurationValidatorTest method verifyMalformedUrl.
@Test
void verifyMalformedUrl() {
String badUrl = "notAValidUrl";
JiraServerGlobalConfigurationValidator validator = new JiraServerGlobalConfigurationValidator();
JiraServerGlobalConfigModel model = new JiraServerGlobalConfigModel(ID, NAME, CREATED_AT, LAST_UPDATED, badUrl, USER_NAME, PASSWORD, Boolean.FALSE, Boolean.FALSE);
ValidationResponseModel validationResponseModel = validator.validate(model);
Collection<AlertFieldStatus> alertFieldStatuses = validationResponseModel.getErrors().values();
assertEquals(1, alertFieldStatuses.size(), "There were errors in the configuration when none were expected.");
for (AlertFieldStatus status : alertFieldStatuses) {
assertEquals("url", status.getFieldName(), "Validation reported an error for an unexpected field.");
}
}
use of com.synopsys.integration.alert.channel.jira.server.model.JiraServerGlobalConfigModel in project hub-alert by blackducksoftware.
the class JiraServerGlobalConfigurationValidatorTest method verifyValidConfig.
@Test
void verifyValidConfig() {
JiraServerGlobalConfigurationValidator validator = new JiraServerGlobalConfigurationValidator();
JiraServerGlobalConfigModel model = new JiraServerGlobalConfigModel(ID, NAME, CREATED_AT, LAST_UPDATED, URL, USER_NAME, PASSWORD, Boolean.FALSE, Boolean.FALSE);
ValidationResponseModel validationResponseModel = validator.validate(model);
Collection<AlertFieldStatus> alertFieldStatuses = validationResponseModel.getErrors().values();
assertEquals(0, alertFieldStatuses.size(), "There were errors in the configuration when none were expected.");
}
use of com.synopsys.integration.alert.channel.jira.server.model.JiraServerGlobalConfigModel in project hub-alert by blackducksoftware.
the class JiraServerGlobalConfigurationModelSaveActions method createConcreteModel.
@Override
public void createConcreteModel(ConfigurationModel configurationModel) {
Optional<JiraServerGlobalConfigModel> jiraGlobalConfigModel = jiraFieldModelConverter.convert(configurationModel);
if (jiraGlobalConfigModel.isPresent()) {
JiraServerGlobalConfigModel model = jiraGlobalConfigModel.get();
model.setName(AlertRestConstants.DEFAULT_CONFIGURATION_NAME);
configurationActions.create(model);
}
}
use of com.synopsys.integration.alert.channel.jira.server.model.JiraServerGlobalConfigModel in project hub-alert by blackducksoftware.
the class JiraServerGlobalConfigurationModelSaveActions method updateConcreteModel.
@Override
public void updateConcreteModel(ConfigurationModel configurationModel) {
Optional<UUID> defaultConfigurationId = configurationAccessor.getConfigurationByName(AlertRestConstants.DEFAULT_CONFIGURATION_NAME).map(JiraServerGlobalConfigModel::getId).map(UUID::fromString);
Optional<JiraServerGlobalConfigModel> jiraGlobalConfigModel = jiraFieldModelConverter.convert(configurationModel);
if (jiraGlobalConfigModel.isPresent()) {
JiraServerGlobalConfigModel model = jiraGlobalConfigModel.get();
model.setName(AlertRestConstants.DEFAULT_CONFIGURATION_NAME);
if (defaultConfigurationId.isPresent()) {
configurationActions.update(defaultConfigurationId.get(), model);
} else {
configurationActions.create(model);
}
}
}
use of com.synopsys.integration.alert.channel.jira.server.model.JiraServerGlobalConfigModel in project hub-alert by blackducksoftware.
the class JiraServerGlobalTestActionTest method testConfigIssueTrackerException.
@Test
void testConfigIssueTrackerException() throws IntegrationException {
AuthorizationManager authorizationManager = createAuthorizationManager(255);
JiraServerGlobalConfigurationValidator validator = new JiraServerGlobalConfigurationValidator();
JiraServerTestActionFactory jiraServerTestActionFactory = Mockito.mock(JiraServerTestActionFactory.class);
Mockito.when(jiraServerTestActionFactory.createTestActionWrapper(Mockito.any())).thenThrow(new IssueTrackerException("Test Exception message"));
JiraServerGlobalConfigModel jiraServerGlobalConfigModel = createValidJiraServerGlobalConfigModel();
JiraServerGlobalTestAction jiraServerGlobalTestAction = new JiraServerGlobalTestAction(authorizationManager, validator, jiraServerTestActionFactory);
ConfigurationTestResult testResult = jiraServerGlobalTestAction.testConfigModelContent(jiraServerGlobalConfigModel);
assertFalse(testResult.isSuccess());
}
Aggregations