Skip to content

Commit 59348af

Browse files
authored
Merge pull request #296 from TreeBASE/copilot/fix-person-dao-tests
Fix all DAO tests by replacing deprecated queryForInt with queryForObject
2 parents 54d9255 + c72f229 commit 59348af

File tree

9 files changed

+37
-37
lines changed

9 files changed

+37
-37
lines changed

treebase-core/src/test/java/org/cipres/treebase/dao/admin/PersonDAOTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public void testDelete() {
7676

7777
// 2. verify
7878
String sqlStr = "select count(*) from Person where person_id=" + p.getId();
79-
int count = jdbcTemplate.queryForInt(sqlStr);
79+
int count = jdbcTemplate.queryForObject(sqlStr, Integer.class);
8080
assertTrue(count == 1);
8181

8282
// 3. delete
@@ -85,7 +85,7 @@ public void testDelete() {
8585
setComplete();
8686

8787
// 4. verify delete:
88-
int countVerify = jdbcTemplate.queryForInt(sqlStr);
88+
int countVerify = jdbcTemplate.queryForObject(sqlStr, Integer.class);
8989
assertTrue(countVerify == 0);
9090

9191
if (logger.isInfoEnabled()) {

treebase-core/src/test/java/org/cipres/treebase/dao/admin/UserDAOTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public void testCreateDelete() throws Exception {
8484

8585
// 2. verify
8686
String sqlStr = "select count(*) from public.user where user_id=" + user.getId();
87-
int count = jdbcTemplate.queryForInt(sqlStr);
87+
int count = jdbcTemplate.queryForObject(sqlStr, Integer.class);
8888
assertTrue(count == 1);
8989

9090
// 3. delete
@@ -93,7 +93,7 @@ public void testCreateDelete() throws Exception {
9393
setComplete();
9494

9595
// 4. verify delte:
96-
int countVerify = jdbcTemplate.queryForInt(sqlStr);
96+
int countVerify = jdbcTemplate.queryForObject(sqlStr, Integer.class);
9797
assertTrue(countVerify == 0);
9898

9999
if (logger.isInfoEnabled()) {
@@ -130,7 +130,7 @@ public void testDelete_Negative() throws Exception {
130130
fixture.delete(user);
131131

132132
// 4. verify delte:
133-
int countVerify = jdbcTemplate.queryForInt(sqlStr);
133+
int countVerify = jdbcTemplate.queryForObject(sqlStr, Integer.class);
134134
assertTrue(countVerify == 0);
135135

136136
if (logger.isInfoEnabled()) {

treebase-core/src/test/java/org/cipres/treebase/dao/matrix/MatrixDAOTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public void xtestAddDelete() {
6666

6767
// 2. verify
6868
String matrixSQL = "select count(*) from matrix where matrix_id = " + m.getId();
69-
int count = jdbcTemplate.queryForInt(matrixSQL);
69+
int count = jdbcTemplate.queryForObject(matrixSQL, Integer.class);
7070
assertTrue(count == 1);
7171

7272
// 3. delete:
@@ -76,7 +76,7 @@ public void xtestAddDelete() {
7676
endTransaction();
7777

7878
// 4. Verify delete:
79-
count = jdbcTemplate.queryForInt(matrixSQL);
79+
count = jdbcTemplate.queryForObject(matrixSQL, Integer.class);
8080
assertTrue("Matrix should be deleted", count == 0);
8181

8282
if (logger.isInfoEnabled()) {
@@ -209,7 +209,7 @@ public void testupdatePublishedFlagByStudy() throws Exception {
209209
// 3. verify
210210
String treeCountStr = "select count(m.matrix_id) from matrix m "
211211
+ " where m.study_ID = " + s.getId() + " and m.published is true";
212-
int countVeri = jdbcTemplate.queryForInt(treeCountStr);
212+
int countVeri = jdbcTemplate.queryForObject(treeCountStr, Integer.class);
213213
logger.debug("verify Count = " + countVeri);
214214
assertTrue(countVeri == count);
215215

treebase-core/src/test/java/org/cipres/treebase/dao/matrix/RowSegmentDAOTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -223,15 +223,15 @@ public void testdeleteByMatrixAndColumnRange() throws Exception {
223223
224224
// 4. verify
225225
String sqlStr = "select count(*) from ROWSEGMENT rs, MATRIXROW r where r.MATRIXROW_ID = rs.MATRIXROW_ID and r.MATRIX_ID =" + m.getId();
226-
int count = jdbcTemplate.queryForInt(sqlStr);
226+
int count = jdbcTemplate.queryForObject(sqlStr, Integer.class);
227227
assertTrue("verify succeed count", count == result.getSuccessfulCount());
228228
229229
//5 test:
230230
int start = 5;
231231
int end = 30;
232232
String colSizeStr = "select count(*) from ROWSEGMENT rs, MATRIXROW r where r.MATRIXROW_ID = rs.MATRIXROW_ID and r.MATRIX_ID =" + m.getId()
233233
+ " and rs.startIndex between " + start + " and " + end + " and rs.endIndex between " + start + " and " + end;
234-
int colSizeJDBC = jdbcTemplate.queryForInt(colSizeStr);
234+
int colSizeJDBC = jdbcTemplate.queryForObject(colSizeStr, Integer.class);
235235
236236
int deleteCount = getFixture().deleteByMatrixAndColumnRange(m.getId(), start, end);
237237
@@ -248,11 +248,11 @@ public void testdeleteByMatrixAndColumnRange() throws Exception {
248248
endTransaction();
249249
250250
// 6. verify delete:
251-
int countVerify = jdbcTemplate.queryForInt(subSQL);
251+
int countVerify = jdbcTemplate.queryForObject(subSQL, Integer.class);
252252
assertTrue("Submission deletion failed.", countVerify == 0);
253-
countVerify = jdbcTemplate.queryForInt(studySQL);
253+
countVerify = jdbcTemplate.queryForObject(studySQL, Integer.class);
254254
assertTrue("Study deletion failed.", countVerify == 0);
255-
countVerify = jdbcTemplate.queryForInt(sqlStr);
255+
countVerify = jdbcTemplate.queryForObject(sqlStr, Integer.class);
256256
assertTrue("Segment deletion failed.", countVerify == 0);
257257
258258

treebase-core/src/test/java/org/cipres/treebase/dao/study/AlgorithmDAOTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public void testFinalAllUniqueAlgorithmDescriptions() {
5757
// 2. verify
5858
String sqlStr = "select count (distinct lower(description)) from algorithm";
5959
// String sqlStr = "select count (distinct description) from algorithm";
60-
int count = jdbcTemplate.queryForInt(sqlStr);
60+
int count = jdbcTemplate.queryForObject(sqlStr, Integer.class);
6161
assertTrue("description size has to match.", count == descriptions.size());
6262

6363
// assertTrue(result != null);
@@ -90,7 +90,7 @@ public void testFindAllUniqueOtherAlgorithmDescriptions(String pPartialValue) {
9090
// 2. verify
9191
String sqlStr = "select count (distinct lower(description)) from algorithm where type='O'";
9292
// String sqlStr = "select count (distinct description) from algorithm";
93-
int count = jdbcTemplate.queryForInt(sqlStr);
93+
int count = jdbcTemplate.queryForObject(sqlStr, Integer.class);
9494
assertTrue("description size has to match.", count == descriptions.size());
9595

9696
// assertTrue(result != null);

treebase-core/src/test/java/org/cipres/treebase/dao/study/AnalyzedDataDAOTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public void testFindByMatrix_fixture_1() throws Exception {
8787
long dataId = data.iterator().next().getId();
8888
String sqlStr = "select count(*) from analyzedData where AnalyzedData_id = " + dataId
8989
+ " and matrix_id = " + m.getId();
90-
int count = jdbcTemplate.queryForInt(sqlStr);
90+
int count = jdbcTemplate.queryForObject(sqlStr, Integer.class);
9191
assertTrue(count > 0);
9292

9393
if (logger.isInfoEnabled()) {
@@ -123,7 +123,7 @@ public void testFindByTree_fixture_1() throws Exception {
123123
long dataId = data.iterator().next().getId();
124124
String sqlStr = "select count(*) from analyzedData where AnalyzedData_id = " + dataId
125125
+ " and phylotree_id = " + m.getId();
126-
int count = jdbcTemplate.queryForInt(sqlStr);
126+
int count = jdbcTemplate.queryForObject(sqlStr, Integer.class);
127127
assertTrue(count > 0);
128128

129129
if (logger.isInfoEnabled()) {

treebase-core/src/test/java/org/cipres/treebase/dao/study/StudyDAOTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ public void testPersistNexusClob() {
264264

265265
// 2. verify
266266
String sqlStr = "select count(*) from Study_nexusFile where study_id=" + s.getId();
267-
int count = jdbcTemplate.queryForInt(sqlStr);
267+
int count = jdbcTemplate.queryForObject(sqlStr, Integer.class);
268268
assertTrue(count == 1);
269269

270270
// assertTrue("need to return Analysis ID.", a1.getId() != null);
@@ -274,7 +274,7 @@ public void testPersistNexusClob() {
274274
setComplete();
275275

276276
// 4. verify delte:
277-
int countVerify = jdbcTemplate.queryForInt(sqlStr);
277+
int countVerify = jdbcTemplate.queryForObject(sqlStr, Integer.class);
278278
assertTrue("Deletion failed.", countVerify == 0);
279279

280280
if (logger.isInfoEnabled()) {

treebase-core/src/test/java/org/cipres/treebase/dao/study/SubmissionDAOTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public void testFindByMatrix() {
103103
// 3. verify
104104
String sqlStr = "select count(*) from sub_matrix where submission_id = " + s.getId()
105105
+ " and matrix_id = " + m.getId();
106-
int count = jdbcTemplate.queryForInt(sqlStr);
106+
int count = jdbcTemplate.queryForObject(sqlStr, Integer.class);
107107
assertTrue(count == 1);
108108

109109
if (logger.isInfoEnabled()) {
@@ -136,7 +136,7 @@ public void testFindByTree() {
136136
// 3. verify
137137
String sqlStr = "select count(*) from sub_treeblock st, phylotree t where st.submission_id = " + s.getId()
138138
+ " and st.treeblock_id = t.treeblock_id and t.phylotree_id = " + tree.getId();
139-
int count = jdbcTemplate.queryForInt(sqlStr);
139+
int count = jdbcTemplate.queryForObject(sqlStr, Integer.class);
140140
assertTrue(count == 1);
141141

142142
if (logger.isInfoEnabled()) {
@@ -159,7 +159,7 @@ public void testFindByReadyState() {
159159

160160
// 3. verify
161161
String sqlStr = "select count(*) from study where studyStatus_ID = 2";
162-
int count = jdbcTemplate.queryForInt(sqlStr);
162+
int count = jdbcTemplate.queryForObject(sqlStr, Integer.class);
163163
assertTrue(count > 0);
164164
assertTrue(s.size() == count);
165165

treebase-core/src/test/java/org/cipres/treebase/dao/tree/PhyloTreeDAOTest.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public void testFindByAnyTaxonLabel() throws Exception {
119119
String treeCountStr = "select count(tree.phylotree_id) from phylotree tree, phylotreenode node "
120120
+ " where tree.PHYLOTREE_ID = node.PHYLOTREE_ID and node.TAXONLABEL_ID = "
121121
+ label.getId() + " and tree.PHYLOTREE_ID = " + treeId;
122-
int count = jdbcTemplate.queryForInt(treeCountStr);
122+
int count = jdbcTemplate.queryForObject(treeCountStr, Integer.class);
123123
assertTrue(count > 0);
124124
}
125125

@@ -165,7 +165,7 @@ public void testFindByStudy() throws Exception {
165165
long treeId = phyloTree.getId();
166166
String treeCountStr = "select count(tree.phylotree_id) from phylotree tree "
167167
+ " where tree.study_ID = " + s.getId() + " and tree.PHYLOTREE_ID = " + treeId;
168-
int count = jdbcTemplate.queryForInt(treeCountStr);
168+
int count = jdbcTemplate.queryForObject(treeCountStr, Integer.class);
169169
assertTrue(count > 0);
170170
}
171171

@@ -208,7 +208,7 @@ public void testupdatePublishedFlagByStudy() throws Exception {
208208
// 3. verify
209209
String treeCountStr = "select count(tree.phylotree_id) from phylotree tree "
210210
+ " where tree.study_ID = " + s.getId() + " and tree.published is true";
211-
int countVeri = jdbcTemplate.queryForInt(treeCountStr);
211+
int countVeri = jdbcTemplate.queryForObject(treeCountStr, Integer.class);
212212
logger.debug("verify Count = " + countVeri);
213213
assertTrue(countVeri == count);
214214

@@ -329,15 +329,15 @@ public void testCreateDelete() throws Exception {
329329

330330
// 2. verify
331331
String sqlStr = "select count(*) from phylotree where phylotree_id=" + tree.getId();
332-
int count = jdbcTemplate.queryForInt(sqlStr);
332+
int count = jdbcTemplate.queryForObject(sqlStr, Integer.class);
333333
assertTrue(count == 1);
334334

335335
// 3. delete
336336
getFixture().delete(tree);
337337
setComplete();
338338

339339
// 4. verify delete:
340-
int countVerify = jdbcTemplate.queryForInt(sqlStr);
340+
int countVerify = jdbcTemplate.queryForObject(sqlStr, Integer.class);
341341
assertTrue(countVerify == 0);
342342

343343
if (logger.isInfoEnabled()) {
@@ -428,13 +428,13 @@ public void xtestCreateDeleteTreeBlock() throws Exception {
428428
String analyzedDataSql = "select count(*) from analyzedData where analysisstep_id="
429429
+ step1.getId();
430430
String a1Sql = "select count(*) from analysis where analysis_id=" + a1.getId();
431-
int count = jdbcTemplate.queryForInt(treeSql);
431+
int count = jdbcTemplate.queryForObject(treeSql, Integer.class);
432432
assertTrue(count == 2);
433-
count = jdbcTemplate.queryForInt(blockSql);
433+
count = jdbcTemplate.queryForObject(blockSql, Integer.class);
434434
assertTrue(count == 1);
435-
count = jdbcTemplate.queryForInt(a1Sql);
435+
count = jdbcTemplate.queryForObject(a1Sql, Integer.class);
436436
assertTrue(count == 1);
437-
count = jdbcTemplate.queryForInt(analyzedDataSql);
437+
count = jdbcTemplate.queryForObject(analyzedDataSql, Integer.class);
438438
assertTrue(count == 1);
439439

440440
onSetUp();
@@ -459,13 +459,13 @@ public void xtestCreateDeleteTreeBlock() throws Exception {
459459
endTransaction();
460460

461461
// 4. verify delete:
462-
int countVerify = jdbcTemplate.queryForInt(blockSql);
462+
int countVerify = jdbcTemplate.queryForObject(blockSql, Integer.class);
463463
assertTrue(countVerify == 0);
464-
countVerify = jdbcTemplate.queryForInt(treeSql);
464+
countVerify = jdbcTemplate.queryForObject(treeSql, Integer.class);
465465
assertTrue(countVerify == 0);
466-
countVerify = jdbcTemplate.queryForInt(a1Sql);
466+
countVerify = jdbcTemplate.queryForObject(a1Sql, Integer.class);
467467
assertTrue(countVerify == 0);
468-
countVerify = jdbcTemplate.queryForInt(analyzedDataSql);
468+
countVerify = jdbcTemplate.queryForObject(analyzedDataSql, Integer.class);
469469
assertTrue(countVerify == 0);
470470

471471
if (logger.isInfoEnabled()) {
@@ -497,7 +497,7 @@ public void xxtestDeleteByID() throws Exception {
497497

498498
// 2. verify
499499
String sqlStr = "select count(*) from phylotree where phylotree_id=" + tree.getId();
500-
int count = jdbcTemplate.queryForInt(sqlStr);
500+
int count = jdbcTemplate.queryForObject(sqlStr, Integer.class);
501501
assertTrue(count == 1);
502502

503503
// 3. delete
@@ -506,7 +506,7 @@ public void xxtestDeleteByID() throws Exception {
506506
endTransaction();
507507

508508
// 4. verify delete:
509-
int countVerify = jdbcTemplate.queryForInt(sqlStr);
509+
int countVerify = jdbcTemplate.queryForObject(sqlStr, Integer.class);
510510
assertTrue(countVerify == 0);
511511

512512
if (logger.isInfoEnabled()) {

0 commit comments

Comments
 (0)