Search in sources :

Example 21 with IntLoadSaveValidator

use of org.pentaho.di.trans.steps.loadsave.validator.IntLoadSaveValidator 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 22 with IntLoadSaveValidator

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

the class MySQLBulkLoaderMetaTest method testRoundTrip.

@Test
public void testRoundTrip() throws KettleException {
    List<String> attributes = Arrays.asList(/*"connection",*/
    "schema", "table", "encoding", "delimiter", "enclosure", "escape_char", "replace", "ignore", "local", "fifo_file_name", "bulk_size", "stream_name", "field_name", "field_format_ok");
    Map<String, String> getterMap = new HashMap<String, String>();
    // getterMap.put( "connection", "" );
    getterMap.put("schema", "getSchemaName");
    getterMap.put("table", "getTableName");
    getterMap.put("encoding", "getEncoding");
    getterMap.put("delimiter", "getDelimiter");
    getterMap.put("enclosure", "getEnclosure");
    getterMap.put("escape_char", "getEscapeChar");
    getterMap.put("replace", "isReplacingData");
    getterMap.put("ignore", "isIgnoringErrors");
    getterMap.put("local", "isLocalFile");
    getterMap.put("fifo_file_name", "getFifoFileName");
    getterMap.put("bulk_size", "getBulkSize");
    getterMap.put("stream_name", "getFieldTable");
    getterMap.put("field_name", "getFieldStream");
    getterMap.put("field_format_ok", "getFieldFormatType");
    Map<String, String> setterMap = new HashMap<String, String>();
    // setterMap.put( "connection", "" );
    setterMap.put("schema", "setSchemaName");
    setterMap.put("table", "setTableName");
    setterMap.put("encoding", "setEncoding");
    setterMap.put("delimiter", "setDelimiter");
    setterMap.put("enclosure", "setEnclosure");
    setterMap.put("escape_char", "setEscapeChar");
    setterMap.put("replace", "setReplacingData");
    setterMap.put("ignore", "setIgnoringErrors");
    setterMap.put("local", "setLocalFile");
    setterMap.put("fifo_file_name", "setFifoFileName");
    setterMap.put("bulk_size", "setBulkSize");
    setterMap.put("stream_name", "setFieldTable");
    setterMap.put("field_name", "setFieldStream");
    setterMap.put("field_format_ok", "setFieldFormatType");
    Map<String, FieldLoadSaveValidator<?>> fieldLoadSaveValidatorAttributeMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    FieldLoadSaveValidator<String[]> stringArrayLoadSaveValidator = new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 25);
    FieldLoadSaveValidator<int[]> fieldFormatTypeArrayLoadSaveValidator = new PrimitiveIntArrayLoadSaveValidator(new IntLoadSaveValidator(MySQLBulkLoaderMeta.getFieldFormatTypeCodes().length), 25);
    fieldLoadSaveValidatorAttributeMap.put("stream_name", stringArrayLoadSaveValidator);
    fieldLoadSaveValidatorAttributeMap.put("field_name", stringArrayLoadSaveValidator);
    fieldLoadSaveValidatorAttributeMap.put("field_format_ok", fieldFormatTypeArrayLoadSaveValidator);
    LoadSaveTester loadSaveTester = new LoadSaveTester(MySQLBulkLoaderMeta.class, attributes, getterMap, setterMap, fieldLoadSaveValidatorAttributeMap, new HashMap<String, FieldLoadSaveValidator<?>>());
    loadSaveTester.testSerialization();
}
Also used : PrimitiveIntArrayLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.PrimitiveIntArrayLoadSaveValidator) ArrayLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.ArrayLoadSaveValidator) 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 23 with IntLoadSaveValidator

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

the class MemoryGroupByMetaTest method setUpLoadSave.

@Before
public void setUpLoadSave() throws Exception {
    KettleEnvironment.init();
    PluginRegistry.init(false);
    List<String> attributes = Arrays.asList("alwaysGivingBackOneRow", "groupField", "aggregateField", "subjectField", "aggregateType", "valueField");
    FieldLoadSaveValidator<String[]> stringArrayLoadSaveValidator = new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 5);
    Map<String, FieldLoadSaveValidator<?>> attrValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    attrValidatorMap.put("groupField", stringArrayLoadSaveValidator);
    attrValidatorMap.put("aggregateField", stringArrayLoadSaveValidator);
    attrValidatorMap.put("subjectField", stringArrayLoadSaveValidator);
    attrValidatorMap.put("valueField", stringArrayLoadSaveValidator);
    attrValidatorMap.put("aggregateType", new PrimitiveIntArrayLoadSaveValidator(new IntLoadSaveValidator(MemoryGroupByMeta.typeGroupCode.length), 5));
    Map<String, FieldLoadSaveValidator<?>> typeValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    loadSaveTester = new LoadSaveTester<MemoryGroupByMeta>(testMetaClass, attributes, new ArrayList<String>(), new ArrayList<String>(), new HashMap<String, String>(), new HashMap<String, String>(), attrValidatorMap, typeValidatorMap, this);
}
Also used : ArrayLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.ArrayLoadSaveValidator) PrimitiveIntArrayLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.PrimitiveIntArrayLoadSaveValidator) IntLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.IntLoadSaveValidator) HashMap(java.util.HashMap) FieldLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.FieldLoadSaveValidator) ArrayList(java.util.ArrayList) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) PrimitiveIntArrayLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.PrimitiveIntArrayLoadSaveValidator) StringLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.StringLoadSaveValidator) Before(org.junit.Before)

