use of org.pentaho.di.core.row.value.ValueMetaInteger in project pentaho-kettle by pentaho.
the class GroupByMetaGetFieldsTest method setup.
@Before
public void setup() throws KettlePluginException {
rowMeta = spy(new RowMeta());
groupByMeta = spy(new GroupByMeta());
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.ValueMetaInteger in project pentaho-kettle by pentaho.
the class GroupByNewAggregateTest method setUp.
@Before
public void setUp() throws Exception {
data = new GroupByData();
data.subjectnrs = new int[18];
int[] arr = new int[18];
String[] arrF = new String[18];
data.previousSums = new Object[18];
data.previousAvgCount = new long[18];
data.previousAvgSum = new Object[18];
for (int i = 0; i < arr.length; i++) {
// set aggregation types (hardcoded integer values from 1 to 18)
arr[i] = i + 1;
data.subjectnrs[i] = i;
}
Arrays.fill(arrF, "x");
Arrays.fill(data.previousSums, 11);
Arrays.fill(data.previousAvgCount, 12);
Arrays.fill(data.previousAvgSum, 13);
GroupByMeta meta = new GroupByMeta();
meta.setAggregateType(arr);
meta.setAggregateField(arrF);
ValueMetaInterface vmi = new ValueMetaInteger();
when(mockHelper.stepMeta.getStepMetaInterface()).thenReturn(meta);
RowMetaInterface rmi = Mockito.mock(RowMetaInterface.class);
data.inputRowMeta = rmi;
when(rmi.getValueMeta(Mockito.anyInt())).thenReturn(vmi);
data.aggMeta = rmi;
data.agg = new Object[] { def };
data.counts = new long[] { 1 };
data.previousSums = new Object[] { 18 };
step = new GroupBy(mockHelper.stepMeta, data, 0, mockHelper.transMeta, mockHelper.trans);
}
use of org.pentaho.di.core.row.value.ValueMetaInteger in project pentaho-kettle by pentaho.
the class GroupByNullInputTest method testNullInputDataForStandardDeviation.
/**
* PMD-1037 NPE error appears when user uses "Data Profile" feature to some tables in Hive 2.
*/
@Test
public void testNullInputDataForStandardDeviation() throws KettleValueException {
setAggregationTypesAndInitData(new int[] { 15 });
ValueMetaInterface vmi = new ValueMetaInteger();
when(rowMetaInterfaceMock.getValueMeta(Mockito.anyInt())).thenReturn(vmi);
Object[] row1 = new Object[NUMBER_OF_COLUMNS];
Arrays.fill(row1, null);
step.newAggregate(row1);
step.calcAggregate(row1);
Object[] aggregateResult = step.getAggregateResult();
Assert.assertNull("Returns null if aggregation is null", aggregateResult[0]);
}
use of org.pentaho.di.core.row.value.ValueMetaInteger in project pentaho-kettle by pentaho.
the class GroupByTest method testProcessRow.
@Test
public void testProcessRow() throws KettleException {
GroupByMeta groupByMeta = mock(GroupByMeta.class);
GroupByData groupByData = mock(GroupByData.class);
GroupBy groupBySpy = Mockito.spy(new GroupBy(mockHelper.stepMeta, mockHelper.stepDataInterface, 0, mockHelper.transMeta, mockHelper.trans));
doReturn(null).when(groupBySpy).getRow();
doReturn(null).when(groupBySpy).getInputRowMeta();
RowMetaInterface rowMeta = new RowMeta();
rowMeta.addValueMeta(new ValueMetaInteger("ROWNR"));
List<RowSet> outputRowSets = new ArrayList<RowSet>();
BlockingRowSet rowSet = new BlockingRowSet(1);
rowSet.putRow(rowMeta, new Object[] { new Long(0) });
outputRowSets.add(rowSet);
groupBySpy.setOutputRowSets(outputRowSets);
final String[] sub = { "b" };
doReturn(sub).when(groupByMeta).getSubjectField();
final String[] groupField = { "a" };
doReturn(groupField).when(groupByMeta).getGroupField();
final String[] aggFields = { "b_g" };
doReturn(aggFields).when(groupByMeta).getAggregateField();
final int[] aggType = { GroupByMeta.TYPE_GROUP_CONCAT_COMMA };
doReturn(aggType).when(groupByMeta).getAggregateType();
when(mockHelper.transMeta.getPrevStepFields(mockHelper.stepMeta)).thenReturn(new RowMeta());
groupBySpy.processRow(groupByMeta, groupByData);
assertTrue(groupBySpy.getOutputRowSets().get(0).isDone());
}
use of org.pentaho.di.core.row.value.ValueMetaInteger in project pentaho-kettle by pentaho.
the class KettleDatabaseRepositoryTest method getNullIntegerRow.
private RowMetaAndData getNullIntegerRow() {
RowMeta rm = new RowMeta();
rm.addValueMeta(new ValueMetaInteger());
return new RowMetaAndData(rm, new Object[] { null });
}
Aggregations