forked from opensearch-project/data-prepper
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make plugin config injectable (opensearch-project#5078)
* making plugin config injectable Signed-off-by: Santhosh Gandhe <1909520+san81@users.noreply.github.com> * End to End test case for plugin config injectable Signed-off-by: Santhosh Gandhe <1909520+san81@users.noreply.github.com> * two additional test cases Signed-off-by: Santhosh Gandhe <1909520+san81@users.noreply.github.com> * reorganized test classes to separate out different test plugins Signed-off-by: Santhosh Gandhe <1909520+san81@users.noreply.github.com> * addressing review comments Signed-off-by: Santhosh Gandhe <1909520+san81@users.noreply.github.com> * better assertions when no injected bean expected in the bean factory Signed-off-by: Santhosh Gandhe <1909520+san81@users.noreply.github.com> --------- Signed-off-by: Santhosh Gandhe <1909520+san81@users.noreply.github.com>
- Loading branch information
Showing
7 changed files
with
165 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
...est/java/org/opensearch/dataprepper/plugins/configtest/TestComponentWithConfigInject.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package org.opensearch.dataprepper.plugins.configtest; | ||
|
||
import org.opensearch.dataprepper.plugin.TestPluginConfiguration; | ||
|
||
import javax.inject.Named; | ||
|
||
@Named | ||
public class TestComponentWithConfigInject { | ||
private final TestPluginConfiguration configuration; | ||
|
||
public TestComponentWithConfigInject(TestPluginConfiguration configuration) { | ||
this.configuration = configuration; | ||
} | ||
|
||
public String getIdentifier() { | ||
return "test-component-with-plugin-config-injected"; | ||
} | ||
|
||
public TestPluginConfiguration getConfiguration() { | ||
return configuration; | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
...k/src/test/java/org/opensearch/dataprepper/plugins/configtest/TestDISourceWithConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.dataprepper.plugins.configtest; | ||
|
||
import org.opensearch.dataprepper.model.annotations.DataPrepperPlugin; | ||
import org.opensearch.dataprepper.model.annotations.DataPrepperPluginConstructor; | ||
import org.opensearch.dataprepper.model.buffer.Buffer; | ||
import org.opensearch.dataprepper.model.record.Record; | ||
import org.opensearch.dataprepper.model.source.Source; | ||
import org.opensearch.dataprepper.plugin.TestPluggableInterface; | ||
import org.opensearch.dataprepper.plugin.TestPluginConfiguration; | ||
|
||
@DataPrepperPlugin(name = "test_di_source_with_config", | ||
alternateNames = { "test_source_alternate_name1", "test_source_alternate_name2" }, | ||
deprecatedName = "test_source_deprecated_name", | ||
pluginType = Source.class, | ||
packagesToScan = {TestDISourceWithConfig.class}, | ||
pluginConfigurationType = TestPluginConfiguration.class | ||
) | ||
public class TestDISourceWithConfig implements Source<Record<String>>, TestPluggableInterface { | ||
|
||
private final TestComponentWithConfigInject testComponent; | ||
|
||
@DataPrepperPluginConstructor | ||
public TestDISourceWithConfig(final TestComponentWithConfigInject testComponent) { | ||
this.testComponent = testComponent; | ||
} | ||
|
||
@Override | ||
public void start(Buffer<Record<String>> buffer) { | ||
} | ||
|
||
public TestComponentWithConfigInject getTestComponent() { | ||
return testComponent; | ||
} | ||
|
||
@Override | ||
public void stop() {} | ||
} |