use of org.pentaho.di.core.row.value.ValueMetaDate in project pentaho-kettle by pentaho.
the class ValueDateUtilTest method shouldCalculateDateWorkingDiff_JUL.
@Test
public void shouldCalculateDateWorkingDiff_JUL() throws KettleValueException {
ValueMetaInterface metaA = new ValueMetaDate();
ValueMetaInterface metaB = new ValueMetaDate();
Calendar startDate = Calendar.getInstance();
Calendar endDate = Calendar.getInstance();
// 2009-07-01 00:00:00
startDate.setTimeInMillis(1246406400000L);
// 2009-07-31 00:00:00
endDate.setTimeInMillis(1248998400000L);
Object workingDayOfJUL = ValueDataUtil.DateWorkingDiff(metaA, endDate.getTime(), metaB, startDate.getTime());
assertEquals("Working days count in JUL ", 23L, workingDayOfJUL);
}
use of org.pentaho.di.core.row.value.ValueMetaDate in project pentaho-kettle by pentaho.
the class ValueDateUtilTest method shouldCalculateDateWorkingDiff_SEP.
@Test
public void shouldCalculateDateWorkingDiff_SEP() throws KettleValueException {
ValueMetaInterface metaA = new ValueMetaDate();
ValueMetaInterface metaB = new ValueMetaDate();
Calendar startDate = Calendar.getInstance();
Calendar endDate = Calendar.getInstance();
// 2009-09-01 00:00:00
startDate.setTimeInMillis(1251763200000L);
// 2009-09-30 00:00:00
endDate.setTimeInMillis(1254268800000L);
Object workingDayOfSEP = ValueDataUtil.DateWorkingDiff(metaA, endDate.getTime(), metaB, startDate.getTime());
assertEquals("Working days count in SEP ", 22L, workingDayOfSEP);
}
use of org.pentaho.di.core.row.value.ValueMetaDate in project pentaho-kettle by pentaho.
the class ValueDateUtilTest method shouldCalculateHourOfDayUsingLocalTimeZoneIfPropertyIsSet.
@Test
public void shouldCalculateHourOfDayUsingLocalTimeZoneIfPropertyIsSet() throws KettleValueException {
Calendar date = Calendar.getInstance();
// 2016-07-01 08:00:00 UTC
date.setTimeInMillis(1454313600000L);
ValueMetaInterface valueMetaDate = new ValueMetaDate();
// UTC +1
valueMetaDate.setDateFormatTimeZone(TimeZone.getTimeZone("CET"));
long offsetLocal = (long) TimeZone.getDefault().getRawOffset() / 3600000;
System.setProperty(Const.KETTLE_COMPATIBILITY_CALCULATION_TIMEZONE_DECOMPOSITION, "true");
Object hourOfDayLocal = ValueDataUtil.hourOfDay(valueMetaDate, date.getTime());
assertEquals(8L + offsetLocal, hourOfDayLocal);
}
use of org.pentaho.di.core.row.value.ValueMetaDate in project pentaho-kettle by pentaho.
the class ValueDateUtilTest method shouldCalculateDateWorkingDiff_OCT.
@Test
public void shouldCalculateDateWorkingDiff_OCT() throws KettleValueException {
ValueMetaInterface metaA = new ValueMetaDate();
ValueMetaInterface metaB = new ValueMetaDate();
Calendar startDate = Calendar.getInstance();
Calendar endDate = Calendar.getInstance();
// 2009-10-01 00:00:00
startDate.setTimeInMillis(1254355200000L);
// 2009-10-31 00:00:00
endDate.setTimeInMillis(1256947200000L);
Object workingDayOfOCT = ValueDataUtil.DateWorkingDiff(metaA, endDate.getTime(), metaB, startDate.getTime());
assertEquals("Working days count in OCT ", 22L, workingDayOfOCT);
}
use of org.pentaho.di.core.row.value.ValueMetaDate in project pentaho-kettle by pentaho.
the class MemoryGroupByAggregationTest method testDefault.
@Test
public void testDefault() throws Exception {
addColumn(new ValueMetaInteger("intg"), 0L, 1L, 1L, 10L);
addColumn(new ValueMetaInteger("nul"));
addColumn(new ValueMetaInteger("mix1"), -1L, 2L);
addColumn(new ValueMetaInteger("mix2"), null, 7L);
addColumn(new ValueMetaNumber("mix3"), -1.0, 2.5);
addColumn(new ValueMetaDate("date1"), new Date(1L), new Date(2L));
RowMetaAndData output = runStep();
assertThat(output.getInteger("intg_min"), is(0L));
assertThat(output.getInteger("intg_max"), is(10L));
assertThat(output.getInteger("intg_sum"), is(12L));
assertThat(output.getInteger("intg_ave"), is(3L));
assertThat(output.getInteger("intg_count"), is(4L));
assertThat(output.getInteger("intg_count_any"), is(4L));
assertThat(output.getInteger("intg_count_distinct"), is(3L));
assertThat(output.getInteger("nul_min"), nullValue());
assertThat(output.getInteger("nul_max"), nullValue());
assertThat(output.getInteger("nul_sum"), nullValue());
assertThat(output.getInteger("nul_ave"), nullValue());
assertThat(output.getInteger("nul_count"), is(0L));
assertThat(output.getInteger("nul_count_any"), is(4L));
assertThat(output.getInteger("nul_count_distinct"), is(0L));
assertThat(output.getInteger("mix1_max"), is(2L));
assertThat(output.getInteger("mix1_min"), is(-1L));
assertThat(output.getInteger("mix1_sum"), is(1L));
assertThat(output.getInteger("mix1_ave"), is(0L));
assertThat(output.getInteger("mix1_count"), is(2L));
assertThat(output.getInteger("mix1_count_any"), is(4L));
assertThat(output.getInteger("mix1_count_distinct"), is(2L));
assertThat(output.getInteger("mix2_max"), is(7L));
assertThat(output.getInteger("mix2_min"), is(7L));
assertThat(output.getInteger("mix2_sum"), is(7L));
assertThat(output.getNumber("mix2_ave", Double.NaN), is(7.0));
assertThat(output.getInteger("mix2_count"), is(1L));
assertThat(output.getInteger("mix2_count_any"), is(4L));
assertThat(output.getInteger("mix2_count_distinct"), is(1L));
assertThat(output.getNumber("mix3_max", Double.NaN), is(2.5));
assertThat(output.getNumber("mix3_min", Double.NaN), is(-1.0));
assertThat(output.getNumber("mix3_sum", Double.NaN), is(1.5));
assertThat(output.getNumber("mix3_ave", Double.NaN), is(0.75));
assertThat(output.getInteger("mix3_count"), is(2L));
assertThat(output.getInteger("mix3_count_any"), is(4L));
assertThat(output.getInteger("mix3_count_distinct"), is(2L));
assertThat(output.getNumber("date1_min", Double.NaN), is(1.0));
assertThat(output.getNumber("date1_max", Double.NaN), is(2.0));
assertThat(output.getNumber("date1_sum", Double.NaN), is(3.0));
assertThat(output.getNumber("date1_ave", Double.NaN), is(1.5));
assertThat(output.getInteger("date1_count"), is(2L));
assertThat(output.getInteger("date1_count_any"), is(4L));
assertThat(output.getInteger("date1_count_distinct"), is(2L));
}
Aggregations