use of com.synopsys.integration.alert.common.descriptor.DescriptorMap in project hub-alert by blackducksoftware.
the class EmailConfigActionTestIT method createEmailGlobalConfigTest.
@Test
void createEmailGlobalConfigTest() {
AuthorizationManager authorizationManager = createEmailAuthorizationManager();
EmailGlobalCrudActions emailGlobalCrudActions = createEmailCrudActions(authorizationManager);
GlobalConfigurationModelToConcreteConversionService globalConfigurationModelToConcreteConversionService = createConversionService(emailGlobalCrudActions);
ConfigActions configActions = new ConfigActions(authorizationManager, descriptorAccessor, configurationModelConfigurationAccessor, fieldModelProcessor, descriptorProcessor, configurationFieldModelConverter, descriptorMap, pkixErrorResponseFactory, encryptionUtility, settingsDescriptorKey, globalConfigurationModelToConcreteConversionService);
FieldModel fieldModel = createEmailFieldModel();
configActions.create(fieldModel);
Optional<EmailGlobalConfigModel> staticEmailConfig = emailGlobalConfigAccessor.getConfiguration();
assertTrue(staticEmailConfig.isPresent());
EmailGlobalConfigModel staticModel = staticEmailConfig.get();
assertEquals(Boolean.TRUE, staticModel.getSmtpAuth().orElse(null));
assertEquals(TEST_AUTH_USER, staticModel.getSmtpUsername().orElse(null));
assertEquals(TEST_AUTH_PASSWORD, staticModel.getSmtpPassword().orElse(null));
assertEquals(TEST_SMTP_HOST, staticModel.getSmtpHost().orElse(null));
assertEquals(Integer.valueOf(TEST_SMTP_PORT), staticModel.getSmtpPort().orElse(null));
assertEquals(TEST_FROM, staticModel.getSmtpFrom().orElse(null));
String propertyValue = staticModel.getAdditionalJavaMailProperties().map(map -> map.get(EmailPropertyKeys.JAVAMAIL_EHLO_KEY.getPropertyKey())).orElse(null);
assertEquals("true", propertyValue);
}
use of com.synopsys.integration.alert.common.descriptor.DescriptorMap in project hub-alert by blackducksoftware.
the class GlobalConfigurationModelToConcreteConversionServiceTest method updatedDescriptorFoundTest.
@Test
void updatedDescriptorFoundTest() {
TestSaveActions saveActions = new TestSaveActions(testDescriptorKey);
DescriptorMap descriptorMap = new DescriptorMap(List.of(testDescriptorKey), List.of());
List<GlobalConfigurationModelToConcreteSaveActions> fieldModelSaveActions = List.of(saveActions);
String timestamp = DateUtils.createCurrentDateString(DateUtils.UTC_DATE_FORMAT_TO_MINUTE);
ConfigurationModel configurationModel = new ConfigurationModel(1L, 1L, timestamp, timestamp, ConfigContextEnum.GLOBAL, Map.of());
GlobalConfigurationModelToConcreteConversionService conversionService = new GlobalConfigurationModelToConcreteConversionService(fieldModelSaveActions, descriptorMap);
conversionService.updateDefaultConcreteModel(TEST_DESCRIPTOR_KEY, configurationModel);
assertTrue(saveActions.wasUpdateCalled());
}
use of com.synopsys.integration.alert.common.descriptor.DescriptorMap in project hub-alert by blackducksoftware.
the class JobConfigActionsTest method validateBadRequestTest.
@Test
public void validateBadRequestTest() {
Descriptor descriptorWithValidator = createDescriptor(Optional::empty, () -> Optional.of(jobFieldModel -> Set.of()));
JobConfigActions jobConfigActionsForTest = createJobConfigActions(new DescriptorMap(List.of(descriptorKey), List.of(descriptorWithValidator)), List.of());
Mockito.when(mockedJobAccessor.getJobByName(Mockito.anyString())).thenReturn(Optional.of(distributionJobModel));
ValidationActionResponse validationActionResponse = jobConfigActionsForTest.validate(jobFieldModel);
assertTrue(validationActionResponse.isSuccessful());
assertEquals(HttpStatus.OK, validationActionResponse.getHttpStatus());
assertTrue(validationActionResponse.hasContent());
ValidationResponseModel validationResponseModel = validationActionResponse.getContent().get();
assertTrue(validationResponseModel.hasErrors(), "Expected validation response to have errors");
}
use of com.synopsys.integration.alert.common.descriptor.DescriptorMap in project hub-alert by blackducksoftware.
the class JobConfigActionsTest method validateTest.
@Test
public void validateTest() {
Descriptor descriptorWithValidator = createDescriptor(Optional::empty, () -> Optional.of(jobFieldModel -> Set.of()));
JobConfigActions jobConfigActionsForTest = createJobConfigActions(new DescriptorMap(List.of(descriptorKey), List.of(descriptorWithValidator)), List.of());
ValidationActionResponse validationActionResponse = jobConfigActionsForTest.validate(jobFieldModel);
assertTrue(validationActionResponse.isSuccessful());
assertEquals(HttpStatus.OK, validationActionResponse.getHttpStatus());
assertTrue(validationActionResponse.hasContent());
ValidationResponseModel validationResponseModel = validationActionResponse.getContent().get();
assertFalse(validationResponseModel.hasErrors());
}
use of com.synopsys.integration.alert.common.descriptor.DescriptorMap in project hub-alert by blackducksoftware.
the class GlobalConfigurationModelToConcreteConversionServiceTest method updatedDescriptorMissingTest.
@Test
void updatedDescriptorMissingTest() {
TestSaveActions saveActions = new TestSaveActions(testDescriptorKey);
DescriptorMap descriptorMap = new DescriptorMap(List.of(), List.of());
List<GlobalConfigurationModelToConcreteSaveActions> fieldModelSaveActions = List.of(saveActions);
String timestamp = DateUtils.createCurrentDateString(DateUtils.UTC_DATE_FORMAT_TO_MINUTE);
ConfigurationModel configurationModel = new ConfigurationModel(1L, 1L, timestamp, timestamp, ConfigContextEnum.GLOBAL, Map.of());
GlobalConfigurationModelToConcreteConversionService conversionService = new GlobalConfigurationModelToConcreteConversionService(fieldModelSaveActions, descriptorMap);
conversionService.updateDefaultConcreteModel(TEST_DESCRIPTOR_KEY, configurationModel);
assertFalse(saveActions.wasUpdateCalled());
}
Aggregations