use of com.synopsys.integration.alert.channel.jira.server.database.configuration.JiraServerConfigurationEntity in project hub-alert by blackducksoftware.
the class JiraServerGlobalConfigAccessorTest method createConfigurationTest.
@Test
void createConfigurationTest() throws AlertConfigurationException {
UUID id = UUID.randomUUID();
JiraServerConfigurationEntity entity = createEntity(id, OffsetDateTime.now(), OffsetDateTime.now());
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, TEST_PASSWORD, false, true);
Mockito.when(jiraServerConfigurationRepository.save(Mockito.any())).thenReturn(entity);
JiraServerGlobalConfigModel createdModel = jiraServerGlobalConfigAccessor.createConfiguration(model);
assertEquals(entity.getConfigurationId().toString(), createdModel.getId());
assertEquals(entity.getUrl(), createdModel.getUrl());
assertEquals(entity.getUsername(), createdModel.getUserName());
assertTrue(createdModel.getIsPasswordSet().orElse(Boolean.FALSE));
assertEquals(TEST_PASSWORD, createdModel.getPassword().orElse(null));
assertEquals(entity.getDisablePluginCheck(), createdModel.getDisablePluginCheck().orElse(null));
}
use of com.synopsys.integration.alert.channel.jira.server.database.configuration.JiraServerConfigurationEntity in project hub-alert by blackducksoftware.
the class JiraServerGlobalConfigAccessorTest method getByConfigurationIdTest.
@Test
void getByConfigurationIdTest() throws AlertConfigurationException {
UUID id = UUID.randomUUID();
JiraServerConfigurationEntity entity = createEntity(id);
Mockito.when(jiraServerConfigurationRepository.findById(id)).thenReturn(Optional.of(entity));
JiraServerGlobalConfigModel configModel = jiraServerGlobalConfigAccessor.getConfiguration(id).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));
}
use of com.synopsys.integration.alert.channel.jira.server.database.configuration.JiraServerConfigurationEntity in project hub-alert by blackducksoftware.
the class JiraServerGlobalConfigAccessorTest method updateConfigurationNotFoundTest.
@Test
void updateConfigurationNotFoundTest() {
UUID id = UUID.randomUUID();
String updatedName = "updatedName";
String newUrl = "https://updated.example.com";
JiraServerConfigurationEntity entity = createEntity(id, OffsetDateTime.now(), OffsetDateTime.now());
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, TEST_PASSWORD, false, true);
Mockito.when(jiraServerConfigurationRepository.findById(id)).thenReturn(Optional.empty());
try {
jiraServerGlobalConfigAccessor.updateConfiguration(id, model);
fail("Exception expected because id not found");
} catch (AlertConfigurationException ex) {
// expected to get here
}
}
Aggregations