int limit = (Integer) (args[1]);
if (SQLTestsConstants.db == DB.MSSQL) {
SQLGenerator gen = new MSSQLGenerator();
if (orderBys == null || orderBys.isEmpty()) {
List<OrderBy> ob = new ArrayList<OrderBy>();
ob.add(new OrderBy("ID", true));
return gen.generateSelectQuery("people", null,
ob, offset, limit, null)
.getQueryString();
} else {
return gen.generateSelectQuery("people", null,
orderBys, offset, limit, null)
.getQueryString();
}
} else if (SQLTestsConstants.db == DB.ORACLE) {
SQLGenerator gen = new OracleGenerator();
if (orderBys == null || orderBys.isEmpty()) {
List<OrderBy> ob = new ArrayList<OrderBy>();
ob.add(new OrderBy("ID", true));
return gen.generateSelectQuery("people", null,
ob, offset, limit, null)
.getQueryString();
} else {
return gen.generateSelectQuery("people", null,
orderBys, offset, limit, null)
.getQueryString();
}
} else {
StringBuffer query = new StringBuffer(
"SELECT * FROM people");
if (!orderBys.isEmpty()) {
query.append(" ORDER BY ");
for (OrderBy orderBy : orderBys) {
query.append("\"" + orderBy.getColumn()
+ "\"");
if (orderBy.isAscending()) {
query.append(" ASC");
} else {
query.append(" DESC");
}
}
}
query.append(" LIMIT ").append(limit)
.append(" OFFSET ").append(offset);
return query.toString();
}
}
}).anyTimes();
EasyMock.expect(delegate.getCountQuery())
.andThrow(new UnsupportedOperationException()).anyTimes();
EasyMock.replay(delegate);
query.setDelegate(delegate);
SQLContainer container = new SQLContainer(query);
// Ville, Kalle, Pelle, Börje
Assert.assertEquals("Ville",
container.getContainerProperty(container.firstItemId(), "NAME")
.getValue());
Assert.assertEquals("Börje",
container.getContainerProperty(container.lastItemId(), "NAME")
.getValue());
container.addOrderBy(new OrderBy("NAME", true));
// Börje, Kalle, Pelle, Ville
Assert.assertEquals("Börje",
container.getContainerProperty(container.firstItemId(), "NAME")
.getValue());
Assert.assertEquals("Ville",