use of test.com.ctrip.platform.dal.dao.unitbase.ClientTestModel in project dal by ctripcorp.
the class DalTableDaoTestStub method testQueryFromWithWhereClauseFailed.
/**
* Test Query range of result with where clause failed when return not enough recodes
* @throws SQLException
*/
@Test
public void testQueryFromWithWhereClauseFailed() throws SQLException {
String whereClause = "type=?";
StatementParameters parameters = new StatementParameters();
parameters.set(1, Types.SMALLINT, 1);
List<ClientTestModel> models = dao.queryFrom(whereClause, parameters, new DalHints(), 0, 10);
Assert.assertTrue(null != models);
Assert.assertEquals(3, models.size());
}
use of test.com.ctrip.platform.dal.dao.unitbase.ClientTestModel in project dal by ctripcorp.
the class DalTableDaoTestStub method testQueryByPkWithEntity.
/**
* Query by Entity with Primary key
* @throws SQLException
*/
@Test
public void testQueryByPkWithEntity() throws SQLException {
ClientTestModel pk = new ClientTestModel();
pk.setId(1);
ClientTestModel model = dao.queryByPk(pk, new DalHints());
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 testInsertMultipleAsListWithKeyHolder.
/**
* Test Insert multiple entities with key-holder
* @throws SQLException
*/
@Test
public void testInsertMultipleAsListWithKeyHolder() 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);
}
KeyHolder holder = diff.supportGetGeneratedKeys ? new KeyHolder() : null;
int[] res = dao.insert(new DalHints(), holder, entities);
assertEquals(new int[] { 1, 1, 1 }, res, 4 + 3);
if (diff.supportGetGeneratedKeys) {
Assert.assertEquals(3, holder.size());
Assert.assertTrue(holder.getKeyList().get(0).containsKey("GENERATED_KEY"));
}
}
use of test.com.ctrip.platform.dal.dao.unitbase.ClientTestModel in project dal by ctripcorp.
the class DalTableDaoTestStub method testDeleteWithWhereClause.
/**
* Test delete entities with where clause and parameters
* @throws SQLException
*/
@Test
public void testDeleteWithWhereClause() throws SQLException {
String whereClause = "type=?";
StatementParameters parameters = new StatementParameters();
parameters.set(1, Types.SMALLINT, 1);
DalHints hints = new DalHints();
int res = dao.delete(whereClause, parameters, hints);
assertEquals(3, res, 1);
List<ClientTestModel> models = dao.query(whereClause, parameters, hints);
Assert.assertEquals(0, models.size());
}
use of test.com.ctrip.platform.dal.dao.unitbase.ClientTestModel in project dal by ctripcorp.
the class DalTableDaoTestStub method testQueryWithWhereClause.
/**
* Query by Entity with where clause
* @throws SQLException
*/
@Test
public void testQueryWithWhereClause() throws SQLException {
String whereClause = "type=? and id=?";
StatementParameters parameters = new StatementParameters();
parameters.set(1, Types.SMALLINT, 1);
parameters.set(2, Types.INTEGER, 1);
List<ClientTestModel> models = dao.query(whereClause, parameters, new DalHints());
Assert.assertTrue(null != models);
Assert.assertEquals(1, models.size());
Assert.assertEquals("SH INFO", models.get(0).getAddress());
}
Aggregations