Search in sources :

Example 71 with StringLoadSaveValidator

use of org.pentaho.di.trans.steps.loadsave.validator.StringLoadSaveValidator in project pentaho-kettle by pentaho.

the class DatabaseJoinMetaTest method setUpLoadSave.

@Before
public void setUpLoadSave() throws Exception {
    KettleEnvironment.init();
    PluginRegistry.init(false);
    List<String> attributes = Arrays.asList("sql", "rowLimit", "outerJoin", "variableReplace", "databaseMeta", "parameterField", "parameterType");
    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("parameterField", new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 5));
    attrValidatorMap.put("parameterType", new PrimitiveIntArrayLoadSaveValidator(new NonZeroIntLoadSaveValidator(7), 5));
    attrValidatorMap.put("databaseMeta", new DatabaseMetaLoadSaveValidator());
    Map<String, FieldLoadSaveValidator<?>> typeValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    loadSaveTester = new LoadSaveTester(testMetaClass, attributes, new ArrayList<String>(), new ArrayList<String>(), getterMap, setterMap, attrValidatorMap, typeValidatorMap, this);
}
Also used : NonZeroIntLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.NonZeroIntLoadSaveValidator) HashMap(java.util.HashMap) LoadSaveTester(org.pentaho.di.trans.steps.loadsave.LoadSaveTester) FieldLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.FieldLoadSaveValidator) ArrayList(java.util.ArrayList) DatabaseMetaLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.DatabaseMetaLoadSaveValidator) PrimitiveIntArrayLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.PrimitiveIntArrayLoadSaveValidator) StringLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.StringLoadSaveValidator) Before(org.junit.Before)

Example 72 with StringLoadSaveValidator

use of org.pentaho.di.trans.steps.loadsave.validator.StringLoadSaveValidator in project pentaho-kettle by pentaho.

the class GPLoadMetaTest method testRoundTrip.

@Test
public void testRoundTrip() throws KettleException {
    List<String> attributes = Arrays.asList("localHosts", "localhostPort", "schemaName", "tableName", "errorTableName", "gploadPath", "controlFile", "dataFile", "logFile", "nullAs", "databaseMeta", "fieldTable", "fieldStream", "matchColumn", "updateColumn", "dateMask", "maxErrors", "loadMethod", "loadAction", "encoding", "eraseFiles", "encloseNumbers", "delimiter", "updateCondition");
    Map<String, String> getterMap = new HashMap<>();
    Map<String, String> setterMap = new HashMap<>();
    for (String attribute : attributes) {
        if (attribute.equals("eraseFiles")) {
            getterMap.put("eraseFiles", "isEraseFiles");
        } else {
            getterMap.put(attribute, "get" + attribute.substring(0, 1).toUpperCase() + attribute.substring(1));
        }
        if (attribute.equals("matchColumn")) {
            setterMap.put("matchColumn", "setMatchColumns");
        } else {
            setterMap.put(attribute, "set" + attribute.substring(0, 1).toUpperCase() + attribute.substring(1));
        }
    }
    Map<String, FieldLoadSaveValidator<?>> fieldLoadSaveValidatorAttributeMap = new HashMap<>();
    Map<String, FieldLoadSaveValidator<?>> fieldLoadSaveValidatorTypeMap = new HashMap<>();
    fieldLoadSaveValidatorAttributeMap.put("dateMask", new ArrayLoadSaveValidator<>(new DateMaskLoadSaveValidator(), 10));
    fieldLoadSaveValidatorTypeMap.put(DatabaseMeta.class.getCanonicalName(), new DatabaseMetaFieldLoadSaveValidator());
    fieldLoadSaveValidatorTypeMap.put(String[].class.getCanonicalName(), new ArrayLoadSaveValidator<>(new StringLoadSaveValidator(), 10));
    fieldLoadSaveValidatorTypeMap.put(boolean[].class.getCanonicalName(), new PrimitiveBooleanArrayLoadSaveValidator(new BooleanLoadSaveValidator(), 10));
    LoadSaveTester loadSaveTester = new LoadSaveTester(GPLoadMeta.class, attributes, getterMap, setterMap, fieldLoadSaveValidatorAttributeMap, fieldLoadSaveValidatorTypeMap);
    loadSaveTester.testRepoRoundTrip();
    loadSaveTester.testXmlRoundTrip();
}
Also used : HashMap(java.util.HashMap) LoadSaveTester(org.pentaho.di.trans.steps.loadsave.LoadSaveTester) FieldLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.FieldLoadSaveValidator) PrimitiveBooleanArrayLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.PrimitiveBooleanArrayLoadSaveValidator) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) BooleanLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.BooleanLoadSaveValidator) StringLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.StringLoadSaveValidator) Test(org.junit.Test)

