use of com.ctrip.platform.dal.dao.unitbase.ClientTestModel in project dal by ctripcorp.
the class DalDirectClientSqlServerTest method TSQLTestForSpWithOutParameter.
@Test
public void TSQLTestForSpWithOutParameter() throws SQLException {
String callSql = "exec " + SP_WITH_OUT_PARAM + " @v_id=?, @count=?";
StatementParameters parameters = new StatementParameters();
parameters.set("v_id", Types.INTEGER, 1);
parameters.registerOut("count", Types.INTEGER);
DalHints hints = new DalHints();
Map<String, ?> res = client.call(callSql, parameters, hints);
Assert.assertTrue(null != res);
Assert.assertEquals(1, res.size());
Assert.assertEquals(2, ((Number) res.get("count")).intValue());
List<ClientTestModel> models = this.queryModelsByIds(1);
Assert.assertEquals(0, models.size());
List<ClientTestModel> models_d = this.queryModelsByIds();
Assert.assertEquals(2, models_d.size());
}
use of com.ctrip.platform.dal.dao.unitbase.ClientTestModel in project dal by ctripcorp.
the class DalDirectClientSqlServerTest method testTSQLBatchCallWithParametersAndResultParameters.
@Test
public void testTSQLBatchCallWithParametersAndResultParameters() throws SQLException {
String callSql = "exec " + SP_WITH_OUT_PARAM + " @v_id=?, @count=Null";
StatementParameters[] parametersList = new StatementParameters[3];
for (int i = 0; i < 3; i++) {
StatementParameters parameters = new StatementParameters();
parameters.set("v_id", Types.INTEGER, i + 1);
// parameters.registerOut("count", Types.INTEGER);
parametersList[i] = parameters;
}
DalHints hints = new DalHints();
int[] res = client.batchCall(callSql, parametersList, hints);
Assert.assertEquals(3, res.length);
List<ClientTestModel> models = this.queryModelsByIds(1, 2, 3);
Assert.assertEquals(0, models.size());
}
use of 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'");
}
use of com.ctrip.platform.dal.dao.unitbase.ClientTestModel in project dal by ctripcorp.
the class DalTableDaoTestStub method testBatchDelete.
/**
* Test batch delete multiple entities
*
* @throws SQLException
*/
@Test
public void testBatchDelete() throws SQLException {
List<ClientTestModel> entities = new ArrayList<ClientTestModel>();
for (int i = 0; i < 3; i++) {
ClientTestModel model = new ClientTestModel();
model.setId(i + 1);
entities.add(model);
}
int[] res = dao.batchDelete(new DalHints(), entities);
assertEqualsBatch(new int[] { 1, 1, 1 }, res, 4 - 3);
}
use of com.ctrip.platform.dal.dao.unitbase.ClientTestModel in project dal by ctripcorp.
the class DalTableDaoTestStub method testInsertCheckForData.
/**
* Test Insert with null or empty parameters
*
* @throws SQLException
*/
@Test
public void testInsertCheckForData() throws SQLException {
ClientTestModel model = null;
try {
dao.insert(new DalHints(), model);
Assert.fail();
} catch (Exception e) {
}
List<ClientTestModel> models = null;
try {
dao.insert(new DalHints(), models);
Assert.fail();
} catch (Exception e) {
}
models = new ArrayList<>();
int[] res = dao.insert(new DalHints(), models);
Assert.assertEquals(0, res.length);
}
Aggregations