Search in sources :

Example 96 with PluginSetting

use of com.amazon.dataprepper.model.configuration.PluginSetting in project data-prepper by opensearch-project.

the class DataPrepperServerConfigurationTest method testGivingSecureConfigThenCreateInsecureSettings.

@Test
public void testGivingSecureConfigThenCreateInsecureSettings() {
    final PluginModel pluginModel = mock(PluginModel.class);
    final Map<String, Object> settings = new HashMap<>();
    when(pluginModel.getPluginName()).thenReturn("super secure plugin");
    when(pluginModel.getPluginSettings()).thenReturn(settings);
    final PluginSetting pluginSetting = serverConfiguration.pluginSetting(pluginModel);
    assertThat(pluginSetting.getName(), is("super secure plugin"));
    assertThat(pluginSetting.getSettings(), is(settings));
}
Also used : PluginModel(com.amazon.dataprepper.model.configuration.PluginModel) HashMap(java.util.HashMap) PluginSetting(com.amazon.dataprepper.model.configuration.PluginSetting) Test(org.junit.jupiter.api.Test)

Example 97 with PluginSetting

use of com.amazon.dataprepper.model.configuration.PluginSetting in project data-prepper by opensearch-project.

the class DataPrepperServerConfigurationTest method testGivingNoConfigThenCreateInsecureSettings.

@Test
public void testGivingNoConfigThenCreateInsecureSettings() {
    final PluginSetting pluginSetting = serverConfiguration.pluginSetting(null);
    assertThat(pluginSetting.getName(), is("unauthenticated"));
    assertThat(pluginSetting.getSettings().isEmpty(), is(true));
}
Also used : PluginSetting(com.amazon.dataprepper.model.configuration.PluginSetting) Test(org.junit.jupiter.api.Test)

Example 98 with PluginSetting

use of com.amazon.dataprepper.model.configuration.PluginSetting in project data-prepper by opensearch-project.

the class DefaultPluginFactoryIT method loadPlugin_should_return_a_new_plugin_instance_with_the_expected_configuration.

@Test
void loadPlugin_should_return_a_new_plugin_instance_with_the_expected_configuration() {
    final String requiredStringValue = UUID.randomUUID().toString();
    final String optionalStringValue = UUID.randomUUID().toString();
    final Map<String, Object> pluginSettingMap = new HashMap<>();
    pluginSettingMap.put("required_string", requiredStringValue);
    pluginSettingMap.put("optional_string", optionalStringValue);
    final PluginSetting pluginSetting = createPluginSettings(pluginSettingMap);
    final TestPluggableInterface plugin = createObjectUnderTest().loadPlugin(TestPluggableInterface.class, pluginSetting);
    assertThat(plugin, instanceOf(TestPlugin.class));
    final TestPlugin testPlugin = (TestPlugin) plugin;
    final TestPluginConfiguration configuration = testPlugin.getConfiguration();
    assertThat(configuration.getRequiredString(), equalTo(requiredStringValue));
    assertThat(configuration.getOptionalString(), equalTo(optionalStringValue));
}
Also used : HashMap(java.util.HashMap) TestPlugin(com.amazon.dataprepper.plugins.TestPlugin) PluginSetting(com.amazon.dataprepper.model.configuration.PluginSetting) Test(org.junit.jupiter.api.Test)

Example 99 with PluginSetting

use of com.amazon.dataprepper.model.configuration.PluginSetting in project data-prepper by opensearch-project.

the class DefaultPluginFactoryIT method createPluginSettings.

private PluginSetting createPluginSettings(final Map<String, Object> pluginSettingMap) {
    final PluginSetting pluginSetting = new PluginSetting(pluginName, pluginSettingMap);
    pluginSetting.setPipelineName(pipelineName);
    return pluginSetting;
}
Also used : PluginSetting(com.amazon.dataprepper.model.configuration.PluginSetting)

Example 100 with PluginSetting

use of com.amazon.dataprepper.model.configuration.PluginSetting in project data-prepper by opensearch-project.

the class PluginArgumentsContextTest method createArguments_with_PluginMetrics.

@Test
void createArguments_with_PluginMetrics() {
    final PluginArgumentsContext objectUnderTest = new PluginArgumentsContext.Builder().withPluginSetting(pluginSetting).build();
    final PluginMetrics pluginMetrics = mock(PluginMetrics.class);
    final Object[] arguments;
    try (final MockedStatic<PluginMetrics> pluginMetricsMockedStatic = mockStatic(PluginMetrics.class)) {
        pluginMetricsMockedStatic.when(() -> PluginMetrics.fromPluginSetting(pluginSetting)).thenReturn(pluginMetrics);
        arguments = objectUnderTest.createArguments(new Class[] { PluginSetting.class, PluginMetrics.class });
    }
    assertThat(arguments, equalTo(new Object[] { pluginSetting, pluginMetrics }));
}
Also used : PluginMetrics(com.amazon.dataprepper.metrics.PluginMetrics) PluginSetting(com.amazon.dataprepper.model.configuration.PluginSetting) Test(org.junit.jupiter.api.Test)

Aggregations

PluginSetting (com.amazon.dataprepper.model.configuration.PluginSetting)150 Test (org.junit.jupiter.api.Test)58 HashMap (java.util.HashMap)55 Test (org.junit.Test)43 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)26 Record (com.amazon.dataprepper.model.record.Record)22 AsciiString (io.netty.util.AsciiString)16 Measurement (io.micrometer.core.instrument.Measurement)12 StringJoiner (java.util.StringJoiner)12 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)12 Map (java.util.Map)11 Path (java.nio.file.Path)9 Server (com.linecorp.armeria.server.Server)8 Before (org.junit.Before)8 BeforeEach (org.junit.jupiter.api.BeforeEach)8 BlockingBuffer (com.amazon.dataprepper.plugins.buffer.blockingbuffer.BlockingBuffer)7 RestHighLevelClient (org.opensearch.client.RestHighLevelClient)7 PluginMetrics (com.amazon.dataprepper.metrics.PluginMetrics)6 CertificateProvider (com.amazon.dataprepper.plugins.certificate.CertificateProvider)6 ACMCertificateProvider (com.amazon.dataprepper.plugins.certificate.acm.ACMCertificateProvider)6