Search in sources :

Example 86 with ValueMetaDate

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

the class MemoryGroupByMetaGetFieldsTest method setup.

@Before
public void setup() throws KettlePluginException {
    mockSpace = mock(VariableSpace.class);
    doReturn("N").when(mockSpace).getVariable(any(), anyString());
    rowMeta = spy(new RowMeta());
    memoryGroupByMeta = spy(new MemoryGroupByMeta());
    mockStatic(ValueMetaFactory.class);
    when(ValueMetaFactory.createValueMeta(anyInt())).thenCallRealMethod();
    when(ValueMetaFactory.createValueMeta(anyString(), anyInt())).thenCallRealMethod();
    when(ValueMetaFactory.createValueMeta("maxDate", 3, -1, -1)).thenReturn(new ValueMetaDate("maxDate"));
    when(ValueMetaFactory.createValueMeta("minDate", 3, -1, -1)).thenReturn(new ValueMetaDate("minDate"));
    when(ValueMetaFactory.createValueMeta("countDate", 5, -1, -1)).thenReturn(new ValueMetaInteger("countDate"));
    when(ValueMetaFactory.getValueMetaName(3)).thenReturn("Date");
    when(ValueMetaFactory.getValueMetaName(5)).thenReturn("Integer");
}
Also used : RowMeta(org.pentaho.di.core.row.RowMeta) VariableSpace(org.pentaho.di.core.variables.VariableSpace) ValueMetaInteger(org.pentaho.di.core.row.value.ValueMetaInteger) ValueMetaDate(org.pentaho.di.core.row.value.ValueMetaDate) Before(org.junit.Before)

Example 87 with ValueMetaDate

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

the class MemoryGroupByMetaGetFieldsTest method getFieldsWithSubject_WithFormat.

@Test
public void getFieldsWithSubject_WithFormat() {
    ValueMetaDate valueMeta = new ValueMetaDate();
    valueMeta.setConversionMask("yyyy-MM-dd");
    valueMeta.setName("date");
    doReturn(valueMeta).when(rowMeta).searchValueMeta("date");
    memoryGroupByMeta.setSubjectField(new String[] { "date" });
    memoryGroupByMeta.setGroupField(new String[] {});
    memoryGroupByMeta.setAggregateField(new String[] { "maxDate" });
    memoryGroupByMeta.setAggregateType(new int[] { TYPE_GROUP_MAX });
    memoryGroupByMeta.getFields(rowMeta, "Memory Group by", mockInfo, mockNextStep, mockSpace, null, mockIMetaStore);
    verify(rowMeta, times(1)).clear();
    verify(rowMeta, times(1)).addRowMeta(any());
    assertEquals("yyyy-MM-dd", rowMeta.searchValueMeta("maxDate").getConversionMask());
}
Also used : ValueMetaDate(org.pentaho.di.core.row.value.ValueMetaDate) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 88 with ValueMetaDate

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

the class MemoryGroupByMetaGetFieldsTest method getFieldsWithoutSubject.

@Test
public void getFieldsWithoutSubject() {
    ValueMetaDate valueMeta = new ValueMetaDate();
    valueMeta.setName("date");
    doReturn(valueMeta).when(rowMeta).searchValueMeta("date");
    memoryGroupByMeta.setSubjectField(new String[] { null });
    memoryGroupByMeta.setGroupField(new String[] { "date" });
    memoryGroupByMeta.setAggregateField(new String[] { "countDate" });
    memoryGroupByMeta.setAggregateType(new int[] { TYPE_GROUP_COUNT_ANY });
    memoryGroupByMeta.getFields(rowMeta, "Group by", mockInfo, mockNextStep, mockSpace, null, mockIMetaStore);
    verify(rowMeta, times(1)).clear();
    verify(rowMeta, times(1)).addRowMeta(any());
    assertNotNull(rowMeta.searchValueMeta("countDate"));
}
Also used : ValueMetaDate(org.pentaho.di.core.row.value.ValueMetaDate) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 89 with ValueMetaDate

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

the class NormaliserTest method getWikiInputRowMetaAndData.

