package com.splicemachine.derby.impl.sql.execute.tester;

import com.splicemachine.db.iapi.types.SQLDouble;
import com.splicemachine.db.iapi.types.SQLTimestamp;
import org.joda.time.DateTime;
import org.junit.Assert;
import org.junit.Test;

import com.splicemachine.derby.impl.sql.execute.LazyNumberDataValueDescriptor;
import com.splicemachine.derby.impl.sql.execute.LazyTimestampDataValueDescriptor;

/**
 * TODO: Should be more tests here for LazyTimestampDataValueDescriptor. Adding this test for verification of fix for DB-2863.
 *
 * @author Jeff Cunningham
 *         Date: 2/13/15
 */
public class LazyTimestampDataValueDescriptorTest {

    @Test
    public void testGetSeconds() throws Exception {
        int expected = 32;
        LazyTimestampDataValueDescriptor timestamp =
            new LazyTimestampDataValueDescriptor(new SQLTimestamp(new DateTime(2012, 2, 14, 12, 12, expected, 0)));
        double actual = timestamp.getSeconds(new LazyNumberDataValueDescriptor(new SQLDouble(0.0))).getDouble();
        Assert.assertEquals(expected, actual, 0.0);
    }
}

@@ -51,16 +51,127 @@
 ester;%0A%0A
+import com.splicemachine.db.iapi.error.StandardException;%0Aimport com.splicemachine.db.iapi.reference.SQLState;%0A
 import c
@@ -212,16 +212,16 @@
 Double;%0A
-
 import c
@@ -507,16 +507,44 @@
 iptor;%0A%0A
+import java.sql.Timestamp;%0A%0A
 /**%0A * T
@@ -1149,16 +1149,16 @@
 uble();%0A
-
         
@@ -1207,10 +1207,844 @@
 ;%0A    %7D%0A
+%0A%0A    @Test%0A    public void testBounds() throws StandardException %7B%0A        Timestamp tsMin = new Timestamp(SQLTimestamp.MIN_TIMESTAMP - 1);%0A        Timestamp tsMax = new Timestamp(SQLTimestamp.MAX_TIMESTAMP + 1);%0A        Timestamp tsOk = new Timestamp(0);%0A%0A        SQLTimestamp sts = new SQLTimestamp();%0A%0A        try %7B%0A            sts.setValue(tsMin);%0A            Assert.fail(%22No exception about bounds%22);%0A        %7D catch (StandardException e) %7B%0A            Assert.assertEquals(SQLState.LANG_DATE_TIME_ARITHMETIC_OVERFLOW, e.getSqlState());%0A        %7D%0A%0A        try %7B%0A            sts.setValue(tsMax);%0A            Assert.fail(%22No exception about bounds%22);%0A        %7D catch (StandardException e) %7B%0A            Assert.assertEquals(SQLState.LANG_DATE_TIME_ARITHMETIC_OVERFLOW, e.getSqlState());%0A        %7D%0A%0A        sts.setValue(tsOk);%0A    %7D%0A
 %7D%0A

Add test