use of org.pentaho.di.core.row.value.ValueMetaDate in project pentaho-kettle by pentaho.
the class NetezzaDatabaseMetaTest method testGetFieldDefinition.
@Test
public void testGetFieldDefinition() {
assertEquals("FOO date", nativeMeta.getFieldDefinition(new ValueMetaDate("FOO"), null, null, false, true, false));
assertEquals("boolean", nativeMeta.getFieldDefinition(new ValueMetaBoolean("FOO"), null, null, false, false, false));
assertEquals("", nativeMeta.getFieldDefinition(new ValueMetaInteger("FOO", 0, 0), null, null, false, false, false));
assertEquals("byteint", nativeMeta.getFieldDefinition(new ValueMetaNumber("FOO", 1, 0), null, null, false, false, false));
assertEquals("byteint", nativeMeta.getFieldDefinition(new ValueMetaBigNumber("FOO", 2, 0), null, null, false, false, false));
assertEquals("smallint", nativeMeta.getFieldDefinition(new ValueMetaInteger("FOO", 3, 0), null, null, false, false, false));
assertEquals("smallint", nativeMeta.getFieldDefinition(new ValueMetaInteger("FOO", 4, 0), null, null, false, false, false));
for (int i = 5; i < 10; i++) {
assertEquals("integer", nativeMeta.getFieldDefinition(new ValueMetaInteger("FOO", i, 0), null, null, false, false, false));
}
assertEquals("bigint", nativeMeta.getFieldDefinition(new ValueMetaInteger("FOO", 10, 0), null, null, false, false, false));
assertEquals("", nativeMeta.getFieldDefinition(new ValueMetaNumber("FOO", -22, 3), null, null, false, false, false));
assertEquals("", nativeMeta.getFieldDefinition(new ValueMetaNumber("FOO", 0, 3), null, null, false, false, false));
assertEquals("real", // pretty sure this is a bug ...
nativeMeta.getFieldDefinition(new ValueMetaNumber("FOO", 1, 3), null, null, false, false, false));
assertEquals("real", // pretty sure this is a bug ...
nativeMeta.getFieldDefinition(new ValueMetaNumber("FOO", 2, 3), null, null, false, false, false));
for (int i = 3; i < 9; i++) {
assertEquals("real", nativeMeta.getFieldDefinition(new ValueMetaNumber("FOO", i, 3), null, null, false, false, false));
}
for (int i = 10; i < 18; i++) {
assertEquals("double", nativeMeta.getFieldDefinition(new ValueMetaNumber("FOO", i, 3), null, null, false, false, false));
}
assertEquals("numeric(18, 3)", nativeMeta.getFieldDefinition(new ValueMetaNumber("FOO", 18, 3), null, null, false, false, false));
assertEquals("numeric(19)", nativeMeta.getFieldDefinition(new ValueMetaNumber("FOO", 19, -12), null, null, false, false, false));
assertEquals("varchar(32767)", nativeMeta.getFieldDefinition(new ValueMetaString("FOO", (NetezzaDatabaseMeta.MAX_CHAR_LEN + 2), 0), null, null, false, false, false));
assertEquals("varchar(10)", nativeMeta.getFieldDefinition(new ValueMetaString("FOO", 10, 0), null, null, false, false, false));
assertEquals(" UNKNOWN", nativeMeta.getFieldDefinition(new ValueMetaBinary("FOO", 10, 0), null, null, false, false, false));
String lineSep = System.getProperty("line.separator");
assertEquals(" UNKNOWN" + lineSep, nativeMeta.getFieldDefinition(new ValueMetaBinary("FOO", 10, 0), null, null, false, false, true));
}
use of org.pentaho.di.core.row.value.ValueMetaDate in project pentaho-kettle by pentaho.
the class RowMetaTest method testRowMetaInitializingFromXmlNode.
@Test
public void testRowMetaInitializingFromXmlNode() throws Exception {
String testXmlNode = null;
try (InputStream in = RowMetaTest.class.getResourceAsStream("rowMetaNode.xml")) {
testXmlNode = IOUtils.toString(in);
}
Document xmlDoc = XMLHandler.loadXMLString(testXmlNode);
RowMeta rowMeta = spy(new RowMeta(xmlDoc.getFirstChild()));
assertEquals(2, rowMeta.getValueMetaList().size());
ValueMetaInterface valueMeta = rowMeta.getValueMeta(0);
assertTrue(valueMeta instanceof ValueMetaDate);
assertEquals("testDate", valueMeta.getName());
assertNull(valueMeta.getConversionMask());
valueMeta = rowMeta.getValueMeta(1);
assertTrue(valueMeta instanceof ValueMetaTimestamp);
assertEquals("testTimestamp", valueMeta.getName());
assertEquals("yyyy/MM/dd HH:mm:ss.000000000", valueMeta.getConversionMask());
}
use of org.pentaho.di.core.row.value.ValueMetaDate in project pentaho-kettle by pentaho.
the class ValueDateUtilTest method shouldCalculateDateWorkingDiff_AUG.
@Test
public void shouldCalculateDateWorkingDiff_AUG() throws KettleValueException {
ValueMetaInterface metaA = new ValueMetaDate();
ValueMetaInterface metaB = new ValueMetaDate();
Calendar startDate = Calendar.getInstance();
Calendar endDate = Calendar.getInstance();
// 2009-08-01 00:00:00
startDate.setTimeInMillis(1249084800000L);
// 2009-08-31 00:00:00
endDate.setTimeInMillis(1251676800000L);
Object workingDayOfAUG = ValueDataUtil.DateWorkingDiff(metaA, endDate.getTime(), metaB, startDate.getTime());
assertEquals("Working days count in AUG ", 21L, workingDayOfAUG);
}
use of org.pentaho.di.core.row.value.ValueMetaDate in project pentaho-kettle by pentaho.
the class ValueDateUtilTest method shouldCalculateDateWorkingDiff_NOV.
@Test
public void shouldCalculateDateWorkingDiff_NOV() throws KettleValueException {
ValueMetaInterface metaA = new ValueMetaDate();
ValueMetaInterface metaB = new ValueMetaDate();
Calendar startDate = Calendar.getInstance();
Calendar endDate = Calendar.getInstance();
// 2009-11-01 00:00:00
startDate.setTimeInMillis(1257033600000L);
// 2009-11-30 00:00:00
endDate.setTimeInMillis(1259539200000L);
Object workingDayOfNOV = ValueDataUtil.DateWorkingDiff(metaA, endDate.getTime(), metaB, startDate.getTime());
assertEquals("Working days count in NOV ", 21L, workingDayOfNOV);
}
use of org.pentaho.di.core.row.value.ValueMetaDate in project pentaho-kettle by pentaho.
the class ValueDateUtilTest method shouldCalculateHourOfDayUsingValueMetasTimeZoneByDefault.
@Test
public void shouldCalculateHourOfDayUsingValueMetasTimeZoneByDefault() 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 offsetCET = (long) TimeZone.getTimeZone("CET").getRawOffset() / 3600000;
Object hourOfDayCET = ValueDataUtil.hourOfDay(valueMetaDate, date.getTime());
assertEquals(8L + offsetCET, hourOfDayCET);
}
Aggregations