Search in sources :

Example 1 with MockSource

use of io.cdap.cdap.etl.mock.batch.MockSource in project cdap by caskdata.

the class ValidationUtilsTest method getPluginConfigurer.

// Mock PluginConfigurer
private PluginConfigurer getPluginConfigurer(PluginClass pluginClass) {
    return new PluginConfigurer() {

        @Override
        public <T> T usePlugin(String pluginType, String pluginName, String pluginId, PluginProperties properties, PluginSelector selector) {
            String tableName = properties.getProperties().get("tableName");
            if (tableName == null || tableName.isEmpty()) {
                throw new InvalidPluginConfigException(pluginClass, Collections.singleton("tableName"), new HashSet<>());
            }
            MockSource.Config config = new MockSource.Config();
            MockSource.ConnectionConfig connectionConfig = new MockSource.ConnectionConfig();
            String schema = properties.getProperties().get("schema");
            String sleep = properties.getProperties().get("sleepInMillis");
            connectionConfig.setTableName(tableName);
            config.setConfig(connectionConfig, schema, null, sleep == null ? null : Long.parseLong(sleep));
            return (T) new MockSource(config);
        }

        @Override
        public <T> Class<T> usePluginClass(String pluginType, String pluginName, String pluginId, PluginProperties properties, PluginSelector selector) {
            return null;
        }

        @Override
        public Map<String, String> evaluateMacros(Map<String, String> properties, MacroEvaluator evaluator, MacroParserOptions options) throws InvalidMacroException {
            return null;
        }
    };
}
Also used : MockSource(io.cdap.cdap.etl.mock.batch.MockSource) PluginSelector(io.cdap.cdap.api.plugin.PluginSelector) MacroEvaluator(io.cdap.cdap.api.macro.MacroEvaluator) InvalidPluginConfigException(io.cdap.cdap.api.plugin.InvalidPluginConfigException) MacroParserOptions(io.cdap.cdap.api.macro.MacroParserOptions) PluginConfigurer(io.cdap.cdap.api.plugin.PluginConfigurer) PluginProperties(io.cdap.cdap.api.plugin.PluginProperties) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

MacroEvaluator (io.cdap.cdap.api.macro.MacroEvaluator)1 MacroParserOptions (io.cdap.cdap.api.macro.MacroParserOptions)1 InvalidPluginConfigException (io.cdap.cdap.api.plugin.InvalidPluginConfigException)1 PluginConfigurer (io.cdap.cdap.api.plugin.PluginConfigurer)1 PluginProperties (io.cdap.cdap.api.plugin.PluginProperties)1 PluginSelector (io.cdap.cdap.api.plugin.PluginSelector)1 MockSource (io.cdap.cdap.etl.mock.batch.MockSource)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1