Search in sources :

Example 86 with ValueMetaString

use of org.pentaho.di.core.row.value.ValueMetaString in project pentaho-kettle by pentaho.

the class JsonInputTest method testChildBracketsNDots.

@Test
public void testChildBracketsNDots() throws Exception {
    final String jsonInputField = getBasicTestJson();
    testSimpleJsonPath("$.['store'].['bicycle'].['color']", new ValueMetaString("bcol"), new Object[][] { new Object[] { jsonInputField } }, new Object[][] { new Object[] { jsonInputField, "red" } });
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) Test(org.junit.Test)

Example 87 with ValueMetaString

use of org.pentaho.di.core.row.value.ValueMetaString in project pentaho-kettle by pentaho.

the class JsonInputTest method testJgdArray.

@Test
public void testJgdArray() throws Exception {
    final String input = " { \"arr\": [ [ { \"a\": 1, \"b\": 1}, { \"a\": 1, \"b\": 2} ], [ {\"a\": 3, \"b\": 4 } ] ] }";
    JsonInput jsonInput = createBasicTestJsonInput("$.arr", new ValueMetaString("array"), "json", new Object[] { input });
    RowComparatorListener rowComparator = new RowComparatorListener(new Object[] { input, "[[{\"a\":1,\"b\":1},{\"a\":1,\"b\":2}],[{\"a\":3,\"b\":4}]]" });
    rowComparator.setComparator(1, new JsonComparison());
    jsonInput.addRowListener(rowComparator);
    processRows(jsonInput, 2);
    Assert.assertEquals(1, jsonInput.getLinesWritten());
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) Test(org.junit.Test)

Example 88 with ValueMetaString

use of org.pentaho.di.core.row.value.ValueMetaString in project pentaho-kettle by pentaho.

the class JsonInputTest method testNullProp.

@Test
public void testNullProp() throws Exception {
    final String input = "{ \"obj\": [ { \"nval\": null, \"val\": 2 }, { \"val\": 1 } ] }";
    JsonInput jsonInput = createBasicTestJsonInput("$.obj[?(@.nval)].val", new ValueMetaString("obj"), "json", new Object[] { input });
    RowComparatorListener rowComparator = new RowComparatorListener(new Object[] { input, "2" });
    rowComparator.setComparator(1, new JsonComparison());
    jsonInput.addRowListener(rowComparator);
    processRows(jsonInput, 2);
    // in jsonpath 2.0->2.1, null value properties started being counted as existing
    Assert.assertEquals(1, jsonInput.getLinesWritten());
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) Test(org.junit.Test)

Example 89 with ValueMetaString

use of org.pentaho.di.core.row.value.ValueMetaString in project pentaho-kettle by pentaho.

the class JsonInputTest method testChildBrackets.

@Test
public void testChildBrackets() throws Exception {
    final String jsonInputField = getBasicTestJson();
    testSimpleJsonPath("$.['store']['bicycle']['color']", new ValueMetaString("bcol"), new Object[][] { new Object[] { jsonInputField } }, new Object[][] { new Object[] { jsonInputField, "red" } });
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) Test(org.junit.Test)

Example 90 with ValueMetaString

use of org.pentaho.di.core.row.value.ValueMetaString in project pentaho-kettle by pentaho.

the class JsonOutputTest method createResultRowMetaInterface.

/**
 * Creates a row meta interface for the fields that are defined by performing a getFields and by checking "Result
 * filenames - Add filenames to result from "Text File Input" dialog.
 *
 * @return
 */
public RowMetaInterface createResultRowMetaInterface() {
    RowMetaInterface rowMetaInterface = new RowMeta();
    ValueMetaInterface[] valuesMeta = { new ValueMetaInteger("Id"), new ValueMetaString("State"), new ValueMetaString("City") };
    for (int i = 0; i < valuesMeta.length; i++) {
        rowMetaInterface.addValueMeta(valuesMeta[i]);
    }
    return rowMetaInterface;
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) RowMeta(org.pentaho.di.core.row.RowMeta) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) ValueMetaInteger(org.pentaho.di.core.row.value.ValueMetaInteger) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface)

Aggregations

ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)447 RowMeta (org.pentaho.di.core.row.RowMeta)219 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)181 Test (org.junit.Test)179 ValueMetaInteger (org.pentaho.di.core.row.value.ValueMetaInteger)176 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)141 RowMetaAndData (org.pentaho.di.core.RowMetaAndData)86 ValueMetaBoolean (org.pentaho.di.core.row.value.ValueMetaBoolean)67 ValueMetaNumber (org.pentaho.di.core.row.value.ValueMetaNumber)66 ValueMetaDate (org.pentaho.di.core.row.value.ValueMetaDate)57 KettleException (org.pentaho.di.core.exception.KettleException)40 ArrayList (java.util.ArrayList)33 LongObjectId (org.pentaho.di.repository.LongObjectId)29 ValueMetaBigNumber (org.pentaho.di.core.row.value.ValueMetaBigNumber)27 ValueMetaBinary (org.pentaho.di.core.row.value.ValueMetaBinary)26 ObjectId (org.pentaho.di.repository.ObjectId)26 ValueMetaTimestamp (org.pentaho.di.core.row.value.ValueMetaTimestamp)21 RowSet (org.pentaho.di.core.RowSet)18 Date (java.util.Date)17 ValueMetaBase (org.pentaho.di.core.row.value.ValueMetaBase)16