use of com.amazon.dataprepper.model.plugin.InvalidPluginConfigurationException in project data-prepper by opensearch-project.
the class DefaultPluginFactoryIT method loadPlugin_should_throw_when_a_plugin_configuration_is_invalid.
@Test
void loadPlugin_should_throw_when_a_plugin_configuration_is_invalid() {
final String optionalStringValue = UUID.randomUUID().toString();
final Map<String, Object> pluginSettingMap = new HashMap<>();
pluginSettingMap.put("optional_string", optionalStringValue);
final PluginSetting pluginSetting = createPluginSettings(pluginSettingMap);
final DefaultPluginFactory objectUnderTest = createObjectUnderTest();
final InvalidPluginConfigurationException actualException = assertThrows(InvalidPluginConfigurationException.class, () -> objectUnderTest.loadPlugin(TestPluggableInterface.class, pluginSetting));
assertThat(actualException.getMessage(), notNullValue());
assertThat(actualException.getMessage(), equalTo("Plugin test_plugin in pipeline " + pipelineName + " is configured incorrectly: requiredString must not be null"));
}
use of com.amazon.dataprepper.model.plugin.InvalidPluginConfigurationException in project data-prepper by opensearch-project.
the class PluginConfigurationConverterTest method convert_with_other_target_should_throw_exception_when_there_are_constraint_violations.
@Test
void convert_with_other_target_should_throw_exception_when_there_are_constraint_violations() {
final String value = UUID.randomUUID().toString();
given(pluginSetting.getSettings()).willReturn(Collections.singletonMap("my_value", value));
final String pluginName = UUID.randomUUID().toString();
given(pluginSetting.getName()).willReturn(pluginName);
final String pipelineName = UUID.randomUUID().toString();
given(pluginSetting.getPipelineName()).willReturn(pipelineName);
@SuppressWarnings("unchecked") final ConstraintViolation<Object> constraintViolation = mock(ConstraintViolation.class);
final String errorMessage = UUID.randomUUID().toString();
given(constraintViolation.getMessage()).willReturn(errorMessage);
final String propertyPathString = UUID.randomUUID().toString();
final Path propertyPath = mock(Path.class);
given(propertyPath.toString()).willReturn(propertyPathString);
given(constraintViolation.getPropertyPath()).willReturn(propertyPath);
given(validator.validate(any())).willReturn(Collections.singleton(constraintViolation));
final PluginConfigurationConverter objectUnderTest = createObjectUnderTest();
final InvalidPluginConfigurationException actualException = assertThrows(InvalidPluginConfigurationException.class, () -> objectUnderTest.convert(TestConfiguration.class, pluginSetting));
assertThat(actualException.getMessage(), containsString(pluginName));
assertThat(actualException.getMessage(), containsString(pipelineName));
assertThat(actualException.getMessage(), containsString(propertyPathString));
assertThat(actualException.getMessage(), containsString(errorMessage));
}
Aggregations