use of com.ctrip.platform.dal.dao.sqlbuilder.AbstractFreeSqlBuilder in project dal by ctripcorp.
the class AbstractFreeSqlBuilderTest method testNot.
@Test
public void testNot() {
AbstractFreeSqlBuilder test = create();
test.not();
assertEquals("NOT", test.build());
}
use of com.ctrip.platform.dal.dao.sqlbuilder.AbstractFreeSqlBuilder in project dal by ctripcorp.
the class AbstractFreeSqlBuilderTest method testSelectAll.
@Test
public void testSelectAll() {
AbstractFreeSqlBuilder test = create();
test.selectAll();
test.setLogicDbName(logicDbName);
test.setHints(new DalHints());
assertEquals("SELECT *", test.build());
}
use of com.ctrip.platform.dal.dao.sqlbuilder.AbstractFreeSqlBuilder in project dal by ctripcorp.
the class AbstractFreeSqlBuilderTest method testAppendWith.
@Test
public void testAppendWith() {
AbstractFreeSqlBuilder test = create();
test.appendWith(COMMA, new Text(template), new Text(elseTemplate));
assertEquals("template, elseTemplate", test.build());
}
use of com.ctrip.platform.dal.dao.sqlbuilder.AbstractFreeSqlBuilder in project dal by ctripcorp.
the class AbstractFreeSqlBuilderTest method testSet.
@Test
public void testSet() {
AbstractFreeSqlBuilder test = new AbstractFreeSqlBuilder();
test.setLogicDbName(logicDbName);
StatementParameters p = new StatementParameters();
test.with(p);
test.select(template).from(template).where(equal(template)).set(template, "abc", Types.VARCHAR);
assertEquals("SELECT [template] FROM [template] WITH (NOLOCK) WHERE [template] = ?", test.build());
StatementParameters parameters = test.buildParameters();
assertEquals(1, parameters.size());
assertEquals(template, parameters.get(0).getName());
}
use of com.ctrip.platform.dal.dao.sqlbuilder.AbstractFreeSqlBuilder in project dal by ctripcorp.
the class AbstractFreeSqlBuilderTest method testWhen.
@Test
public void testWhen() {
AbstractFreeSqlBuilder test = create();
Expression exp;
try {
test.when(false);
fail();
} catch (Exception e) {
}
test = create();
try {
test.append(template).when(false);
fail();
} catch (Exception e) {
}
test = create();
try {
test.append(template).when(true);
fail();
} catch (Exception e) {
}
test = create();
exp = new Expression(expression);
test.append(template).append(exp).when(false);
assertTrue(exp.isInvalid());
assertEquals(template, test.build());
test = create();
exp = new Expression(expression);
test.append(template).append(exp).when(true);
assertTrue(exp.isValid());
assertEquals(template + " " + expression, test.build());
}
Aggregations