use of com.synopsys.integration.alert.channel.jira.server.model.JiraServerGlobalConfigModel in project hub-alert by blackducksoftware.
the class JiraServerGlobalConfigAccessorTest method updateConfigurationPasswordSavedTest.
@Test
void updateConfigurationPasswordSavedTest() throws AlertConfigurationException {
UUID id = UUID.randomUUID();
String updatedName = "updatedName";
String newUrl = "https://updated.example.com";
JiraServerConfigurationEntity entity = createEntity(id, OffsetDateTime.now(), OffsetDateTime.now());
JiraServerConfigurationEntity updatedEntity = new JiraServerConfigurationEntity(entity.getConfigurationId(), updatedName, entity.getCreatedAt(), entity.getLastUpdated(), newUrl, entity.getUsername(), entity.getPassword(), entity.getDisablePluginCheck());
JiraServerGlobalConfigModel model = new JiraServerGlobalConfigModel(null, AlertRestConstants.DEFAULT_CONFIGURATION_NAME, DateUtils.formatDate(entity.getCreatedAt(), DateUtils.UTC_DATE_FORMAT_TO_MINUTE), DateUtils.formatDate(entity.getLastUpdated(), DateUtils.UTC_DATE_FORMAT_TO_MINUTE), TEST_URL, TEST_USERNAME, null, true, true);
Mockito.when(jiraServerConfigurationRepository.findById(id)).thenReturn(Optional.of(entity));
Mockito.when(jiraServerConfigurationRepository.save(Mockito.any())).thenReturn(updatedEntity);
JiraServerGlobalConfigModel updatedModel = jiraServerGlobalConfigAccessor.updateConfiguration(id, model);
assertEquals(updatedEntity.getConfigurationId().toString(), updatedModel.getId());
assertEquals(updatedEntity.getUrl(), updatedModel.getUrl());
assertEquals(updatedEntity.getUsername(), updatedModel.getUserName());
assertTrue(updatedModel.getIsPasswordSet().orElse(Boolean.FALSE));
assertEquals(TEST_PASSWORD, updatedModel.getPassword().orElse(null));
assertEquals(updatedEntity.getDisablePluginCheck(), updatedModel.getDisablePluginCheck().orElse(null));
}
use of com.synopsys.integration.alert.channel.jira.server.model.JiraServerGlobalConfigModel in project hub-alert by blackducksoftware.
the class JiraServerGlobalConfigAccessorTest method getByConfigurationIdNotFoundTest.
@Test
void getByConfigurationIdNotFoundTest() {
UUID id = UUID.randomUUID();
JiraServerConfigurationEntity entity = createEntity(id);
Mockito.when(jiraServerConfigurationRepository.findById(id)).thenReturn(Optional.of(entity));
Optional<JiraServerGlobalConfigModel> configModel = jiraServerGlobalConfigAccessor.getConfiguration(UUID.randomUUID());
assertTrue(configModel.isEmpty());
}
use of com.synopsys.integration.alert.channel.jira.server.model.JiraServerGlobalConfigModel in project hub-alert by blackducksoftware.
the class JiraServerGlobalConfigAccessorTest method getPageEmptyTest.
@Test
void getPageEmptyTest() {
UUID id = UUID.randomUUID();
Page<JiraServerConfigurationEntity> jiraConfigurations = new PageImpl<>(List.of());
Mockito.when(jiraServerConfigurationRepository.findAll(Mockito.any(PageRequest.class))).thenReturn(jiraConfigurations);
AlertPagedModel<JiraServerGlobalConfigModel> pagedModel = jiraServerGlobalConfigAccessor.getConfigurationPage(0, 10);
assertEquals(0, pagedModel.getCurrentPage());
assertEquals(1, pagedModel.getTotalPages());
assertEquals(0, pagedModel.getModels().size());
}
use of com.synopsys.integration.alert.channel.jira.server.model.JiraServerGlobalConfigModel in project hub-alert by blackducksoftware.
the class JiraServerGlobalConfigurationValidatorTest method verifyPasswordIsSavedAndMissingFromModel.
@Test
void verifyPasswordIsSavedAndMissingFromModel() {
JiraServerGlobalConfigurationValidator validator = new JiraServerGlobalConfigurationValidator();
JiraServerGlobalConfigModel model = new JiraServerGlobalConfigModel(ID, NAME, CREATED_AT, LAST_UPDATED, URL, USER_NAME, null, Boolean.TRUE, 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 JiraServerGlobalConfigurationValidatorTest method verifyEmptyConfig.
@Test
void verifyEmptyConfig() {
JiraServerGlobalConfigurationValidator validator = new JiraServerGlobalConfigurationValidator();
JiraServerGlobalConfigModel model = new JiraServerGlobalConfigModel();
ValidationResponseModel validationResponseModel = validator.validate(model);
Collection<AlertFieldStatus> alertFieldStatuses = validationResponseModel.getErrors().values();
assertEquals(4, alertFieldStatuses.size(), "There were errors in the configuration when none were expected.");
for (AlertFieldStatus status : alertFieldStatuses) {
assertEquals(ConfigurationFieldValidator.REQUIRED_FIELD_MISSING_MESSAGE, status.getFieldMessage(), "Validation had unexpected field message.");
}
}
Aggregations