use of test.com.ctrip.platform.dal.dao.unitbase.ClientTestModel in project dal by ctripcorp.
the class DalQueryDaoTestStub method testQueryForObjectNullableSuccess.
/**
* Test query for object success
* @throws SQLException
*/
@Test
public void testQueryForObjectNullableSuccess() throws SQLException {
String sql = "SELECT * FROM " + TABLE_NAME + " WHERE id = 1";
StatementParameters param = new StatementParameters();
DalHints hints = new DalHints();
ClientTestModel model = client.queryForObjectNullable(sql, param, hints, mapper);
Assert.assertNotNull(model);
Assert.assertEquals(1, model.getId().intValue());
sql = "SELECT * FROM " + TABLE_NAME + " WHERE id = -1";
Assert.assertNull(client.queryForObjectNullable(sql, param, hints, mapper));
}
use of test.com.ctrip.platform.dal.dao.unitbase.ClientTestModel in project dal by ctripcorp.
the class DalQueryDaoTestStub method testQueryForObjectSuccess.
/**
* Test query for object success
* @throws SQLException
*/
@Test
public void testQueryForObjectSuccess() throws SQLException {
String sql = "SELECT * FROM " + TABLE_NAME + " WHERE id = 1";
StatementParameters param = new StatementParameters();
DalHints hints = new DalHints();
ClientTestModel model = client.queryForObject(sql, param, hints, mapper);
Assert.assertEquals(1, model.getId().intValue());
FreeSelectSqlBuilder<List<Map<String, Object>>> builder = new FreeSelectSqlBuilder<>();
builder.append("select count(*) as c1, 111 as c2");
builder.mapWith(new DalCustomRowMapper("c1", "c2"));
builder.with(new StatementParameters());
List<Map<String, Object>> l = client.query(builder, hints);
}
use of test.com.ctrip.platform.dal.dao.unitbase.ClientTestModel in project dal by ctripcorp.
the class DalTableDaoTestStub method testDeleteMultiple.
/**
* Test delete multiple entities
* @throws SQLException
*/
@Test
public void testDeleteMultiple() throws SQLException {
List<ClientTestModel> modelList = new ArrayList<>();
for (int i = 0; i < 3; i++) {
ClientTestModel model = new ClientTestModel();
model.setId(i + 1);
modelList.add(model);
}
int[] res = dao.delete(new DalHints(), modelList);
assertEquals(new int[] { 1, 1, 1 }, res, 4 - 3);
}
use of test.com.ctrip.platform.dal.dao.unitbase.ClientTestModel in project dal by ctripcorp.
the class DalTableDaoTestStub method testQueryByPkWithEntityByColumnNames.
/**
* Query by Entity with Primary key
* @throws SQLException
*/
@Test
public void testQueryByPkWithEntityByColumnNames() throws SQLException {
ClientTestModel pk = new ClientTestModel();
pk.setId(1);
ClientTestModel model = dao.queryByPk(pk, new DalHints().selectByNames());
Assert.assertTrue(null != model);
Assert.assertEquals(10, model.getQuantity().intValue());
model = dao.queryByPk(pk, new DalHints(DalHintEnum.selectByNames));
Assert.assertTrue(null != model);
Assert.assertEquals(10, model.getQuantity().intValue());
}
use of test.com.ctrip.platform.dal.dao.unitbase.ClientTestModel in project dal by ctripcorp.
the class DalTableDaoTestStub method testQueryFirstWithWhereClause.
/**
* Test Query the first row with where clause
* @throws SQLException
*/
@Test
public void testQueryFirstWithWhereClause() throws SQLException {
String whereClause = "type=?";
StatementParameters parameters = new StatementParameters();
parameters.set(1, Types.SMALLINT, 1);
ClientTestModel model = dao.queryFirst(whereClause, parameters, new DalHints());
Assert.assertTrue(null != model);
Assert.assertEquals(1, model.getId().intValue());
}
Aggregations