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