private List<RowMetaAndData> getWikiInputRowMetaAndData() {
    List<RowMetaAndData> list = new ArrayList<>();
    Object[] row = new Object[7];
    RowMetaInterface rm = new RowMeta();
    rm.addValueMeta(new ValueMetaDate("DATE"));
    row[0] = new Date(103, 01, 01);
    rm.addValueMeta(new ValueMetaInteger("PR1_NR"));
    row[1] = 5;
    rm.addValueMeta(new ValueMetaInteger("PR_SL"));
    row[2] = 100;
    rm.addValueMeta(new ValueMetaInteger("PR2_NR"));
    row[3] = 10;
    rm.addValueMeta(new ValueMetaInteger("PR2_SL"));
    row[4] = 250;
    rm.addValueMeta(new ValueMetaInteger("PR3_NR"));
    row[5] = 4;
    rm.addValueMeta(new ValueMetaInteger("PR3_SL"));
    row[6] = 150;
    list.add(new RowMetaAndData(rm, row));
    return list;
}
Also used : RowMetaAndData(org.pentaho.di.core.RowMetaAndData) RowMeta(org.pentaho.di.core.row.RowMeta) ArrayList(java.util.ArrayList) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) ValueMetaInteger(org.pentaho.di.core.row.value.ValueMetaInteger) ValueMetaDate(org.pentaho.di.core.row.value.ValueMetaDate) Date(java.util.Date) ValueMetaDate(org.pentaho.di.core.row.value.ValueMetaDate)

Example 90 with ValueMetaDate

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

the class NormaliserTest method getExpectedWikiOutputRowMetaAndData.

private List<RowMetaAndData> getExpectedWikiOutputRowMetaAndData() {
    final Date theDate = new Date(103, 01, 01);
    List<RowMetaAndData> list = new ArrayList<>();
    RowMetaInterface rm = new RowMeta();
    rm.addValueMeta(new ValueMetaDate("DATE"));
    rm.addValueMeta(new ValueMetaString("Type"));
    rm.addValueMeta(new ValueMetaInteger("Product Sales"));
    rm.addValueMeta(new ValueMetaInteger("Product Number"));
    Object[] row = new Object[4];
    row[0] = theDate;
    row[1] = "Product1";
    row[2] = 100;
    row[3] = 5;
    list.add(new RowMetaAndData(rm, row));
    row = new Object[4];
    row[0] = theDate;
    row[1] = "Product2";
    row[2] = 250;
    row[3] = 10;
    list.add(new RowMetaAndData(rm, row));
    row = new Object[4];
    row[0] = theDate;
    row[1] = "Product3";
    row[2] = 150;
    row[3] = 4;
    list.add(new RowMetaAndData(rm, row));
    return list;
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) RowMetaAndData(org.pentaho.di.core.RowMetaAndData) RowMeta(org.pentaho.di.core.row.RowMeta) ArrayList(java.util.ArrayList) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) ValueMetaInteger(org.pentaho.di.core.row.value.ValueMetaInteger) ValueMetaDate(org.pentaho.di.core.row.value.ValueMetaDate) Date(java.util.Date) ValueMetaDate(org.pentaho.di.core.row.value.ValueMetaDate)

Aggregations

ValueMetaDate (org.pentaho.di.core.row.value.ValueMetaDate)104 ValueMetaInteger (org.pentaho.di.core.row.value.ValueMetaInteger)63 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)59 Test (org.junit.Test)50 ValueMetaBoolean (org.pentaho.di.core.row.value.ValueMetaBoolean)44 RowMeta (org.pentaho.di.core.row.RowMeta)43 ValueMetaNumber (org.pentaho.di.core.row.value.ValueMetaNumber)34 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)33 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)25 ValueMetaBigNumber (org.pentaho.di.core.row.value.ValueMetaBigNumber)23 ValueMetaTimestamp (org.pentaho.di.core.row.value.ValueMetaTimestamp)21 Calendar (java.util.Calendar)17 Date (java.util.Date)17 KettleException (org.pentaho.di.core.exception.KettleException)15 ValueMetaInternetAddress (org.pentaho.di.core.row.value.ValueMetaInternetAddress)15 RowMetaAndData (org.pentaho.di.core.RowMetaAndData)14 ValueMetaBinary (org.pentaho.di.core.row.value.ValueMetaBinary)13 KettleDatabaseException (org.pentaho.di.core.exception.KettleDatabaseException)10 KettleStepException (org.pentaho.di.core.exception.KettleStepException)10 SQLException (java.sql.SQLException)8