Search in sources :

Example 11 with PrimitiveIntArrayLoadSaveValidator

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

the class JobEntryPGPEncryptFilesLoadSaveTest method createAttributeValidatorsMap.

@Override
protected Map<String, FieldLoadSaveValidator<?>> createAttributeValidatorsMap() {
    Map<String, FieldLoadSaveValidator<?>> validators = new HashMap<String, FieldLoadSaveValidator<?>>();
    int count = new Random().nextInt(50) + 1;
    validators.put("action_type", new PrimitiveIntArrayLoadSaveValidator(new IntLoadSaveValidator(JobEntryPGPEncryptFiles.actionTypeCodes.length), count));
    validators.put("source_filefolder", new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), count));
    validators.put("userid", new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), count));
    validators.put("destination_filefolder", new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), count));
    validators.put("wildcard", new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), count));
    return validators;
}
Also used : Random(java.util.Random) IntLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.IntLoadSaveValidator) 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 12 with PrimitiveIntArrayLoadSaveValidator

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

the class DatabaseLookupMetaTest method setUpLoadSave.

@Before
public void setUpLoadSave() throws Exception {
    KettleEnvironment.init();
    PluginRegistry.init(false);
    List<String> attributes = Arrays.asList("schemaName", "tablename", "databaseMeta", "orderByClause", "cached", "cacheSize", "loadingAllDataInCache", "failingOnMultipleResults", "eatingRowOnLookupFailure", "streamKeyField1", "streamKeyField2", "keyCondition", "tableKeyField", "returnValueField", "returnValueNewName", "returnValueDefault", "returnValueDefaultType");
    Map<String, String> getterMap = new HashMap<String, String>();
    Map<String, String> setterMap = new HashMap<String, String>();
    FieldLoadSaveValidator<String[]> stringArrayLoadSaveValidator = new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 5);
    Map<String, FieldLoadSaveValidator<?>> attrValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    attrValidatorMap.put("streamKeyField1", stringArrayLoadSaveValidator);
    attrValidatorMap.put("streamKeyField2", stringArrayLoadSaveValidator);
    attrValidatorMap.put("keyCondition", stringArrayLoadSaveValidator);
    attrValidatorMap.put("tableKeyField", stringArrayLoadSaveValidator);
    attrValidatorMap.put("returnValueField", stringArrayLoadSaveValidator);
    attrValidatorMap.put("returnValueNewName", stringArrayLoadSaveValidator);
    attrValidatorMap.put("returnValueDefault", stringArrayLoadSaveValidator);
    attrValidatorMap.put("returnValueDefaultType", 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 : ArrayLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.ArrayLoadSaveValidator) PrimitiveIntArrayLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.PrimitiveIntArrayLoadSaveValidator) 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) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) 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 13 with PrimitiveIntArrayLoadSaveValidator

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

the class GaInputStepMetaTest method testSerialization.

@Test
public void testSerialization() throws KettleException {
    List<String> attributes = Arrays.asList("OAuthServiceAccount", "GaAppName", "OAuthKeyFile", "GaProfileName", "GaProfileTableId", "GaCustomTableId", "UseCustomTableId", "StartDate", "EndDate", "Dimensions", "Metrics", "Filters", "Sort", "UseSegment", "UseCustomSegment", "CustomSegment", "SegmentId", "SegmentName", "SamplingLevel", "RowLimit", "FeedFieldType", "FeedField", "OutputField", "OutputType", "ConversionMask");
    Map<String, FieldLoadSaveValidator<?>> attributeMap = new HashMap<>();
    Map<String, FieldLoadSaveValidator<?>> typeMap = new HashMap<>();
    int maxValueCount = ValueMetaFactory.getAllValueMetaNames().length;
    attributeMap.put("FeedField", new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 25));
    attributeMap.put("FeedFieldType", new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 25));
    attributeMap.put("OutputField", new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 25));
    attributeMap.put("OutputType", new PrimitiveIntArrayLoadSaveValidator(new IntLoadSaveValidator(maxValueCount), 25));
    attributeMap.put("ConversionMask", new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 25));
    LoadSaveTester<GaInputStepMeta> tester = new LoadSaveTester<>(GaInputStepMeta.class, attributes, new HashMap<String, String>(), new HashMap<String, String>(), attributeMap, typeMap);
    tester.testSerialization();
}
Also used : IntLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.IntLoadSaveValidator) HashMap(java.util.HashMap) LoadSaveTester(org.pentaho.di.trans.steps.loadsave.LoadSaveTester) 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) Test(org.junit.Test)

Example 14 with PrimitiveIntArrayLoadSaveValidator

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

