use of org.pentaho.di.trans.steps.loadsave.validator.FieldLoadSaveValidator in project pentaho-kettle by pentaho.
the class JavaFilterMetaTest method setUpLoadSave.
@Before
public void setUpLoadSave() throws Exception {
KettleEnvironment.init();
PluginRegistry.init(false);
List<String> attributes = Arrays.asList("condition");
Map<String, String> getterMap = new HashMap<String, String>();
Map<String, String> setterMap = new HashMap<String, String>();
Map<String, FieldLoadSaveValidator<?>> attrValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
Map<String, FieldLoadSaveValidator<?>> typeValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
loadSaveTester = new LoadSaveTester(testMetaClass, attributes, getterMap, setterMap, attrValidatorMap, typeValidatorMap);
}
use of org.pentaho.di.trans.steps.loadsave.validator.FieldLoadSaveValidator in project pentaho-kettle by pentaho.
the class JobExecutorMetaTest method setUp.
/**
* Check all simple string fields.
*
* @throws Exception
*/
@Before
public void setUp() throws Exception {
List<String> attributes = Arrays.asList("fileName", "jobName", "directoryPath", "groupSize", "groupField", "groupTime", "executionTimeField", "executionFilesRetrievedField", "executionLogTextField", "executionLogChannelIdField", "executionResultField", "executionNrErrorsField", "executionLinesReadField", "executionLinesWrittenField", "executionLinesInputField", "executionLinesOutputField", "executionLinesRejectedField", "executionLinesUpdatedField", "executionLinesDeletedField", "executionExitStatusField");
// executionResultTargetStepMeta -? (see for switch case meta)
Map<String, String> getterMap = new HashMap<String, String>();
Map<String, String> setterMap = new HashMap<String, String>();
Map<String, FieldLoadSaveValidator<?>> attrValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
Map<String, FieldLoadSaveValidator<?>> typeValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
loadSaveTester = new LoadSaveTester(JobExecutorMeta.class, attributes, getterMap, setterMap, attrValidatorMap, typeValidatorMap);
}
use of org.pentaho.di.trans.steps.loadsave.validator.FieldLoadSaveValidator in project pentaho-kettle by pentaho.
the class LoadSaveTester method createValidatorMapAndInvokeSetters.
@Override
@SuppressWarnings("unchecked")
protected Map<String, FieldLoadSaveValidator<?>> createValidatorMapAndInvokeSetters(List<String> attributes, T metaToSave) {
Map<String, FieldLoadSaveValidator<?>> validatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
for (String attribute : attributes) {
Getter<?> getter = manipulator.getGetter(attribute);
@SuppressWarnings("rawtypes") Setter setter = manipulator.getSetter(attribute);
FieldLoadSaveValidator<?> validator = fieldLoadSaveValidatorFactory.createValidator(getter);
try {
Object testValue = validator.getTestObject();
setter.set(metaToSave, testValue);
if (validator instanceof DatabaseMetaLoadSaveValidator) {
addDatabase((DatabaseMeta) testValue);
validateStepUsesDatabaseMeta(metaToSave, (DatabaseMeta) testValue);
}
} catch (Exception e) {
throw new RuntimeException("Unable to invoke setter for " + attribute, e);
}
validatorMap.put(attribute, validator);
}
return validatorMap;
}
use of org.pentaho.di.trans.steps.loadsave.validator.FieldLoadSaveValidator in project pentaho-kettle by pentaho.
the class LoadSaveTester method testXmlRoundTrip.
/**
* @deprecated the {@link #testSerialization()} method should be used instead,
* as additional tests may be added in the future to cover other
* topics related to step serialization
* @throws KettleException
*/
@Deprecated
public // TODO Change method visibility to protected
void testXmlRoundTrip() throws KettleException {
T metaToSave = createMeta();
if (initializer != null) {
initializer.modify(metaToSave);
}
Map<String, FieldLoadSaveValidator<?>> validatorMap = createValidatorMapAndInvokeSetters(xmlAttributes, metaToSave);
T metaLoaded = createMeta();
String xml = "<step>" + metaToSave.getXML() + "</step>";
InputStream is = new ByteArrayInputStream(xml.getBytes());
metaLoaded.loadXML(XMLHandler.getSubNode(XMLHandler.loadXMLFile(is, null, false, false), "step"), databases, (IMetaStore) null);
validateLoadedMeta(xmlAttributes, validatorMap, metaToSave, metaLoaded);
// TODO Remove after method visibility changed, it should be called in testSerialization
testClone();
}
use of org.pentaho.di.trans.steps.loadsave.validator.FieldLoadSaveValidator in project pentaho-kettle by pentaho.
the class MailInputMetaTest method setUpLoadSave.
@Before
public void setUpLoadSave() throws Exception {
KettleEnvironment.init();
PluginRegistry.init(false);
List<String> attributes = Arrays.asList("conditionReceivedDate", "valueimaplist", "serverName", "userName", "password", "useSSL", "port", "firstMails", "retrievemails", "delete", "protocol", "firstIMAPMails", "IMAPFolder", "senderSearchTerm", "notTermSenderSearch", "recipientSearch", "subjectSearch", "receivedDate1", "receivedDate2", "notTermSubjectSearch", "notTermRecipientSearch", "notTermReceivedDateSearch", "includeSubFolders", "useProxy", "proxyUsername", "folderField", "dynamicFolder", "rowLimit", "useBatch", "start", "end", "batchSize", "stopOnError", "inputFields");
Map<String, String> getterMap = new HashMap<String, String>();
Map<String, String> setterMap = new HashMap<String, String>();
Map<String, FieldLoadSaveValidator<?>> attrValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
attrValidatorMap.put("inputFields", new ArrayLoadSaveValidator<MailInputField>(new MailInputFieldLoadSaveValidator(), 5));
attrValidatorMap.put("batchSize", new IntLoadSaveValidator(1000));
attrValidatorMap.put("conditionReceivedDate", new IntLoadSaveValidator(MailConnectionMeta.conditionDateCode.length));
attrValidatorMap.put("valueimaplist", new IntLoadSaveValidator(MailConnectionMeta.valueIMAPListCode.length));
attrValidatorMap.put("port", new StringIntLoadSaveValidator(65534));
Map<String, FieldLoadSaveValidator<?>> typeValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
loadSaveTester = new LoadSaveTester(testMetaClass, attributes, new ArrayList<String>(), new ArrayList<String>(), getterMap, setterMap, attrValidatorMap, typeValidatorMap, this);
}
Aggregations