use of test.com.ctrip.platform.dal.dao.unitbase.ClientTestModel in project dal by ctripcorp.
the class DalQueryDaoTestStub method testQueryFirstSuccess.
/**
* Test query for first success
* @throws SQLException
*/
@Test
public void testQueryFirstSuccess() throws SQLException {
String sql = "SELECT * FROM " + TABLE_NAME + " WHERE id = 1";
StatementParameters param = new StatementParameters();
DalHints hints = new DalHints();
ClientTestModel model = client.queryFirst(sql, param, hints, mapper);
Assert.assertEquals(1, model.getId().intValue());
}
use of test.com.ctrip.platform.dal.dao.unitbase.ClientTestModel in project dal by ctripcorp.
the class DalQueryDaoTestStub method testQueryWithMapper.
/**
* Test the basic query function with mapper
* @throws SQLException
*/
@Test
public void testQueryWithMapper() throws SQLException {
String sql = "SELECT * FROM " + TABLE_NAME;
StatementParameters param = new StatementParameters();
DalHints hints = new DalHints();
List<ClientTestModel> models = client.query(sql, param, hints, mapper);
Assert.assertEquals(ROW_COUNT, models.size());
}
use of test.com.ctrip.platform.dal.dao.unitbase.ClientTestModel in project dal by ctripcorp.
the class DalQueryDaoTestStub method testQueryTopSuccess.
/**
* Test query for Top success
* @throws SQLException
*/
@Test
public void testQueryTopSuccess() throws SQLException {
String sql = "SELECT * FROM " + TABLE_NAME + " WHERE quantity = 10";
StatementParameters param = new StatementParameters();
DalHints hints = new DalHints();
List<ClientTestModel> models = client.queryTop(sql, param, hints, mapper, 10);
Assert.assertEquals(10, models.size());
Assert.assertEquals(10, models.get(0).getQuantity().intValue());
}
use of test.com.ctrip.platform.dal.dao.unitbase.ClientTestModel in project dal by ctripcorp.
the class DalQueryDaoTestStub method testQueryFromFailed.
/**
* Test query for From Failed
* @throws SQLException
*/
@Test
public void testQueryFromFailed() throws SQLException {
String sql = "SELECT * FROM " + TABLE_NAME + " LIMIT x 5";
StatementParameters param = new StatementParameters();
DalHints hints = new DalHints();
List<ClientTestModel> models;
try {
models = client.queryFrom(sql, param, hints, mapper, 0, 10);
Assert.fail();
} catch (Exception e) {
}
}
use of test.com.ctrip.platform.dal.dao.unitbase.ClientTestModel in project dal by ctripcorp.
the class DalTableDaoTestStub method testInsertMultipleAsList.
/**
* Test Insert multiple entities one by one
* @throws SQLException
*/
@Test
public void testInsertMultipleAsList() throws SQLException {
List<ClientTestModel> entities = new ArrayList<ClientTestModel>();
for (int i = 0; i < 3; i++) {
ClientTestModel model = new ClientTestModel();
model.setQuantity(10 + 1 % 3);
model.setType(((Number) (1 % 3)).shortValue());
model.setAddress("CTRIP");
entities.add(model);
}
int[] res = dao.insert(new DalHints(), entities);
assertEquals(new int[] { 1, 1, 1 }, res, 3, "address='CTRIP'");
}
Aggregations