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;
}
};
}
Aggregations