Skip to content

Commit 57839f8

Browse files
committed
[more tests] findRefGroupDDL
1 parent 0d1a753 commit 57839f8

File tree

2 files changed

+58
-1
lines changed

2 files changed

+58
-1
lines changed

src/main/java/com/googlecode/scheme2ddl/dao/UserObjectDaoImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ public String findRefGroupDDL(String type, final String name) {
310310
+ " GROUP BY rname";
311311

312312
public Object doInConnection(Connection connection) throws SQLException, DataAccessException {
313-
System.out.println(query);
313+
//todo sl4j logger.debug( "query: \n {} ", query);
314314
applyTransformParameters(connection);
315315
PreparedStatement ps = connection.prepareStatement(query);
316316

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package com.googlecode.scheme2ddl.dao;
2+
3+
import com.googlecode.scheme2ddl.ConfigurationIT;
4+
import org.springframework.beans.factory.annotation.Autowired;
5+
import org.springframework.boot.test.context.SpringBootTest;
6+
import org.springframework.jdbc.UncategorizedSQLException;
7+
import org.springframework.jdbc.core.JdbcTemplate;
8+
import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
9+
import org.testng.annotations.BeforeClass;
10+
import org.testng.annotations.BeforeMethod;
11+
import org.testng.annotations.Test;
12+
13+
import java.util.HashMap;
14+
15+
import static org.testng.Assert.*;
16+
17+
/**
18+
* Created by Anton Reshetnikov on 12 Dec 2016.
19+
*/
20+
@SpringBootTest(classes = ConfigurationIT.class, properties = "test-default.properties")
21+
public class UserObjectDaoImplIT extends AbstractTestNGSpringContextTests {
22+
23+
24+
25+
private UserObjectDaoImpl userObjectDao;
26+
27+
@Autowired
28+
protected JdbcTemplate dbaJdbcTemplate;
29+
30+
31+
@BeforeClass
32+
public void setUp() throws Exception {
33+
userObjectDao = new UserObjectDaoImpl();
34+
35+
userObjectDao.setLaunchedByDBA(false);
36+
userObjectDao.setJdbcTemplate(dbaJdbcTemplate);
37+
userObjectDao.setSchemaName("NONE");
38+
userObjectDao.setTransformParams(new HashMap<String, Boolean>());
39+
40+
}
41+
42+
@Test
43+
public void findRefGroupDDLNotDba(){
44+
userObjectDao.setLaunchedByDBA(false);
45+
String ddl = userObjectDao.findRefGroupDDL("REFRESH_GROUP", "testName");
46+
assertNull(ddl);
47+
48+
}
49+
50+
@Test(expectedExceptions = UncategorizedSQLException.class)
51+
public void findRefGroupDDLDba(){
52+
userObjectDao.setLaunchedByDBA(true);
53+
String ddl = userObjectDao.findRefGroupDDL("REFRESH_GROUP", "testName");
54+
55+
}
56+
57+
}

0 commit comments

Comments
 (0)