the class AnalyticQueryMetaTest method testRoundTrip.

@Test
public void testRoundTrip() throws KettleException {
    List<String> attributes = Arrays.asList("groupField", "aggregateField", "subjectField", "aggregateType", "valueField");
    Map<String, String> getterMap = new HashMap<String, String>();
    Map<String, String> setterMap = new HashMap<String, String>();
    Map<String, FieldLoadSaveValidator<?>> typeValidators = new HashMap<String, FieldLoadSaveValidator<?>>();
    Map<String, FieldLoadSaveValidator<?>> fieldValidators = new HashMap<String, FieldLoadSaveValidator<?>>();
    fieldValidators.put("aggregateField", new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 50));
    fieldValidators.put("subjectField", new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 50));
    fieldValidators.put("aggregateType", new PrimitiveIntArrayLoadSaveValidator(new IntLoadSaveValidator(AnalyticQueryMeta.typeGroupCode.length), 50));
    fieldValidators.put("valueField", new PrimitiveIntArrayLoadSaveValidator(new IntLoadSaveValidator(), 50));
    LoadSaveTester loadSaveTester = new LoadSaveTester(AnalyticQueryMeta.class, attributes, getterMap, setterMap, fieldValidators, typeValidators);
    loadSaveTester.testSerialization();
}
Also used : IntLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.IntLoadSaveValidator) HashMap(java.util.HashMap) LoadSaveTester(org.pentaho.di.trans.steps.loadsave.LoadSaveTester) 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) Test(org.junit.Test)

Example 15 with PrimitiveIntArrayLoadSaveValidator

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

the class MappingInputMetaCloningTest method setUp.

@Before
public void setUp() throws Exception {
    KettleEnvironment.init();
    PluginRegistry.init(false);
    List<String> attributes = Arrays.asList("selectingAndSortingUnspecifiedFields", "fieldName", "fieldType", "fieldLength", "fieldPrecision");
    Map<String, String> getterMap = new HashMap<String, String>() {

        {
            put("selectingAndSortingUnspecifiedFields", "isSelectingAndSortingUnspecifiedFields");
            put("fieldName", "getFieldName");
            put("fieldType", "getFieldType");
            put("fieldLength", "getFieldLength");
            put("fieldPrecision", "getFieldPrecision");
        }
    };
    Map<String, String> setterMap = new HashMap<String, String>() {

        {
            put("selectingAndSortingUnspecifiedFields", "setSelectingAndSortingUnspecifiedFields");
            put("fieldName", "setFieldName");
            put("fieldType", "setFieldType");
            put("fieldLength", "setFieldLength");
            put("fieldPrecision", "setFieldPrecision");
        }
    };
    FieldLoadSaveValidator<String[]> stringArrayLoadSaveValidator = new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 5);
    Map<String, FieldLoadSaveValidator<?>> attrValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    attrValidatorMap.put("fieldName", stringArrayLoadSaveValidator);
    Map<String, FieldLoadSaveValidator<?>> typeValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    typeValidatorMap.put(int[].class.getCanonicalName(), new PrimitiveIntArrayLoadSaveValidator(new NonZeroIntLoadSaveValidator(6), 5));
    loadSaveTester = new LoadSaveTester<MappingInputMeta>(MappingInputMeta.class, attributes, getterMap, setterMap, attrValidatorMap, typeValidatorMap);
}
Also used : PrimitiveIntArrayLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.PrimitiveIntArrayLoadSaveValidator) ArrayLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.ArrayLoadSaveValidator) NonZeroIntLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.NonZeroIntLoadSaveValidator) 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) Before(org.junit.Before)

Aggregations

HashMap (java.util.HashMap)30 FieldLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.FieldLoadSaveValidator)30 PrimitiveIntArrayLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.PrimitiveIntArrayLoadSaveValidator)30 StringLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.StringLoadSaveValidator)30 IntLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.IntLoadSaveValidator)27 LoadSaveTester (org.pentaho.di.trans.steps.loadsave.LoadSaveTester)23 ArrayLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.ArrayLoadSaveValidator)20 Before (org.junit.Before)18 ArrayList (java.util.ArrayList)16 Test (org.junit.Test)8 BooleanLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.BooleanLoadSaveValidator)6 PrimitiveBooleanArrayLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.PrimitiveBooleanArrayLoadSaveValidator)6 Random (java.util.Random)4 DatabaseMetaLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.DatabaseMetaLoadSaveValidator)4 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)3 NonZeroIntLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.NonZeroIntLoadSaveValidator)3 Mockito.anyString (org.mockito.Mockito.anyString)1 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)1