use of com.synopsys.integration.alert.mock.MockDescriptorAccessor in project hub-alert by blackducksoftware.
the class ConfigurationFieldModelTest method convertDefinedFieldModelWithValuesEmptyTest.
@Test
public void convertDefinedFieldModelWithValuesEmptyTest() throws Exception {
List<DefinedFieldModel> configFields = createConfigFields();
EncryptionUtility encryptionUtility = Mockito.mock(EncryptionUtility.class);
DescriptorAccessor descriptorAccessor = new MockDescriptorAccessor(configFields);
List<DescriptorKey> descriptorKeys = createDescriptorKeyList();
ConfigurationFieldModelConverter modelConverter = new ConfigurationFieldModelConverter(encryptionUtility, descriptorAccessor, descriptorKeys);
Optional<ConfigurationFieldModel> optionalModel = modelConverter.convertFromDefinedFieldModel(new DefinedFieldModel(KEY_FIELD_1, ConfigContextEnum.GLOBAL, true), List.of(VALUE_FIELD_1, VALUE_FIELD_2), true);
assertTrue(optionalModel.isEmpty());
}
use of com.synopsys.integration.alert.mock.MockDescriptorAccessor in project hub-alert by blackducksoftware.
the class ConfigurationFieldModelTest method convertDefinedFieldModelTest.
@Test
public void convertDefinedFieldModelTest() throws Exception {
List<DefinedFieldModel> configFields = createConfigFields();
EncryptionUtility encryptionUtility = Mockito.mock(EncryptionUtility.class);
Mockito.when(encryptionUtility.isInitialized()).thenReturn(true);
DescriptorAccessor descriptorAccessor = new MockDescriptorAccessor(configFields);
List<DescriptorKey> descriptorKeys = createDescriptorKeyList();
ConfigurationFieldModelConverter modelConverter = new ConfigurationFieldModelConverter(encryptionUtility, descriptorAccessor, descriptorKeys);
Optional<ConfigurationFieldModel> optionalModel = modelConverter.convertFromDefinedFieldModel(new DefinedFieldModel(KEY_FIELD_1, ConfigContextEnum.GLOBAL, false), VALUE_FIELD_1, true);
assertTrue(optionalModel.isPresent());
ConfigurationFieldModel actualModel = optionalModel.get();
assertEquals(VALUE_FIELD_1, actualModel.getFieldValue().orElseThrow(IllegalArgumentException::new));
assertFalse(actualModel.isSensitive());
assertEquals(KEY_FIELD_1, actualModel.getFieldKey());
optionalModel = modelConverter.convertFromDefinedFieldModel(new DefinedFieldModel(KEY_FIELD_1, ConfigContextEnum.GLOBAL, true), VALUE_FIELD_1, true);
assertTrue(optionalModel.isPresent());
actualModel = optionalModel.get();
assertEquals(VALUE_FIELD_1, actualModel.getFieldValue().orElseThrow(IllegalArgumentException::new));
assertTrue(actualModel.isSensitive());
assertEquals(KEY_FIELD_1, actualModel.getFieldKey());
}
Aggregations