Search in sources :

Example 21 with PluginSetting

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

the class PluginFactoryTests method testNoMandatoryConstructor.

@Test
public void testNoMandatoryConstructor() {
    final PluginSetting testPluginSettings = new PluginSetting("junit-test", new HashMap<>());
    final Class<Source> clazz = PluginRepository.getSourceClass(testPluginSettings.getName());
    assertNotNull(clazz);
    try {
        PluginFactory.newPlugin(testPluginSettings, clazz);
    } catch (PluginException e) {
        assertTrue("Incorrect exception or exception message was thrown", e.getMessage().startsWith("Data Prepper plugin requires a constructor with PluginSetting parameter; Plugin " + "ConstructorLessComponent with name junit-test is missing such constructor."));
    }
}
Also used : PluginSetting(com.amazon.dataprepper.model.configuration.PluginSetting) Source(com.amazon.dataprepper.model.source.Source) Test(org.junit.Test)

Example 22 with PluginSetting

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

the class PrepperFactoryTests method testNewSingletonPrepperClassByNameThatExists.

/**
 * Tests if PrepperFactory is able to retrieve default Source plugins by name
 */
@Test
public void testNewSingletonPrepperClassByNameThatExists() {
    PrepperFactory.dangerousMethod_setPluginFunction((s, c) -> new NoOpPrepper());
    final PluginSetting noOpPrepperConfiguration = new PluginSetting("no-op", new HashMap<>());
    noOpPrepperConfiguration.setPipelineName(TEST_PIPELINE);
    final List<Processor> actualPrepperSets = PrepperFactory.newPreppers(noOpPrepperConfiguration);
    assertEquals(1, actualPrepperSets.size());
    final Processor actualPrepper = actualPrepperSets.get(0);
    final Processor expectedPrepper = new NoOpPrepper();
    assertThat(actualPrepper, notNullValue());
    assertThat(actualPrepper.getClass().getSimpleName(), is(equalTo(expectedPrepper.getClass().getSimpleName())));
}
Also used : Processor(com.amazon.dataprepper.model.processor.Processor) PluginSetting(com.amazon.dataprepper.model.configuration.PluginSetting) Test(org.junit.jupiter.api.Test)

Example 23 with PluginSetting

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

the class PrepperFactoryTests method testNewMultiInstancePrepperClassByNameThatExists.

@Test
public void testNewMultiInstancePrepperClassByNameThatExists() {
    final PluginSetting testPrepperConfiguration = new PluginSetting("test_prepper", new HashMap<>());
    testPrepperConfiguration.setProcessWorkers(2);
    testPrepperConfiguration.setPipelineName(TEST_PIPELINE);
    final List<Processor> actualPrepperSets = PrepperFactory.newPreppers(testPrepperConfiguration);
    assertEquals(2, actualPrepperSets.size());
    final Processor expectedPrepper = new TestPrepper(testPrepperConfiguration);
    assertThat(actualPrepperSets.get(0), notNullValue());
    assertThat(actualPrepperSets.get(0).getClass().getSimpleName(), is(equalTo(expectedPrepper.getClass().getSimpleName())));
    assertThat(actualPrepperSets.get(1), notNullValue());
    assertThat(actualPrepperSets.get(1).getClass().getSimpleName(), is(equalTo(expectedPrepper.getClass().getSimpleName())));
}
Also used : Processor(com.amazon.dataprepper.model.processor.Processor) PluginSetting(com.amazon.dataprepper.model.configuration.PluginSetting) Test(org.junit.jupiter.api.Test)

Example 24 with PluginSetting

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

the class BlockingBufferTests method testBufferIsNotEmpty.

@Test
public void testBufferIsNotEmpty() throws Exception {
    final PluginSetting completePluginSetting = completePluginSettingForBlockingBuffer();
    final BlockingBuffer<Record<String>> blockingBuffer = new BlockingBuffer<>(completePluginSetting);
    Record<String> record = new Record<>("TEST");
    blockingBuffer.write(record, TEST_WRITE_TIMEOUT);
    assertFalse(blockingBuffer.isEmpty());
}
Also used : Record(com.amazon.dataprepper.model.record.Record) PluginSetting(com.amazon.dataprepper.model.configuration.PluginSetting) Test(org.junit.jupiter.api.Test)

Example 25 with PluginSetting

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

the class BlockingBufferTests method testCreationUsingPluginSetting.

@Test
public void testCreationUsingPluginSetting() {
    final PluginSetting completePluginSetting = completePluginSettingForBlockingBuffer();
    final BlockingBuffer<Record<String>> blockingBuffer = new BlockingBuffer<>(completePluginSetting);
    assertThat(blockingBuffer, notNullValue());
}
Also used : Record(com.amazon.dataprepper.model.record.Record) 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