Example 24 with IntLoadSaveValidator

use of org.pentaho.di.trans.steps.loadsave.validator.IntLoadSaveValidator 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);
}
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) ArrayList(java.util.ArrayList) Before(org.junit.Before)

Example 25 with IntLoadSaveValidator

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

the class ExcelInputMetaTest method testRepoRoundTripWithNullAttr.

@Test
public void testRepoRoundTripWithNullAttr() throws KettleException {
    List<String> attributes = Arrays.asList("fileName", "fileMask", "excludeFileMask", "fileRequired", "includeSubFolders", "field", "sheetName", "startRow", "startColumn", "spreadSheetType", "fileField", "sheetField", "sheetRowNumberField", "rowNumberField", "shortFileFieldName", "extensionFieldName", "pathFieldName", "sizeFieldName", "hiddenFieldName", "lastModificationTimeFieldName", "uriNameFieldName", "rootUriNameFieldName");
    Map<String, String> getterMap = new HashMap<String, String>() {

        {
            put("excludeFileMask", "getExludeFileMask");
            put("shortFileFieldName", "getShortFileNameField");
            put("extensionFieldName", "getExtensionField");
            put("pathFieldName", "getPathField");
            put("sizeFieldName", "getSizeField");
            put("hiddenFieldName", "isHiddenField");
            put("lastModificationTimeFieldName", "getLastModificationDateField");
            put("uriNameFieldName", "getUriField");
            put("rootUriNameFieldName", "getRootUriField");
        }
    };
    Map<String, String> setterMap = new HashMap<String, String>() {

        {
            put("shortFileFieldName", "setShortFileNameField");
            put("extensionFieldName", "setExtensionField");
            put("pathFieldName", "setPathField");
            put("sizeFieldName", "setSizeField");
            put("hiddenFieldName", "setIsHiddenField");
            put("lastModificationTimeFieldName", "setLastModificationDateField");
            put("uriNameFieldName", "setUriField");
            put("rootUriNameFieldName", "setRootUriField");
        }
    };
    FieldLoadSaveValidator<String[]> nullStringArrayLoadSaveValidator = new NullStringArrayLoadSaveValidator();
    FieldLoadSaveValidator<String[]> stringArrayLoadSaveValidator = new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 1);
    NullNameExcelInputArrayFieldLoadSaveValidator nullNameExcelInputArrayFieldLoadSaveValidator = new NullNameExcelInputArrayFieldLoadSaveValidator();
    Map<String, FieldLoadSaveValidator<?>> attrValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    attrValidatorMap.put("fileName", nullStringArrayLoadSaveValidator);
    attrValidatorMap.put("fileMask", stringArrayLoadSaveValidator);
    attrValidatorMap.put("excludeFileMask", stringArrayLoadSaveValidator);
    attrValidatorMap.put("fileRequired", stringArrayLoadSaveValidator);
    attrValidatorMap.put("includeSubFolders", stringArrayLoadSaveValidator);
    attrValidatorMap.put("sheetName", nullStringArrayLoadSaveValidator);
    attrValidatorMap.put("field", nullNameExcelInputArrayFieldLoadSaveValidator);
    attrValidatorMap.put("spreadSheetType", new SpreadSheetTypeFieldLoadSaveValidator());
    Map<String, FieldLoadSaveValidator<?>> typeValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
    typeValidatorMap.put(int[].class.getCanonicalName(), new PrimitiveIntArrayLoadSaveValidator(new IntLoadSaveValidator(), 1));
    loadSaveTester = new LoadSaveTester(ExcelInputMeta.class, attributes, getterMap, setterMap, attrValidatorMap, typeValidatorMap);
    loadSaveTester.testRepoRoundTrip();
}
Also used : PrimitiveIntArrayLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.PrimitiveIntArrayLoadSaveValidator) ArrayLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.ArrayLoadSaveValidator) 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)

Aggregations

IntLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.IntLoadSaveValidator)46 HashMap (java.util.HashMap)45 FieldLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.FieldLoadSaveValidator)45 LoadSaveTester (org.pentaho.di.trans.steps.loadsave.LoadSaveTester)32 StringLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.StringLoadSaveValidator)31 PrimitiveIntArrayLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.PrimitiveIntArrayLoadSaveValidator)27 Before (org.junit.Before)22 ArrayLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.ArrayLoadSaveValidator)20 ArrayList (java.util.ArrayList)18 Test (org.junit.Test)12 BooleanLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.BooleanLoadSaveValidator)7 PrimitiveBooleanArrayLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.PrimitiveBooleanArrayLoadSaveValidator)6 Random (java.util.Random)5 DatabaseMetaLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.DatabaseMetaLoadSaveValidator)3 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)2 EnumMap (java.util.EnumMap)1 Matchers.anyString (org.mockito.Matchers.anyString)1 Mockito.anyString (org.mockito.Mockito.anyString)1 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)1 StepInjectionMetaEntry (org.pentaho.di.trans.step.StepInjectionMetaEntry)1