package com.addthis.hydra.data.query;

import org.junit.Test;

public class TestOpDateFormat extends TestOp {

    @Test
    public void testOpDateFormat() throws Exception {
        doOpTest(
                new DataTableHelper().
                        tr().td("140101").
                        tr().td("140108"),
                "datef=0:yyMMdd:yyww",
                new DataTableHelper().
                        tr().td("1401").
                        tr().td("1402")
        );
        doOpTest(
                new DataTableHelper().
                        tr().td("140101", "0").
                        tr().td("140108", "0"),
                "datef=0:yyMMdd:yyww:1",
                new DataTableHelper().
                        tr().td("140101", "1401").
                        tr().td("140108", "1402")
        );
        doOpTest(
                new DataTableHelper().
                        tr().td("1418078000000", "0"),
                "datef=0:unixmillis:yyMMdd:1",
                new DataTableHelper().
                        tr().td("1418078000000", "141208")
        );
    }
}

@@ -32,16 +32,60 @@
 query;%0A%0A
+import org.joda.time.format.DateTimeFormat;%0A
 import o
@@ -178,28 +178,35 @@
 oid test
-OpDateFormat
+ConvertDatesInPlace
 () throw
@@ -524,32 +524,118 @@
 02%22)%0A        );%0A
+    %7D%0A%0A    @Test%0A    public void testConvertDatesDifferentColumn() throws Exception %7B%0A
         doOpTest
@@ -959,24 +959,354 @@
 %0A        );%0A
+    %7D%0A%0A    @Test%0A    public void testParseUnixMillis() throws Exception %7B%0A        long testTimeMillis = 1418078000000l;%0A        String outputFormat = %22yyMMdd%22;%0A        // Manually convert the test-time to yyMMdd in the local time zone%0A        String expectedResult = DateTimeFormat.forPattern(outputFormat).print(testTimeMillis);%0A
         doOp
@@ -1382,31 +1382,45 @@
 tr().td(
-%221418078000000%22
+Long.toString(testTimeMillis)
 , %220%22),%0A
@@ -1427,32 +1427,46 @@
                 
+String.format(
 %22datef=0:unixmil
@@ -1473,17 +1473,28 @@
 lis:
-yyMMdd:1%22
+%25s:1%22, outputFormat)
 ,%0A  
@@ -1566,33 +1566,53 @@
 .td(
-%221418078000000%22, %22141208%22
+Long.toString(testTimeMillis), expectedResult
 )%0A  

Fix OpDateFormat test in other time zones and separate into dedicated methods