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");
}
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());
}
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"));
}
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;
}
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;
}
Aggregations