Skip to content

Commit

Permalink
TEIID-4110: added unit tests to test month function with datetimeoffsset
Browse files Browse the repository at this point in the history
  • Loading branch information
rareddy authored and shawkins committed Mar 31, 2016
1 parent 953de78 commit 75a2f3d
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
35 changes: 35 additions & 0 deletions olingo/src/test/java/org/teiid/olingo/TestODataIntegration.java
Original file line number Diff line number Diff line change
Expand Up @@ -2210,4 +2210,39 @@ public void testIndexingOfStringFunctions() throws Exception {
teiid.undeployVDB("northwind");
}
}

@Test
public void testMonthFunctions() throws Exception {
try {
ModelMetaData mmd = new ModelMetaData();
mmd.setName("vw");
mmd.addSourceMetadata("ddl", "CREATE VIEW SimpleTable(\n" +
" intkey integer PRIMARY KEY,\n" +
" intnum integer,\n" +
" stringkey varchar(20),\n" +
" stringval varchar(20),\n" +
" booleanval boolean,\n" +
" decimalval decimal(20, 10),\n" +
" timeval time,\n" +
" dateval date,\n" +
" timestampval timestamp,\n" +
" clobval clob) as select 1,1, '1','1',true,1.0,{t '00:01:01'}, "
+ "{d '2001-01-01'},{ts '2001-01-01 00:01:01.01'},null;");
mmd.setModelType(Model.Type.VIRTUAL);
teiid.deployVDB("northwind", mmd);

Properties props = new Properties();
localClient = getClient(teiid.getDriver(), "northwind", 1, props);

ContentResponse response = http.GET(baseURL + "/northwind/vw/SimpleTable?$filter="
+Encoder.encode("month(2001-01-01T00:01:01.01Z) eq intkey")+"&$select=intkey");
assertEquals(200, response.getStatus());
assertEquals("{\"@odata.context\":\"$metadata#SimpleTable(intkey)\",\"value\":[{\"intkey\":1}]}",
response.getContentAsString());

} finally {
localClient = null;
teiid.undeployVDB("northwind");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1030,6 +1030,14 @@ public void testFloor() throws Exception {
"SELECT g0.e1, g0.e2, g0.e3 FROM PM1.G1 AS g0 WHERE g0.e2 = FLOOR(4.2) ORDER BY g0.e2");
}

@Test
public void testMonthWithDatetimeoffser() throws Exception {
helpTest("/odata4/vdb/PM1/SimpleTable?$filter="+Encoder.encode("month(2001-01-01T00:01:01.01Z) eq intkey"),
"SELECT g0.intkey, g0.intnum, g0.stringkey, g0.stringval, g0.booleanval, g0.decimalval, "
+ "g0.timeval, g0.dateval, g0.timestampval, g0.clobval FROM "
+ "PM1.SimpleTable AS g0 WHERE MONTH({ts'2001-01-01 00:01:01.01'}) = g0.intkey ORDER BY g0.intkey");
}

@BeforeClass public static void oneTimeSetup() {
TimestampWithTimezone.resetCalendar(TimeZone.getTimeZone("GMT"));
}
Expand Down

0 comments on commit 75a2f3d

Please sign in to comment.