mirror of
https://github.com/apache/sqoop.git
synced 2025-05-12 15:01:45 +08:00
SQOOP-1442: Sqoop2: Validations: Serialize validations over the wire for client transfer
(Abraham Fine via Jarek Jarcec Cecho)
This commit is contained in:
parent
1d4d70ac23
commit
d69bd34e0b
@ -44,6 +44,7 @@
|
||||
import org.apache.sqoop.model.MFromConfig;
|
||||
import org.apache.sqoop.model.MLinkConfig;
|
||||
import org.apache.sqoop.model.MToConfig;
|
||||
import org.apache.sqoop.model.MValidator;
|
||||
import org.apache.sqoop.utils.MapResourceBundle;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.Test;
|
||||
@ -221,13 +222,13 @@ private DriverBean driverBean(MDriver driver) {
|
||||
|
||||
private MConnector connector(long id) {
|
||||
MConnector connector = new MConnector("A" + id, "A" + id, "1.0" + id,
|
||||
new MLinkConfig(null), new MFromConfig(null), new MToConfig(null));
|
||||
new MLinkConfig(null, null), new MFromConfig(null, null), new MToConfig(null, null));
|
||||
connector.setPersistenceId(id);
|
||||
return connector;
|
||||
}
|
||||
|
||||
private MDriver driver() {
|
||||
MDriver driver = new MDriver(new MDriverConfig(new LinkedList<MConfig>()), "1");
|
||||
MDriver driver = new MDriver(new MDriverConfig(new LinkedList<MConfig>(), new LinkedList<MValidator>()), "1");
|
||||
driver.setPersistenceId(1);
|
||||
return driver;
|
||||
}
|
||||
|
@ -18,10 +18,12 @@
|
||||
package org.apache.sqoop.json;
|
||||
|
||||
import static org.apache.sqoop.json.util.ConfigInputSerialization.extractConfigList;
|
||||
import static org.apache.sqoop.json.util.ConfigInputSerialization.restoreConfigList;
|
||||
import static org.apache.sqoop.json.util.ConfigBundleSerialization.extractConfigParamBundle;
|
||||
import static org.apache.sqoop.json.util.ConfigBundleSerialization.restoreConfigParamBundle;
|
||||
|
||||
import static org.apache.sqoop.json.util.ConfigInputSerialization.restoreConfigs;
|
||||
import static org.apache.sqoop.json.util.ConfigInputSerialization.restoreValidator;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@ -31,11 +33,13 @@
|
||||
import org.apache.sqoop.classification.InterfaceAudience;
|
||||
import org.apache.sqoop.classification.InterfaceStability;
|
||||
import org.apache.sqoop.common.Direction;
|
||||
import org.apache.sqoop.json.util.ConfigInputConstants;
|
||||
import org.apache.sqoop.model.MConfig;
|
||||
import org.apache.sqoop.model.MConnector;
|
||||
import org.apache.sqoop.model.MFromConfig;
|
||||
import org.apache.sqoop.model.MLinkConfig;
|
||||
import org.apache.sqoop.model.MToConfig;
|
||||
import org.apache.sqoop.model.MValidator;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
@ -99,22 +103,19 @@ private JSONObject extractConnector(boolean skipSensitive, MConnector connector)
|
||||
connectorJsonObject.put(CONFIGURABLE_VERSION, connector.getVersion());
|
||||
connectorJsonObject.put(
|
||||
CONNECTOR_LINK_CONFIG,
|
||||
extractConfigList(connector.getLinkConfig().getConfigs(), connector.getLinkConfig()
|
||||
.getType(), skipSensitive));
|
||||
extractConfigList(connector.getLinkConfig(), skipSensitive));
|
||||
|
||||
connectorJsonObject.put(CONNECTOR_JOB_CONFIG, new JSONObject());
|
||||
// add sub fields to the job config for from and to
|
||||
if (connector.getFromConfig() != null) {
|
||||
((JSONObject) connectorJsonObject.get(CONNECTOR_JOB_CONFIG)).put(
|
||||
Direction.FROM,
|
||||
extractConfigList(connector.getFromConfig().getConfigs(), connector.getFromConfig()
|
||||
.getType(), skipSensitive));
|
||||
extractConfigList(connector.getFromConfig(), skipSensitive));
|
||||
}
|
||||
if (connector.getToConfig() != null) {
|
||||
((JSONObject) connectorJsonObject.get(CONNECTOR_JOB_CONFIG)).put(
|
||||
Direction.TO,
|
||||
extractConfigList(connector.getToConfig().getConfigs(), connector.getToConfig()
|
||||
.getType(), skipSensitive));
|
||||
extractConfigList(connector.getToConfig(), skipSensitive));
|
||||
}
|
||||
// add the config-param inside each connector
|
||||
connectorJsonObject.put(ALL_CONFIGS, new JSONObject());
|
||||
@ -148,28 +149,33 @@ private MConnector restoreConnector(Object obj) {
|
||||
String className = (String) object.get(CLASS);
|
||||
String version = (String) object.get(CONFIGURABLE_VERSION);
|
||||
|
||||
List<MConfig> linkConfigs = restoreConfigList((JSONArray) object
|
||||
.get(CONNECTOR_LINK_CONFIG));
|
||||
JSONObject jsonLink = (JSONObject) object.get(CONNECTOR_LINK_CONFIG);
|
||||
List<MConfig> linkConfigs = restoreConfigs((JSONArray) jsonLink.get(ConfigInputConstants.CONFIGS));
|
||||
List<MValidator> linkValidators = restoreValidator((JSONArray) jsonLink
|
||||
.get(ConfigInputConstants.CONFIG_VALIDATORS));
|
||||
|
||||
// parent that encapsulates both the from/to configs
|
||||
JSONObject jobConfigJson = (JSONObject) object.get(CONNECTOR_JOB_CONFIG);
|
||||
JSONArray fromJobConfigJson = (JSONArray) jobConfigJson.get(Direction.FROM.name());
|
||||
JSONArray toJobConfigJson = (JSONArray) jobConfigJson.get(Direction.TO.name());
|
||||
JSONObject fromJobConfigJson = (JSONObject) jobConfigJson.get(Direction.FROM.name());
|
||||
JSONObject toJobConfigJson = (JSONObject) jobConfigJson.get(Direction.TO.name());
|
||||
|
||||
MFromConfig fromConfig = null;
|
||||
MToConfig toConfig = null;
|
||||
if (fromJobConfigJson != null) {
|
||||
|
||||
List<MConfig> fromJobConfig = restoreConfigList(fromJobConfigJson);
|
||||
fromConfig = new MFromConfig(fromJobConfig);
|
||||
List<MConfig> fromLinkConfigs = restoreConfigs((JSONArray) fromJobConfigJson.get(ConfigInputConstants.CONFIGS));
|
||||
List<MValidator> fromLinkValidators = restoreValidator((JSONArray)
|
||||
fromJobConfigJson.get(ConfigInputConstants.CONFIG_VALIDATORS));
|
||||
fromConfig = new MFromConfig(fromLinkConfigs, fromLinkValidators);
|
||||
|
||||
}
|
||||
if (toJobConfigJson != null) {
|
||||
List<MConfig> toJobConfig = restoreConfigList(toJobConfigJson);
|
||||
toConfig = new MToConfig(toJobConfig);
|
||||
List<MConfig> toLinkConfigs = restoreConfigs((JSONArray) toJobConfigJson.get(ConfigInputConstants.CONFIGS));
|
||||
List<MValidator> toLinkValidators = restoreValidator((JSONArray)
|
||||
toJobConfigJson.get(ConfigInputConstants.CONFIG_VALIDATORS));
|
||||
toConfig = new MToConfig(toLinkConfigs, toLinkValidators);
|
||||
}
|
||||
|
||||
MLinkConfig linkConfig = new MLinkConfig(linkConfigs);
|
||||
MLinkConfig linkConfig = new MLinkConfig(linkConfigs, linkValidators);
|
||||
MConnector connector = new MConnector(uniqueName, className, version, linkConfig, fromConfig,
|
||||
toConfig);
|
||||
|
||||
|
@ -18,18 +18,24 @@
|
||||
package org.apache.sqoop.json;
|
||||
|
||||
import static org.apache.sqoop.json.util.ConfigInputSerialization.extractConfigList;
|
||||
import static org.apache.sqoop.json.util.ConfigInputSerialization.restoreConfigList;
|
||||
import static org.apache.sqoop.json.util.ConfigBundleSerialization.extractConfigParamBundle;
|
||||
import static org.apache.sqoop.json.util.ConfigBundleSerialization.restoreConfigParamBundle;
|
||||
|
||||
|
||||
|
||||
import static org.apache.sqoop.json.util.ConfigInputSerialization.restoreConfigs;
|
||||
import static org.apache.sqoop.json.util.ConfigInputSerialization.restoreValidator;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
import org.apache.sqoop.classification.InterfaceAudience;
|
||||
import org.apache.sqoop.classification.InterfaceStability;
|
||||
import org.apache.sqoop.json.util.ConfigInputConstants;
|
||||
import org.apache.sqoop.model.MConfig;
|
||||
import org.apache.sqoop.model.MDriver;
|
||||
import org.apache.sqoop.model.MDriverConfig;
|
||||
import org.apache.sqoop.model.MValidator;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
/**
|
||||
@ -66,8 +72,8 @@ public ResourceBundle getDriverConfigResourceBundle() {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public JSONObject extract(boolean skipSensitive) {
|
||||
JSONArray configs =
|
||||
extractConfigList(driver.getDriverConfig().getConfigs(), driver.getDriverConfig().getType(), skipSensitive);
|
||||
JSONObject configs =
|
||||
extractConfigList(driver.getDriverConfig(), skipSensitive);
|
||||
|
||||
JSONObject result = new JSONObject();
|
||||
result.put(ID, driver.getPersistenceId());
|
||||
@ -81,8 +87,11 @@ public JSONObject extract(boolean skipSensitive) {
|
||||
public void restore(JSONObject jsonObject) {
|
||||
long id = (Long) jsonObject.get(ID);
|
||||
String driverVersion = (String) jsonObject.get(CONFIGURABLE_VERSION);
|
||||
List<MConfig> driverConfig = restoreConfigList((JSONArray) jsonObject.get(DRIVER_JOB_CONFIG));
|
||||
driver = new MDriver(new MDriverConfig(driverConfig), driverVersion);
|
||||
JSONObject driverJobConfig = (JSONObject) jsonObject.get(DRIVER_JOB_CONFIG);
|
||||
List<MConfig> driverConfigs = restoreConfigs((JSONArray) driverJobConfig.get(ConfigInputConstants.CONFIGS));
|
||||
List<MValidator> driverValidators = restoreValidator((JSONArray)
|
||||
driverJobConfig.get(ConfigInputConstants.CONFIG_VALIDATORS));
|
||||
driver = new MDriver(new MDriverConfig(driverConfigs, driverValidators), driverVersion);
|
||||
driver.setPersistenceId(id);
|
||||
driverConfigBundle = restoreConfigParamBundle((JSONObject) jsonObject.get(ALL_CONFIGS));
|
||||
}
|
||||
|
@ -18,7 +18,8 @@
|
||||
package org.apache.sqoop.json;
|
||||
|
||||
import static org.apache.sqoop.json.util.ConfigInputSerialization.extractConfigList;
|
||||
import static org.apache.sqoop.json.util.ConfigInputSerialization.restoreConfigList;
|
||||
import static org.apache.sqoop.json.util.ConfigInputSerialization.restoreConfigs;
|
||||
import static org.apache.sqoop.json.util.ConfigInputSerialization.restoreValidator;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
@ -29,12 +30,14 @@
|
||||
|
||||
import org.apache.sqoop.classification.InterfaceAudience;
|
||||
import org.apache.sqoop.classification.InterfaceStability;
|
||||
import org.apache.sqoop.common.Direction;
|
||||
import org.apache.sqoop.json.util.ConfigInputConstants;
|
||||
import org.apache.sqoop.json.util.ConfigValidatorConstants;
|
||||
import org.apache.sqoop.model.MConfig;
|
||||
import org.apache.sqoop.model.MDriverConfig;
|
||||
import org.apache.sqoop.model.MFromConfig;
|
||||
import org.apache.sqoop.model.MJob;
|
||||
import org.apache.sqoop.model.MToConfig;
|
||||
import org.apache.sqoop.model.MValidator;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
@ -138,16 +141,13 @@ private JSONObject extractJob(boolean skipSensitive, MJob job) {
|
||||
object.put(TO_LINK_ID, job.getToLinkId());
|
||||
// job configs
|
||||
MFromConfig fromConfigList = job.getFromJobConfig();
|
||||
object.put(FROM_CONFIG_VALUES,
|
||||
extractConfigList(fromConfigList.getConfigs(), fromConfigList.getType(), skipSensitive));
|
||||
object.put(FROM_CONFIG_VALUES, extractConfigList(fromConfigList, skipSensitive));
|
||||
MToConfig toConfigList = job.getToJobConfig();
|
||||
object.put(TO_CONFIG_VALUES,
|
||||
extractConfigList(toConfigList.getConfigs(), toConfigList.getType(), skipSensitive));
|
||||
object.put(TO_CONFIG_VALUES, extractConfigList(toConfigList, skipSensitive));
|
||||
MDriverConfig driverConfigList = job.getDriverConfig();
|
||||
object.put(
|
||||
DRIVER_CONFIG_VALUES,
|
||||
extractConfigList(driverConfigList.getConfigs(), driverConfigList.getType(),
|
||||
skipSensitive));
|
||||
extractConfigList(driverConfigList, skipSensitive));
|
||||
|
||||
return object;
|
||||
}
|
||||
@ -172,22 +172,31 @@ private MJob restoreJob(Object obj) {
|
||||
long toConnectorId = (Long) object.get(TO_CONNECTOR_ID);
|
||||
long fromConnectionId = (Long) object.get(FROM_LINK_ID);
|
||||
long toConnectionId = (Long) object.get(TO_LINK_ID);
|
||||
JSONArray fromConfigJson = (JSONArray) object.get(FROM_CONFIG_VALUES);
|
||||
JSONArray toConfigJson = (JSONArray) object.get(TO_CONFIG_VALUES);
|
||||
JSONArray driverConfigJson = (JSONArray) object.get(DRIVER_CONFIG_VALUES);
|
||||
JSONObject fromConfigJson = (JSONObject) object.get(FROM_CONFIG_VALUES);
|
||||
JSONObject toConfigJson = (JSONObject) object.get(TO_CONFIG_VALUES);
|
||||
JSONObject driverConfigJson = (JSONObject) object.get(DRIVER_CONFIG_VALUES);
|
||||
|
||||
List<MConfig> fromConfig = restoreConfigList(fromConfigJson);
|
||||
List<MConfig> toConfig = restoreConfigList(toConfigJson);
|
||||
List<MConfig> driverConfig = restoreConfigList(driverConfigJson);
|
||||
List<MConfig> fromConfigs = restoreConfigs((JSONArray) fromConfigJson.get(ConfigInputConstants.CONFIGS));
|
||||
List<MValidator> fromValidators = restoreValidator((JSONArray)
|
||||
fromConfigJson.get(ConfigInputConstants.CONFIG_VALIDATORS));
|
||||
|
||||
List<MConfig> toConfigs = restoreConfigs((JSONArray) toConfigJson.get(ConfigInputConstants.CONFIGS));
|
||||
List<MValidator> toValidators = restoreValidator((JSONArray)
|
||||
toConfigJson.get(ConfigInputConstants.CONFIG_VALIDATORS));
|
||||
|
||||
List<MConfig> driverConfigs = restoreConfigs((JSONArray) driverConfigJson
|
||||
.get(ConfigInputConstants.CONFIGS));
|
||||
List<MValidator> driverValidators = restoreValidator((JSONArray)
|
||||
driverConfigJson.get(ConfigInputConstants.CONFIG_VALIDATORS));
|
||||
|
||||
MJob job = new MJob(
|
||||
fromConnectorId,
|
||||
toConnectorId,
|
||||
fromConnectionId,
|
||||
toConnectionId,
|
||||
new MFromConfig(fromConfig),
|
||||
new MToConfig(toConfig),
|
||||
new MDriverConfig(driverConfig)
|
||||
new MFromConfig(fromConfigs, fromValidators),
|
||||
new MToConfig(toConfigs, toValidators),
|
||||
new MDriverConfig(driverConfigs, driverValidators)
|
||||
);
|
||||
|
||||
job.setPersistenceId((Long) object.get(ID));
|
||||
|
@ -18,7 +18,8 @@
|
||||
package org.apache.sqoop.json;
|
||||
|
||||
import static org.apache.sqoop.json.util.ConfigInputSerialization.extractConfigList;
|
||||
import static org.apache.sqoop.json.util.ConfigInputSerialization.restoreConfigList;
|
||||
import static org.apache.sqoop.json.util.ConfigInputSerialization.restoreConfigs;
|
||||
import static org.apache.sqoop.json.util.ConfigInputSerialization.restoreValidator;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
@ -29,9 +30,11 @@
|
||||
|
||||
import org.apache.sqoop.classification.InterfaceAudience;
|
||||
import org.apache.sqoop.classification.InterfaceStability;
|
||||
import org.apache.sqoop.json.util.ConfigInputConstants;
|
||||
import org.apache.sqoop.model.MConfig;
|
||||
import org.apache.sqoop.model.MLink;
|
||||
import org.apache.sqoop.model.MLinkConfig;
|
||||
import org.apache.sqoop.model.MValidator;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
@ -118,7 +121,7 @@ private JSONObject extractLink(boolean skipSensitive, MLink link) {
|
||||
linkJsonObject.put(UPDATE_DATE, link.getLastUpdateDate().getTime());
|
||||
linkJsonObject.put(CONNECTOR_ID, link.getConnectorId());
|
||||
linkJsonObject.put(LINK_CONFIG_VALUES,
|
||||
extractConfigList(link.getConnectorLinkConfig().getConfigs(), link.getConnectorLinkConfig().getType(), skipSensitive));
|
||||
extractConfigList(link.getConnectorLinkConfig(), skipSensitive));
|
||||
return linkJsonObject;
|
||||
}
|
||||
|
||||
@ -139,9 +142,10 @@ protected void restoreLinks(JSONArray array) {
|
||||
private MLink restoreLink(Object obj) {
|
||||
JSONObject object = (JSONObject) obj;
|
||||
long connectorId = (Long) object.get(CONNECTOR_ID);
|
||||
JSONArray connectorLinkConfig = (JSONArray) object.get(LINK_CONFIG_VALUES);
|
||||
List<MConfig> linkConfig = restoreConfigList(connectorLinkConfig);
|
||||
MLink link = new MLink(connectorId, new MLinkConfig(linkConfig));
|
||||
JSONObject connectorLinkConfig = (JSONObject) object.get(LINK_CONFIG_VALUES);
|
||||
List<MConfig> linkConfigs = restoreConfigs((JSONArray) connectorLinkConfig.get(ConfigInputConstants.CONFIGS));
|
||||
List<MValidator> linkValidators = restoreValidator((JSONArray) connectorLinkConfig.get(ConfigInputConstants.CONFIG_VALIDATORS));
|
||||
MLink link = new MLink(connectorId, new MLinkConfig(linkConfigs, linkValidators));
|
||||
link.setPersistenceId((Long) object.get(ID));
|
||||
link.setName((String) object.get(NAME));
|
||||
link.setEnabled((Boolean) object.get(ENABLED));
|
||||
|
@ -32,6 +32,7 @@ public class ConfigInputConstants {
|
||||
public static final String CONFIG_NAME = "name";
|
||||
public static final String CONFIG_TYPE = "type";
|
||||
public static final String CONFIG_INPUTS = "inputs";
|
||||
public static final String CONFIGS = "configs";
|
||||
public static final String CONFIG_INPUT_NAME = "name";
|
||||
public static final String CONFIG_INPUT_TYPE = "type";
|
||||
public static final String CONFIG_INPUT_SENSITIVE = "sensitive";
|
||||
@ -41,6 +42,7 @@ public class ConfigInputConstants {
|
||||
public static final String CONFIG_INPUT_OVERRIDES = "overrides";
|
||||
public static final String CONFIG_INPUT_VALUE = "value";
|
||||
public static final String CONFIG_INPUT_ENUM_VALUES = "values";
|
||||
public static final String CONFIG_VALIDATORS = "validators";
|
||||
|
||||
private ConfigInputConstants() {
|
||||
|
||||
|
@ -23,6 +23,7 @@
|
||||
import org.apache.sqoop.common.SqoopException;
|
||||
import org.apache.sqoop.model.InputEditable;
|
||||
import org.apache.sqoop.model.MBooleanInput;
|
||||
import org.apache.sqoop.model.MConfigList;
|
||||
import org.apache.sqoop.model.MDateTimeInput;
|
||||
import org.apache.sqoop.model.MEnumInput;
|
||||
import org.apache.sqoop.model.MConfig;
|
||||
@ -34,6 +35,7 @@
|
||||
import org.apache.sqoop.model.MLongInput;
|
||||
import org.apache.sqoop.model.MMapInput;
|
||||
import org.apache.sqoop.model.MStringInput;
|
||||
import org.apache.sqoop.model.MValidator;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
@ -51,18 +53,23 @@ public final class ConfigInputSerialization {
|
||||
/**
|
||||
* Transform given list of configs to JSON Array object.
|
||||
*
|
||||
* @param mConfigs List of configs.
|
||||
* @param mConfigList List of configs.
|
||||
* @return JSON object with serialized config of the list.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static JSONArray extractConfigList(List<MConfig> mConfigs, MConfigType type,
|
||||
boolean skipSensitive) {
|
||||
public static JSONObject extractConfigList(MConfigList mConfigList, boolean skipSensitive) {
|
||||
JSONObject jsonConfigList = new JSONObject();
|
||||
|
||||
jsonConfigList.put(ConfigInputConstants.CONFIG_VALIDATORS, extractValidators(mConfigList.getValidators()));
|
||||
|
||||
JSONArray configs = new JSONArray();
|
||||
|
||||
for (MConfig mConfig : mConfigs) {
|
||||
configs.add(extractConfig(mConfig, type, skipSensitive));
|
||||
for (MConfig mConfig : mConfigList.getConfigs()) {
|
||||
configs.add(extractConfig(mConfig, mConfigList.getType(), skipSensitive));
|
||||
}
|
||||
return configs;
|
||||
|
||||
jsonConfigList.put(ConfigInputConstants.CONFIGS, configs);
|
||||
return jsonConfigList;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -78,6 +85,9 @@ static JSONObject extractConfig(MConfig mConfig, MConfigType type, boolean skipS
|
||||
config.put(ConfigInputConstants.CONFIG_ID, mConfig.getPersistenceId());
|
||||
config.put(ConfigInputConstants.CONFIG_NAME, mConfig.getName());
|
||||
config.put(ConfigInputConstants.CONFIG_TYPE, type.name());
|
||||
|
||||
config.put(ConfigInputConstants.CONFIG_VALIDATORS, extractValidators(mConfig.getValidators()));
|
||||
|
||||
JSONArray mInputs = new JSONArray();
|
||||
config.put(ConfigInputConstants.CONFIG_INPUTS, mInputs);
|
||||
|
||||
@ -90,6 +100,8 @@ static JSONObject extractConfig(MConfig mConfig, MConfigType type, boolean skipS
|
||||
input.put(ConfigInputConstants.CONFIG_INPUT_EDITABLE, mInput.getEditable().name());
|
||||
input.put(ConfigInputConstants.CONFIG_INPUT_OVERRIDES, mInput.getOverrides());
|
||||
|
||||
input.put(ConfigInputConstants.CONFIG_VALIDATORS, extractValidators(mInput.getValidators()));
|
||||
|
||||
// String specific serialization
|
||||
if (mInput.getType() == MInputType.STRING) {
|
||||
input.put(ConfigInputConstants.CONFIG_INPUT_SIZE,
|
||||
@ -124,13 +136,47 @@ static JSONObject extractConfig(MConfig mConfig, MConfigType type, boolean skipS
|
||||
return config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract list of MValidators to JSONArray.
|
||||
*
|
||||
* @param mValidators List of MValidators
|
||||
* @return JSONArray containing json objects representing the MValidators
|
||||
*/
|
||||
public static JSONArray extractValidators(List<MValidator> mValidators) {
|
||||
JSONArray jsonValidators = new JSONArray();
|
||||
for (MValidator mValidator : mValidators) {
|
||||
JSONObject jsonValidator = new JSONObject();
|
||||
jsonValidator.put(ConfigValidatorConstants.VALIDATOR_CLASS, mValidator.getValidatorClass());
|
||||
jsonValidator.put(ConfigValidatorConstants.VALIDATOR_STR_ARG, mValidator.getStrArg());
|
||||
jsonValidators.add(jsonValidator);
|
||||
}
|
||||
return jsonValidators;
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore List of MValidations from JSON Array.
|
||||
*
|
||||
* @param jsonValidators JSON array representing list of MValidators
|
||||
* @return Restored list of MValidations
|
||||
*/
|
||||
public static List<MValidator> restoreValidator(JSONArray jsonValidators) {
|
||||
List<MValidator> mValidators = new ArrayList<>();
|
||||
for (int validatorCounter = 0; validatorCounter < jsonValidators.size(); validatorCounter++) {
|
||||
JSONObject jsonValidator = (JSONObject) jsonValidators.get(validatorCounter);
|
||||
String validatorClassName = (String) jsonValidator.get(ConfigValidatorConstants.VALIDATOR_CLASS);
|
||||
String validatorStrArg = (String) jsonValidator.get(ConfigValidatorConstants.VALIDATOR_STR_ARG);
|
||||
mValidators.add(new MValidator(validatorClassName, validatorStrArg));
|
||||
}
|
||||
return mValidators;
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore List of MConfigs from JSON Array.
|
||||
*
|
||||
* @param configs JSON array representing list of MConfigs
|
||||
* @return Restored list of MConfigs
|
||||
*/
|
||||
public static List<MConfig> restoreConfigList(JSONArray configs) {
|
||||
public static List<MConfig> restoreConfigs(JSONArray configs) {
|
||||
List<MConfig> mConfigs = new ArrayList<MConfig>();
|
||||
|
||||
for (int i = 0; i < configs.size(); i++) {
|
||||
@ -163,40 +209,43 @@ static MConfig restoreConfig(JSONObject config) {
|
||||
String overrides = (String) input.get(ConfigInputConstants.CONFIG_INPUT_OVERRIDES);
|
||||
String sensitveKeyPattern = (String) input.get(ConfigInputConstants.CONFIG_INPUT_SENSITIVE_KEY_PATTERN);
|
||||
|
||||
List<MValidator> mValidatorsForInput = restoreValidator((JSONArray)
|
||||
input.get(ConfigInputConstants.CONFIG_VALIDATORS));
|
||||
|
||||
MInput mInput = null;
|
||||
switch (type) {
|
||||
case STRING: {
|
||||
long size = (Long) input.get(ConfigInputConstants.CONFIG_INPUT_SIZE);
|
||||
mInput = new MStringInput(name, sensitive.booleanValue(), editable, overrides, (short) size);
|
||||
mInput = new MStringInput(name, sensitive.booleanValue(), editable, overrides, (short) size, mValidatorsForInput);
|
||||
break;
|
||||
}
|
||||
case MAP: {
|
||||
mInput = new MMapInput(name, sensitive.booleanValue(), editable, overrides, sensitveKeyPattern);
|
||||
mInput = new MMapInput(name, sensitive.booleanValue(), editable, overrides, sensitveKeyPattern, mValidatorsForInput);
|
||||
break;
|
||||
}
|
||||
case INTEGER: {
|
||||
mInput = new MIntegerInput(name, sensitive.booleanValue(), editable, overrides);
|
||||
mInput = new MIntegerInput(name, sensitive.booleanValue(), editable, overrides, mValidatorsForInput);
|
||||
break;
|
||||
}
|
||||
case LONG: {
|
||||
mInput = new MLongInput(name, sensitive.booleanValue(), editable, overrides);
|
||||
mInput = new MLongInput(name, sensitive.booleanValue(), editable, overrides, mValidatorsForInput);
|
||||
break;
|
||||
}
|
||||
case BOOLEAN: {
|
||||
mInput = new MBooleanInput(name, sensitive.booleanValue(), editable, overrides);
|
||||
mInput = new MBooleanInput(name, sensitive.booleanValue(), editable, overrides, mValidatorsForInput);
|
||||
break;
|
||||
}
|
||||
case ENUM: {
|
||||
String values = (String) input.get(ConfigInputConstants.CONFIG_INPUT_ENUM_VALUES);
|
||||
mInput = new MEnumInput(name, sensitive.booleanValue(), editable, overrides, values.split(","));
|
||||
mInput = new MEnumInput(name, sensitive.booleanValue(), editable, overrides, values.split(","), mValidatorsForInput);
|
||||
break;
|
||||
}
|
||||
case LIST: {
|
||||
mInput = new MListInput(name, sensitive.booleanValue(), editable, overrides);
|
||||
mInput = new MListInput(name, sensitive.booleanValue(), editable, overrides, mValidatorsForInput);
|
||||
break;
|
||||
}
|
||||
case DATETIME: {
|
||||
mInput = new MDateTimeInput(name, sensitive.booleanValue(), editable, overrides);
|
||||
mInput = new MDateTimeInput(name, sensitive.booleanValue(), editable, overrides, mValidatorsForInput);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@ -230,12 +279,16 @@ static MConfig restoreConfig(JSONObject config) {
|
||||
mInputs.add(mInput);
|
||||
}
|
||||
|
||||
MConfig mConfig = new MConfig((String) config.get(ConfigInputConstants.CONFIG_NAME), mInputs);
|
||||
mConfig.setPersistenceId((Long) config.get(ConfigInputConstants.CONFIG_ID));
|
||||
return mConfig;
|
||||
}
|
||||
|
||||
private ConfigInputSerialization() {
|
||||
|
||||
List<MValidator> mValidatorsForConfig = restoreValidator((JSONArray)
|
||||
config.get(ConfigInputConstants.CONFIG_VALIDATORS));
|
||||
MConfig mConfig = new MConfig((String) config.get(ConfigInputConstants.CONFIG_NAME), mInputs, mValidatorsForConfig);
|
||||
mConfig.setPersistenceId((Long) config.get(ConfigInputConstants.CONFIG_ID));
|
||||
return mConfig;
|
||||
}
|
||||
|
||||
private ConfigInputSerialization() {
|
||||
// Do not instantiate
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,26 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.sqoop.json.util;
|
||||
|
||||
/**
|
||||
* Constants related to validators
|
||||
*/
|
||||
public class ConfigValidatorConstants {
|
||||
public static final String VALIDATOR_CLASS = "validator-class";
|
||||
public static final String VALIDATOR_STR_ARG = "validator-str-arg";
|
||||
}
|
@ -21,7 +21,6 @@
|
||||
import org.apache.sqoop.classification.InterfaceAudience;
|
||||
import org.apache.sqoop.classification.InterfaceStability;
|
||||
import org.apache.sqoop.common.SqoopException;
|
||||
import org.apache.sqoop.error.code.CommonRepositoryError;
|
||||
import org.apache.sqoop.json.JSONUtils;
|
||||
import org.apache.sqoop.utils.ClassUtils;
|
||||
import org.apache.sqoop.validation.ConfigValidationRunner;
|
||||
@ -125,6 +124,11 @@ private static MConfig toConfig(String configName, Class klass, Object object) {
|
||||
"Missing annotation ConfigClass on class " + klass.getName());
|
||||
}
|
||||
|
||||
List<MValidator> mValidatorsForConfigClass = new ArrayList<>();
|
||||
for (Validator validator : global.validators()) {
|
||||
mValidatorsForConfigClass.add(getMValidator(validator));
|
||||
}
|
||||
|
||||
// Intermediate list of inputs
|
||||
List<MInput<?>> inputs = new LinkedList<MInput<?>>();
|
||||
|
||||
@ -140,6 +144,10 @@ private static MConfig toConfig(String configName, Class klass, Object object) {
|
||||
Input inputAnnotation = field.getAnnotation(Input.class);
|
||||
|
||||
if(inputAnnotation != null) {
|
||||
List<MValidator> mValidatorsForInput = new ArrayList<>();
|
||||
for (Validator validator : inputAnnotation.validators()) {
|
||||
mValidatorsForInput.add(getMValidator(validator));
|
||||
}
|
||||
boolean sensitive = inputAnnotation.sensitive();
|
||||
short maxLen = inputAnnotation.size();
|
||||
InputEditable editable = inputAnnotation.editable();
|
||||
@ -157,22 +165,22 @@ private static MConfig toConfig(String configName, Class klass, Object object) {
|
||||
|
||||
// Instantiate corresponding MInput<?> structure
|
||||
if (type == String.class) {
|
||||
input = new MStringInput(inputName, sensitive, editable, overrides, maxLen);
|
||||
input = new MStringInput(inputName, sensitive, editable, overrides, maxLen, mValidatorsForInput);
|
||||
} else if (type.isAssignableFrom(Map.class)) {
|
||||
input = new MMapInput(inputName, sensitive, editable, overrides, sensitiveKeyPattern);
|
||||
input = new MMapInput(inputName, sensitive, editable, overrides, sensitiveKeyPattern, mValidatorsForInput);
|
||||
} else if (type == Integer.class) {
|
||||
input = new MIntegerInput(inputName, sensitive, editable, overrides);
|
||||
input = new MIntegerInput(inputName, sensitive, editable, overrides, mValidatorsForInput);
|
||||
} else if (type == Long.class) {
|
||||
input = new MLongInput(inputName, sensitive, editable, overrides);
|
||||
input = new MLongInput(inputName, sensitive, editable, overrides, mValidatorsForInput);
|
||||
} else if (type == Boolean.class) {
|
||||
input = new MBooleanInput(inputName, sensitive, editable, overrides);
|
||||
input = new MBooleanInput(inputName, sensitive, editable, overrides, mValidatorsForInput);
|
||||
} else if (type.isEnum()) {
|
||||
input = new MEnumInput(inputName, sensitive, editable, overrides,
|
||||
ClassUtils.getEnumStrings(type));
|
||||
ClassUtils.getEnumStrings(type), mValidatorsForInput);
|
||||
} else if (type.isAssignableFrom(List.class)) {
|
||||
input = new MListInput(inputName, sensitive, editable, overrides);
|
||||
input = new MListInput(inputName, sensitive, editable, overrides, mValidatorsForInput);
|
||||
} else if (type == DateTime.class) {
|
||||
input = new MDateTimeInput(inputName, sensitive, editable, overrides);
|
||||
input = new MDateTimeInput(inputName, sensitive, editable, overrides, mValidatorsForInput);
|
||||
} else {
|
||||
throw new SqoopException(ModelError.MODEL_004, "Unsupported type "
|
||||
+ type.getName() + " for input " + fieldName);
|
||||
@ -203,7 +211,7 @@ private static MConfig toConfig(String configName, Class klass, Object object) {
|
||||
inputs.add(input);
|
||||
}
|
||||
}
|
||||
MConfig config = new MConfig(configName, inputs);
|
||||
MConfig config = new MConfig(configName, inputs, mValidatorsForConfigClass);
|
||||
// validation has to happen only when all inputs have been parsed
|
||||
for (MInput<?> input : config.getInputs()) {
|
||||
validateInputOverridesAttribute(input, config);
|
||||
@ -615,20 +623,38 @@ public static String getName(Field config, Config annotation) {
|
||||
}
|
||||
|
||||
public static ConfigurationClass getConfigurationClassAnnotation(Object object, boolean strict) {
|
||||
ConfigurationClass annotation = object.getClass().getAnnotation(ConfigurationClass.class);
|
||||
return getConfigurationClassAnnotation(object.getClass(), strict);
|
||||
}
|
||||
|
||||
public static ConfigurationClass getConfigurationClassAnnotation(Class<?> klass, boolean strict) {
|
||||
ConfigurationClass annotation = klass.getAnnotation(ConfigurationClass.class);
|
||||
|
||||
if(strict && annotation == null) {
|
||||
throw new SqoopException(ModelError.MODEL_003, "Missing annotation ConfigurationGroupClass on class " + object.getClass().getName());
|
||||
throw new SqoopException(ModelError.MODEL_003, "Missing annotation ConfigurationGroupClass on class " + klass.getName());
|
||||
}
|
||||
|
||||
return annotation;
|
||||
}
|
||||
|
||||
public static List<MValidator> getMValidatorsFromConfigurationClass(Class<?> klass) {
|
||||
ConfigurationClass annotation = getConfigurationClassAnnotation(klass, true);
|
||||
|
||||
List<MValidator> mValidators = new ArrayList<>();
|
||||
for (Validator validator : annotation.validators()) {
|
||||
mValidators.add(getMValidator(validator));
|
||||
}
|
||||
return mValidators;
|
||||
}
|
||||
|
||||
public static ConfigClass getConfigClassAnnotation(Object object, boolean strict) {
|
||||
ConfigClass annotation = object.getClass().getAnnotation(ConfigClass.class);
|
||||
return getConfigClassAnnotation(object.getClass(), strict);
|
||||
}
|
||||
|
||||
public static ConfigClass getConfigClassAnnotation(Class<?> klass, boolean strict) {
|
||||
ConfigClass annotation = klass.getAnnotation(ConfigClass.class);
|
||||
|
||||
if(strict && annotation == null) {
|
||||
throw new SqoopException(ModelError.MODEL_003, "Missing annotation ConfigurationGroupClass on class " + object.getClass().getName());
|
||||
throw new SqoopException(ModelError.MODEL_003, "Missing annotation ConfigurationGroupClass on class " + klass.getName());
|
||||
}
|
||||
|
||||
return annotation;
|
||||
@ -644,6 +670,8 @@ public static Config getConfigAnnotation(Field field, boolean strict) {
|
||||
return annotation;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static Input getInputAnnotation(Field field, boolean strict) {
|
||||
Input annotation = field.getAnnotation(Input.class);
|
||||
|
||||
@ -711,4 +739,8 @@ public Object run() {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static MValidator getMValidator(Validator validator) {
|
||||
return new MValidator(validator.value().getName(), validator.strArg());
|
||||
}
|
||||
}
|
@ -20,6 +20,7 @@
|
||||
import org.apache.sqoop.classification.InterfaceAudience;
|
||||
import org.apache.sqoop.classification.InterfaceStability;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
@ -64,7 +65,7 @@ abstract public class MAccountableEntity extends MNamedElement {
|
||||
* the accountable entity is enabled.
|
||||
*/
|
||||
public MAccountableEntity() {
|
||||
super((String)null);
|
||||
super((String)null, Collections.EMPTY_LIST);
|
||||
this.creationUser = null;
|
||||
this.creationDate = new Date();
|
||||
this.lastUpdateUser = this.creationUser;
|
||||
|
@ -20,6 +20,8 @@
|
||||
import org.apache.sqoop.classification.InterfaceAudience;
|
||||
import org.apache.sqoop.classification.InterfaceStability;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Represents a <tt>Boolean</tt> input.
|
||||
*/
|
||||
@ -27,8 +29,8 @@
|
||||
@InterfaceStability.Unstable
|
||||
public class MBooleanInput extends MInput<Boolean> {
|
||||
|
||||
public MBooleanInput(String name, boolean sensitive, InputEditable editable, String overrides) {
|
||||
super(name, sensitive, editable, overrides);
|
||||
public MBooleanInput(String name, boolean sensitive, InputEditable editable, String overrides, List<MValidator> mValidators) {
|
||||
super(name, sensitive, editable, overrides, mValidators);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -78,7 +80,7 @@ public void setEmpty() {
|
||||
|
||||
@Override
|
||||
public Object clone(boolean cloneWithValue) {
|
||||
MBooleanInput copy = new MBooleanInput(getName(), isSensitive(), getEditable(), getOverrides());
|
||||
MBooleanInput copy = new MBooleanInput(getName(), isSensitive(), getEditable(), getOverrides(), getCloneOfValidators());
|
||||
copy.setPersistenceId(getPersistenceId());
|
||||
if(cloneWithValue) {
|
||||
copy.setValue(getValue());
|
||||
|
@ -39,8 +39,8 @@ public final class MConfig extends MNamedElement implements MClonable {
|
||||
private Set<String> inputNames = new HashSet<String>();
|
||||
private Set<String> userOnlyEditableInputNames = new HashSet<String>();
|
||||
|
||||
public MConfig(String name, List<MInput<?>> inputs) {
|
||||
super(name);
|
||||
public MConfig(String name, List<MInput<?>> inputs, List<MValidator> mValidators) {
|
||||
super(name, mValidators);
|
||||
this.inputs = inputs;
|
||||
if (inputs != null && inputs.size() > 0) {
|
||||
for (MInput<?> input : inputs) {
|
||||
@ -142,11 +142,11 @@ public int hashCode() {
|
||||
|
||||
@Override
|
||||
public MConfig clone(boolean cloneWithValue) {
|
||||
List<MInput<?>> copyInputs = new ArrayList<MInput<?>>();
|
||||
List<MInput<?>> copyInputs = new ArrayList<>();
|
||||
for(MInput<?> itr : this.getInputs()) {
|
||||
copyInputs.add((MInput<?>)itr.clone(cloneWithValue));
|
||||
}
|
||||
MConfig copyConfig = new MConfig(this.getName(), copyInputs);
|
||||
MConfig copyConfig = new MConfig(this.getName(), copyInputs, getCloneOfValidators());
|
||||
return copyConfig;
|
||||
}
|
||||
}
|
||||
|
@ -34,7 +34,8 @@ public class MConfigList extends MValidatedElement implements MClonable {
|
||||
private final List<MConfig> configObjects;
|
||||
private final MConfigType type;
|
||||
|
||||
public MConfigList(List<MConfig> configObjects, MConfigType type) {
|
||||
public MConfigList(List<MConfig> configObjects, MConfigType type, List<MValidator> mValidators) {
|
||||
super(mValidators);
|
||||
this.configObjects = configObjects;
|
||||
this.type = type;
|
||||
}
|
||||
@ -144,7 +145,7 @@ public MConfigList clone(boolean cloneWithValue) {
|
||||
copyConfigs.add(newConfig);
|
||||
}
|
||||
}
|
||||
MConfigList copyConfigList = new MConfigList(copyConfigs, type);
|
||||
MConfigList copyConfigList = new MConfigList(copyConfigs, type, getCloneOfValidators());
|
||||
return copyConfigList;
|
||||
}
|
||||
}
|
||||
|
@ -22,12 +22,14 @@
|
||||
import org.apache.sqoop.classification.InterfaceAudience;
|
||||
import org.apache.sqoop.classification.InterfaceStability;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@InterfaceAudience.Public
|
||||
@InterfaceStability.Unstable
|
||||
public class MDateTimeInput extends MInput<DateTime> {
|
||||
|
||||
public MDateTimeInput(String name, boolean sensitive, InputEditable editable, String overrides) {
|
||||
super(name, sensitive, editable, overrides);
|
||||
public MDateTimeInput(String name, boolean sensitive, InputEditable editable, String overrides, List<MValidator> mValidators) {
|
||||
super(name, sensitive, editable, overrides, mValidators);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -84,7 +86,7 @@ public void setEmpty() {
|
||||
|
||||
@Override
|
||||
public MDateTimeInput clone(boolean cloneWithValue) {
|
||||
MDateTimeInput copy = new MDateTimeInput(getName(), isSensitive(), getEditable(), getOverrides());
|
||||
MDateTimeInput copy = new MDateTimeInput(getName(), isSensitive(), getEditable(), getOverrides(), getCloneOfValidators());
|
||||
copy.setPersistenceId(getPersistenceId());
|
||||
if(cloneWithValue && this.getValue() != null) {
|
||||
copy.setValue(new DateTime(this.getValue()));
|
||||
|
@ -30,8 +30,8 @@
|
||||
@InterfaceAudience.Public
|
||||
@InterfaceStability.Unstable
|
||||
public class MDriverConfig extends MConfigList {
|
||||
public MDriverConfig(List<MConfig> configs) {
|
||||
super(configs, MConfigType.JOB);
|
||||
public MDriverConfig(List<MConfig> configs, List<MValidator> mValidators) {
|
||||
super(configs, MConfigType.JOB, mValidators);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -62,7 +62,7 @@ public int hashCode() {
|
||||
|
||||
@Override
|
||||
public MDriverConfig clone(boolean cloneWithValue) {
|
||||
MDriverConfig copy = new MDriverConfig(super.clone(cloneWithValue).getConfigs());
|
||||
MDriverConfig copy = new MDriverConfig(super.clone(cloneWithValue).getConfigs(), getCloneOfValidators());
|
||||
return copy;
|
||||
}
|
||||
}
|
@ -23,6 +23,7 @@
|
||||
import org.apache.sqoop.common.SqoopException;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -36,8 +37,8 @@ public class MEnumInput extends MInput<String> {
|
||||
*/
|
||||
String []values;
|
||||
|
||||
public MEnumInput(String name, boolean sensitive, InputEditable editable, String overrides, String[] values) {
|
||||
super(name, sensitive, editable, overrides);
|
||||
public MEnumInput(String name, boolean sensitive, InputEditable editable, String overrides, String[] values, List<MValidator> mValidators) {
|
||||
super(name, sensitive, editable, overrides, mValidators);
|
||||
if (values != null) {
|
||||
this.values = values.clone();
|
||||
} else {
|
||||
@ -139,7 +140,7 @@ public void setEmpty() {
|
||||
@Override
|
||||
public MEnumInput clone(boolean cloneWithValue) {
|
||||
MEnumInput copy = new MEnumInput(getName(), isSensitive(), getEditable(), getOverrides(),
|
||||
getValues());
|
||||
getValues(), getCloneOfValidators());
|
||||
copy.setPersistenceId(getPersistenceId());
|
||||
if(cloneWithValue) {
|
||||
copy.setValue(this.getValue());
|
||||
|
@ -30,8 +30,8 @@
|
||||
@InterfaceAudience.Public
|
||||
@InterfaceStability.Unstable
|
||||
public class MFromConfig extends MConfigList {
|
||||
public MFromConfig(List<MConfig> configs) {
|
||||
super(configs, MConfigType.JOB);
|
||||
public MFromConfig(List<MConfig> configs, List<MValidator> mValidators) {
|
||||
super(configs, MConfigType.JOB, mValidators);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -62,7 +62,7 @@ public int hashCode() {
|
||||
|
||||
@Override
|
||||
public MFromConfig clone(boolean cloneWithValue) {
|
||||
MFromConfig copy = new MFromConfig(super.clone(cloneWithValue).getConfigs());
|
||||
MFromConfig copy = new MFromConfig(super.clone(cloneWithValue).getConfigs(), getCloneOfValidators());
|
||||
return copy;
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,8 @@
|
||||
import org.apache.sqoop.classification.InterfaceAudience;
|
||||
import org.apache.sqoop.classification.InterfaceStability;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Represents a parameter input used by the connector for creating a link
|
||||
* or a job object.
|
||||
@ -37,8 +39,8 @@ public abstract class MInput<T> extends MNamedElement implements MClonable {
|
||||
|
||||
private T value;
|
||||
|
||||
protected MInput(String name, boolean sensitive, InputEditable editable, String overrides) {
|
||||
super(name);
|
||||
protected MInput(String name, boolean sensitive, InputEditable editable, String overrides, List<MValidator> mValidators) {
|
||||
super(name, mValidators);
|
||||
this.sensitive = sensitive;
|
||||
this.editable = editable;
|
||||
this.overrides = overrides;
|
||||
|
@ -20,6 +20,8 @@
|
||||
import org.apache.sqoop.classification.InterfaceAudience;
|
||||
import org.apache.sqoop.classification.InterfaceStability;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Integer base user input.
|
||||
*
|
||||
@ -29,8 +31,8 @@
|
||||
@InterfaceStability.Unstable
|
||||
public class MIntegerInput extends MInput<Integer> {
|
||||
|
||||
public MIntegerInput(String name, boolean sensitive, InputEditable editable, String overrides) {
|
||||
super(name, sensitive, editable, overrides);
|
||||
public MIntegerInput(String name, boolean sensitive, InputEditable editable, String overrides, List<MValidator> mValidators) {
|
||||
super(name, sensitive, editable, overrides, mValidators);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -87,7 +89,7 @@ public void setEmpty() {
|
||||
|
||||
@Override
|
||||
public MIntegerInput clone(boolean cloneWithValue) {
|
||||
MIntegerInput copy = new MIntegerInput(getName(), isSensitive(), getEditable(), getOverrides());
|
||||
MIntegerInput copy = new MIntegerInput(getName(), isSensitive(), getEditable(), getOverrides(), getCloneOfValidators());
|
||||
copy.setPersistenceId(getPersistenceId());
|
||||
if(cloneWithValue) {
|
||||
copy.setValue(this.getValue());
|
||||
|
@ -31,8 +31,8 @@
|
||||
@InterfaceStability.Unstable
|
||||
public class MLinkConfig extends MConfigList {
|
||||
|
||||
public MLinkConfig(List<MConfig> configs) {
|
||||
super(configs, MConfigType.LINK);
|
||||
public MLinkConfig(List<MConfig> configs, List<MValidator> mValidators) {
|
||||
super(configs, MConfigType.LINK, mValidators);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -44,7 +44,7 @@ public String toString() {
|
||||
|
||||
@Override
|
||||
public MLinkConfig clone(boolean cloneWithValue) {
|
||||
MLinkConfig copy = new MLinkConfig(super.clone(cloneWithValue).getConfigs());
|
||||
MLinkConfig copy = new MLinkConfig(super.clone(cloneWithValue).getConfigs(), getCloneOfValidators());
|
||||
return copy;
|
||||
}
|
||||
}
|
||||
|
@ -28,8 +28,8 @@
|
||||
@InterfaceStability.Unstable
|
||||
public class MListInput extends MInput<List<String>> {
|
||||
|
||||
public MListInput(String name, boolean sensitive, InputEditable editable, String overrides) {
|
||||
super(name, sensitive, editable, overrides);
|
||||
public MListInput(String name, boolean sensitive, InputEditable editable, String overrides, List<MValidator> mValidators) {
|
||||
super(name, sensitive, editable, overrides, mValidators);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -102,7 +102,7 @@ public void setEmpty() {
|
||||
|
||||
@Override
|
||||
public Object clone(boolean cloneWithValue) {
|
||||
MListInput copy = new MListInput(getName(), isSensitive(), getEditable(), getOverrides());
|
||||
MListInput copy = new MListInput(getName(), isSensitive(), getEditable(), getOverrides(), getCloneOfValidators());
|
||||
copy.setPersistenceId(getPersistenceId());
|
||||
if(cloneWithValue && this.getValue() != null) {
|
||||
List<String> copyList = new LinkedList<String>();
|
||||
|
@ -20,6 +20,8 @@
|
||||
import org.apache.sqoop.classification.InterfaceAudience;
|
||||
import org.apache.sqoop.classification.InterfaceStability;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Long user input.
|
||||
*
|
||||
@ -28,8 +30,8 @@
|
||||
@InterfaceStability.Unstable
|
||||
public class MLongInput extends MInput<Long> {
|
||||
|
||||
public MLongInput(String name, boolean sensitive, InputEditable editable, String overrides) {
|
||||
super(name, sensitive, editable, overrides);
|
||||
public MLongInput(String name, boolean sensitive, InputEditable editable, String overrides, List<MValidator> mValidators) {
|
||||
super(name, sensitive, editable, overrides, mValidators);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -86,7 +88,7 @@ public void setEmpty() {
|
||||
|
||||
@Override
|
||||
public MLongInput clone(boolean cloneWithValue) {
|
||||
MLongInput copy = new MLongInput(getName(), isSensitive(), getEditable(), getOverrides());
|
||||
MLongInput copy = new MLongInput(getName(), isSensitive(), getEditable(), getOverrides(), getCloneOfValidators());
|
||||
copy.setPersistenceId(getPersistenceId());
|
||||
if(cloneWithValue) {
|
||||
copy.setValue(this.getValue());
|
||||
|
@ -18,6 +18,7 @@
|
||||
package org.apache.sqoop.model;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
@ -35,8 +36,8 @@ public final class MMapInput extends MInput<Map<String, String>> {
|
||||
|
||||
private final String sensitiveKeyPattern;
|
||||
|
||||
public MMapInput(String name, boolean sensitive, InputEditable editable, String overrides, String sensitiveKeyPattern) {
|
||||
super(name, sensitive, editable, overrides);
|
||||
public MMapInput(String name, boolean sensitive, InputEditable editable, String overrides, String sensitiveKeyPattern, List<MValidator> mValidators) {
|
||||
super(name, sensitive, editable, overrides, mValidators);
|
||||
this.sensitiveKeyPattern = sensitiveKeyPattern;
|
||||
}
|
||||
|
||||
@ -124,7 +125,7 @@ public void setEmpty() {
|
||||
|
||||
@Override
|
||||
public MMapInput clone(boolean cloneWithValue) {
|
||||
MMapInput copy = new MMapInput(getName(), isSensitive(), getEditable(), getOverrides(), getSensitiveKeyPattern());
|
||||
MMapInput copy = new MMapInput(getName(), isSensitive(), getEditable(), getOverrides(), getSensitiveKeyPattern(), getCloneOfValidators());
|
||||
copy.setPersistenceId(getPersistenceId());
|
||||
if(cloneWithValue && this.getValue() != null) {
|
||||
Map<String, String> copyMap = new HashMap<String, String>();
|
||||
|
@ -20,6 +20,8 @@
|
||||
import org.apache.sqoop.classification.InterfaceAudience;
|
||||
import org.apache.sqoop.classification.InterfaceStability;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Represents an element of metadata used by the connector.
|
||||
*/
|
||||
@ -33,12 +35,13 @@ public abstract class MNamedElement extends MValidatedElement {
|
||||
private String labelKey;
|
||||
private String helpKey;
|
||||
|
||||
protected MNamedElement(String name) {
|
||||
protected MNamedElement(String name, List<MValidator> mValidators) {
|
||||
super(mValidators);
|
||||
setName(name);
|
||||
}
|
||||
|
||||
protected MNamedElement(MNamedElement other) {
|
||||
this(other.name);
|
||||
this(other.name, other.getCloneOfValidators());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -21,6 +21,8 @@
|
||||
import org.apache.sqoop.classification.InterfaceStability;
|
||||
import org.apache.sqoop.utils.UrlSafeUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Represents a <tt>String</tt> input. The boolean flag <tt>sensitive</tt> supplied
|
||||
* to its constructor can be used to indicate if the string should be masked
|
||||
@ -38,8 +40,8 @@ public final class MStringInput extends MInput<String> {
|
||||
* @param sensitive a flag indicating if the string should be masked
|
||||
* @param maxLength the maximum length of the string
|
||||
*/
|
||||
public MStringInput(String name, boolean sensitive, InputEditable editable, String overrides, short maxLength) {
|
||||
super(name, sensitive, editable, overrides);
|
||||
public MStringInput(String name, boolean sensitive, InputEditable editable, String overrides, short maxLength, List<MValidator> mValidators) {
|
||||
super(name, sensitive, editable, overrides, mValidators);
|
||||
this.maxLength = maxLength;
|
||||
}
|
||||
|
||||
@ -112,7 +114,7 @@ public void setEmpty() {
|
||||
@Override
|
||||
public MStringInput clone(boolean cloneWithValue) {
|
||||
MStringInput copy = new MStringInput(getName(), isSensitive(), getEditable(), getOverrides(),
|
||||
getMaxLength());
|
||||
getMaxLength(), getCloneOfValidators());
|
||||
copy.setPersistenceId(getPersistenceId());
|
||||
if(cloneWithValue) {
|
||||
copy.setValue(this.getValue());
|
||||
|
@ -30,8 +30,8 @@
|
||||
@InterfaceAudience.Public
|
||||
@InterfaceStability.Unstable
|
||||
public class MToConfig extends MConfigList {
|
||||
public MToConfig(List<MConfig> configs) {
|
||||
super(configs, MConfigType.JOB);
|
||||
public MToConfig(List<MConfig> configs, List<MValidator> mValidators) {
|
||||
super(configs, MConfigType.JOB, mValidators);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -62,7 +62,7 @@ public int hashCode() {
|
||||
|
||||
@Override
|
||||
public MToConfig clone(boolean cloneWithValue) {
|
||||
MToConfig copy = new MToConfig(super.clone(cloneWithValue).getConfigs());
|
||||
MToConfig copy = new MToConfig(super.clone(cloneWithValue).getConfigs(), getCloneOfValidators());
|
||||
return copy;
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,7 @@
|
||||
import org.apache.sqoop.validation.Message;
|
||||
import org.apache.sqoop.validation.Status;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
@ -32,6 +33,8 @@
|
||||
@InterfaceStability.Unstable
|
||||
public abstract class MValidatedElement extends MPersistableEntity {
|
||||
|
||||
private List<MValidator> mValidators;
|
||||
|
||||
/**
|
||||
* Validation messages.
|
||||
*/
|
||||
@ -42,13 +45,15 @@ public abstract class MValidatedElement extends MPersistableEntity {
|
||||
*/
|
||||
private Status validationStatus;
|
||||
|
||||
public MValidatedElement() {
|
||||
public MValidatedElement(List<MValidator> mValidators) {
|
||||
this.mValidators = mValidators;
|
||||
resetValidationMessages();
|
||||
}
|
||||
|
||||
public MValidatedElement(MValidatedElement other) {
|
||||
super(other);
|
||||
resetValidationMessages();
|
||||
this.mValidators = other.getCloneOfValidators();
|
||||
this.validationStatus = other.validationStatus;
|
||||
this.validationMessages.addAll(other.validationMessages);
|
||||
}
|
||||
@ -97,6 +102,10 @@ public List<Message> getValidationMessages() {
|
||||
return this.validationMessages;
|
||||
}
|
||||
|
||||
public List<MValidator> getValidators() {
|
||||
return mValidators;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return message validation status.
|
||||
*/
|
||||
@ -104,4 +113,14 @@ public Status getValidationStatus() {
|
||||
return validationStatus;
|
||||
}
|
||||
|
||||
public List<MValidator> getCloneOfValidators() {
|
||||
if (getValidators() == null) return null;
|
||||
|
||||
List<MValidator> copyValidators = new ArrayList<>();
|
||||
for(MValidator itr : this.getValidators()) {
|
||||
copyValidators.add((MValidator)itr.clone(true));
|
||||
}
|
||||
return copyValidators;
|
||||
}
|
||||
|
||||
}
|
||||
|
68
common/src/main/java/org/apache/sqoop/model/MValidator.java
Normal file
68
common/src/main/java/org/apache/sqoop/model/MValidator.java
Normal file
@ -0,0 +1,68 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.sqoop.model;
|
||||
|
||||
import org.apache.sqoop.classification.InterfaceAudience;
|
||||
import org.apache.sqoop.classification.InterfaceStability;
|
||||
|
||||
/**
|
||||
* Represents an @Validator class by its name and optional argument
|
||||
*/
|
||||
@InterfaceAudience.Public
|
||||
@InterfaceStability.Unstable
|
||||
public class MValidator implements MClonable {
|
||||
private final String validatorClass;
|
||||
private final String strArg;
|
||||
|
||||
public MValidator(String validatorClass, String strArg) {
|
||||
this.validatorClass = validatorClass;
|
||||
this.strArg = strArg;
|
||||
}
|
||||
|
||||
// The value of cloneWithValue is ignored
|
||||
@Override
|
||||
public Object clone(boolean cloneWithValue) {
|
||||
return new MValidator(validatorClass, strArg);
|
||||
}
|
||||
|
||||
public String getValidatorClass() {
|
||||
return validatorClass;
|
||||
}
|
||||
|
||||
public String getStrArg() {
|
||||
return strArg;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof MValidator)) return false;
|
||||
|
||||
MValidator that = (MValidator) o;
|
||||
|
||||
if (!getValidatorClass().equals(that.getValidatorClass())) return false;
|
||||
return getStrArg().equals(that.getStrArg());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = getValidatorClass().hashCode();
|
||||
result = 31 * result + getStrArg().hashCode();
|
||||
return result;
|
||||
}
|
||||
}
|
@ -17,16 +17,19 @@
|
||||
*/
|
||||
package org.apache.sqoop.json;
|
||||
|
||||
import static org.apache.sqoop.json.util.ConfigInputSerialization.restoreValidator;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertFalse;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.sqoop.json.util.BeanTestUtil;
|
||||
import org.apache.sqoop.json.util.ConfigInputConstants;
|
||||
import org.apache.sqoop.model.MLink;
|
||||
import org.apache.sqoop.model.MStringInput;
|
||||
import org.apache.sqoop.model.MValidator;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.testng.annotations.Test;
|
||||
@ -50,7 +53,13 @@ public void testLinkSerialization() {
|
||||
|
||||
// Check for sensitivity
|
||||
JSONObject linkObj = (JSONObject) json.get(LinkBean.LINK);
|
||||
JSONArray linkConfigs = (JSONArray) linkObj.get(LinkBean.LINK_CONFIG_VALUES);
|
||||
JSONObject linkConfigList = (JSONObject) linkObj.get(LinkBean.LINK_CONFIG_VALUES);
|
||||
JSONArray linkConfigs = (JSONArray) linkConfigList.get(ConfigInputConstants.CONFIGS);
|
||||
List<MValidator> linkValidators = restoreValidator((JSONArray)
|
||||
linkConfigList.get(ConfigInputConstants.CONFIG_VALIDATORS));
|
||||
MValidator mValidator = linkValidators.get(0);
|
||||
assertEquals("testValidator1", mValidator.getValidatorClass());
|
||||
assertEquals("", mValidator.getStrArg());
|
||||
JSONObject linkConfig = (JSONObject) linkConfigs.get(0);
|
||||
JSONArray inputs = (JSONArray) linkConfig.get(ConfigInputConstants.CONFIG_INPUTS);
|
||||
for (Object in : inputs) {
|
||||
@ -100,8 +109,9 @@ public void testSensitivityFilter() {
|
||||
|
||||
// Sensitive values should exist
|
||||
JSONObject linkObj = (JSONObject) json.get(LinkBean.LINK);
|
||||
JSONArray linkConfigsObj = (JSONArray) linkObj.get(LinkBean.LINK_CONFIG_VALUES);
|
||||
JSONObject linkConfigObj = (JSONObject) linkConfigsObj.get(0);
|
||||
JSONObject linkConfigList = (JSONObject) linkObj.get(LinkBean.LINK_CONFIG_VALUES);
|
||||
JSONArray linkConfigs = (JSONArray) linkConfigList.get(ConfigInputConstants.CONFIGS);
|
||||
JSONObject linkConfigObj = (JSONObject) linkConfigs.get(0);
|
||||
JSONArray inputs = (JSONArray) linkConfigObj.get(ConfigInputConstants.CONFIG_INPUTS);
|
||||
assertEquals(3, inputs.size());
|
||||
// Inputs are ordered when creating link
|
||||
@ -110,8 +120,9 @@ public void testSensitivityFilter() {
|
||||
|
||||
// Sensitive values should not exist
|
||||
linkObj = (JSONObject) jsonFiltered.get(LinkBean.LINK);
|
||||
linkConfigsObj = (JSONArray) linkObj.get(LinkBean.LINK_CONFIG_VALUES);
|
||||
linkConfigObj = (JSONObject) linkConfigsObj.get(0);
|
||||
linkConfigList = (JSONObject) linkObj.get(LinkBean.LINK_CONFIG_VALUES);
|
||||
linkConfigs = (JSONArray) linkConfigList.get(ConfigInputConstants.CONFIGS);
|
||||
linkConfigObj = (JSONObject) linkConfigs.get(0);
|
||||
inputs = (JSONArray) linkConfigObj.get(ConfigInputConstants.CONFIG_INPUTS);
|
||||
assertEquals(3, inputs.size());
|
||||
// Inputs are ordered when creating link
|
||||
|
@ -58,7 +58,8 @@ public void testLinksSerialization() {
|
||||
JSONArray linksObj = (JSONArray) json.get(LinksBean.LINKS);
|
||||
JSONObject linkObj = (JSONObject) linksObj.get(0);
|
||||
|
||||
JSONArray linkConfigs = (JSONArray) linkObj.get(LinkBean.LINK_CONFIG_VALUES);
|
||||
JSONObject linkConfigList = (JSONObject) linkObj.get(LinkBean.LINK_CONFIG_VALUES);
|
||||
JSONArray linkConfigs = (JSONArray) linkConfigList.get(ConfigInputConstants.CONFIGS);
|
||||
JSONObject linkConfig = (JSONObject) linkConfigs.get(0);
|
||||
JSONArray inputs = (JSONArray) linkConfig.get(ConfigInputConstants.CONFIG_INPUTS);
|
||||
for (Object inp : inputs) {
|
||||
|
@ -24,6 +24,7 @@
|
||||
import org.apache.sqoop.model.MJob;
|
||||
import org.apache.sqoop.model.MLink;
|
||||
import org.apache.sqoop.model.MToConfig;
|
||||
import org.apache.sqoop.model.MValidator;
|
||||
|
||||
public class BeanTestUtil {
|
||||
|
||||
|
@ -18,6 +18,7 @@
|
||||
package org.apache.sqoop.json.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -33,6 +34,7 @@
|
||||
import org.apache.sqoop.model.MLinkConfig;
|
||||
import org.apache.sqoop.model.MStringInput;
|
||||
import org.apache.sqoop.model.MToConfig;
|
||||
import org.apache.sqoop.model.MValidator;
|
||||
import org.apache.sqoop.utils.MapResourceBundle;
|
||||
|
||||
public class ConfigTestUtil {
|
||||
@ -44,18 +46,24 @@ public static MDriverConfig getDriverConfig() {
|
||||
List<MConfig> driverConfigs = new ArrayList<MConfig>();
|
||||
inputs = new ArrayList<MInput<?>>();
|
||||
|
||||
input = new MIntegerInput("numExtractors", false, InputEditable.ANY, StringUtils.EMPTY);
|
||||
input = new MIntegerInput("numExtractors", false, InputEditable.ANY, StringUtils.EMPTY, Collections.EMPTY_LIST);
|
||||
input.setPersistenceId(1);
|
||||
inputs.add(input);
|
||||
|
||||
input = new MIntegerInput("numLoaders", false, InputEditable.USER_ONLY, StringUtils.EMPTY);
|
||||
input = new MIntegerInput("numLoaders", false, InputEditable.USER_ONLY, StringUtils.EMPTY, Collections.EMPTY_LIST);
|
||||
input.setPersistenceId(2);
|
||||
inputs.add(input);
|
||||
|
||||
config = new MConfig("driver", inputs);
|
||||
config = new MConfig("driver", inputs, Collections.EMPTY_LIST);
|
||||
config.setPersistenceId(10);
|
||||
driverConfigs.add(config);
|
||||
return new MDriverConfig(driverConfigs);
|
||||
|
||||
|
||||
List<MValidator> validators = new ArrayList<>();
|
||||
validators.add(new MValidator("testValidator1", ""));
|
||||
validators.add(new MValidator("testValidator2", "blah"));
|
||||
|
||||
return new MDriverConfig(driverConfigs, validators);
|
||||
}
|
||||
|
||||
public static MLinkConfig getLinkConfig() {
|
||||
@ -65,25 +73,28 @@ public static MLinkConfig getLinkConfig() {
|
||||
List<MConfig> linkConfig = new ArrayList<MConfig>();
|
||||
inputs = new ArrayList<MInput<?>>();
|
||||
|
||||
input = new MStringInput("url", false, InputEditable.USER_ONLY, StringUtils.EMPTY, (short) 10);
|
||||
input = new MStringInput("url", false, InputEditable.USER_ONLY, StringUtils.EMPTY, (short) 10, Collections.EMPTY_LIST);
|
||||
input.setPersistenceId(1);
|
||||
inputs.add(input);
|
||||
|
||||
input = new MStringInput("username", false, InputEditable.USER_ONLY, "password", (short) 10);
|
||||
input = new MStringInput("username", false, InputEditable.USER_ONLY, "password", (short) 10, Collections.EMPTY_LIST);
|
||||
input.setPersistenceId(2);
|
||||
input.setValue("test");
|
||||
inputs.add(input);
|
||||
|
||||
input = new MStringInput("password", true, InputEditable.USER_ONLY, StringUtils.EMPTY, (short) 10);
|
||||
input = new MStringInput("password", true, InputEditable.USER_ONLY, StringUtils.EMPTY, (short) 10, Collections.EMPTY_LIST);
|
||||
input.setPersistenceId(3);
|
||||
input.setValue("test");
|
||||
inputs.add(input);
|
||||
|
||||
config = new MConfig("connection", inputs);
|
||||
config = new MConfig("connection", inputs, Collections.EMPTY_LIST);
|
||||
config.setPersistenceId(10);
|
||||
linkConfig.add(config);
|
||||
|
||||
return new MLinkConfig(linkConfig);
|
||||
List<MValidator> validators = new ArrayList<>();
|
||||
validators.add(new MValidator("testValidator1", ""));
|
||||
|
||||
return new MLinkConfig(linkConfig, validators);
|
||||
}
|
||||
|
||||
static MFromConfig getFromConfig() {
|
||||
@ -94,41 +105,43 @@ static MFromConfig getFromConfig() {
|
||||
|
||||
inputs = new ArrayList<MInput<?>>();
|
||||
|
||||
input = new MStringInput("A", false, InputEditable.USER_ONLY, StringUtils.EMPTY, (short) 10);
|
||||
input = new MStringInput("A", false, InputEditable.USER_ONLY, StringUtils.EMPTY, (short) 10, Collections.EMPTY_LIST);
|
||||
input.setPersistenceId(4);
|
||||
inputs.add(input);
|
||||
|
||||
input = new MStringInput("B", false, InputEditable.USER_ONLY, StringUtils.EMPTY, (short) 10);
|
||||
input = new MStringInput("B", false, InputEditable.USER_ONLY, StringUtils.EMPTY, (short) 10, Collections.EMPTY_LIST);
|
||||
input.setPersistenceId(5);
|
||||
inputs.add(input);
|
||||
|
||||
input = new MStringInput("C", false, InputEditable.USER_ONLY, StringUtils.EMPTY, (short) 10);
|
||||
input = new MStringInput("C", false, InputEditable.USER_ONLY, StringUtils.EMPTY, (short) 10, Collections.EMPTY_LIST);
|
||||
input.setPersistenceId(6);
|
||||
inputs.add(input);
|
||||
|
||||
config = new MConfig("Z", inputs);
|
||||
config = new MConfig("Z", inputs, Collections.EMPTY_LIST);
|
||||
config.setPersistenceId(11);
|
||||
jobConfigs.add(config);
|
||||
|
||||
inputs = new ArrayList<MInput<?>>();
|
||||
|
||||
input = new MStringInput("D", false, InputEditable.USER_ONLY, StringUtils.EMPTY, (short) 10);
|
||||
input = new MStringInput("D", false, InputEditable.USER_ONLY, StringUtils.EMPTY, (short) 10, Collections.EMPTY_LIST);
|
||||
input.setPersistenceId(7);
|
||||
inputs.add(input);
|
||||
|
||||
input = new MStringInput("E", false, InputEditable.USER_ONLY, "D, F", (short) 10);
|
||||
input = new MStringInput("E", false, InputEditable.USER_ONLY, "D, F", (short) 10, Collections.EMPTY_LIST);
|
||||
input.setPersistenceId(8);
|
||||
inputs.add(input);
|
||||
|
||||
input = new MStringInput("F", false, InputEditable.USER_ONLY, StringUtils.EMPTY, (short) 10);
|
||||
input = new MStringInput("F", false, InputEditable.USER_ONLY, StringUtils.EMPTY, (short) 10, Collections.EMPTY_LIST);
|
||||
input.setPersistenceId(9);
|
||||
inputs.add(input);
|
||||
|
||||
config = new MConfig("from-table", inputs);
|
||||
config = new MConfig("from-table", inputs, Collections.EMPTY_LIST);
|
||||
config.setPersistenceId(12);
|
||||
jobConfigs.add(config);
|
||||
|
||||
return new MFromConfig(jobConfigs);
|
||||
List<MValidator> validators = new ArrayList<>();
|
||||
|
||||
return new MFromConfig(jobConfigs, validators);
|
||||
}
|
||||
|
||||
static MToConfig getToConfig() {
|
||||
@ -139,41 +152,45 @@ static MToConfig getToConfig() {
|
||||
|
||||
inputs = new ArrayList<MInput<?>>();
|
||||
|
||||
input = new MStringInput("A", false, InputEditable.ANY, StringUtils.EMPTY, (short) 10);
|
||||
input = new MStringInput("A", false, InputEditable.ANY, StringUtils.EMPTY, (short) 10, Collections.EMPTY_LIST);
|
||||
input.setPersistenceId(4);
|
||||
inputs.add(input);
|
||||
|
||||
input = new MStringInput("B", false, InputEditable.ANY, StringUtils.EMPTY, (short) 10);
|
||||
input = new MStringInput("B", false, InputEditable.ANY, StringUtils.EMPTY, (short) 10, Collections.EMPTY_LIST);
|
||||
input.setPersistenceId(5);
|
||||
inputs.add(input);
|
||||
|
||||
input = new MStringInput("C", false, InputEditable.ANY, StringUtils.EMPTY, (short) 10);
|
||||
input = new MStringInput("C", false, InputEditable.ANY, StringUtils.EMPTY, (short) 10, Collections.EMPTY_LIST);
|
||||
input.setPersistenceId(6);
|
||||
inputs.add(input);
|
||||
|
||||
config = new MConfig("Z", inputs);
|
||||
config = new MConfig("Z", inputs, Collections.EMPTY_LIST);
|
||||
config.setPersistenceId(11);
|
||||
jobConfigs.add(config);
|
||||
|
||||
inputs = new ArrayList<MInput<?>>();
|
||||
|
||||
input = new MStringInput("D", false, InputEditable.ANY, StringUtils.EMPTY, (short) 10);
|
||||
input = new MStringInput("D", false, InputEditable.ANY, StringUtils.EMPTY, (short) 10, Collections.EMPTY_LIST);
|
||||
input.setPersistenceId(7);
|
||||
inputs.add(input);
|
||||
|
||||
input = new MStringInput("E", false, InputEditable.ANY, StringUtils.EMPTY, (short) 10);
|
||||
input = new MStringInput("E", false, InputEditable.ANY, StringUtils.EMPTY, (short) 10, Collections.EMPTY_LIST);
|
||||
input.setPersistenceId(8);
|
||||
inputs.add(input);
|
||||
|
||||
input = new MStringInput("F", false, InputEditable.ANY, StringUtils.EMPTY, (short) 10);
|
||||
input = new MStringInput("F", false, InputEditable.ANY, StringUtils.EMPTY, (short) 10, Collections.EMPTY_LIST);
|
||||
input.setPersistenceId(9);
|
||||
inputs.add(input);
|
||||
|
||||
config = new MConfig("to-table", inputs);
|
||||
config = new MConfig("to-table", inputs, Collections.EMPTY_LIST);
|
||||
config.setPersistenceId(12);
|
||||
jobConfigs.add(config);
|
||||
|
||||
return new MToConfig(jobConfigs);
|
||||
List<MValidator> validators = new ArrayList<>();
|
||||
validators.add(new MValidator("testValidator1", ""));
|
||||
validators.add(new MValidator("testValidator2", "blah"));
|
||||
|
||||
return new MToConfig(jobConfigs, validators);
|
||||
}
|
||||
|
||||
public static ResourceBundle getResourceBundle() {
|
||||
|
@ -21,6 +21,8 @@
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
@ -41,6 +43,8 @@
|
||||
import org.apache.sqoop.model.MLongInput;
|
||||
import org.apache.sqoop.model.MMapInput;
|
||||
import org.apache.sqoop.model.MStringInput;
|
||||
import org.apache.sqoop.model.MValidator;
|
||||
import org.apache.sqoop.validation.validators.AbstractValidator;
|
||||
import org.joda.time.DateTime;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
@ -82,6 +86,18 @@ public void testAllDataTypes() {
|
||||
assertEquals(1, (int)retrieved.getIntegerInput("Integer").getValue());
|
||||
assertEquals(true, retrieved.getBooleanInput("Boolean").getValue().booleanValue());
|
||||
assertEquals("YES", retrieved.getEnumInput("Enum").getValue());
|
||||
|
||||
// Verify all expected input validators
|
||||
assertEquals(Collections.EMPTY_LIST, retrieved.getStringInput("String")
|
||||
.getValidators());
|
||||
assertEquals(buildMValidators(), retrieved.getMapInput("Map")
|
||||
.getValidators());
|
||||
assertEquals(Collections.EMPTY_LIST, retrieved.getIntegerInput("Integer").getValidators());
|
||||
assertEquals(Collections.EMPTY_LIST, retrieved.getBooleanInput("Boolean").getValidators());
|
||||
assertEquals(Collections.EMPTY_LIST, retrieved.getEnumInput("Enum").getValidators());
|
||||
|
||||
// Verify config validators
|
||||
assertEquals(buildMValidators(), config.getValidators());
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -204,6 +220,18 @@ public void testInputEditableOptional() {
|
||||
assertEquals("YES", retrieved.getEnumInput("Enum").getValue());
|
||||
assertEquals(list, retrieved.getListInput("List").getValue());
|
||||
assertEquals(dt, retrieved.getDateTimeInput("DateTime").getValue());
|
||||
|
||||
// Verify all expected input validators
|
||||
assertEquals(Collections.EMPTY_LIST, retrieved.getStringInput("String").getValidators());
|
||||
assertEquals(buildMValidators(), retrieved.getMapInput("Map").getValidators());
|
||||
assertEquals(Collections.EMPTY_LIST, retrieved.getIntegerInput("Integer").getValidators());
|
||||
assertEquals(Collections.EMPTY_LIST, retrieved.getBooleanInput("Boolean").getValidators());
|
||||
assertEquals(Collections.EMPTY_LIST, retrieved.getEnumInput("Enum").getValidators());
|
||||
assertEquals(Collections.EMPTY_LIST, retrieved.getListInput("List").getValidators());
|
||||
assertEquals(buildMValidators(), retrieved.getDateTimeInput("DateTime").getValidators());
|
||||
|
||||
// Verify config validators
|
||||
assertEquals(buildMValidators(), config.getValidators());
|
||||
}
|
||||
|
||||
protected MConfig getMapConfig() {
|
||||
@ -212,10 +240,10 @@ protected MConfig getMapConfig() {
|
||||
|
||||
inputs = new LinkedList<MInput<?>>();
|
||||
|
||||
input = new MMapInput("Map", false, InputEditable.ANY, StringUtils.EMPTY, "A");
|
||||
input = new MMapInput("Map", false, InputEditable.ANY, StringUtils.EMPTY, "A", Collections.EMPTY_LIST);
|
||||
inputs.add(input);
|
||||
|
||||
return new MConfig("c", inputs);
|
||||
return new MConfig("c", inputs, Collections.EMPTY_LIST);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -227,32 +255,43 @@ protected MConfig getConfig() {
|
||||
List<MInput<?>> inputs;
|
||||
MInput<?> input;
|
||||
|
||||
List<MValidator> mValidatorsForInput = buildMValidators();
|
||||
|
||||
inputs = new LinkedList<MInput<?>>();
|
||||
|
||||
input = new MStringInput("String", false, InputEditable.ANY, StringUtils.EMPTY, (short)30);
|
||||
input = new MStringInput("String", false, InputEditable.ANY, StringUtils.EMPTY, (short)30, Collections.EMPTY_LIST);
|
||||
inputs.add(input);
|
||||
|
||||
input = new MMapInput("Map", false, InputEditable.ANY, StringUtils.EMPTY, StringUtils.EMPTY);
|
||||
input = new MMapInput("Map", false, InputEditable.ANY, StringUtils.EMPTY, StringUtils.EMPTY, mValidatorsForInput);
|
||||
inputs.add(input);
|
||||
|
||||
input = new MIntegerInput("Integer", false, InputEditable.ANY, StringUtils.EMPTY);
|
||||
input = new MIntegerInput("Integer", false, InputEditable.ANY, StringUtils.EMPTY, Collections.EMPTY_LIST);
|
||||
inputs.add(input);
|
||||
|
||||
input = new MLongInput("Long", false, InputEditable.ANY, StringUtils.EMPTY);
|
||||
input = new MLongInput("Long", false, InputEditable.ANY, StringUtils.EMPTY, Collections.EMPTY_LIST);
|
||||
inputs.add(input);
|
||||
|
||||
input = new MBooleanInput("Boolean", false, InputEditable.ANY, StringUtils.EMPTY);
|
||||
input = new MBooleanInput("Boolean", false, InputEditable.ANY, StringUtils.EMPTY, Collections.EMPTY_LIST);
|
||||
inputs.add(input);
|
||||
|
||||
input = new MEnumInput("Enum", false, InputEditable.ANY, StringUtils.EMPTY, new String[] {"YES", "NO"});
|
||||
input = new MEnumInput("Enum", false, InputEditable.ANY, StringUtils.EMPTY, new String[] {"YES", "NO"}, Collections.EMPTY_LIST);
|
||||
inputs.add(input);
|
||||
|
||||
input = new MListInput("List", false, InputEditable.ANY, StringUtils.EMPTY);
|
||||
input = new MListInput("List", false, InputEditable.ANY, StringUtils.EMPTY, Collections.EMPTY_LIST);
|
||||
inputs.add(input);
|
||||
|
||||
input = new MDateTimeInput("DateTime", false, InputEditable.ANY, StringUtils.EMPTY);
|
||||
input = new MDateTimeInput("DateTime", false, InputEditable.ANY, StringUtils.EMPTY, mValidatorsForInput);
|
||||
inputs.add(input);
|
||||
|
||||
return new MConfig("c", inputs);
|
||||
List<MValidator> mValidatorsForConfig = buildMValidators();
|
||||
|
||||
return new MConfig("c", inputs, mValidatorsForConfig);
|
||||
}
|
||||
|
||||
protected List<MValidator> buildMValidators() {
|
||||
List<MValidator> mValidators = new ArrayList<>();
|
||||
mValidators.add(new MValidator("validator1", AbstractValidator.DEFAULT_STRING_ARGUMENT));
|
||||
mValidators.add(new MValidator("validator1", "strarg"));
|
||||
return mValidators;
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,9 @@
|
||||
*/
|
||||
package org.apache.sqoop.model;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import org.apache.sqoop.validation.Status;
|
||||
import org.apache.sqoop.validation.validators.AbstractValidator;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
@ -24,7 +27,9 @@
|
||||
import static org.testng.Assert.assertNull;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
@ -45,10 +50,18 @@ public void testConfigs() {
|
||||
config.aConfig.a1 = "value";
|
||||
config.cConfig.enumeration = Enumeration.X;
|
||||
|
||||
List<MValidator> expectedValidatorsOnAConfig = new ArrayList<>();
|
||||
expectedValidatorsOnAConfig.add(new MValidator(AConfig.AConfigValidator.class.getName(), AbstractValidator.DEFAULT_STRING_ARGUMENT));
|
||||
|
||||
List<MValidator> expectedValidatorsOnA1 = new ArrayList<>();
|
||||
expectedValidatorsOnA1.add(new MValidator(AConfig.A1Validator.class.getName(), AbstractValidator.DEFAULT_STRING_ARGUMENT));
|
||||
|
||||
List<MConfig> configsByInstance = ConfigUtils.toConfigs(config);
|
||||
assertEquals(getConfigs(), configsByInstance);
|
||||
assertEquals("value", configsByInstance.get(0).getInputs().get(0).getValue());
|
||||
assertEquals(expectedValidatorsOnA1, configsByInstance.get(0).getInputs().get(0).getValidators());
|
||||
assertEquals("X", configsByInstance.get(2).getInput("cConfig.enumeration").getValue());
|
||||
assertEquals(expectedValidatorsOnAConfig, configsByInstance.get(0).getValidators());
|
||||
|
||||
List<MConfig> configsByClass = ConfigUtils.toConfigs(TestConfiguration.class);
|
||||
assertEquals(getConfigs(), configsByClass);
|
||||
@ -229,28 +242,28 @@ protected List<MConfig> getConfigs() {
|
||||
// Config A
|
||||
inputs = new LinkedList<MInput<?>>();
|
||||
inputs.add(new MStringInput("aConfig.a1", false, InputEditable.ANY, StringUtils.EMPTY,
|
||||
(short) 30));
|
||||
(short) 30, Collections.EMPTY_LIST));
|
||||
inputs.add(new MStringInput("aConfig.a2", true, InputEditable.ANY, StringUtils.EMPTY,
|
||||
(short) -1));
|
||||
ret.add(new MConfig("aConfig", inputs));
|
||||
(short) -1, Collections.EMPTY_LIST));
|
||||
ret.add(new MConfig("aConfig", inputs, Collections.EMPTY_LIST));
|
||||
|
||||
// Config B
|
||||
inputs = new LinkedList<MInput<?>>();
|
||||
inputs.add(new MStringInput("bConfig.b1", false, InputEditable.ANY, StringUtils.EMPTY,
|
||||
(short) 2));
|
||||
(short) 2, Collections.EMPTY_LIST));
|
||||
inputs.add(new MStringInput("bConfig.b2", false, InputEditable.ANY, StringUtils.EMPTY,
|
||||
(short) 3));
|
||||
ret.add(new MConfig("bConfig", inputs));
|
||||
(short) 3, Collections.EMPTY_LIST));
|
||||
ret.add(new MConfig("bConfig", inputs, Collections.EMPTY_LIST));
|
||||
|
||||
// Config C
|
||||
inputs = new LinkedList<MInput<?>>();
|
||||
inputs.add(new MLongInput("cConfig.longValue", false, InputEditable.ANY, StringUtils.EMPTY));
|
||||
inputs.add(new MMapInput("cConfig.map", false, InputEditable.ANY, StringUtils.EMPTY, StringUtils.EMPTY));
|
||||
inputs.add(new MLongInput("cConfig.longValue", false, InputEditable.ANY, StringUtils.EMPTY, Collections.EMPTY_LIST));
|
||||
inputs.add(new MMapInput("cConfig.map", false, InputEditable.ANY, StringUtils.EMPTY, StringUtils.EMPTY, Collections.EMPTY_LIST));
|
||||
inputs.add(new MEnumInput("cConfig.enumeration", false, InputEditable.ANY, StringUtils.EMPTY,
|
||||
new String[] { "X", "Y" }));
|
||||
inputs.add(new MListInput("cConfig.list", false, InputEditable.ANY, StringUtils.EMPTY));
|
||||
inputs.add(new MDateTimeInput("cConfig.dt", false, InputEditable.ANY, StringUtils.EMPTY));
|
||||
ret.add(new MConfig("cConfig", inputs));
|
||||
new String[] { "X", "Y" }, Collections.EMPTY_LIST));
|
||||
inputs.add(new MListInput("cConfig.list", false, InputEditable.ANY, StringUtils.EMPTY, Collections.EMPTY_LIST));
|
||||
inputs.add(new MDateTimeInput("cConfig.dt", false, InputEditable.ANY, StringUtils.EMPTY, Collections.EMPTY_LIST));
|
||||
ret.add(new MConfig("cConfig", inputs, Collections.EMPTY_LIST));
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -261,10 +274,10 @@ protected List<MConfig> getBadConfigWithSelfOverrideInputs() {
|
||||
List<MInput<?>> inputs;
|
||||
// Config A
|
||||
inputs = new LinkedList<MInput<?>>();
|
||||
inputs.add(new MStringInput("aConfig.a1", false, InputEditable.ANY, "aConfig.a1", (short) 30));
|
||||
inputs.add(new MStringInput("aConfig.a1", false, InputEditable.ANY, "aConfig.a1", (short) 30, Collections.EMPTY_LIST));
|
||||
inputs.add(new MStringInput("aConfig.a2", true, InputEditable.ANY, StringUtils.EMPTY,
|
||||
(short) -1));
|
||||
ret.add(new MConfig("aConfig", inputs));
|
||||
(short) -1, Collections.EMPTY_LIST));
|
||||
ret.add(new MConfig("aConfig", inputs, Collections.EMPTY_LIST));
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -274,10 +287,10 @@ protected List<MConfig> getBadConfigWithNonExistingOverrideInputs() {
|
||||
List<MInput<?>> inputs;
|
||||
// Config A
|
||||
inputs = new LinkedList<MInput<?>>();
|
||||
inputs.add(new MStringInput("aConfig.a1", false, InputEditable.ANY, "aConfig.a3", (short) 30));
|
||||
inputs.add(new MStringInput("aConfig.a1", false, InputEditable.ANY, "aConfig.a3", (short) 30, Collections.EMPTY_LIST));
|
||||
inputs.add(new MStringInput("aConfig.a2", true, InputEditable.ANY, StringUtils.EMPTY,
|
||||
(short) -1));
|
||||
ret.add(new MConfig("aConfig", inputs));
|
||||
(short) -1, Collections.EMPTY_LIST));
|
||||
ret.add(new MConfig("aConfig", inputs, Collections.EMPTY_LIST));
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -287,10 +300,10 @@ protected List<MConfig> getBadConfigWithUserEditableOverrideInputs() {
|
||||
List<MInput<?>> inputs;
|
||||
// Config A
|
||||
inputs = new LinkedList<MInput<?>>();
|
||||
inputs.add(new MStringInput("aConfig.a1", false, InputEditable.ANY, "aConfig.a2", (short) 30));
|
||||
inputs.add(new MStringInput("aConfig.a1", false, InputEditable.ANY, "aConfig.a2", (short) 30, Collections.EMPTY_LIST));
|
||||
inputs.add(new MStringInput("aConfig.a2", true, InputEditable.USER_ONLY, StringUtils.EMPTY,
|
||||
(short) -1));
|
||||
ret.add(new MConfig("aConfig", inputs));
|
||||
(short) -1, Collections.EMPTY_LIST));
|
||||
ret.add(new MConfig("aConfig", inputs, Collections.EMPTY_LIST));
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -383,12 +396,30 @@ public static class PrimitiveConfig {
|
||||
DConfig dConfig;
|
||||
}
|
||||
|
||||
@ConfigClass
|
||||
@ConfigClass(validators = {@Validator(AConfig.AConfigValidator.class)})
|
||||
public static class AConfig {
|
||||
@Input(size = 30)
|
||||
@Input(size = 30, validators = {@Validator(AConfig.A1Validator.class)})
|
||||
String a1;
|
||||
@Input(sensitive = true)
|
||||
String a2;
|
||||
|
||||
public static class AConfigValidator extends AbstractValidator<AConfig> {
|
||||
@Override
|
||||
public void validate(AConfig aConfig) {
|
||||
if (Strings.isNullOrEmpty(aConfig.a1)) {
|
||||
addMessage(Status.ERROR, "a1 cannot be empty");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class A1Validator extends AbstractValidator<String> {
|
||||
@Override
|
||||
public void validate(String a1) {
|
||||
if (Strings.isNullOrEmpty(a1)) {
|
||||
addMessage(Status.ERROR, "I am a redundant validator");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ConfigClass
|
||||
|
@ -18,6 +18,7 @@
|
||||
package org.apache.sqoop.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@ -37,15 +38,20 @@ public class TestMAccountableEntity {
|
||||
@Test
|
||||
public void testInitialization() {
|
||||
List<MConfig> configs = new ArrayList<MConfig>();
|
||||
MIntegerInput intInput = new MIntegerInput("INTEGER-INPUT", false, InputEditable.ANY, StringUtils.EMPTY);
|
||||
MLongInput longInput = new MLongInput("LONG-INPUT", false, InputEditable.ANY, StringUtils.EMPTY);
|
||||
MIntegerInput intInput = new MIntegerInput("INTEGER-INPUT", false, InputEditable.ANY, StringUtils.EMPTY, Collections.EMPTY_LIST);
|
||||
MLongInput longInput = new MLongInput("LONG-INPUT", false, InputEditable.ANY, StringUtils.EMPTY, Collections.EMPTY_LIST);
|
||||
List<MInput<?>> list = new ArrayList<MInput<?>>();
|
||||
list.add(intInput);
|
||||
list.add(longInput);
|
||||
|
||||
MConfig config = new MConfig("CONFIGNAME", list);
|
||||
MConfig config = new MConfig("CONFIGNAME", list, Collections.EMPTY_LIST);
|
||||
configs.add(config);
|
||||
MAccountableEntity link = new MLink(123l, new MLinkConfig(configs));
|
||||
|
||||
List<MValidator> validators = new ArrayList<>();
|
||||
MValidator validator = new MValidator("test", "");
|
||||
validators.add(validator);
|
||||
|
||||
MAccountableEntity link = new MLink(123l, new MLinkConfig(configs, validators));
|
||||
// Initially creation date and last update date is same
|
||||
assertEquals(link.getCreationDate(), link.getLastUpdateDate());
|
||||
Date testCreationDate = new Date();
|
||||
@ -63,5 +69,6 @@ public void testInitialization() {
|
||||
assertEquals(1, ((MLink) link).getConnectorLinkConfig().getConfigs().size());
|
||||
assertEquals(2, ((MLink) link).getConnectorLinkConfig().getConfigs().get(0).getInputs().size());
|
||||
|
||||
assertEquals(validator, ((MLink) link).getConnectorLinkConfig().getValidators().get(0));
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,8 @@
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertFalse;
|
||||
import static org.testng.Assert.assertNull;
|
||||
@ -36,7 +38,7 @@ public class TestMBooleanInput {
|
||||
@Test
|
||||
public void testInitialization() {
|
||||
MBooleanInput input = new MBooleanInput("sqoopsqoop", true, InputEditable.ANY,
|
||||
StringUtils.EMPTY);
|
||||
StringUtils.EMPTY, Collections.EMPTY_LIST);
|
||||
assertEquals("sqoopsqoop", input.getName());
|
||||
assertEquals(true, input.isSensitive());
|
||||
assertEquals(MInputType.BOOLEAN, input.getType());
|
||||
@ -49,18 +51,18 @@ public void testInitialization() {
|
||||
public void testEquals() {
|
||||
// Positive test
|
||||
MBooleanInput input1 = new MBooleanInput("sqoopsqoop", true, InputEditable.ANY,
|
||||
StringUtils.EMPTY);
|
||||
StringUtils.EMPTY, Collections.EMPTY_LIST);
|
||||
MBooleanInput input2 = new MBooleanInput("sqoopsqoop", true, InputEditable.ANY,
|
||||
StringUtils.EMPTY);
|
||||
StringUtils.EMPTY, Collections.EMPTY_LIST);
|
||||
assertTrue(input1.equals(input2));
|
||||
|
||||
// Negative test
|
||||
MBooleanInput input3 = new MBooleanInput("sqoopsqoop", false, InputEditable.ANY, StringUtils.EMPTY );
|
||||
MBooleanInput input4 = new MBooleanInput("sqoopsqoop", true, InputEditable.ANY, StringUtils.EMPTY );
|
||||
MBooleanInput input3 = new MBooleanInput("sqoopsqoop", false, InputEditable.ANY, StringUtils.EMPTY, Collections.EMPTY_LIST );
|
||||
MBooleanInput input4 = new MBooleanInput("sqoopsqoop", true, InputEditable.ANY, StringUtils.EMPTY, Collections.EMPTY_LIST );
|
||||
assertFalse(input3.equals(input4));
|
||||
|
||||
MBooleanInput input5 = new MBooleanInput("sqoopsqoop", false, InputEditable.ANY, StringUtils.EMPTY );
|
||||
MBooleanInput input6 = new MBooleanInput("sqoop", false, InputEditable.ANY, StringUtils.EMPTY );
|
||||
MBooleanInput input5 = new MBooleanInput("sqoopsqoop", false, InputEditable.ANY, StringUtils.EMPTY, Collections.EMPTY_LIST );
|
||||
MBooleanInput input6 = new MBooleanInput("sqoop", false, InputEditable.ANY, StringUtils.EMPTY, Collections.EMPTY_LIST );
|
||||
assertFalse(input5.equals(input6));
|
||||
}
|
||||
|
||||
@ -69,7 +71,7 @@ public void testEquals() {
|
||||
*/
|
||||
@Test
|
||||
public void testValue() {
|
||||
MBooleanInput input1 = new MBooleanInput("sqoopsqoop", true, InputEditable.ANY, StringUtils.EMPTY );
|
||||
MBooleanInput input1 = new MBooleanInput("sqoopsqoop", true, InputEditable.ANY, StringUtils.EMPTY, Collections.EMPTY_LIST );
|
||||
input1.setValue(true);
|
||||
assertEquals(true, input1.getValue().booleanValue());
|
||||
input1.setEmpty();
|
||||
@ -81,7 +83,7 @@ public void testValue() {
|
||||
*/
|
||||
@Test
|
||||
public void testUrlSafe() {
|
||||
MBooleanInput input1 = new MBooleanInput("sqoopsqoop", true, InputEditable.ANY, StringUtils.EMPTY );
|
||||
MBooleanInput input1 = new MBooleanInput("sqoopsqoop", true, InputEditable.ANY, StringUtils.EMPTY, Collections.EMPTY_LIST );
|
||||
input1.setValue(true);
|
||||
// Getting URL safe string
|
||||
String tmp = input1.getUrlSafeValueString();
|
||||
@ -96,7 +98,7 @@ public void testUrlSafe() {
|
||||
@Test
|
||||
public void testNamedElement() {
|
||||
MBooleanInput input1 = new MBooleanInput("sqoopsqoop", true, InputEditable.ANY,
|
||||
StringUtils.EMPTY);
|
||||
StringUtils.EMPTY, Collections.EMPTY_LIST);
|
||||
assertEquals("sqoopsqoop.label", input1.getLabelKey());
|
||||
assertEquals("sqoopsqoop.help", input1.getHelpKey());
|
||||
}
|
||||
|
@ -18,6 +18,7 @@
|
||||
package org.apache.sqoop.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
@ -32,13 +33,13 @@ public class TestMConfig {
|
||||
*/
|
||||
@Test
|
||||
public void testInitialization() {
|
||||
MInput<String> input1 = new MStringInput("sqoopsqoop1", true, InputEditable.ANY, StringUtils.EMPTY , (short) 5);
|
||||
MInput<String> input2 = new MStringInput("sqoopsqoop2", true, InputEditable.ANY, StringUtils.EMPTY , (short) 5);
|
||||
MInput<String> input1 = new MStringInput("sqoopsqoop1", true, InputEditable.ANY, StringUtils.EMPTY , (short) 5, Collections.EMPTY_LIST);
|
||||
MInput<String> input2 = new MStringInput("sqoopsqoop2", true, InputEditable.ANY, StringUtils.EMPTY , (short) 5, Collections.EMPTY_LIST);
|
||||
|
||||
List<MInput<?>> list = new ArrayList<MInput<?>>();
|
||||
list.add(input1);
|
||||
list.add(input2);
|
||||
MConfig mConfig = new MConfig("config", list);
|
||||
MConfig mConfig = new MConfig("config", list, Collections.EMPTY_LIST);
|
||||
|
||||
assertEquals("config", mConfig.getName());
|
||||
assertEquals(2, mConfig.getInputs().size());
|
||||
@ -49,33 +50,33 @@ public void testInitialization() {
|
||||
*/
|
||||
@Test
|
||||
public void testEquals() {
|
||||
MInput<Integer> input1 = new MIntegerInput("sqoopsqoop1", false, InputEditable.ANY, StringUtils.EMPTY );
|
||||
MInput<Integer> input2 = new MIntegerInput("sqoopsqoop2", false, InputEditable.ANY, StringUtils.EMPTY );
|
||||
MInput<Integer> input1 = new MIntegerInput("sqoopsqoop1", false, InputEditable.ANY, StringUtils.EMPTY , Collections.EMPTY_LIST);
|
||||
MInput<Integer> input2 = new MIntegerInput("sqoopsqoop2", false, InputEditable.ANY, StringUtils.EMPTY , Collections.EMPTY_LIST);
|
||||
List<MInput<?>> list1 = new ArrayList<MInput<?>>();
|
||||
list1.add(input1);
|
||||
list1.add(input2);
|
||||
MConfig mConfig1 = new MConfig("config", list1);
|
||||
MConfig mConfig1 = new MConfig("config", list1, Collections.EMPTY_LIST);
|
||||
|
||||
MInput<Integer> input3 = new MIntegerInput("sqoopsqoop1", false, InputEditable.ANY, StringUtils.EMPTY );
|
||||
MInput<Integer> input4 = new MIntegerInput("sqoopsqoop2", false, InputEditable.ANY, StringUtils.EMPTY );
|
||||
MInput<Integer> input3 = new MIntegerInput("sqoopsqoop1", false, InputEditable.ANY, StringUtils.EMPTY , Collections.EMPTY_LIST);
|
||||
MInput<Integer> input4 = new MIntegerInput("sqoopsqoop2", false, InputEditable.ANY, StringUtils.EMPTY , Collections.EMPTY_LIST);
|
||||
List<MInput<?>> list2 = new ArrayList<MInput<?>>();
|
||||
list2.add(input3);
|
||||
list2.add(input4);
|
||||
MConfig mConfig2 = new MConfig("config", list2);
|
||||
MConfig mConfig2 = new MConfig("config", list2, Collections.EMPTY_LIST);
|
||||
assertEquals(mConfig2, mConfig1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetInputs() {
|
||||
MIntegerInput intInput = new MIntegerInput("Config.A", false, InputEditable.ANY, StringUtils.EMPTY );
|
||||
MLongInput longInput = new MLongInput("Config.A1", false, InputEditable.ANY, StringUtils.EMPTY );
|
||||
MMapInput mapInput = new MMapInput("Config.B", false, InputEditable.ANY, StringUtils.EMPTY, StringUtils.EMPTY );
|
||||
MIntegerInput intInput = new MIntegerInput("Config.A", false, InputEditable.ANY, StringUtils.EMPTY , Collections.EMPTY_LIST);
|
||||
MLongInput longInput = new MLongInput("Config.A1", false, InputEditable.ANY, StringUtils.EMPTY, Collections.EMPTY_LIST );
|
||||
MMapInput mapInput = new MMapInput("Config.B", false, InputEditable.ANY, StringUtils.EMPTY, StringUtils.EMPTY , Collections.EMPTY_LIST);
|
||||
MStringInput stringInput = new MStringInput("Config.C", false, InputEditable.ANY,
|
||||
StringUtils.EMPTY, (short) 3);
|
||||
StringUtils.EMPTY, (short) 3, Collections.EMPTY_LIST);
|
||||
MEnumInput enumInput = new MEnumInput("Config.D", false, InputEditable.ANY, StringUtils.EMPTY,
|
||||
new String[] { "I", "V" });
|
||||
MListInput listInput = new MListInput("Config.E", false, InputEditable.ANY, StringUtils.EMPTY );
|
||||
MDateTimeInput dtInput = new MDateTimeInput("Config.F", false, InputEditable.ANY, StringUtils.EMPTY );
|
||||
new String[] { "I", "V" }, Collections.EMPTY_LIST);
|
||||
MListInput listInput = new MListInput("Config.E", false, InputEditable.ANY, StringUtils.EMPTY, Collections.EMPTY_LIST );
|
||||
MDateTimeInput dtInput = new MDateTimeInput("Config.F", false, InputEditable.ANY, StringUtils.EMPTY, Collections.EMPTY_LIST );
|
||||
|
||||
List<MInput<?>> inputs = new ArrayList<MInput<?>>();
|
||||
inputs.add(intInput);
|
||||
@ -86,7 +87,7 @@ public void testGetInputs() {
|
||||
inputs.add(listInput);
|
||||
inputs.add(dtInput);
|
||||
|
||||
MConfig config = new MConfig("Config", inputs);
|
||||
MConfig config = new MConfig("Config", inputs, Collections.EMPTY_LIST);
|
||||
assertEquals(intInput, config.getIntegerInput("Config.A"));
|
||||
assertEquals(longInput, config.getLongInput("Config.A1"));
|
||||
assertEquals(mapInput, config.getMapInput("Config.B"));
|
||||
|
@ -21,6 +21,7 @@
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
@ -31,29 +32,29 @@ public class TestMConfigList {
|
||||
public void testGetInputs() {
|
||||
List<MConfig> configs = new LinkedList<MConfig>();
|
||||
|
||||
MIntegerInput intInput = new MIntegerInput("Config1.A", false, InputEditable.ANY, StringUtils.EMPTY);
|
||||
MMapInput mapInput = new MMapInput("Config1.B", false, InputEditable.ANY, StringUtils.EMPTY, StringUtils.EMPTY);
|
||||
MIntegerInput intInput = new MIntegerInput("Config1.A", false, InputEditable.ANY, StringUtils.EMPTY, Collections.EMPTY_LIST);
|
||||
MMapInput mapInput = new MMapInput("Config1.B", false, InputEditable.ANY, StringUtils.EMPTY, StringUtils.EMPTY, Collections.EMPTY_LIST);
|
||||
|
||||
List<MInput<?>> inputs = new ArrayList<MInput<?>>();
|
||||
inputs.add(intInput);
|
||||
inputs.add(mapInput);
|
||||
configs.add(new MConfig("Config1", inputs));
|
||||
configs.add(new MConfig("Config1", inputs, Collections.EMPTY_LIST));
|
||||
|
||||
MStringInput stringInput = new MStringInput("Config2.C", false, InputEditable.ANY,
|
||||
StringUtils.EMPTY, (short) 3);
|
||||
StringUtils.EMPTY, (short) 3, Collections.EMPTY_LIST);
|
||||
MEnumInput enumInput = new MEnumInput("Config2.D", false, InputEditable.ANY, StringUtils.EMPTY,
|
||||
new String[] { "I", "V" });
|
||||
MListInput listInput = new MListInput("Config2.E", false, InputEditable.ANY, StringUtils.EMPTY);
|
||||
MDateTimeInput dtInput = new MDateTimeInput("Config2.F", false, InputEditable.ANY, StringUtils.EMPTY);
|
||||
new String[] { "I", "V" }, Collections.EMPTY_LIST);
|
||||
MListInput listInput = new MListInput("Config2.E", false, InputEditable.ANY, StringUtils.EMPTY, Collections.EMPTY_LIST);
|
||||
MDateTimeInput dtInput = new MDateTimeInput("Config2.F", false, InputEditable.ANY, StringUtils.EMPTY, Collections.EMPTY_LIST);
|
||||
|
||||
inputs = new ArrayList<MInput<?>>();
|
||||
inputs.add(stringInput);
|
||||
inputs.add(enumInput);
|
||||
inputs.add(listInput);
|
||||
inputs.add(dtInput);
|
||||
configs.add(new MConfig("Config2", inputs));
|
||||
configs.add(new MConfig("Config2", inputs, Collections.EMPTY_LIST));
|
||||
|
||||
MConfigList config = new MConfigList(configs, MConfigType.JOB);
|
||||
MConfigList config = new MConfigList(configs, MConfigType.JOB, Collections.EMPTY_LIST);
|
||||
assertEquals(intInput, config.getIntegerInput("Config1.A"));
|
||||
assertEquals(mapInput, config.getMapInput("Config1.B"));
|
||||
assertEquals(stringInput, config.getStringInput("Config2.C"));
|
||||
|
@ -26,6 +26,7 @@
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
@ -36,26 +37,29 @@ public class TestMConnector {
|
||||
|
||||
private MConnector createConnector(List<Direction> supportedDirections) {
|
||||
List<MConfig> configs = new ArrayList<MConfig>();
|
||||
MIntegerInput inputs = new MIntegerInput("INTEGER-INPUT", false, InputEditable.ANY, StringUtils.EMPTY);
|
||||
MIntegerInput inputs = new MIntegerInput("INTEGER-INPUT", false, InputEditable.ANY, StringUtils.EMPTY, Collections.EMPTY_LIST);
|
||||
inputs.setValue(100);
|
||||
MStringInput strInput = new MStringInput("STRING-INPUT",false, InputEditable.ANY, StringUtils.EMPTY, (short)20);
|
||||
MStringInput strInput = new MStringInput("STRING-INPUT",false, InputEditable.ANY, StringUtils.EMPTY, (short)20, Collections.EMPTY_LIST);
|
||||
strInput.setValue("TEST-VALUE");
|
||||
List<MInput<?>> list = new ArrayList<MInput<?>>();
|
||||
list.add(inputs);
|
||||
list.add(strInput);
|
||||
MConfig config = new MConfig("CONFIGNAME", list);
|
||||
MConfig config = new MConfig("CONFIGNAME", list, Collections.EMPTY_LIST);
|
||||
configs.add(config);
|
||||
|
||||
MLinkConfig linkConfig = new MLinkConfig(configs);
|
||||
List<MValidator> validators = new ArrayList<>();
|
||||
validators.add(new MValidator("test", ""));
|
||||
|
||||
MLinkConfig linkConfig = new MLinkConfig(configs, validators);
|
||||
MFromConfig fromConfig = null;
|
||||
MToConfig toConfig = null;
|
||||
|
||||
if (supportedDirections.contains(Direction.FROM)) {
|
||||
fromConfig = new MFromConfig(configs);
|
||||
fromConfig = new MFromConfig(configs, validators);
|
||||
}
|
||||
|
||||
if (supportedDirections.contains(Direction.TO)) {
|
||||
toConfig = new MToConfig(configs);
|
||||
toConfig = new MToConfig(configs, validators);
|
||||
}
|
||||
|
||||
return new MConnector("NAME", "CLASSNAME", "1.0",
|
||||
@ -67,11 +71,13 @@ private MConnector createConnector(List<Direction> supportedDirections) {
|
||||
*/
|
||||
@Test
|
||||
public void testInitialization() {
|
||||
List<MConfig> fromJobConfig = new ArrayList<MConfig>();
|
||||
List<MConfig> toJobConfig = new ArrayList<MConfig>();
|
||||
MLinkConfig linkConfig = new MLinkConfig(fromJobConfig);
|
||||
MFromConfig fromConfig1 = new MFromConfig(fromJobConfig);
|
||||
MToConfig toConfig1 = new MToConfig(toJobConfig);
|
||||
List<MConfig> fromJobConfig = new ArrayList<>();
|
||||
List<MValidator> fromValidators = new ArrayList<>();
|
||||
List<MConfig> toJobConfig = new ArrayList<>();
|
||||
List<MValidator> toValidators = new ArrayList<>();
|
||||
MLinkConfig linkConfig = new MLinkConfig(fromJobConfig, fromValidators);
|
||||
MFromConfig fromConfig1 = new MFromConfig(fromJobConfig, fromValidators);
|
||||
MToConfig toConfig1 = new MToConfig(toJobConfig, toValidators);
|
||||
MConnector connector1 = new MConnector("NAME", "CLASSNAME", "1.0",
|
||||
linkConfig, fromConfig1, toConfig1);
|
||||
assertEquals("NAME", connector1.getUniqueName());
|
||||
|
@ -27,6 +27,8 @@
|
||||
import org.joda.time.DateTime;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
/**
|
||||
* Test class for org.apache.sqoop.model.MDateTimeInput
|
||||
*/
|
||||
@ -36,7 +38,7 @@ public class TestMDateTimeInput {
|
||||
*/
|
||||
@Test
|
||||
public void testInitialization() {
|
||||
MDateTimeInput input = new MDateTimeInput("sqoopsqoop", false, InputEditable.ANY, StringUtils.EMPTY);
|
||||
MDateTimeInput input = new MDateTimeInput("sqoopsqoop", false, InputEditable.ANY, StringUtils.EMPTY, Collections.EMPTY_LIST);
|
||||
assertEquals("sqoopsqoop", input.getName());
|
||||
assertEquals(MInputType.DATETIME, input.getType());
|
||||
}
|
||||
@ -47,13 +49,13 @@ public void testInitialization() {
|
||||
@Test
|
||||
public void testEquals() {
|
||||
// Positive test
|
||||
MDateTimeInput input1 = new MDateTimeInput("sqoopsqoop", false, InputEditable.ANY, StringUtils.EMPTY);
|
||||
MDateTimeInput input2 = new MDateTimeInput("sqoopsqoop", false, InputEditable.ANY, StringUtils.EMPTY);
|
||||
MDateTimeInput input1 = new MDateTimeInput("sqoopsqoop", false, InputEditable.ANY, StringUtils.EMPTY, Collections.EMPTY_LIST);
|
||||
MDateTimeInput input2 = new MDateTimeInput("sqoopsqoop", false, InputEditable.ANY, StringUtils.EMPTY, Collections.EMPTY_LIST);
|
||||
assertTrue(input1.equals(input2));
|
||||
|
||||
// Negative test
|
||||
MDateTimeInput input3 = new MDateTimeInput("sqoopsqoop", false, InputEditable.ANY, StringUtils.EMPTY);
|
||||
MDateTimeInput input4 = new MDateTimeInput("sqoopsqoop1", false, InputEditable.ANY, StringUtils.EMPTY);
|
||||
MDateTimeInput input3 = new MDateTimeInput("sqoopsqoop", false, InputEditable.ANY, StringUtils.EMPTY, Collections.EMPTY_LIST);
|
||||
MDateTimeInput input4 = new MDateTimeInput("sqoopsqoop1", false, InputEditable.ANY, StringUtils.EMPTY, Collections.EMPTY_LIST);
|
||||
assertFalse(input3.equals(input4));
|
||||
}
|
||||
|
||||
@ -62,7 +64,7 @@ public void testEquals() {
|
||||
*/
|
||||
@Test
|
||||
public void testValue() {
|
||||
MDateTimeInput input1 = new MDateTimeInput("sqoopsqoop", false, InputEditable.ANY, StringUtils.EMPTY);
|
||||
MDateTimeInput input1 = new MDateTimeInput("sqoopsqoop", false, InputEditable.ANY, StringUtils.EMPTY, Collections.EMPTY_LIST);
|
||||
|
||||
// Test for long format
|
||||
DateTime dt = new DateTime(1234567L);
|
||||
@ -83,7 +85,7 @@ public void testValue() {
|
||||
*/
|
||||
@Test
|
||||
public void testUrlSafe() {
|
||||
MDateTimeInput input1 = new MDateTimeInput("sqoopsqoop", false, InputEditable.ANY, StringUtils.EMPTY);
|
||||
MDateTimeInput input1 = new MDateTimeInput("sqoopsqoop", false, InputEditable.ANY, StringUtils.EMPTY, Collections.EMPTY_LIST);
|
||||
DateTime dt = new DateTime(1234567L);
|
||||
input1.setValue(dt);
|
||||
// Getting URL safe string
|
||||
@ -104,7 +106,7 @@ public void testUrlSafe() {
|
||||
*/
|
||||
@Test
|
||||
public void testNamedElement() {
|
||||
MDateTimeInput input1 = new MDateTimeInput("sqoopsqoop", true, InputEditable.ANY, StringUtils.EMPTY);
|
||||
MDateTimeInput input1 = new MDateTimeInput("sqoopsqoop", true, InputEditable.ANY, StringUtils.EMPTY, Collections.EMPTY_LIST);
|
||||
assertEquals("sqoopsqoop.label", input1.getLabelKey());
|
||||
assertEquals("sqoopsqoop.help", input1.getHelpKey());
|
||||
}
|
||||
@ -114,8 +116,8 @@ public void testNamedElement() {
|
||||
*/
|
||||
@Test
|
||||
public void testSensitivity() {
|
||||
MDateTimeInput input1 = new MDateTimeInput("NAME", false, InputEditable.ANY, StringUtils.EMPTY );
|
||||
MDateTimeInput input2 = new MDateTimeInput("NAME", true, InputEditable.ANY, StringUtils.EMPTY );
|
||||
MDateTimeInput input1 = new MDateTimeInput("NAME", false, InputEditable.ANY, StringUtils.EMPTY, Collections.EMPTY_LIST );
|
||||
MDateTimeInput input2 = new MDateTimeInput("NAME", true, InputEditable.ANY, StringUtils.EMPTY, Collections.EMPTY_LIST );
|
||||
assertFalse(input1.isSensitive());
|
||||
assertTrue(input2.isSensitive());
|
||||
}
|
||||
|
@ -20,6 +20,7 @@
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.sqoop.json.DriverBean;
|
||||
@ -29,12 +30,18 @@ public class TestMDriver {
|
||||
|
||||
@Test
|
||||
public void testDriver() {
|
||||
List<MConfig> driverConfig = new ArrayList<MConfig>();
|
||||
driverConfig.add(new MConfig("driver-test", new ArrayList<MInput<?>>()));
|
||||
MDriverConfig mDriverConfig = new MDriverConfig(driverConfig);
|
||||
List<MConfig> driverConfig = new ArrayList<>();
|
||||
driverConfig.add(new MConfig("driver-test", new ArrayList<MInput<?>>(), Collections.EMPTY_LIST));
|
||||
|
||||
List<MValidator> driverValidators = new ArrayList<>();
|
||||
driverValidators.add(new MValidator("test", ""));
|
||||
|
||||
MDriverConfig mDriverConfig = new MDriverConfig(driverConfig, driverValidators);
|
||||
|
||||
MDriver driver = new MDriver(mDriverConfig, DriverBean.CURRENT_DRIVER_VERSION);
|
||||
assertEquals(1, driver.getDriverConfig().getConfigs().size());
|
||||
assertEquals("driver-test", driver.getDriverConfig().getConfigs().get(0).getName());
|
||||
assertEquals("test", driver.getDriverConfig().getValidators().get(0).getValidatorClass());
|
||||
assertEquals("", driver.getDriverConfig().getValidators().get(0).getStrArg());
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,8 @@
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertFalse;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
@ -36,19 +38,19 @@ public enum Enumeration { value1, value2}
|
||||
@Test
|
||||
public void testInitialization() {
|
||||
String[] values = { "value1", "value2" };
|
||||
MEnumInput input = new MEnumInput("NAME", false, InputEditable.ANY, StringUtils.EMPTY, values);
|
||||
MEnumInput input = new MEnumInput("NAME", false, InputEditable.ANY, StringUtils.EMPTY, values, Collections.EMPTY_LIST);
|
||||
assertEquals("NAME", input.getName());
|
||||
assertEquals(values, input.getValues());
|
||||
assertEquals(MInputType.ENUM, input.getType());
|
||||
|
||||
MEnumInput input1 = new MEnumInput("NAME", false, InputEditable.ANY, StringUtils.EMPTY, values);
|
||||
MEnumInput input1 = new MEnumInput("NAME", false, InputEditable.ANY, StringUtils.EMPTY, values, Collections.EMPTY_LIST);
|
||||
assertEquals(input1, input);
|
||||
String[] testVal = { "val", "test" };
|
||||
MEnumInput input2 = new MEnumInput("NAME1", false, InputEditable.ANY, StringUtils.EMPTY,
|
||||
testVal);
|
||||
testVal, Collections.EMPTY_LIST);
|
||||
assertFalse(input1.equals(input2));
|
||||
|
||||
MEnumInput input3 = new MEnumInput("NAME", false, InputEditable.ANY, StringUtils.EMPTY, values);
|
||||
MEnumInput input3 = new MEnumInput("NAME", false, InputEditable.ANY, StringUtils.EMPTY, values, Collections.EMPTY_LIST);
|
||||
input3.setValue(Enumeration.value1);
|
||||
assertEquals("value1", input3.getValue());
|
||||
}
|
||||
@ -59,8 +61,8 @@ public void testInitialization() {
|
||||
@Test
|
||||
public void testSensitivity() {
|
||||
String[] values = { "value1", "value2" };
|
||||
MEnumInput input1 = new MEnumInput("NAME", false, InputEditable.ANY, StringUtils.EMPTY, values);
|
||||
MEnumInput input2 = new MEnumInput("NAME", true, InputEditable.ANY, StringUtils.EMPTY, values);
|
||||
MEnumInput input1 = new MEnumInput("NAME", false, InputEditable.ANY, StringUtils.EMPTY, values, Collections.EMPTY_LIST);
|
||||
MEnumInput input2 = new MEnumInput("NAME", true, InputEditable.ANY, StringUtils.EMPTY, values, Collections.EMPTY_LIST);
|
||||
assertFalse(input1.isSensitive());
|
||||
assertTrue(input2.isSensitive());
|
||||
}
|
||||
|
@ -20,6 +20,8 @@
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertFalse;
|
||||
import static org.testng.Assert.assertNull;
|
||||
@ -34,7 +36,7 @@ public class TestMIntegerInput {
|
||||
*/
|
||||
@Test
|
||||
public void testInitialization() {
|
||||
MIntegerInput input = new MIntegerInput("sqoopsqoop", false, InputEditable.ANY, StringUtils.EMPTY);
|
||||
MIntegerInput input = new MIntegerInput("sqoopsqoop", false, InputEditable.ANY, StringUtils.EMPTY, Collections.EMPTY_LIST);
|
||||
assertEquals("sqoopsqoop", input.getName());
|
||||
assertEquals(MInputType.INTEGER, input.getType());
|
||||
}
|
||||
@ -45,13 +47,13 @@ public void testInitialization() {
|
||||
@Test
|
||||
public void testEquals() {
|
||||
// Positive test
|
||||
MIntegerInput input1 = new MIntegerInput("sqoopsqoop", false, InputEditable.ANY, StringUtils.EMPTY);
|
||||
MIntegerInput input2 = new MIntegerInput("sqoopsqoop", false, InputEditable.ANY, StringUtils.EMPTY);
|
||||
MIntegerInput input1 = new MIntegerInput("sqoopsqoop", false, InputEditable.ANY, StringUtils.EMPTY, Collections.EMPTY_LIST);
|
||||
MIntegerInput input2 = new MIntegerInput("sqoopsqoop", false, InputEditable.ANY, StringUtils.EMPTY, Collections.EMPTY_LIST);
|
||||
assertTrue(input1.equals(input2));
|
||||
|
||||
// Negative test
|
||||
MIntegerInput input3 = new MIntegerInput("sqoopsqoop", false, InputEditable.ANY, StringUtils.EMPTY);
|
||||
MIntegerInput input4 = new MIntegerInput("sqoopsqoop1", false, InputEditable.ANY, StringUtils.EMPTY);
|
||||
MIntegerInput input3 = new MIntegerInput("sqoopsqoop", false, InputEditable.ANY, StringUtils.EMPTY, Collections.EMPTY_LIST);
|
||||
MIntegerInput input4 = new MIntegerInput("sqoopsqoop1", false, InputEditable.ANY, StringUtils.EMPTY, Collections.EMPTY_LIST);
|
||||
assertFalse(input3.equals(input4));
|
||||
}
|
||||
|
||||
@ -60,7 +62,7 @@ public void testEquals() {
|
||||
*/
|
||||
@Test
|
||||
public void testValue() {
|
||||
MIntegerInput input1 = new MIntegerInput("sqoopsqoop", false, InputEditable.ANY, StringUtils.EMPTY);
|
||||
MIntegerInput input1 = new MIntegerInput("sqoopsqoop", false, InputEditable.ANY, StringUtils.EMPTY, Collections.EMPTY_LIST);
|
||||
input1.setValue(99);
|
||||
assertEquals(new Integer(99), input1.getValue());
|
||||
input1.setEmpty();
|
||||
@ -72,7 +74,7 @@ public void testValue() {
|
||||
*/
|
||||
@Test
|
||||
public void testUrlSafe() {
|
||||
MIntegerInput input1 = new MIntegerInput("sqoopsqoop", false, InputEditable.ANY, StringUtils.EMPTY);
|
||||
MIntegerInput input1 = new MIntegerInput("sqoopsqoop", false, InputEditable.ANY, StringUtils.EMPTY, Collections.EMPTY_LIST);
|
||||
input1.setValue(1001);
|
||||
// Getting URL safe string
|
||||
String tmp = input1.getUrlSafeValueString();
|
||||
@ -86,7 +88,7 @@ public void testUrlSafe() {
|
||||
*/
|
||||
@Test
|
||||
public void testNamedElement() {
|
||||
MStringInput input1 = new MStringInput("sqoopsqoop", true, InputEditable.CONNECTOR_ONLY, StringUtils.EMPTY, (short) 5);
|
||||
MStringInput input1 = new MStringInput("sqoopsqoop", true, InputEditable.CONNECTOR_ONLY, StringUtils.EMPTY, (short) 5, Collections.EMPTY_LIST);
|
||||
assertEquals("sqoopsqoop.label", input1.getLabelKey());
|
||||
assertEquals("sqoopsqoop.help", input1.getHelpKey());
|
||||
}
|
||||
@ -96,8 +98,8 @@ public void testNamedElement() {
|
||||
*/
|
||||
@Test
|
||||
public void testSensitivity() {
|
||||
MIntegerInput input1 = new MIntegerInput("NAME", false, InputEditable.USER_ONLY, StringUtils.EMPTY);
|
||||
MIntegerInput input2 = new MIntegerInput("NAME", true, InputEditable.CONNECTOR_ONLY, StringUtils.EMPTY);
|
||||
MIntegerInput input1 = new MIntegerInput("NAME", false, InputEditable.USER_ONLY, StringUtils.EMPTY, Collections.EMPTY_LIST);
|
||||
MIntegerInput input2 = new MIntegerInput("NAME", true, InputEditable.CONNECTOR_ONLY, StringUtils.EMPTY, Collections.EMPTY_LIST);
|
||||
assertFalse(input1.isSensitive());
|
||||
assertTrue(input2.isSensitive());
|
||||
}
|
||||
|
@ -21,6 +21,7 @@
|
||||
import static org.testng.Assert.assertNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
@ -105,37 +106,49 @@ private MJob job() {
|
||||
|
||||
private MFromConfig fromConfig() {
|
||||
List<MConfig> configs = new ArrayList<MConfig>();
|
||||
MIntegerInput input = new MIntegerInput("INTEGER-INPUT", false, InputEditable.ANY, StringUtils.EMPTY);
|
||||
MIntegerInput input = new MIntegerInput("INTEGER-INPUT", false, InputEditable.ANY, StringUtils.EMPTY, Collections.EMPTY_LIST);
|
||||
input.setValue(100);
|
||||
MLongInput lInput = new MLongInput("LONG-INPUT", false, InputEditable.ANY, StringUtils.EMPTY);
|
||||
MLongInput lInput = new MLongInput("LONG-INPUT", false, InputEditable.ANY, StringUtils.EMPTY, Collections.EMPTY_LIST);
|
||||
lInput.setValue(100L);
|
||||
MStringInput strInput = new MStringInput("STRING-INPUT",false, InputEditable.ANY, StringUtils.EMPTY, (short)20);
|
||||
MStringInput strInput = new MStringInput("STRING-INPUT",false, InputEditable.ANY, StringUtils.EMPTY, (short)20, Collections.EMPTY_LIST);
|
||||
strInput.setValue("TEST-VALUE");
|
||||
List<MInput<?>> list = new ArrayList<MInput<?>>();
|
||||
list.add(input);
|
||||
list.add(strInput);
|
||||
MConfig config = new MConfig("CONFIGFROMNAME", list);
|
||||
MConfig config = new MConfig("CONFIGFROMNAME", list, Collections.EMPTY_LIST);
|
||||
configs.add(config);
|
||||
return new MFromConfig(configs);
|
||||
|
||||
List<MValidator> validators = new ArrayList<>();
|
||||
validators.add(new MValidator("testValidator", ""));
|
||||
|
||||
return new MFromConfig(configs, validators);
|
||||
}
|
||||
|
||||
private MToConfig toConfig() {
|
||||
List<MConfig> configs = new ArrayList<MConfig>();
|
||||
MMapInput input = new MMapInput("MAP-INPUT", false, InputEditable.ANY, StringUtils.EMPTY, StringUtils.EMPTY);
|
||||
MMapInput input = new MMapInput("MAP-INPUT", false, InputEditable.ANY, StringUtils.EMPTY, StringUtils.EMPTY, Collections.EMPTY_LIST);
|
||||
List<MInput<?>> list = new ArrayList<MInput<?>>();
|
||||
list.add(input);
|
||||
MConfig config = new MConfig("CONFIGTONAME", list);
|
||||
MConfig config = new MConfig("CONFIGTONAME", list, Collections.EMPTY_LIST);
|
||||
configs.add(config);
|
||||
return new MToConfig(configs);
|
||||
|
||||
List<MValidator> validators = new ArrayList<>();
|
||||
|
||||
return new MToConfig(configs, validators);
|
||||
}
|
||||
|
||||
private MDriverConfig driverConfig() {
|
||||
List<MConfig> configs = new ArrayList<MConfig>();
|
||||
MMapInput input = new MMapInput("MAP-INPUT", false, InputEditable.ANY, StringUtils.EMPTY, StringUtils.EMPTY);
|
||||
MMapInput input = new MMapInput("MAP-INPUT", false, InputEditable.ANY, StringUtils.EMPTY, StringUtils.EMPTY, Collections.EMPTY_LIST);
|
||||
List<MInput<?>> list = new ArrayList<MInput<?>>();
|
||||
list.add(input);
|
||||
MConfig config = new MConfig("CONFIGDRIVERNAME", list);
|
||||
MConfig config = new MConfig("CONFIGDRIVERNAME", list, Collections.EMPTY_LIST);
|
||||
configs.add(config);
|
||||
return new MDriverConfig(configs);
|
||||
|
||||
List<MValidator> validators = new ArrayList<>();
|
||||
validators.add(new MValidator("testValidator1", ""));
|
||||
validators.add(new MValidator("testValidator2", "blah"));
|
||||
|
||||
return new MDriverConfig(configs, validators);
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,7 @@
|
||||
package org.apache.sqoop.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
@ -30,12 +31,14 @@ public class TestMJobConfig {
|
||||
*/
|
||||
@Test
|
||||
public void testInitialization() {
|
||||
List<MConfig> configs = new ArrayList<MConfig>();
|
||||
MFromConfig fromJobConfig = new MFromConfig(configs);
|
||||
List<MConfig> configs2 = new ArrayList<MConfig>();
|
||||
MFromConfig fromJobConfig2 = new MFromConfig(configs2);
|
||||
List<MConfig> configs = new ArrayList<>();
|
||||
List<MValidator> validators = new ArrayList<>();
|
||||
MFromConfig fromJobConfig = new MFromConfig(configs, validators);
|
||||
List<MConfig> configs2 = new ArrayList<>();
|
||||
List<MValidator> validators2 = new ArrayList<>();
|
||||
MFromConfig fromJobConfig2 = new MFromConfig(configs2, validators2);
|
||||
assertEquals(fromJobConfig2, fromJobConfig);
|
||||
MConfig c = new MConfig("test", null);
|
||||
MConfig c = new MConfig("test", null, Collections.EMPTY_LIST);
|
||||
configs2.add(c);
|
||||
assertFalse(fromJobConfig.equals(fromJobConfig2));
|
||||
}
|
||||
|
@ -18,6 +18,7 @@
|
||||
package org.apache.sqoop.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
@ -82,16 +83,20 @@ private MLink link() {
|
||||
|
||||
private MLinkConfig linkConfig() {
|
||||
List<MConfig> configs = new ArrayList<MConfig>();
|
||||
MIntegerInput input = new MIntegerInput("INTEGER-INPUT", false, InputEditable.ANY, StringUtils.EMPTY);
|
||||
MIntegerInput input = new MIntegerInput("INTEGER-INPUT", false, InputEditable.ANY, StringUtils.EMPTY, Collections.EMPTY_LIST);
|
||||
input.setValue(100);
|
||||
MStringInput strInput = new MStringInput("STRING-INPUT",false, InputEditable.ANY, StringUtils.EMPTY, (short)20);
|
||||
MStringInput strInput = new MStringInput("STRING-INPUT",false, InputEditable.ANY, StringUtils.EMPTY, (short)20, Collections.EMPTY_LIST);
|
||||
strInput.setValue("TEST-VALUE");
|
||||
List<MInput<?>> list = new ArrayList<MInput<?>>();
|
||||
list.add(input);
|
||||
list.add(strInput);
|
||||
MConfig config = new MConfig("CONFIGNAME", list);
|
||||
MConfig config = new MConfig("CONFIGNAME", list, Collections.EMPTY_LIST);
|
||||
configs.add(config);
|
||||
return new MLinkConfig(configs);
|
||||
|
||||
List<MValidator> validators = new ArrayList<>();
|
||||
validators.add(new MValidator("test", ""));
|
||||
|
||||
return new MLinkConfig(configs, validators);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -18,6 +18,7 @@
|
||||
package org.apache.sqoop.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
@ -31,14 +32,16 @@ public class TestMLinkConfig {
|
||||
*/
|
||||
@Test
|
||||
public void testInitialization() {
|
||||
List<MConfig> configs = new ArrayList<MConfig>();
|
||||
MLinkConfig linkConfig = new MLinkConfig(configs);
|
||||
List<MConfig> testConfig = new ArrayList<MConfig>();
|
||||
List<MConfig> configs = new ArrayList<>();
|
||||
List<MValidator> validators = new ArrayList<>();
|
||||
MLinkConfig linkConfig = new MLinkConfig(configs, validators);
|
||||
List<MConfig> testConfig = new ArrayList<>();
|
||||
List<MValidator> testValidator = new ArrayList<>();
|
||||
assertEquals(testConfig, linkConfig.getConfigs());
|
||||
MLinkConfig linkConfig2 = new MLinkConfig(testConfig);
|
||||
MLinkConfig linkConfig2 = new MLinkConfig(testConfig, testValidator);
|
||||
assertEquals(linkConfig2, linkConfig);
|
||||
// Add a config to list for checking not equals
|
||||
MConfig c = new MConfig("test", null);
|
||||
MConfig c = new MConfig("test", null, Collections.EMPTY_LIST);
|
||||
testConfig.add(c);
|
||||
assertFalse(linkConfig.equals(linkConfig2));
|
||||
}
|
||||
|
@ -23,6 +23,7 @@
|
||||
import static org.testng.Assert.assertNull;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
@ -38,7 +39,7 @@ public class TestMListInput {
|
||||
*/
|
||||
@Test
|
||||
public void testInitialization() {
|
||||
MListInput input = new MListInput("sqoopsqoop", false, InputEditable.ANY, StringUtils.EMPTY);
|
||||
MListInput input = new MListInput("sqoopsqoop", false, InputEditable.ANY, StringUtils.EMPTY, Collections.EMPTY_LIST);
|
||||
assertEquals("sqoopsqoop", input.getName());
|
||||
assertEquals(MInputType.LIST, input.getType());
|
||||
}
|
||||
@ -49,13 +50,13 @@ public void testInitialization() {
|
||||
@Test
|
||||
public void testEquals() {
|
||||
// Positive test
|
||||
MListInput input1 = new MListInput("sqoopsqoop", false, InputEditable.ANY, StringUtils.EMPTY);
|
||||
MListInput input2 = new MListInput("sqoopsqoop", false, InputEditable.ANY, StringUtils.EMPTY);
|
||||
MListInput input1 = new MListInput("sqoopsqoop", false, InputEditable.ANY, StringUtils.EMPTY, Collections.EMPTY_LIST);
|
||||
MListInput input2 = new MListInput("sqoopsqoop", false, InputEditable.ANY, StringUtils.EMPTY, Collections.EMPTY_LIST);
|
||||
assertTrue(input1.equals(input2));
|
||||
|
||||
// Negative test
|
||||
MListInput input3 = new MListInput("sqoopsqoop", false, InputEditable.ANY, StringUtils.EMPTY);
|
||||
MListInput input4 = new MListInput("sqoopsqoop1", false, InputEditable.ANY, StringUtils.EMPTY);
|
||||
MListInput input3 = new MListInput("sqoopsqoop", false, InputEditable.ANY, StringUtils.EMPTY, Collections.EMPTY_LIST);
|
||||
MListInput input4 = new MListInput("sqoopsqoop1", false, InputEditable.ANY, StringUtils.EMPTY, Collections.EMPTY_LIST);
|
||||
assertFalse(input3.equals(input4));
|
||||
}
|
||||
|
||||
@ -64,7 +65,7 @@ public void testEquals() {
|
||||
*/
|
||||
@Test
|
||||
public void testValue() {
|
||||
MListInput input1 = new MListInput("sqoopsqoop", false, InputEditable.ANY, StringUtils.EMPTY);
|
||||
MListInput input1 = new MListInput("sqoopsqoop", false, InputEditable.ANY, StringUtils.EMPTY, Collections.EMPTY_LIST);
|
||||
List<String> list = new LinkedList<String>();
|
||||
input1.setValue(list);
|
||||
assertEquals(list, input1.getValue());
|
||||
@ -77,7 +78,7 @@ public void testValue() {
|
||||
*/
|
||||
@Test
|
||||
public void testUrlSafe() {
|
||||
MListInput input1 = new MListInput("sqoopsqoop", false, InputEditable.ANY, StringUtils.EMPTY);
|
||||
MListInput input1 = new MListInput("sqoopsqoop", false, InputEditable.ANY, StringUtils.EMPTY, Collections.EMPTY_LIST);
|
||||
List<String> list = new LinkedList<String>();
|
||||
input1.setValue(list);
|
||||
// Getting URL safe string
|
||||
@ -98,7 +99,7 @@ public void testUrlSafe() {
|
||||
*/
|
||||
@Test
|
||||
public void testNamedElement() {
|
||||
MListInput input1 = new MListInput("sqoopsqoop", true, InputEditable.ANY, StringUtils.EMPTY);
|
||||
MListInput input1 = new MListInput("sqoopsqoop", true, InputEditable.ANY, StringUtils.EMPTY, Collections.EMPTY_LIST);
|
||||
assertEquals("sqoopsqoop.label", input1.getLabelKey());
|
||||
assertEquals("sqoopsqoop.help", input1.getHelpKey());
|
||||
}
|
||||
@ -108,8 +109,8 @@ public void testNamedElement() {
|
||||
*/
|
||||
@Test
|
||||
public void testSensitivity() {
|
||||
MListInput input1 = new MListInput("NAME", false, InputEditable.ANY, StringUtils.EMPTY );
|
||||
MListInput input2 = new MListInput("NAME", true, InputEditable.ANY, StringUtils.EMPTY );
|
||||
MListInput input1 = new MListInput("NAME", false, InputEditable.ANY, StringUtils.EMPTY, Collections.EMPTY_LIST );
|
||||
MListInput input2 = new MListInput("NAME", true, InputEditable.ANY, StringUtils.EMPTY, Collections.EMPTY_LIST );
|
||||
assertFalse(input1.isSensitive());
|
||||
assertTrue(input2.isSensitive());
|
||||
}
|
||||
|
@ -17,6 +17,7 @@
|
||||
*/
|
||||
package org.apache.sqoop.model;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@ -38,7 +39,7 @@ public class TestMMapInput {
|
||||
*/
|
||||
@Test
|
||||
public void testInitialization() {
|
||||
MMapInput input = new MMapInput("sqoopsqoop", false, InputEditable.ANY, StringUtils.EMPTY, StringUtils.EMPTY);
|
||||
MMapInput input = new MMapInput("sqoopsqoop", false, InputEditable.ANY, StringUtils.EMPTY, StringUtils.EMPTY, Collections.EMPTY_LIST);
|
||||
assertEquals("sqoopsqoop", input.getName());
|
||||
assertEquals(MInputType.MAP, input.getType());
|
||||
}
|
||||
@ -49,13 +50,13 @@ public void testInitialization() {
|
||||
@Test
|
||||
public void testEquals() {
|
||||
// Positive test
|
||||
MMapInput input1 = new MMapInput("sqoopsqoop", false, InputEditable.ANY, StringUtils.EMPTY, StringUtils.EMPTY);
|
||||
MMapInput input2 = new MMapInput("sqoopsqoop", false, InputEditable.ANY, StringUtils.EMPTY, StringUtils.EMPTY);
|
||||
MMapInput input1 = new MMapInput("sqoopsqoop", false, InputEditable.ANY, StringUtils.EMPTY, StringUtils.EMPTY, Collections.EMPTY_LIST);
|
||||
MMapInput input2 = new MMapInput("sqoopsqoop", false, InputEditable.ANY, StringUtils.EMPTY, StringUtils.EMPTY, Collections.EMPTY_LIST);
|
||||
assertTrue(input1.equals(input2));
|
||||
|
||||
// Negative test
|
||||
MMapInput input3 = new MMapInput("sqoopsqoop", false, InputEditable.ANY, StringUtils.EMPTY, StringUtils.EMPTY);
|
||||
MMapInput input4 = new MMapInput("sqoopsqoop1", false, InputEditable.ANY, StringUtils.EMPTY, StringUtils.EMPTY);
|
||||
MMapInput input3 = new MMapInput("sqoopsqoop", false, InputEditable.ANY, StringUtils.EMPTY, StringUtils.EMPTY, Collections.EMPTY_LIST);
|
||||
MMapInput input4 = new MMapInput("sqoopsqoop1", false, InputEditable.ANY, StringUtils.EMPTY, StringUtils.EMPTY, Collections.EMPTY_LIST);
|
||||
assertFalse(input3.equals(input4));
|
||||
}
|
||||
|
||||
@ -64,7 +65,7 @@ public void testEquals() {
|
||||
*/
|
||||
@Test
|
||||
public void testValue() {
|
||||
MMapInput input1 = new MMapInput("sqoopsqoop", false, InputEditable.ANY, StringUtils.EMPTY, StringUtils.EMPTY);
|
||||
MMapInput input1 = new MMapInput("sqoopsqoop", false, InputEditable.ANY, StringUtils.EMPTY, StringUtils.EMPTY, Collections.EMPTY_LIST);
|
||||
Map<String, String> map1 = new HashMap<String, String>();
|
||||
input1.setValue(map1);
|
||||
assertEquals(map1, input1.getValue());
|
||||
@ -77,7 +78,7 @@ public void testValue() {
|
||||
*/
|
||||
@Test
|
||||
public void testUrlSafe() {
|
||||
MMapInput input1 = new MMapInput("sqoopsqoop", false, InputEditable.ANY, StringUtils.EMPTY, StringUtils.EMPTY);
|
||||
MMapInput input1 = new MMapInput("sqoopsqoop", false, InputEditable.ANY, StringUtils.EMPTY, StringUtils.EMPTY, Collections.EMPTY_LIST);
|
||||
Map<String, String> map1 = new HashMap<String, String>();
|
||||
input1.setValue(map1);
|
||||
// Getting URL safe string
|
||||
@ -98,7 +99,7 @@ public void testUrlSafe() {
|
||||
*/
|
||||
@Test
|
||||
public void testNamedElement() {
|
||||
MMapInput input1 = new MMapInput("sqoopsqoop", true, InputEditable.ANY, StringUtils.EMPTY, StringUtils.EMPTY);
|
||||
MMapInput input1 = new MMapInput("sqoopsqoop", true, InputEditable.ANY, StringUtils.EMPTY, StringUtils.EMPTY, Collections.EMPTY_LIST);
|
||||
assertEquals("sqoopsqoop.label", input1.getLabelKey());
|
||||
assertEquals("sqoopsqoop.help", input1.getHelpKey());
|
||||
}
|
||||
@ -108,8 +109,8 @@ public void testNamedElement() {
|
||||
*/
|
||||
@Test
|
||||
public void testSensitivity() {
|
||||
MMapInput input1 = new MMapInput("NAME", false, InputEditable.ANY, StringUtils.EMPTY, StringUtils.EMPTY );
|
||||
MMapInput input2 = new MMapInput("NAME", true, InputEditable.ANY, StringUtils.EMPTY, StringUtils.EMPTY );
|
||||
MMapInput input1 = new MMapInput("NAME", false, InputEditable.ANY, StringUtils.EMPTY, StringUtils.EMPTY , Collections.EMPTY_LIST);
|
||||
MMapInput input2 = new MMapInput("NAME", true, InputEditable.ANY, StringUtils.EMPTY, StringUtils.EMPTY , Collections.EMPTY_LIST);
|
||||
assertFalse(input1.isSensitive());
|
||||
assertTrue(input2.isSensitive());
|
||||
}
|
||||
@ -123,9 +124,9 @@ public void testSensitiveKeyPattern() {
|
||||
testValue.put("sqoop features", "awesome features");
|
||||
testValue.put("sqoop bugs", "horrible bugs");
|
||||
|
||||
MMapInput input1 = new MMapInput("NAME", false, InputEditable.ANY, StringUtils.EMPTY, StringUtils.EMPTY );
|
||||
MMapInput input1 = new MMapInput("NAME", false, InputEditable.ANY, StringUtils.EMPTY, StringUtils.EMPTY , Collections.EMPTY_LIST);
|
||||
input1.setValue(testValue);
|
||||
MMapInput input2 = new MMapInput("NAME", true, InputEditable.ANY, StringUtils.EMPTY, ".*bugs.*");
|
||||
MMapInput input2 = new MMapInput("NAME", true, InputEditable.ANY, StringUtils.EMPTY, ".*bugs.*", Collections.EMPTY_LIST);
|
||||
input2.setValue(testValue);
|
||||
|
||||
assertEquals(input1.getNonsenstiveValue(), testValue);
|
||||
|
@ -20,6 +20,8 @@
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import static org.testng.Assert.*;
|
||||
|
||||
/**
|
||||
@ -32,7 +34,7 @@ public class TestMNamedElement {
|
||||
*/
|
||||
@Test
|
||||
public void testInitialization() {
|
||||
MNamedElement named = new MIntegerInput("SQOOP", false, InputEditable.ANY, StringUtils.EMPTY);
|
||||
MNamedElement named = new MIntegerInput("SQOOP", false, InputEditable.ANY, StringUtils.EMPTY, Collections.EMPTY_LIST);
|
||||
assertEquals("SQOOP", named.getName());
|
||||
assertEquals("SQOOP.label", named.getLabelKey());
|
||||
assertEquals("SQOOP.help", named.getHelpKey());
|
||||
|
@ -20,6 +20,8 @@
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import static org.testng.Assert.*;
|
||||
|
||||
/**
|
||||
@ -34,7 +36,7 @@ public class TestMStringInput {
|
||||
public void testInitialization() {
|
||||
short len = 6;
|
||||
MStringInput input = new MStringInput("sqoopsqoop", true, InputEditable.ANY, StringUtils.EMPTY,
|
||||
len);
|
||||
len, Collections.EMPTY_LIST);
|
||||
assertEquals("sqoopsqoop", input.getName());
|
||||
assertEquals(true, input.isSensitive());
|
||||
assertEquals(len, input.getMaxLength());
|
||||
@ -49,16 +51,16 @@ public void testEquals() {
|
||||
short len = 6;
|
||||
// Positive test
|
||||
MStringInput input1 = new MStringInput("sqoopsqoop", true, InputEditable.ANY,
|
||||
StringUtils.EMPTY, len);
|
||||
StringUtils.EMPTY, len, Collections.EMPTY_LIST);
|
||||
MStringInput input2 = new MStringInput("sqoopsqoop", true, InputEditable.ANY,
|
||||
StringUtils.EMPTY, len);
|
||||
StringUtils.EMPTY, len, Collections.EMPTY_LIST);
|
||||
assertTrue(input1.equals(input2));
|
||||
|
||||
// Negative test
|
||||
MStringInput input3 = new MStringInput("sqoopsqoop", false, InputEditable.ANY,
|
||||
StringUtils.EMPTY, len);
|
||||
StringUtils.EMPTY, len, Collections.EMPTY_LIST);
|
||||
MStringInput input4 = new MStringInput("sqoopsqoop", true, InputEditable.ANY,
|
||||
StringUtils.EMPTY, len);
|
||||
StringUtils.EMPTY, len, Collections.EMPTY_LIST);
|
||||
assertFalse(input3.equals(input4));
|
||||
}
|
||||
|
||||
@ -68,7 +70,7 @@ public void testEquals() {
|
||||
@Test
|
||||
public void testValue() {
|
||||
MStringInput input1 = new MStringInput("sqoopsqoop", true, InputEditable.ANY,
|
||||
StringUtils.EMPTY, (short) 5);
|
||||
StringUtils.EMPTY, (short) 5, Collections.EMPTY_LIST);
|
||||
input1.setValue("sqoop");
|
||||
assertEquals("sqoop", input1.getValue());
|
||||
input1.setEmpty();
|
||||
@ -81,7 +83,7 @@ public void testValue() {
|
||||
@Test
|
||||
public void testUrlSafe() {
|
||||
MStringInput input1 = new MStringInput("sqoopsqoop", true, InputEditable.ANY,
|
||||
StringUtils.EMPTY, (short) 5);
|
||||
StringUtils.EMPTY, (short) 5, Collections.EMPTY_LIST);
|
||||
String s = "Sqoop%$!@#&*()Sqoop";
|
||||
input1.setValue(s);
|
||||
// Getting URL safe string
|
||||
@ -97,7 +99,7 @@ public void testUrlSafe() {
|
||||
@Test
|
||||
public void testNamedElement() {
|
||||
MStringInput input1 = new MStringInput("sqoopsqoop", true, InputEditable.ANY,
|
||||
StringUtils.EMPTY, (short) 5);
|
||||
StringUtils.EMPTY, (short) 5, Collections.EMPTY_LIST);
|
||||
assertEquals("sqoopsqoop.label", input1.getLabelKey());
|
||||
assertEquals("sqoopsqoop.help", input1.getHelpKey());
|
||||
}
|
||||
|
@ -22,6 +22,10 @@
|
||||
import org.apache.sqoop.validation.Status;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static org.testng.Assert.*;
|
||||
|
||||
/**
|
||||
@ -34,7 +38,10 @@ public class TestMValidatedElement {
|
||||
*/
|
||||
@Test
|
||||
public void testInitialization() {
|
||||
MValidatedElement input = new MIntegerInput("input", false,InputEditable.ANY, StringUtils.EMPTY );
|
||||
MValidator testMValidator = new MValidator("testValidator", null);
|
||||
List<MValidator> mValidatorList = new ArrayList<>();
|
||||
mValidatorList.add(testMValidator);
|
||||
MValidatedElement input = new MIntegerInput("input", false,InputEditable.ANY, StringUtils.EMPTY, mValidatorList);
|
||||
assertEquals(Status.OK, input.getValidationStatus());
|
||||
}
|
||||
|
||||
@ -43,7 +50,7 @@ public void testInitialization() {
|
||||
*/
|
||||
@Test
|
||||
public void testVarious() {
|
||||
MValidatedElement input = new MIntegerInput("input", false, InputEditable.ANY, StringUtils.EMPTY );
|
||||
MValidatedElement input = new MIntegerInput("input", false, InputEditable.ANY, StringUtils.EMPTY, Collections.EMPTY_LIST);
|
||||
|
||||
// Default status
|
||||
assertEquals(Status.OK, input.getValidationStatus());
|
||||
|
@ -0,0 +1,34 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.sqoop.model;
|
||||
|
||||
import org.apache.sqoop.validation.validators.AbstractValidator;
|
||||
import org.testng.annotations.Test;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Test class for org.apache.sqoop.model.MValidator
|
||||
*/
|
||||
public class TestMValidator {
|
||||
@Test
|
||||
public void testEquality() {
|
||||
MValidator testMValidator1 = new MValidator("testValidator", AbstractValidator.DEFAULT_STRING_ARGUMENT);
|
||||
MValidator testMValidator2 = new MValidator("testValidator", AbstractValidator.DEFAULT_STRING_ARGUMENT);
|
||||
assertEquals(testMValidator1, testMValidator2);
|
||||
}
|
||||
}
|
@ -44,8 +44,8 @@ public void setUp() {
|
||||
@Test
|
||||
public void testFromConfig() {
|
||||
// No upgrade
|
||||
MFromConfig originalConfigs = new MFromConfig(ConfigUtils.toConfigs(FromJobConfiguration.class));
|
||||
MFromConfig newConfigs = new MFromConfig(ConfigUtils.toConfigs(FromJobConfiguration.class));
|
||||
MFromConfig originalConfigs = new MFromConfig(ConfigUtils.toConfigs(FromJobConfiguration.class), ConfigUtils.getMValidatorsFromConfigurationClass(FromJobConfiguration.class));
|
||||
MFromConfig newConfigs = new MFromConfig(ConfigUtils.toConfigs(FromJobConfiguration.class), ConfigUtils.getMValidatorsFromConfigurationClass(FromJobConfiguration.class));
|
||||
originalConfigs.getInput("fromJobConfig.schemaName").setValue("test-schema");
|
||||
originalConfigs.getInput("fromJobConfig.tableName").setValue("test-tableName");
|
||||
originalConfigs.getInput("fromJobConfig.columns").setValue("test-columns");
|
||||
@ -63,8 +63,8 @@ public void testFromConfig() {
|
||||
@Test
|
||||
public void testToConfig() {
|
||||
// No upgrade
|
||||
MToConfig originalConfigs = new MToConfig(ConfigUtils.toConfigs(ToJobConfiguration.class));
|
||||
MToConfig newConfigs = new MToConfig(ConfigUtils.toConfigs(ToJobConfiguration.class));
|
||||
MToConfig originalConfigs = new MToConfig(ConfigUtils.toConfigs(ToJobConfiguration.class), ConfigUtils.getMValidatorsFromConfigurationClass(ToJobConfiguration.class));
|
||||
MToConfig newConfigs = new MToConfig(ConfigUtils.toConfigs(ToJobConfiguration.class), ConfigUtils.getMValidatorsFromConfigurationClass(ToJobConfiguration.class));
|
||||
originalConfigs.getInput("toJobConfig.schemaName").setValue("test-schema");
|
||||
originalConfigs.getInput("toJobConfig.tableName").setValue("test-tableName");
|
||||
originalConfigs.getInput("toJobConfig.columns").setValue("test-columns");
|
||||
@ -82,8 +82,8 @@ public void testToConfig() {
|
||||
@Test
|
||||
public void testLinkConfig() {
|
||||
// No upgrade
|
||||
MLinkConfig originalConfigs = new MLinkConfig(ConfigUtils.toConfigs(LinkConfiguration.class));
|
||||
MLinkConfig newConfigs = new MLinkConfig(ConfigUtils.toConfigs(LinkConfiguration.class));
|
||||
MLinkConfig originalConfigs = new MLinkConfig(ConfigUtils.toConfigs(LinkConfiguration.class), ConfigUtils.getMValidatorsFromConfigurationClass(LinkConfiguration.class));
|
||||
MLinkConfig newConfigs = new MLinkConfig(ConfigUtils.toConfigs(LinkConfiguration.class), ConfigUtils.getMValidatorsFromConfigurationClass(LinkConfiguration.class));
|
||||
originalConfigs.getInput("linkConfig.jdbcDriver").setValue("test-jdbcDriver");
|
||||
originalConfigs.getInput("linkConfig.connectionString").setValue("test-connectionString");
|
||||
originalConfigs.getInput("linkConfig.username").setValue("test-username");
|
||||
|
@ -26,9 +26,11 @@
|
||||
import org.apache.sqoop.model.MInput;
|
||||
import org.apache.sqoop.model.MLinkConfig;
|
||||
import org.apache.sqoop.model.MStringInput;
|
||||
import org.apache.sqoop.model.MValidator;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
@ -43,10 +45,10 @@ public void setup() {
|
||||
|
||||
@Test
|
||||
public void testLinkUpgrade() throws Exception {
|
||||
MLinkConfig originalConfigs = new MLinkConfig(new LinkedList<MConfig>());
|
||||
MLinkConfig newConfigs = new MLinkConfig(ConfigUtils.toConfigs(LinkConfiguration.class));
|
||||
originalConfigs.getConfigs().add(new MConfig("linkConfig", new LinkedList<MInput<?>>()));
|
||||
originalConfigs.getConfigs().get(0).getInputs().add(new MStringInput("linkConfig.hdfsHostAndPort", false, InputEditable.ANY, StringUtils.EMPTY, (short)255));
|
||||
MLinkConfig originalConfigs = new MLinkConfig(new LinkedList<MConfig>(), new LinkedList<MValidator>());
|
||||
MLinkConfig newConfigs = new MLinkConfig(ConfigUtils.toConfigs(LinkConfiguration.class), ConfigUtils.getMValidatorsFromConfigurationClass(LinkConfiguration.class));
|
||||
originalConfigs.getConfigs().add(new MConfig("linkConfig", new LinkedList<MInput<?>>(), Collections.EMPTY_LIST));
|
||||
originalConfigs.getConfigs().get(0).getInputs().add(new MStringInput("linkConfig.hdfsHostAndPort", false, InputEditable.ANY, StringUtils.EMPTY, (short)255, Collections.EMPTY_LIST));
|
||||
originalConfigs.getInput("linkConfig.hdfsHostAndPort").setValue("test:8020");
|
||||
upgrader.upgradeLinkConfig(originalConfigs, newConfigs);
|
||||
assertEquals("test:8020", newConfigs.getInput("linkConfig.authority").getValue());
|
||||
|
@ -90,16 +90,16 @@ public ConnectorHandler(URL configFileUrl) {
|
||||
MToConfig toConfig = null;
|
||||
if (connector.getSupportedDirections().contains(Direction.FROM)) {
|
||||
fromConfig = new MFromConfig(ConfigUtils.toConfigs(
|
||||
connector.getJobConfigurationClass(Direction.FROM)));
|
||||
connector.getJobConfigurationClass(Direction.FROM)), ConfigUtils.getMValidatorsFromConfigurationClass(connector.getJobConfigurationClass(Direction.FROM)));
|
||||
}
|
||||
|
||||
if (connector.getSupportedDirections().contains(Direction.TO)) {
|
||||
toConfig = new MToConfig(ConfigUtils.toConfigs(
|
||||
connector.getJobConfigurationClass(Direction.TO)));
|
||||
connector.getJobConfigurationClass(Direction.TO)), ConfigUtils.getMValidatorsFromConfigurationClass(connector.getJobConfigurationClass(Direction.TO)));
|
||||
}
|
||||
|
||||
MLinkConfig linkConfig = new MLinkConfig(
|
||||
ConfigUtils.toConfigs(connector.getLinkConfigurationClass()));
|
||||
ConfigUtils.toConfigs(connector.getLinkConfigurationClass()), ConfigUtils.getMValidatorsFromConfigurationClass(connector.getLinkConfigurationClass()));
|
||||
|
||||
connectorConfigurable = new MConnector(connectorUniqueName, connectorClassName, connector.getVersion(),
|
||||
linkConfig, fromConfig, toConfig);
|
||||
|
@ -17,6 +17,7 @@
|
||||
*/
|
||||
package org.apache.sqoop.driver;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.ResourceBundle;
|
||||
@ -32,6 +33,8 @@
|
||||
import org.apache.sqoop.model.MConfig;
|
||||
import org.apache.sqoop.model.MDriver;
|
||||
import org.apache.sqoop.model.MDriverConfig;
|
||||
import org.apache.sqoop.model.MValidator;
|
||||
import org.apache.sqoop.model.Validator;
|
||||
import org.apache.sqoop.repository.RepositoryManager;
|
||||
|
||||
/**
|
||||
@ -112,7 +115,8 @@ public Class getDriverJobConfigurationClass() {
|
||||
|
||||
private Driver() {
|
||||
List<MConfig> driverConfig = ConfigUtils.toConfigs(getDriverJobConfigurationClass());
|
||||
mDriver = new MDriver(new MDriverConfig(driverConfig), DriverBean.CURRENT_DRIVER_VERSION);
|
||||
List<MValidator> mValidators = ConfigUtils.getMValidatorsFromConfigurationClass(getDriverJobConfigurationClass());
|
||||
mDriver = new MDriver(new MDriverConfig(driverConfig, mValidators), DriverBean.CURRENT_DRIVER_VERSION);
|
||||
|
||||
// Build upgrader
|
||||
driverUpgrader = new DriverUpgrader();
|
||||
|
@ -34,6 +34,7 @@
|
||||
import org.apache.sqoop.json.DriverBean;
|
||||
import org.apache.sqoop.model.ConfigUtils;
|
||||
import org.apache.sqoop.model.MConfig;
|
||||
import org.apache.sqoop.model.MConfigList;
|
||||
import org.apache.sqoop.model.MConnector;
|
||||
import org.apache.sqoop.model.MDriver;
|
||||
import org.apache.sqoop.model.MDriverConfig;
|
||||
@ -476,8 +477,8 @@ public final void upgradeConnector(MConnector oldConnector, MConnector newConnec
|
||||
for (MLink link : existingLinksByConnector) {
|
||||
LOG.info(" Link upgrade for link:" + link.getName() + " for connector:" + connectorName);
|
||||
// Make a new copy of the configs
|
||||
List<MConfig> linkConfig = newConnector.getLinkConfig().clone(false).getConfigs();
|
||||
MLinkConfig newLinkConfig = new MLinkConfig(linkConfig);
|
||||
MConfigList linkConfig = newConnector.getLinkConfig().clone(false);
|
||||
MLinkConfig newLinkConfig = new MLinkConfig(linkConfig.getConfigs(), linkConfig.getCloneOfValidators());
|
||||
MLinkConfig oldLinkConfig = link.getConnectorLinkConfig();
|
||||
upgrader.upgradeLinkConfig(oldLinkConfig, newLinkConfig);
|
||||
MLink newlink = new MLink(link, newLinkConfig);
|
||||
@ -513,9 +514,9 @@ public final void upgradeConnector(MConnector oldConnector, MConnector newConnec
|
||||
&& supportedDirections.isDirectionSupported(Direction.TO)
|
||||
&& job.getToConnectorId() == newConnector.getPersistenceId()) {
|
||||
// Upgrade both configs
|
||||
MFromConfig newFromConfig = new MFromConfig(newConnector.getFromConfig().clone(false).getConfigs());
|
||||
MFromConfig newFromConfig = new MFromConfig(newConnector.getFromConfig().clone(false).getConfigs(), newConnector.getFromConfig().getCloneOfValidators());
|
||||
MFromConfig oldFromConfig = job.getFromJobConfig();
|
||||
MToConfig newToConfig = new MToConfig(newConnector.getToConfig().clone(false).getConfigs());
|
||||
MToConfig newToConfig = new MToConfig(newConnector.getToConfig().clone(false).getConfigs(), newConnector.getToConfig().getCloneOfValidators());
|
||||
MToConfig oldToConfig = job.getToJobConfig();
|
||||
upgrader.upgradeFromJobConfig(oldFromConfig, newFromConfig);
|
||||
upgrader.upgradeToJobConfig(oldToConfig, newToConfig);
|
||||
@ -536,7 +537,7 @@ public final void upgradeConnector(MConnector oldConnector, MConnector newConnec
|
||||
}
|
||||
} else if (supportedDirections.isDirectionSupported(Direction.FROM)
|
||||
&& job.getFromConnectorId() == newConnector.getPersistenceId()) {
|
||||
MFromConfig newFromConfig = new MFromConfig(newConnector.getFromConfig().clone(false).getConfigs());
|
||||
MFromConfig newFromConfig = new MFromConfig(newConnector.getFromConfig().clone(false).getConfigs(), newConnector.getFromConfig().getCloneOfValidators());
|
||||
MFromConfig oldFromConfig = job.getFromJobConfig();
|
||||
upgrader.upgradeFromJobConfig(oldFromConfig, newFromConfig);
|
||||
MToConfig oldToConfig = job.getToJobConfig();
|
||||
@ -559,7 +560,7 @@ public final void upgradeConnector(MConnector oldConnector, MConnector newConnec
|
||||
} else if (supportedDirections.isDirectionSupported(Direction.TO)
|
||||
&& job.getToConnectorId() == newConnector.getPersistenceId()) {
|
||||
MToConfig oldToConfig = job.getToJobConfig();
|
||||
MToConfig newToConfig = new MToConfig(newConnector.getToConfig().clone(false).getConfigs());
|
||||
MToConfig newToConfig = new MToConfig(newConnector.getToConfig().clone(false).getConfigs(), newConnector.getToConfig().getCloneOfValidators());
|
||||
upgrader.upgradeToJobConfig(oldToConfig, newToConfig);
|
||||
MFromConfig oldFromConfig = job.getFromJobConfig();
|
||||
// create a job with old FROM direction configs but new TO direction
|
||||
|
@ -21,6 +21,7 @@
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNull;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
@ -32,6 +33,7 @@
|
||||
import org.apache.sqoop.model.MInput;
|
||||
import org.apache.sqoop.model.MIntegerInput;
|
||||
import org.apache.sqoop.model.MStringInput;
|
||||
import org.apache.sqoop.model.MValidator;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
@ -106,56 +108,73 @@ public void testNonExistingConfig() {
|
||||
}
|
||||
|
||||
MDriverConfig job() {
|
||||
return new MDriverConfig(configs1());
|
||||
return new MDriverConfig(configs1(), validators1());
|
||||
}
|
||||
|
||||
MDriverConfig job1() {
|
||||
return new MDriverConfig(configs1());
|
||||
return new MDriverConfig(configs1(), validators1());
|
||||
}
|
||||
|
||||
MDriverConfig job2() {
|
||||
return new MDriverConfig(configs2());
|
||||
return new MDriverConfig(configs2(), validators2());
|
||||
}
|
||||
|
||||
MDriverConfig job3() {
|
||||
return new MDriverConfig(configs3());
|
||||
return new MDriverConfig(configs3(), validators3());
|
||||
}
|
||||
|
||||
List<MConfig> configs1() {
|
||||
List<MConfig> list = new LinkedList<MConfig>();
|
||||
list.add(new MConfig("f1", inputs1("f1")));
|
||||
List<MConfig> list = new LinkedList<>();
|
||||
list.add(new MConfig("f1", inputs1("f1"), Collections.EMPTY_LIST));
|
||||
return list;
|
||||
}
|
||||
|
||||
List<MValidator> validators1() {
|
||||
List<MValidator> list = new LinkedList<>();
|
||||
list.add(new MValidator("testClass", ""));
|
||||
return list;
|
||||
}
|
||||
|
||||
List<MInput<?>> inputs1(String formName) {
|
||||
List<MInput<?>> list = new LinkedList<MInput<?>>();
|
||||
list.add(new MStringInput(formName + ".s1", false, InputEditable.ANY, StringUtils.EMPTY,
|
||||
(short) 30));
|
||||
(short) 30, Collections.EMPTY_LIST));
|
||||
list.add(new MStringInput(formName + ".s2", false, InputEditable.ANY, StringUtils.EMPTY,
|
||||
(short) 30));
|
||||
list.add(new MIntegerInput(formName + ".i", false, InputEditable.ANY, StringUtils.EMPTY));
|
||||
(short) 30, Collections.EMPTY_LIST));
|
||||
list.add(new MIntegerInput(formName + ".i", false, InputEditable.ANY, StringUtils.EMPTY, Collections.EMPTY_LIST));
|
||||
return list;
|
||||
}
|
||||
|
||||
List<MConfig> configs2() {
|
||||
List<MConfig> list = new LinkedList<MConfig>();
|
||||
list.add(new MConfig("f1", inputs2("f1")));
|
||||
list.add(new MConfig("f1", inputs2("f1"), Collections.EMPTY_LIST));
|
||||
return list;
|
||||
}
|
||||
|
||||
List<MValidator> validators2() {
|
||||
List<MValidator> list = new LinkedList<>();
|
||||
list.add(new MValidator("testClass2", "2"));
|
||||
return list;
|
||||
}
|
||||
|
||||
List<MInput<?>> inputs2(String formName) {
|
||||
List<MInput<?>> list = new LinkedList<MInput<?>>();
|
||||
list.add(new MStringInput(formName + ".s1", false, InputEditable.ANY, StringUtils.EMPTY,
|
||||
(short) 30));
|
||||
(short) 30, Collections.EMPTY_LIST));
|
||||
list.add(new MStringInput(formName + ".s2_", false, InputEditable.ANY, StringUtils.EMPTY,
|
||||
(short) 30));
|
||||
list.add(new MIntegerInput(formName + ".i", false, InputEditable.ANY, StringUtils.EMPTY));
|
||||
(short) 30, Collections.EMPTY_LIST));
|
||||
list.add(new MIntegerInput(formName + ".i", false, InputEditable.ANY, StringUtils.EMPTY, Collections.EMPTY_LIST));
|
||||
return list;
|
||||
}
|
||||
|
||||
List<MConfig> configs3() {
|
||||
List<MConfig> list = new LinkedList<MConfig>();
|
||||
list.add(new MConfig("f2", inputs1("f2")));
|
||||
list.add(new MConfig("f2", inputs1("f2"), Collections.EMPTY_LIST));
|
||||
return list;
|
||||
}
|
||||
|
||||
List<MValidator> validators3() {
|
||||
List<MValidator> list = new LinkedList<>();
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
@ -59,6 +59,7 @@
|
||||
import org.apache.sqoop.model.MLink;
|
||||
import org.apache.sqoop.model.MLinkConfig;
|
||||
import org.apache.sqoop.model.MToConfig;
|
||||
import org.apache.sqoop.model.MValidator;
|
||||
import org.apache.sqoop.model.Validator;
|
||||
import org.apache.sqoop.validation.Status;
|
||||
import org.apache.sqoop.validation.validators.AbstractValidator;
|
||||
@ -743,9 +744,9 @@ public void testDriverConfigUpgradeHandlerWithUpdateJobError() {
|
||||
|
||||
private MConnector connector(long connectorId, String version) {
|
||||
MConnector connector = new MConnector("A" + connectorId, "A" + connectorId, version + connectorId,
|
||||
new MLinkConfig(new LinkedList<MConfig>()),
|
||||
new MFromConfig(ConfigUtils.toConfigs(ValidConfiguration.class)),
|
||||
new MToConfig(ConfigUtils.toConfigs(ValidConfiguration.class)));
|
||||
new MLinkConfig(new LinkedList<MConfig>(), new LinkedList<MValidator>()),
|
||||
new MFromConfig(ConfigUtils.toConfigs(ValidConfiguration.class), ConfigUtils.getMValidatorsFromConfigurationClass(ValidConfiguration.class)),
|
||||
new MToConfig(ConfigUtils.toConfigs(ValidConfiguration.class), ConfigUtils.getMValidatorsFromConfigurationClass(ValidConfiguration.class)));
|
||||
connector.setPersistenceId(connectorId);
|
||||
return connector;
|
||||
}
|
||||
@ -755,7 +756,7 @@ private MConnector connector(long connectoId) {
|
||||
}
|
||||
|
||||
private MDriver driver() {
|
||||
MDriver driver = new MDriver(new MDriverConfig(new LinkedList<MConfig>()),
|
||||
MDriver driver = new MDriver(new MDriverConfig(new LinkedList<MConfig>(), new LinkedList<MValidator>()),
|
||||
DriverBean.CURRENT_DRIVER_VERSION);
|
||||
driver.setPersistenceId(1);
|
||||
return driver;
|
||||
@ -768,7 +769,7 @@ private MDriver anotherDriver() {
|
||||
}
|
||||
|
||||
private MLink link(long linkId, String linkName, long connectorId) {
|
||||
MLink link = new MLink(connectorId, new MLinkConfig(new LinkedList<MConfig>()));
|
||||
MLink link = new MLink(connectorId, new MLinkConfig(new LinkedList<MConfig>(), new LinkedList<MValidator>()));
|
||||
link.setPersistenceId(linkId);
|
||||
link.setName(linkName);
|
||||
return link;
|
||||
@ -776,9 +777,9 @@ private MLink link(long linkId, String linkName, long connectorId) {
|
||||
|
||||
private MJob job(long id, String jobName, long fromConnectorId, long toConnectorId, long fromLinkId, long toLinkId) {
|
||||
MJob job = new MJob(fromConnectorId, toConnectorId, fromLinkId, toLinkId,
|
||||
new MFromConfig(new LinkedList<MConfig>()),
|
||||
new MToConfig(new LinkedList<MConfig>()),
|
||||
new MDriverConfig(new LinkedList<MConfig>()));
|
||||
new MFromConfig(new LinkedList<MConfig>(), new LinkedList<MValidator>()),
|
||||
new MToConfig(new LinkedList<MConfig>(), new LinkedList<MValidator>()),
|
||||
new MDriverConfig(new LinkedList<MConfig>(), new LinkedList<MValidator>()));
|
||||
job.setPersistenceId(id);
|
||||
job.setName(jobName);
|
||||
return job;
|
||||
|
@ -25,6 +25,7 @@
|
||||
import java.sql.Timestamp;
|
||||
import java.sql.Types;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
@ -341,7 +342,7 @@ public MDriver findDriver(String shortName, Connection conn) {
|
||||
List<MConfig> driverConfigs = new ArrayList<MConfig>();
|
||||
loadDriverConfigs(driverConfigs, driverConfigFetchStmt, driverConfigInputFetchStmt, 1, conn);
|
||||
|
||||
mDriver = new MDriver(new MDriverConfig(driverConfigs), driverVersion);
|
||||
mDriver = new MDriver(new MDriverConfig(driverConfigs, Collections.EMPTY_LIST), driverVersion);
|
||||
mDriver.setPersistenceId(driverId);
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
@ -1491,13 +1492,13 @@ private List<MConnector> loadConnectors(PreparedStatement stmt, Connection conn)
|
||||
MFromConfig fromJobConfig = null;
|
||||
MToConfig toJobConfig = null;
|
||||
if (supportedDirections.isDirectionSupported(Direction.FROM)) {
|
||||
fromJobConfig = new MFromConfig(fromConfig);
|
||||
fromJobConfig = new MFromConfig(fromConfig, Collections.EMPTY_LIST);
|
||||
}
|
||||
if (supportedDirections.isDirectionSupported(Direction.TO)) {
|
||||
toJobConfig = new MToConfig(toConfig);
|
||||
toJobConfig = new MToConfig(toConfig, Collections.EMPTY_LIST);
|
||||
}
|
||||
MConnector mc = new MConnector(connectorName, connectorClassName, connectorVersion,
|
||||
new MLinkConfig(linkConfig), fromJobConfig, toJobConfig);
|
||||
new MLinkConfig(linkConfig, Collections.EMPTY_LIST), fromJobConfig, toJobConfig);
|
||||
mc.setPersistenceId(connectorId);
|
||||
|
||||
connectors.add(mc);
|
||||
@ -1534,7 +1535,7 @@ private List<MLink> loadLinksForUpgrade(PreparedStatement stmt,
|
||||
|
||||
loadConnectorConfigs(connectorLinkConfig, fromConfig, toConfig, connectorConfigFetchStatement,
|
||||
connectorConfigInputStatement, 2, conn);
|
||||
MLink link = new MLink(connectorId, new MLinkConfig(connectorLinkConfig));
|
||||
MLink link = new MLink(connectorId, new MLinkConfig(connectorLinkConfig, Collections.EMPTY_LIST));
|
||||
|
||||
link.setPersistenceId(id);
|
||||
link.setName(name);
|
||||
@ -1649,9 +1650,9 @@ private List<MJob> loadJobsForUpgrade(PreparedStatement stmt,
|
||||
MJob job = new MJob(
|
||||
fromConnectorId, toConnectorId,
|
||||
fromLinkId, toLinkId,
|
||||
new MFromConfig(fromConnectorFromJobConfig),
|
||||
new MToConfig(toConnectorToJobConfig),
|
||||
new MDriverConfig(driverConfig));
|
||||
new MFromConfig(fromConnectorFromJobConfig, Collections.EMPTY_LIST),
|
||||
new MToConfig(toConnectorToJobConfig, Collections.EMPTY_LIST),
|
||||
new MDriverConfig(driverConfig, Collections.EMPTY_LIST));
|
||||
|
||||
job.setPersistenceId(id);
|
||||
job.setName(name);
|
||||
@ -1724,9 +1725,9 @@ private List<MJob> loadJobs(PreparedStatement stmt,
|
||||
MJob job = new MJob(
|
||||
fromConnectorId, toConnectorId,
|
||||
fromLinkId, toLinkId,
|
||||
new MFromConfig(mFromConfig.getConfigs()),
|
||||
new MToConfig(mToConfig.getConfigs()),
|
||||
new MDriverConfig(driverConfig));
|
||||
new MFromConfig(mFromConfig.getConfigs(), Collections.EMPTY_LIST),
|
||||
new MToConfig(mToConfig.getConfigs(), Collections.EMPTY_LIST),
|
||||
new MDriverConfig(driverConfig, Collections.EMPTY_LIST));
|
||||
|
||||
job.setPersistenceId(id);
|
||||
job.setName(name);
|
||||
@ -1969,7 +1970,7 @@ private void loadDriverConfigs(List<MConfig> driverConfig,
|
||||
int configIndex = rsetConfig.getInt(5);
|
||||
List<MInput<?>> configInputs = new ArrayList<MInput<?>>();
|
||||
|
||||
MConfig mDriverConfig = new MConfig(configName, configInputs);
|
||||
MConfig mDriverConfig = new MConfig(configName, configInputs, Collections.EMPTY_LIST);
|
||||
mDriverConfig.setPersistenceId(configId);
|
||||
|
||||
inputFetchStmt.setLong(configPosition, configId);
|
||||
@ -1995,28 +1996,28 @@ private void loadDriverConfigs(List<MConfig> driverConfig,
|
||||
MInput input = null;
|
||||
switch (mit) {
|
||||
case STRING:
|
||||
input = new MStringInput(inputName, inputSensitivity, editableEnum, overrides, inputStrLength);
|
||||
input = new MStringInput(inputName, inputSensitivity, editableEnum, overrides, inputStrLength, Collections.EMPTY_LIST);
|
||||
break;
|
||||
case MAP:
|
||||
input = new MMapInput(inputName, inputSensitivity, editableEnum, overrides, StringUtils.EMPTY);
|
||||
input = new MMapInput(inputName, inputSensitivity, editableEnum, overrides, StringUtils.EMPTY, Collections.EMPTY_LIST);
|
||||
break;
|
||||
case BOOLEAN:
|
||||
input = new MBooleanInput(inputName, inputSensitivity, editableEnum, overrides);
|
||||
input = new MBooleanInput(inputName, inputSensitivity, editableEnum, overrides, Collections.EMPTY_LIST);
|
||||
break;
|
||||
case INTEGER:
|
||||
input = new MIntegerInput(inputName, inputSensitivity, editableEnum, overrides);
|
||||
input = new MIntegerInput(inputName, inputSensitivity, editableEnum, overrides, Collections.EMPTY_LIST);
|
||||
break;
|
||||
case LONG:
|
||||
input = new MLongInput(inputName, inputSensitivity, editableEnum, overrides);
|
||||
input = new MLongInput(inputName, inputSensitivity, editableEnum, overrides, Collections.EMPTY_LIST);
|
||||
break;
|
||||
case ENUM:
|
||||
input = new MEnumInput(inputName, inputSensitivity, editableEnum, overrides, inputEnumValues.split(","));
|
||||
input = new MEnumInput(inputName, inputSensitivity, editableEnum, overrides, inputEnumValues.split(","), Collections.EMPTY_LIST);
|
||||
break;
|
||||
case LIST:
|
||||
input = new MListInput(inputName, inputSensitivity, editableEnum, overrides);
|
||||
input = new MListInput(inputName, inputSensitivity, editableEnum, overrides, Collections.EMPTY_LIST);
|
||||
break;
|
||||
case DATETIME:
|
||||
input = new MDateTimeInput(inputName, inputSensitivity, editableEnum, overrides);
|
||||
input = new MDateTimeInput(inputName, inputSensitivity, editableEnum, overrides, Collections.EMPTY_LIST);
|
||||
break;
|
||||
default:
|
||||
throw new SqoopException(CommonRepositoryError.COMMON_0003,
|
||||
@ -2145,7 +2146,7 @@ public void loadConnectorConfigs(List<MConfig> linkConfig, List<MConfig> fromCon
|
||||
int configIndex = rsetConfig.getInt(5);
|
||||
List<MInput<?>> configInputs = new ArrayList<MInput<?>>();
|
||||
|
||||
MConfig config = new MConfig(configName, configInputs);
|
||||
MConfig config = new MConfig(configName, configInputs, Collections.EMPTY_LIST);
|
||||
config.setPersistenceId(configId);
|
||||
|
||||
inputFetchStmt.setLong(configPosition, configId);
|
||||
@ -2173,29 +2174,29 @@ public void loadConnectorConfigs(List<MConfig> linkConfig, List<MConfig> fromCon
|
||||
switch (mit) {
|
||||
case STRING:
|
||||
input = new MStringInput(inputName, inputSensitivity, editableEnum, overrides,
|
||||
inputStrLength);
|
||||
inputStrLength, Collections.EMPTY_LIST);
|
||||
break;
|
||||
case MAP:
|
||||
input = new MMapInput(inputName, inputSensitivity, editableEnum, overrides, StringUtils.EMPTY);
|
||||
input = new MMapInput(inputName, inputSensitivity, editableEnum, overrides, StringUtils.EMPTY, Collections.EMPTY_LIST);
|
||||
break;
|
||||
case BOOLEAN:
|
||||
input = new MBooleanInput(inputName, inputSensitivity, editableEnum, overrides);
|
||||
input = new MBooleanInput(inputName, inputSensitivity, editableEnum, overrides, Collections.EMPTY_LIST);
|
||||
break;
|
||||
case INTEGER:
|
||||
input = new MIntegerInput(inputName, inputSensitivity, editableEnum, overrides);
|
||||
input = new MIntegerInput(inputName, inputSensitivity, editableEnum, overrides, Collections.EMPTY_LIST);
|
||||
break;
|
||||
case LONG:
|
||||
input = new MLongInput(inputName, inputSensitivity, editableEnum, overrides);
|
||||
input = new MLongInput(inputName, inputSensitivity, editableEnum, overrides, Collections.EMPTY_LIST);
|
||||
break;
|
||||
case ENUM:
|
||||
input = new MEnumInput(inputName, inputSensitivity, editableEnum, overrides,
|
||||
inputEnumValues.split(","));
|
||||
inputEnumValues.split(","), Collections.EMPTY_LIST);
|
||||
break;
|
||||
case LIST:
|
||||
input = new MListInput(inputName, inputSensitivity, editableEnum, overrides);
|
||||
input = new MListInput(inputName, inputSensitivity, editableEnum, overrides, Collections.EMPTY_LIST);
|
||||
break;
|
||||
case DATETIME:
|
||||
input = new MDateTimeInput(inputName, inputSensitivity, editableEnum, overrides);
|
||||
input = new MDateTimeInput(inputName, inputSensitivity, editableEnum, overrides, Collections.EMPTY_LIST);
|
||||
break;
|
||||
default:
|
||||
throw new SqoopException(CommonRepositoryError.COMMON_0003, "input-" + inputName + ":"
|
||||
|
@ -31,6 +31,7 @@
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
|
||||
import java.sql.*;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
@ -984,65 +985,65 @@ protected void fillJob(MJob job) {
|
||||
}
|
||||
|
||||
protected MLinkConfig getLinkConfig() {
|
||||
return new MLinkConfig(getConfigs("LINK1", "LINK2"));
|
||||
return new MLinkConfig(getConfigs("LINK1", "LINK2"), Collections.EMPTY_LIST);
|
||||
}
|
||||
|
||||
protected MFromConfig getFromConfig() {
|
||||
return new MFromConfig(getConfigs("JOB3", "JOB4"));
|
||||
return new MFromConfig(getConfigs("JOB3", "JOB4"), Collections.EMPTY_LIST);
|
||||
}
|
||||
|
||||
protected MFromConfig getBadFromConfig() {
|
||||
return new MFromConfig(getBadConfigs("FROM1", "FROM2"));
|
||||
return new MFromConfig(getBadConfigs("FROM1", "FROM2"), Collections.EMPTY_LIST);
|
||||
}
|
||||
|
||||
protected MFromConfig getMultipleOverridesFromConfig() {
|
||||
return new MFromConfig(getMultipleOverrideConfigs("FROM1", "FROM2"));
|
||||
return new MFromConfig(getMultipleOverrideConfigs("FROM1", "FROM2"), Collections.EMPTY_LIST);
|
||||
}
|
||||
|
||||
protected MFromConfig getNonExistentOverridesFromConfig() {
|
||||
return new MFromConfig(getBadConfigsWithNonExistingInputOverrides("FROM1", "FROM2"));
|
||||
return new MFromConfig(getBadConfigsWithNonExistingInputOverrides("FROM1", "FROM2"), Collections.EMPTY_LIST);
|
||||
}
|
||||
|
||||
protected MToConfig getToConfig() {
|
||||
return new MToConfig(getConfigs("JOB5", "JOB6"));
|
||||
return new MToConfig(getConfigs("JOB5", "JOB6"), Collections.EMPTY_LIST);
|
||||
}
|
||||
|
||||
protected MDriverConfig getDriverConfig() {
|
||||
return new MDriverConfig(getConfigs("DRIVER1", "DRIVER2"));
|
||||
return new MDriverConfig(getConfigs("DRIVER1", "DRIVER2"), Collections.EMPTY_LIST);
|
||||
}
|
||||
|
||||
protected MDriverConfig getBadDriverConfig() {
|
||||
return new MDriverConfig(getBadConfigsWithSelfOverrides("DRIVER1", "DRIVER2"));
|
||||
return new MDriverConfig(getBadConfigsWithSelfOverrides("DRIVER1", "DRIVER2"), Collections.EMPTY_LIST);
|
||||
}
|
||||
|
||||
protected List<MConfig> getConfigs(String configName1, String configName2) {
|
||||
List<MConfig> configs = new LinkedList<MConfig>();
|
||||
|
||||
List<MInput<?>> inputs = new LinkedList<MInput<?>>();
|
||||
MInput input = new MStringInput(configName1 + ".I1", false, InputEditable.USER_ONLY, configName1 + ".I2", (short) 30);
|
||||
MInput input = new MStringInput(configName1 + ".I1", false, InputEditable.USER_ONLY, configName1 + ".I2", (short) 30, Collections.EMPTY_LIST);
|
||||
inputs.add(input);
|
||||
input = new MMapInput(configName1 + ".I2", false, InputEditable.CONNECTOR_ONLY, configName1 + ".I5", StringUtils.EMPTY);
|
||||
input = new MMapInput(configName1 + ".I2", false, InputEditable.CONNECTOR_ONLY, configName1 + ".I5", StringUtils.EMPTY, Collections.EMPTY_LIST);
|
||||
inputs.add(input);
|
||||
input = new MIntegerInput(configName1 + ".I3", false, InputEditable.ANY, configName1 + ".I1");
|
||||
input = new MIntegerInput(configName1 + ".I3", false, InputEditable.ANY, configName1 + ".I1", Collections.EMPTY_LIST);
|
||||
inputs.add(input);
|
||||
input = new MBooleanInput(configName1 + ".I4", false, InputEditable.USER_ONLY, StringUtils.EMPTY);
|
||||
input = new MBooleanInput(configName1 + ".I4", false, InputEditable.USER_ONLY, StringUtils.EMPTY, Collections.EMPTY_LIST);
|
||||
inputs.add(input);
|
||||
input = new MEnumInput(configName1 + ".I5", false, InputEditable.ANY, configName1 + ".I4," + configName1 + ".I3", new String[] {"YES", "NO"});
|
||||
input = new MEnumInput(configName1 + ".I5", false, InputEditable.ANY, configName1 + ".I4," + configName1 + ".I3", new String[] {"YES", "NO"}, Collections.EMPTY_LIST);
|
||||
inputs.add(input);
|
||||
configs.add(new MConfig(configName1, inputs));
|
||||
configs.add(new MConfig(configName1, inputs, Collections.EMPTY_LIST));
|
||||
|
||||
inputs = new LinkedList<MInput<?>>();
|
||||
input = new MStringInput(configName2 + ".I1", false, InputEditable.USER_ONLY, configName2 + ".I2", (short) 30);
|
||||
input = new MStringInput(configName2 + ".I1", false, InputEditable.USER_ONLY, configName2 + ".I2", (short) 30, Collections.EMPTY_LIST);
|
||||
inputs.add(input);
|
||||
input = new MMapInput(configName2 + ".I2", false, InputEditable.CONNECTOR_ONLY, configName2 + ".I5", StringUtils.EMPTY);
|
||||
input = new MMapInput(configName2 + ".I2", false, InputEditable.CONNECTOR_ONLY, configName2 + ".I5", StringUtils.EMPTY, Collections.EMPTY_LIST);
|
||||
inputs.add(input);
|
||||
input = new MIntegerInput(configName2 + ".I3", false, InputEditable.ANY, configName2 + ".I1");
|
||||
input = new MIntegerInput(configName2 + ".I3", false, InputEditable.ANY, configName2 + ".I1", Collections.EMPTY_LIST);
|
||||
inputs.add(input);
|
||||
input = new MBooleanInput(configName2 + ".I4", false, InputEditable.USER_ONLY, StringUtils.EMPTY);
|
||||
input = new MBooleanInput(configName2 + ".I4", false, InputEditable.USER_ONLY, StringUtils.EMPTY, Collections.EMPTY_LIST);
|
||||
inputs.add(input);
|
||||
input = new MEnumInput(configName2 + ".I5", false, InputEditable.ANY, configName2 + ".I4," + configName2 + ".I3", new String[] {"YES", "NO"});
|
||||
input = new MEnumInput(configName2 + ".I5", false, InputEditable.ANY, configName2 + ".I4," + configName2 + ".I3", new String[] {"YES", "NO"}, Collections.EMPTY_LIST);
|
||||
inputs.add(input);
|
||||
configs.add(new MConfig(configName2, inputs));
|
||||
configs.add(new MConfig(configName2, inputs, Collections.EMPTY_LIST));
|
||||
|
||||
return configs;
|
||||
}
|
||||
@ -1052,30 +1053,30 @@ protected List<MConfig> getBadConfigs(String configName1, String configName2) {
|
||||
|
||||
List<MInput<?>> inputs = new LinkedList<MInput<?>>();
|
||||
// I1 overrides another user_only attribute, hence a bad config
|
||||
MInput input = new MStringInput(configName1 + ".I1", false, InputEditable.USER_ONLY, configName1 + ".I4", (short) 30);
|
||||
MInput input = new MStringInput(configName1 + ".I1", false, InputEditable.USER_ONLY, configName1 + ".I4", (short) 30, Collections.EMPTY_LIST);
|
||||
inputs.add(input);
|
||||
input = new MMapInput(configName1 + ".I2", false, InputEditable.CONNECTOR_ONLY, configName1 + ".I5", StringUtils.EMPTY);
|
||||
input = new MMapInput(configName1 + ".I2", false, InputEditable.CONNECTOR_ONLY, configName1 + ".I5", StringUtils.EMPTY, Collections.EMPTY_LIST);
|
||||
inputs.add(input);
|
||||
input = new MIntegerInput(configName1 + ".I3", false, InputEditable.ANY, configName1 + ".I1");
|
||||
input = new MIntegerInput(configName1 + ".I3", false, InputEditable.ANY, configName1 + ".I1", Collections.EMPTY_LIST);
|
||||
inputs.add(input);
|
||||
input = new MBooleanInput(configName1 + ".I4", false, InputEditable.USER_ONLY, StringUtils.EMPTY);
|
||||
input = new MBooleanInput(configName1 + ".I4", false, InputEditable.USER_ONLY, StringUtils.EMPTY, Collections.EMPTY_LIST);
|
||||
inputs.add(input);
|
||||
input = new MEnumInput(configName1 + ".I5", false, InputEditable.ANY, configName1 + ".I4," + configName1 + ".I3", new String[] {"YES", "NO"});
|
||||
input = new MEnumInput(configName1 + ".I5", false, InputEditable.ANY, configName1 + ".I4," + configName1 + ".I3", new String[] {"YES", "NO"}, Collections.EMPTY_LIST);
|
||||
inputs.add(input);
|
||||
configs.add(new MConfig(configName1, inputs));
|
||||
configs.add(new MConfig(configName1, inputs, Collections.EMPTY_LIST));
|
||||
|
||||
inputs = new LinkedList<MInput<?>>();
|
||||
input = new MStringInput(configName2 + ".I1", false, InputEditable.USER_ONLY, configName2 + ".I2", (short) 30);
|
||||
input = new MStringInput(configName2 + ".I1", false, InputEditable.USER_ONLY, configName2 + ".I2", (short) 30, Collections.EMPTY_LIST);
|
||||
inputs.add(input);
|
||||
input = new MMapInput(configName2 + ".I2", false, InputEditable.CONNECTOR_ONLY, configName2 + ".I5", StringUtils.EMPTY);
|
||||
input = new MMapInput(configName2 + ".I2", false, InputEditable.CONNECTOR_ONLY, configName2 + ".I5", StringUtils.EMPTY, Collections.EMPTY_LIST);
|
||||
inputs.add(input);
|
||||
input = new MIntegerInput(configName2 + ".I3", false, InputEditable.ANY, configName2 + ".I1");
|
||||
input = new MIntegerInput(configName2 + ".I3", false, InputEditable.ANY, configName2 + ".I1", Collections.EMPTY_LIST);
|
||||
inputs.add(input);
|
||||
input = new MBooleanInput(configName2 + ".I4", false, InputEditable.USER_ONLY, StringUtils.EMPTY);
|
||||
input = new MBooleanInput(configName2 + ".I4", false, InputEditable.USER_ONLY, StringUtils.EMPTY, Collections.EMPTY_LIST);
|
||||
inputs.add(input);
|
||||
input = new MEnumInput(configName2 + ".I5", false, InputEditable.ANY, configName2 + ".I4," + configName2 + ".I3", new String[] {"YES", "NO"});
|
||||
input = new MEnumInput(configName2 + ".I5", false, InputEditable.ANY, configName2 + ".I4," + configName2 + ".I3", new String[] {"YES", "NO"}, Collections.EMPTY_LIST);
|
||||
inputs.add(input);
|
||||
configs.add(new MConfig(configName2, inputs));
|
||||
configs.add(new MConfig(configName2, inputs, Collections.EMPTY_LIST));
|
||||
|
||||
return configs;
|
||||
}
|
||||
@ -1085,30 +1086,30 @@ protected List<MConfig> getBadConfigsWithSelfOverrides(String configName1, Strin
|
||||
|
||||
List<MInput<?>> inputs = new LinkedList<MInput<?>>();
|
||||
// I1 overrides another user_only attribute, hence a bad config
|
||||
MInput input = new MStringInput(configName1 + ".I1", false, InputEditable.USER_ONLY, configName1 + ".I4", (short) 30);
|
||||
MInput input = new MStringInput(configName1 + ".I1", false, InputEditable.USER_ONLY, configName1 + ".I4", (short) 30, Collections.EMPTY_LIST);
|
||||
inputs.add(input);
|
||||
input = new MMapInput(configName1 + ".I2", false, InputEditable.CONNECTOR_ONLY, configName1 + ".I5", StringUtils.EMPTY);
|
||||
input = new MMapInput(configName1 + ".I2", false, InputEditable.CONNECTOR_ONLY, configName1 + ".I5", StringUtils.EMPTY, Collections.EMPTY_LIST);
|
||||
inputs.add(input);
|
||||
input = new MIntegerInput(configName1 + ".I3", false, InputEditable.ANY, configName1 + ".I1");
|
||||
input = new MIntegerInput(configName1 + ".I3", false, InputEditable.ANY, configName1 + ".I1", Collections.EMPTY_LIST);
|
||||
inputs.add(input);
|
||||
input = new MBooleanInput(configName1 + ".I4", false, InputEditable.USER_ONLY, configName1 + ".I4");
|
||||
input = new MBooleanInput(configName1 + ".I4", false, InputEditable.USER_ONLY, configName1 + ".I4", Collections.EMPTY_LIST);
|
||||
inputs.add(input);
|
||||
input = new MEnumInput(configName1 + ".I5", false, InputEditable.ANY, configName1 + ".I4," + configName1 + ".I3", new String[] {"YES", "NO"});
|
||||
input = new MEnumInput(configName1 + ".I5", false, InputEditable.ANY, configName1 + ".I4," + configName1 + ".I3", new String[] {"YES", "NO"}, Collections.EMPTY_LIST);
|
||||
inputs.add(input);
|
||||
configs.add(new MConfig(configName1, inputs));
|
||||
configs.add(new MConfig(configName1, inputs, Collections.EMPTY_LIST));
|
||||
|
||||
inputs = new LinkedList<MInput<?>>();
|
||||
input = new MStringInput(configName2 + ".I1", false, InputEditable.USER_ONLY, configName2 + ".I2", (short) 30);
|
||||
input = new MStringInput(configName2 + ".I1", false, InputEditable.USER_ONLY, configName2 + ".I2", (short) 30, Collections.EMPTY_LIST);
|
||||
inputs.add(input);
|
||||
input = new MMapInput(configName2 + ".I2", false, InputEditable.CONNECTOR_ONLY, configName2 + ".I5", StringUtils.EMPTY);
|
||||
input = new MMapInput(configName2 + ".I2", false, InputEditable.CONNECTOR_ONLY, configName2 + ".I5", StringUtils.EMPTY, Collections.EMPTY_LIST);
|
||||
inputs.add(input);
|
||||
input = new MIntegerInput(configName2 + ".I3", false, InputEditable.ANY, configName2 + ".I1");
|
||||
input = new MIntegerInput(configName2 + ".I3", false, InputEditable.ANY, configName2 + ".I1", Collections.EMPTY_LIST);
|
||||
inputs.add(input);
|
||||
input = new MBooleanInput(configName2 + ".I4", false, InputEditable.USER_ONLY, StringUtils.EMPTY);
|
||||
input = new MBooleanInput(configName2 + ".I4", false, InputEditable.USER_ONLY, StringUtils.EMPTY, Collections.EMPTY_LIST);
|
||||
inputs.add(input);
|
||||
input = new MEnumInput(configName2 + ".I5", false, InputEditable.ANY, configName2 + ".I4," + configName2 + ".I3", new String[] {"YES", "NO"});
|
||||
input = new MEnumInput(configName2 + ".I5", false, InputEditable.ANY, configName2 + ".I4," + configName2 + ".I3", new String[] {"YES", "NO"}, Collections.EMPTY_LIST);
|
||||
inputs.add(input);
|
||||
configs.add(new MConfig(configName2, inputs));
|
||||
configs.add(new MConfig(configName2, inputs, Collections.EMPTY_LIST));
|
||||
|
||||
return configs;
|
||||
}
|
||||
@ -1117,30 +1118,30 @@ protected List<MConfig> getMultipleOverrideConfigs(String configName1, String co
|
||||
List<MConfig> configs = new LinkedList<MConfig>();
|
||||
|
||||
List<MInput<?>> inputs = new LinkedList<MInput<?>>();
|
||||
MInput input = new MStringInput(configName1 + ".I1", false, InputEditable.USER_ONLY, configName1 + ".I2", (short) 30);
|
||||
MInput input = new MStringInput(configName1 + ".I1", false, InputEditable.USER_ONLY, configName1 + ".I2", (short) 30, Collections.EMPTY_LIST);
|
||||
inputs.add(input);
|
||||
input = new MMapInput(configName1 + ".I2", false, InputEditable.CONNECTOR_ONLY, configName1 + ".I1," + configName1 + ".I3", StringUtils.EMPTY);
|
||||
input = new MMapInput(configName1 + ".I2", false, InputEditable.CONNECTOR_ONLY, configName1 + ".I1," + configName1 + ".I3", StringUtils.EMPTY, Collections.EMPTY_LIST);
|
||||
inputs.add(input);
|
||||
input = new MIntegerInput(configName1 + ".I3", false, InputEditable.ANY, configName1 + ".I1");
|
||||
input = new MIntegerInput(configName1 + ".I3", false, InputEditable.ANY, configName1 + ".I1", Collections.EMPTY_LIST);
|
||||
inputs.add(input);
|
||||
input = new MBooleanInput(configName1 + ".I4", false, InputEditable.USER_ONLY, StringUtils.EMPTY);
|
||||
input = new MBooleanInput(configName1 + ".I4", false, InputEditable.USER_ONLY, StringUtils.EMPTY, Collections.EMPTY_LIST);
|
||||
inputs.add(input);
|
||||
input = new MEnumInput(configName1 + ".I5", false, InputEditable.ANY, configName1 + ".I4," + configName1 + ".I3", new String[] {"YES", "NO"});
|
||||
input = new MEnumInput(configName1 + ".I5", false, InputEditable.ANY, configName1 + ".I4," + configName1 + ".I3", new String[] {"YES", "NO"}, Collections.EMPTY_LIST);
|
||||
inputs.add(input);
|
||||
configs.add(new MConfig(configName1, inputs));
|
||||
configs.add(new MConfig(configName1, inputs, Collections.EMPTY_LIST));
|
||||
|
||||
inputs = new LinkedList<MInput<?>>();
|
||||
input = new MStringInput(configName2 + ".I1", false, InputEditable.USER_ONLY, configName2 + ".I2", (short) 30);
|
||||
input = new MStringInput(configName2 + ".I1", false, InputEditable.USER_ONLY, configName2 + ".I2", (short) 30, Collections.EMPTY_LIST);
|
||||
inputs.add(input);
|
||||
input = new MMapInput(configName2 + ".I2", false, InputEditable.CONNECTOR_ONLY, configName2 + ".I5", StringUtils.EMPTY);
|
||||
input = new MMapInput(configName2 + ".I2", false, InputEditable.CONNECTOR_ONLY, configName2 + ".I5", StringUtils.EMPTY, Collections.EMPTY_LIST);
|
||||
inputs.add(input);
|
||||
input = new MIntegerInput(configName2 + ".I3", false, InputEditable.ANY, configName2 + ".I1");
|
||||
input = new MIntegerInput(configName2 + ".I3", false, InputEditable.ANY, configName2 + ".I1", Collections.EMPTY_LIST);
|
||||
inputs.add(input);
|
||||
input = new MBooleanInput(configName2 + ".I4", false, InputEditable.USER_ONLY, StringUtils.EMPTY);
|
||||
input = new MBooleanInput(configName2 + ".I4", false, InputEditable.USER_ONLY, StringUtils.EMPTY, Collections.EMPTY_LIST);
|
||||
inputs.add(input);
|
||||
input = new MEnumInput(configName2 + ".I5", false, InputEditable.ANY, configName2 + ".I4," + configName2 + ".I3", new String[] {"YES", "NO"});
|
||||
input = new MEnumInput(configName2 + ".I5", false, InputEditable.ANY, configName2 + ".I4," + configName2 + ".I3", new String[] {"YES", "NO"}, Collections.EMPTY_LIST);
|
||||
inputs.add(input);
|
||||
configs.add(new MConfig(configName2, inputs));
|
||||
configs.add(new MConfig(configName2, inputs, Collections.EMPTY_LIST));
|
||||
|
||||
return configs;
|
||||
}
|
||||
@ -1151,30 +1152,30 @@ protected List<MConfig> getBadConfigsWithNonExistingInputOverrides(String config
|
||||
|
||||
List<MInput<?>> inputs = new LinkedList<MInput<?>>();
|
||||
// I2 overrides a nonexistant input
|
||||
MInput input = new MStringInput(configName1 + ".I1", false, InputEditable.USER_ONLY, configName1 + ".I2", (short) 30);
|
||||
MInput input = new MStringInput(configName1 + ".I1", false, InputEditable.USER_ONLY, configName1 + ".I2", (short) 30, Collections.EMPTY_LIST);
|
||||
inputs.add(input);
|
||||
input = new MMapInput(configName1 + ".I2", false, InputEditable.CONNECTOR_ONLY, configName1 + ".FOO", StringUtils.EMPTY);
|
||||
input = new MMapInput(configName1 + ".I2", false, InputEditable.CONNECTOR_ONLY, configName1 + ".FOO", StringUtils.EMPTY, Collections.EMPTY_LIST);
|
||||
inputs.add(input);
|
||||
input = new MIntegerInput(configName1 + ".I3", false, InputEditable.ANY, configName1 + ".I1");
|
||||
input = new MIntegerInput(configName1 + ".I3", false, InputEditable.ANY, configName1 + ".I1", Collections.EMPTY_LIST);
|
||||
inputs.add(input);
|
||||
input = new MBooleanInput(configName1 + ".I4", false, InputEditable.USER_ONLY, StringUtils.EMPTY);
|
||||
input = new MBooleanInput(configName1 + ".I4", false, InputEditable.USER_ONLY, StringUtils.EMPTY, Collections.EMPTY_LIST);
|
||||
inputs.add(input);
|
||||
input = new MEnumInput(configName1 + ".I5", false, InputEditable.ANY, configName1 + ".I4," + configName1 + ".I3", new String[] {"YES", "NO"});
|
||||
input = new MEnumInput(configName1 + ".I5", false, InputEditable.ANY, configName1 + ".I4," + configName1 + ".I3", new String[] {"YES", "NO"}, Collections.EMPTY_LIST);
|
||||
inputs.add(input);
|
||||
configs.add(new MConfig(configName1, inputs));
|
||||
configs.add(new MConfig(configName1, inputs, Collections.EMPTY_LIST));
|
||||
|
||||
inputs = new LinkedList<MInput<?>>();
|
||||
input = new MStringInput(configName2 + ".I1", false, InputEditable.USER_ONLY, configName2 + ".I2", (short) 30);
|
||||
input = new MStringInput(configName2 + ".I1", false, InputEditable.USER_ONLY, configName2 + ".I2", (short) 30, Collections.EMPTY_LIST);
|
||||
inputs.add(input);
|
||||
input = new MMapInput(configName2 + ".I2", false, InputEditable.CONNECTOR_ONLY, configName2 + ".I5", StringUtils.EMPTY);
|
||||
input = new MMapInput(configName2 + ".I2", false, InputEditable.CONNECTOR_ONLY, configName2 + ".I5", StringUtils.EMPTY, Collections.EMPTY_LIST);
|
||||
inputs.add(input);
|
||||
input = new MIntegerInput(configName2 + ".I3", false, InputEditable.ANY, configName2 + ".I1");
|
||||
input = new MIntegerInput(configName2 + ".I3", false, InputEditable.ANY, configName2 + ".I1", Collections.EMPTY_LIST);
|
||||
inputs.add(input);
|
||||
input = new MBooleanInput(configName2 + ".I4", false, InputEditable.USER_ONLY, StringUtils.EMPTY);
|
||||
input = new MBooleanInput(configName2 + ".I4", false, InputEditable.USER_ONLY, StringUtils.EMPTY, Collections.EMPTY_LIST);
|
||||
inputs.add(input);
|
||||
input = new MEnumInput(configName2 + ".I5", false, InputEditable.ANY, configName2 + ".I4," + configName2 + ".I3", new String[] {"YES", "NO"});
|
||||
input = new MEnumInput(configName2 + ".I5", false, InputEditable.ANY, configName2 + ".I4," + configName2 + ".I3", new String[] {"YES", "NO"}, Collections.EMPTY_LIST);
|
||||
inputs.add(input);
|
||||
configs.add(new MConfig(configName2, inputs));
|
||||
configs.add(new MConfig(configName2, inputs, Collections.EMPTY_LIST));
|
||||
|
||||
return configs;
|
||||
}
|
||||
|
@ -17,6 +17,7 @@
|
||||
*/
|
||||
package org.apache.sqoop.integration.repository.mysql;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
@ -148,19 +149,19 @@ protected void fillSubmission(MSubmission submission) {
|
||||
}
|
||||
|
||||
protected MLinkConfig getLinkConfig() {
|
||||
return new MLinkConfig(getConfigs("l1", "l2"));
|
||||
return new MLinkConfig(getConfigs("l1", "l2"), Collections.EMPTY_LIST);
|
||||
}
|
||||
|
||||
protected MFromConfig getFromConfig() {
|
||||
return new MFromConfig(getConfigs("from1", "from2"));
|
||||
return new MFromConfig(getConfigs("from1", "from2"), Collections.EMPTY_LIST);
|
||||
}
|
||||
|
||||
protected MToConfig getToConfig() {
|
||||
return new MToConfig(getConfigs("to1", "to2"));
|
||||
return new MToConfig(getConfigs("to1", "to2"), Collections.EMPTY_LIST);
|
||||
}
|
||||
|
||||
protected MDriverConfig getDriverConfig() {
|
||||
return new MDriverConfig(getConfigs("d1", "d2"));
|
||||
return new MDriverConfig(getConfigs("d1", "d2"), Collections.EMPTY_LIST);
|
||||
}
|
||||
|
||||
protected List<MConfig> getConfigs(String configName1, String configName2) {
|
||||
@ -168,18 +169,18 @@ protected List<MConfig> getConfigs(String configName1, String configName2) {
|
||||
|
||||
List<MInput<?>> inputs = new LinkedList<MInput<?>>();
|
||||
MInput<?> input = new MStringInput("I1", false, InputEditable.ANY,
|
||||
StringUtils.EMPTY, (short) 30);
|
||||
StringUtils.EMPTY, (short) 30, Collections.EMPTY_LIST);
|
||||
inputs.add(input);
|
||||
input = new MMapInput("I2", false, InputEditable.ANY, "I1", StringUtils.EMPTY);
|
||||
input = new MMapInput("I2", false, InputEditable.ANY, "I1", StringUtils.EMPTY, Collections.EMPTY_LIST);
|
||||
inputs.add(input);
|
||||
configs.add(new MConfig(configName1, inputs));
|
||||
configs.add(new MConfig(configName1, inputs, Collections.EMPTY_LIST));
|
||||
|
||||
inputs = new LinkedList<MInput<?>>();
|
||||
input = new MStringInput("I3", false, InputEditable.ANY, "I4", (short) 30);
|
||||
input = new MStringInput("I3", false, InputEditable.ANY, "I4", (short) 30, Collections.EMPTY_LIST);
|
||||
inputs.add(input);
|
||||
input = new MMapInput("I4", false, InputEditable.ANY, "I3", StringUtils.EMPTY);
|
||||
input = new MMapInput("I4", false, InputEditable.ANY, "I3", StringUtils.EMPTY, Collections.EMPTY_LIST);
|
||||
inputs.add(input);
|
||||
configs.add(new MConfig(configName2, inputs));
|
||||
configs.add(new MConfig(configName2, inputs, Collections.EMPTY_LIST));
|
||||
|
||||
return configs;
|
||||
}
|
||||
|
@ -31,6 +31,7 @@
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
@ -130,37 +131,37 @@ protected void fillSubmission(MSubmission submission) {
|
||||
}
|
||||
|
||||
protected MLinkConfig getLinkConfig() {
|
||||
return new MLinkConfig(getConfigs("l1", "l2"));
|
||||
return new MLinkConfig(getConfigs("l1", "l2"), Collections.EMPTY_LIST);
|
||||
}
|
||||
|
||||
protected MFromConfig getFromConfig() {
|
||||
return new MFromConfig(getConfigs("from1", "from2"));
|
||||
return new MFromConfig(getConfigs("from1", "from2"), Collections.EMPTY_LIST);
|
||||
}
|
||||
|
||||
protected MToConfig getToConfig() {
|
||||
return new MToConfig(getConfigs("to1", "to2"));
|
||||
return new MToConfig(getConfigs("to1", "to2"), Collections.EMPTY_LIST);
|
||||
}
|
||||
|
||||
protected MDriverConfig getDriverConfig() {
|
||||
return new MDriverConfig(getConfigs("d1", "d2"));
|
||||
return new MDriverConfig(getConfigs("d1", "d2"), Collections.EMPTY_LIST);
|
||||
}
|
||||
|
||||
protected List<MConfig> getConfigs(String configName1, String configName2) {
|
||||
List<MConfig> configs = new LinkedList<MConfig>();
|
||||
|
||||
List<MInput<?>> inputs = new LinkedList<MInput<?>>();
|
||||
MInput<?> input = new MStringInput("I1", false, InputEditable.ANY, StringUtils.EMPTY, (short) 30);
|
||||
MInput<?> input = new MStringInput("I1", false, InputEditable.ANY, StringUtils.EMPTY, (short) 30, Collections.EMPTY_LIST);
|
||||
inputs.add(input);
|
||||
input = new MMapInput("I2", false, InputEditable.ANY, "I1", StringUtils.EMPTY);
|
||||
input = new MMapInput("I2", false, InputEditable.ANY, "I1", StringUtils.EMPTY, Collections.EMPTY_LIST);
|
||||
inputs.add(input);
|
||||
configs.add(new MConfig(configName1, inputs));
|
||||
configs.add(new MConfig(configName1, inputs, Collections.EMPTY_LIST));
|
||||
|
||||
inputs = new LinkedList<MInput<?>>();
|
||||
input = new MStringInput("I3", false, InputEditable.ANY, "I4", (short) 30);
|
||||
input = new MStringInput("I3", false, InputEditable.ANY, "I4", (short) 30, Collections.EMPTY_LIST);
|
||||
inputs.add(input);
|
||||
input = new MMapInput("I4", false, InputEditable.ANY, "I3", StringUtils.EMPTY);
|
||||
input = new MMapInput("I4", false, InputEditable.ANY, "I3", StringUtils.EMPTY, Collections.EMPTY_LIST);
|
||||
inputs.add(input);
|
||||
configs.add(new MConfig(configName2, inputs));
|
||||
configs.add(new MConfig(configName2, inputs, Collections.EMPTY_LIST));
|
||||
|
||||
return configs;
|
||||
}
|
||||
|
@ -42,6 +42,7 @@
|
||||
import org.joda.time.DateTime;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -59,7 +60,7 @@ public final class ConfigFiller {
|
||||
* Internal input that will be reused for loading names for link and
|
||||
* job objects.
|
||||
*/
|
||||
private static MStringInput nameInput = new MStringInput("object-name", false, InputEditable.ANY, StringUtils.EMPTY, (short)25);
|
||||
private static MStringInput nameInput = new MStringInput("object-name", false, InputEditable.ANY, StringUtils.EMPTY, (short)25, Collections.EMPTY_LIST);
|
||||
|
||||
/**
|
||||
* Fill job object based on CLI options.
|
||||
|
@ -59,6 +59,7 @@
|
||||
import org.apache.sqoop.model.MPersistableEntity;
|
||||
import org.apache.sqoop.model.MSubmission;
|
||||
import org.apache.sqoop.model.MToConfig;
|
||||
import org.apache.sqoop.model.MValidator;
|
||||
import org.apache.sqoop.repository.Repository;
|
||||
import org.apache.sqoop.repository.RepositoryManager;
|
||||
import org.apache.sqoop.tools.ConfiguredTool;
|
||||
@ -273,7 +274,8 @@ private long loadLink(MLink link) {
|
||||
ConnectorConfigurableUpgrader connectorConfigUpgrader = ConnectorManager.getInstance().getSqoopConnector(mConnector.getUniqueName()).getConfigurableUpgrader();
|
||||
|
||||
List<MConfig> connectorConfigs = mConnector.getLinkConfig().clone(false).getConfigs();
|
||||
MLinkConfig newLinkConfigs = new MLinkConfig(connectorConfigs);
|
||||
List<MValidator> connectorValidators = mConnector.getLinkConfig().getCloneOfValidators();
|
||||
MLinkConfig newLinkConfigs = new MLinkConfig(connectorConfigs, connectorValidators);
|
||||
|
||||
// upgrading the configs to make sure they match the current repository
|
||||
connectorConfigUpgrader.upgradeLinkConfig(link.getConnectorLinkConfig(), newLinkConfigs);
|
||||
|
Loading…
Reference in New Issue
Block a user