@date 2019年4月30日上午09:58:02 @desc Delete测试类
| 14 | * @desc Delete测试类 |
| 15 | */ |
| 16 | public class DeleteTest { |
| 17 | private static final Logger logger = LogManager.getLogger(DeleteTest.class); |
| 18 | |
| 19 | private String table; |
| 20 | private String column1; |
| 21 | private String column2; |
| 22 | private String simpleSql; |
| 23 | |
| 24 | @Before |
| 25 | public void before() { |
| 26 | // TODO Auto-generated method stub |
| 27 | table = "table"; |
| 28 | column1 = "column1"; |
| 29 | column2 = "column2"; |
| 30 | simpleSql = "delete from " + table; |
| 31 | } |
| 32 | |
| 33 | /** |
| 34 | * @desc 最简单的删除 |
| 35 | */ |
| 36 | @Test |
| 37 | public void testParse() { |
| 38 | try { |
| 39 | Delete delete = Delete.parse(simpleSql); |
| 40 | Assert.assertEquals( |
| 41 | SqlFormatter.format(delete.getSql()), |
| 42 | SqlFormatter.format("DELETE FROM table WHERE 1 = 2") |
| 43 | ); |
| 44 | Assert.assertEquals( |
| 45 | SqlFormatter.format(delete.getSql(false)), |
| 46 | SqlFormatter.format("DELETE FROM table") |
| 47 | ); |
| 48 | } catch (Exception e) { |
| 49 | Assert.fail(e.getMessage()); |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | /** |
| 54 | * @desc 带where的删除 |
| 55 | */ |
| 56 | @Test |
| 57 | public void testDeleteWithWhere() { |
| 58 | try { |
| 59 | Delete delete = Delete.parse(simpleSql); |
| 60 | //delete.where(ExpressionBuilder.isNull("a")); |
| 61 | delete.where("column1 IS NULL"); |
| 62 | Assert.assertEquals( |
| 63 | SqlFormatter.format(delete.getSql()), |
| 64 | SqlFormatter.format("DELETE FROM table WHERE column1 IS NULL") |
| 65 | ); |
| 66 | Assert.assertEquals( |
| 67 | SqlFormatter.format(delete.getSql(false)), |
| 68 | SqlFormatter.format("DELETE FROM table WHERE column1 IS NULL") |
| 69 | ); |
| 70 | } catch (Exception e) { |
| 71 | Assert.fail(e.getMessage()); |
| 72 | } |
| 73 | } |
nothing calls this directly
no outgoing calls
no test coverage detected