Search in sources :

Example 46 with ClientTestModel

use of test.com.ctrip.platform.dal.dao.unitbase.ClientTestModel in project dal by ctripcorp.

the class DalTableDaoTestStub method testQueryLike.

/**
 * Query against sample entity
 * @throws SQLException
 */
@Test
public void testQueryLike() throws SQLException {
    ClientTestModel pk = new ClientTestModel();
    pk.setType((short) 1);
    List<ClientTestModel> models = dao.queryLike(pk, new DalHints());
    Assert.assertTrue(null != models);
    Assert.assertEquals(3, models.size());
}
Also used : DalHints(com.ctrip.platform.dal.dao.DalHints) ClientTestModel(test.com.ctrip.platform.dal.dao.unitbase.ClientTestModel) Test(org.junit.Test)

Example 47 with ClientTestModel

use of test.com.ctrip.platform.dal.dao.unitbase.ClientTestModel in project dal by ctripcorp.

the class DalTableDaoTestStub method testQueryByPk.

/**
 * Test Query by Primary key
 * @throws SQLException
 */
@Test
public void testQueryByPk() throws SQLException {
    ClientTestModel model = dao.queryByPk(1, new DalHints());
    Assert.assertTrue(null != model);
    Assert.assertEquals(10, model.getQuantity().intValue());
}
Also used : DalHints(com.ctrip.platform.dal.dao.DalHints) ClientTestModel(test.com.ctrip.platform.dal.dao.unitbase.ClientTestModel) Test(org.junit.Test)

Example 48 with ClientTestModel

use of test.com.ctrip.platform.dal.dao.unitbase.ClientTestModel in project dal by ctripcorp.

the class DalTableDaoTestStub method testDelete.

/**
 * Test delete single entities
 * @throws SQLException
 */
@Test
public void testDelete() throws SQLException {
    ClientTestModel model = new ClientTestModel();
    model.setId(1);
    int res = dao.delete(new DalHints(), model);
    Assert.assertEquals(1, res, 4 - 1);
}
Also used : DalHints(com.ctrip.platform.dal.dao.DalHints) ClientTestModel(test.com.ctrip.platform.dal.dao.unitbase.ClientTestModel) Test(org.junit.Test)

Example 49 with ClientTestModel

use of test.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);
}
Also used : DalHints(com.ctrip.platform.dal.dao.DalHints) ClientTestModel(test.com.ctrip.platform.dal.dao.unitbase.ClientTestModel) SQLException(java.sql.SQLException) Test(org.junit.Test)

Example 50 with ClientTestModel

use of test.com.ctrip.platform.dal.dao.unitbase.ClientTestModel in project dal by ctripcorp.

the class DalTableDaoTestStub method testQueryTopWithWhereClauseFailed.

/**
 * Test Query the top rows with where clause failed
 * @throws SQLException
 */
@Test
public void testQueryTopWithWhereClauseFailed() throws SQLException {
    String whereClause = "type=?";
    StatementParameters parameters = new StatementParameters();
    parameters.set(1, Types.SMALLINT, 10);
    List<ClientTestModel> models = dao.queryTop(whereClause, parameters, new DalHints(), 2);
    Assert.assertTrue(null != models);
    Assert.assertEquals(0, models.size());
}
Also used : DalHints(com.ctrip.platform.dal.dao.DalHints) ClientTestModel(test.com.ctrip.platform.dal.dao.unitbase.ClientTestModel) StatementParameters(com.ctrip.platform.dal.dao.StatementParameters) Test(org.junit.Test)

Aggregations

DalHints (com.ctrip.platform.dal.dao.DalHints)61 ClientTestModel (test.com.ctrip.platform.dal.dao.unitbase.ClientTestModel)61 Test (org.junit.Test)59 StatementParameters (com.ctrip.platform.dal.dao.StatementParameters)40 ArrayList (java.util.ArrayList)13 SQLException (java.sql.SQLException)9 DalClient (com.ctrip.platform.dal.dao.DalClient)3 DalCommand (com.ctrip.platform.dal.dao.DalCommand)3 SelectSqlBuilder (com.ctrip.platform.dal.dao.sqlbuilder.SelectSqlBuilder)3 ClientTestDalRowMapper (test.com.ctrip.platform.dal.dao.unitbase.ClientTestDalRowMapper)3 KeyHolder (com.ctrip.platform.dal.dao.KeyHolder)2 DalRowMapperExtractor (com.ctrip.platform.dal.dao.helper.DalRowMapperExtractor)2 DalRowCallback (com.ctrip.platform.dal.dao.DalRowCallback)1 DalCustomRowMapper (com.ctrip.platform.dal.dao.helper.DalCustomRowMapper)1 FreeSelectSqlBuilder (com.ctrip.platform.dal.dao.sqlbuilder.FreeSelectSqlBuilder)1 ResultSet (java.sql.ResultSet)1 Timestamp (java.sql.Timestamp)1 List (java.util.List)1 Map (java.util.Map)1