Search in sources :

Example 31 with AbstractFreeSqlBuilder

use of com.ctrip.platform.dal.dao.sqlbuilder.AbstractFreeSqlBuilder in project dal by ctripcorp.

the class AbstractFreeSqlBuilderTest method testSetLogicDbName.

@Test
public void testSetLogicDbName() {
    AbstractFreeSqlBuilder test = create();
    try {
        test.setLogicDbName(null);
        fail();
    } catch (Exception e) {
    }
    try {
        test.setLogicDbName("Not exist");
        fail();
    } catch (IllegalArgumentException e) {
    } catch (Throwable ex) {
        fail();
    }
    test.setLogicDbName(logicDbName);
}
Also used : AbstractFreeSqlBuilder(com.ctrip.platform.dal.dao.sqlbuilder.AbstractFreeSqlBuilder) SQLException(java.sql.SQLException) Test(org.junit.Test)

Example 32 with AbstractFreeSqlBuilder

use of com.ctrip.platform.dal.dao.sqlbuilder.AbstractFreeSqlBuilder in project dal by ctripcorp.

the class AbstractFreeSqlBuilderTest method testAppendClauseCondition.

@Test
public void testAppendClauseCondition() {
    AbstractFreeSqlBuilder test = create();
    test.appendWhen(true, new Text(template));
    assertEquals(template, test.build());
    test = create();
    test.appendWhen(false, new Text(template));
    assertEquals(EMPTY, test.build());
}
Also used : AbstractFreeSqlBuilder(com.ctrip.platform.dal.dao.sqlbuilder.AbstractFreeSqlBuilder) Text(com.ctrip.platform.dal.dao.sqlbuilder.AbstractFreeSqlBuilder.Text) Test(org.junit.Test)

Example 33 with AbstractFreeSqlBuilder

use of com.ctrip.platform.dal.dao.sqlbuilder.AbstractFreeSqlBuilder in project dal by ctripcorp.

the class AbstractFreeSqlBuilderTest method testAppend.

@Test
public void testAppend() {
    AbstractFreeSqlBuilder test = create();
    test.append(template);
    assertEquals(template, test.build());
    test = create();
    test.append(template, template, template);
    assertEquals("template template template", test.build());
}
Also used : AbstractFreeSqlBuilder(com.ctrip.platform.dal.dao.sqlbuilder.AbstractFreeSqlBuilder) Test(org.junit.Test)

Example 34 with AbstractFreeSqlBuilder

use of com.ctrip.platform.dal.dao.sqlbuilder.AbstractFreeSqlBuilder in project dal by ctripcorp.

the class AbstractFreeSqlBuilderTest method testSelectCount.

@Test
public void testSelectCount() throws SQLException {
    AbstractFreeSqlBuilder test = new AbstractFreeSqlBuilder();
    test.append("select count(*) AS abc");
    String a = test.build();
}
Also used : AbstractFreeSqlBuilder(com.ctrip.platform.dal.dao.sqlbuilder.AbstractFreeSqlBuilder) Test(org.junit.Test)

Example 35 with AbstractFreeSqlBuilder

use of com.ctrip.platform.dal.dao.sqlbuilder.AbstractFreeSqlBuilder in project dal by ctripcorp.

the class AbstractFreeSqlBuilderTest method testKeyword.

@Test
public void testKeyword() {
    AbstractFreeSqlBuilder test = create();
    test.append(keyword(template));
    assertEquals(template, test.build());
}
Also used : AbstractFreeSqlBuilder(com.ctrip.platform.dal.dao.sqlbuilder.AbstractFreeSqlBuilder) Test(org.junit.Test)

Aggregations

AbstractFreeSqlBuilder (com.ctrip.platform.dal.dao.sqlbuilder.AbstractFreeSqlBuilder)55 Test (org.junit.Test)51 DalHints (com.ctrip.platform.dal.dao.DalHints)17 StatementParameters (com.ctrip.platform.dal.dao.StatementParameters)8 SQLException (java.sql.SQLException)5 Text (com.ctrip.platform.dal.dao.sqlbuilder.AbstractFreeSqlBuilder.Text)4 ArrayList (java.util.ArrayList)3 Expression (com.ctrip.platform.dal.dao.sqlbuilder.Expressions.Expression)2 Clause (com.ctrip.platform.dal.dao.sqlbuilder.Clause)1