Example 73 with StringLoadSaveValidator

use of org.pentaho.di.trans.steps.loadsave.validator.StringLoadSaveValidator in project pentaho-kettle by pentaho.

the class JobEntryMailLoadSaveTest method createAttributeValidatorsMap.

@Override
protected Map<String, FieldLoadSaveValidator<?>> createAttributeValidatorsMap() {
    Map<String, FieldLoadSaveValidator<?>> validators = new HashMap<String, FieldLoadSaveValidator<?>>();
    validators.put("fileType", new PrimitiveIntArrayLoadSaveValidator(new IntLoadSaveValidator(ResultFile.fileTypeCode.length)));
    int entries = new Random().nextInt(20) + 1;
    validators.put("embeddedimages", new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), entries));
    validators.put("contentids", new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), entries));
    return validators;
}
Also used : IntLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.IntLoadSaveValidator) Random(java.util.Random) HashMap(java.util.HashMap) FieldLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.FieldLoadSaveValidator) PrimitiveIntArrayLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.PrimitiveIntArrayLoadSaveValidator) StringLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.StringLoadSaveValidator)

Example 74 with StringLoadSaveValidator

use of org.pentaho.di.trans.steps.loadsave.validator.StringLoadSaveValidator in project pentaho-kettle by pentaho.

the class JobEntrySetVariablesLoadSaveTest method createAttributeValidatorsMap.

@Override
protected Map<String, FieldLoadSaveValidator<?>> createAttributeValidatorsMap() {
    Map<String, FieldLoadSaveValidator<?>> validators = new HashMap<String, FieldLoadSaveValidator<?>>();
    validators.put("fileVariableType", new IntLoadSaveValidator(JobEntrySetVariables.variableTypeCode.length));
    int count = new Random().nextInt(50) + 1;
    validators.put("variableName", new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), count));
    validators.put("variableValue", new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), count));
    validators.put("variableType", new PrimitiveIntArrayLoadSaveValidator(new IntLoadSaveValidator(JobEntryPGPEncryptFiles.actionTypeCodes.length), count));
    return validators;
}
Also used : IntLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.IntLoadSaveValidator) Random(java.util.Random) HashMap(java.util.HashMap) FieldLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.FieldLoadSaveValidator) PrimitiveIntArrayLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.PrimitiveIntArrayLoadSaveValidator) StringLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.StringLoadSaveValidator)

Example 75 with StringLoadSaveValidator

use of org.pentaho.di.trans.steps.loadsave.validator.StringLoadSaveValidator in project pentaho-kettle by pentaho.

the class ValueMapperMetaTest method setUpLoadSave.

@Before
public void setUpLoadSave() throws Exception {
    FieldLoadSaveValidator<String[]> stringArrayLoadSaveValidator = new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 7);
    init(stringArrayLoadSaveValidator, stringArrayLoadSaveValidator);
}
Also used : ArrayLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.ArrayLoadSaveValidator) StringLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.StringLoadSaveValidator) Before(org.junit.Before)

Aggregations

StringLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.StringLoadSaveValidator)91 HashMap (java.util.HashMap)89 FieldLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.FieldLoadSaveValidator)89 LoadSaveTester (org.pentaho.di.trans.steps.loadsave.LoadSaveTester)80 ArrayLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.ArrayLoadSaveValidator)68 Before (org.junit.Before)59 ArrayList (java.util.ArrayList)49 IntLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.IntLoadSaveValidator)31 PrimitiveIntArrayLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.PrimitiveIntArrayLoadSaveValidator)30 Test (org.junit.Test)26 BooleanLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.BooleanLoadSaveValidator)21 PrimitiveBooleanArrayLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.PrimitiveBooleanArrayLoadSaveValidator)15 DatabaseMetaLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.DatabaseMetaLoadSaveValidator)12 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)8 Random (java.util.Random)6 NonZeroIntLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.NonZeroIntLoadSaveValidator)4 SalesforceMetaTest (org.pentaho.di.trans.steps.salesforce.SalesforceMetaTest)4 YNLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.YNLoadSaveValidator)3 Matchers.anyString (org.mockito.Matchers.anyString)2 Mockito.anyString (org.mockito.Mockito.anyString)2