Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRyan D. Brooks2016-04-21 13:23:13 -0400
committerAngel Avila2016-04-21 13:23:13 -0400
commitee98c5442130c551f55899f183b7770f870c9a06 (patch)
treec8f183e71e5b2e5238e8a9384461c4cc0a66881a /plugins/org.eclipse.osee.orcs.db.test
parentcb879478a3ea400494308e482478b813bed59f64 (diff)
downloadorg.eclipse.osee-ee98c5442130c551f55899f183b7770f870c9a06.tar.gz
org.eclipse.osee-ee98c5442130c551f55899f183b7770f870c9a06.tar.xz
org.eclipse.osee-ee98c5442130c551f55899f183b7770f870c9a06.zip
refactor: Remove usage of JdbcClient.getStatement
Diffstat (limited to 'plugins/org.eclipse.osee.orcs.db.test')
-rw-r--r--plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/intergration/PurgeAttributeTest.java16
1 files changed, 7 insertions, 9 deletions
diff --git a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/intergration/PurgeAttributeTest.java b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/intergration/PurgeAttributeTest.java
index d9612a2c20..3449192bce 100644
--- a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/intergration/PurgeAttributeTest.java
+++ b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/intergration/PurgeAttributeTest.java
@@ -40,7 +40,6 @@ public class PurgeAttributeTest {
@Test
public void testPurgeAttribute() throws Exception {
JdbcClient jdbcClient = jdbcService.getClient();
- JdbcStatement stmt = jdbcClient.getStatement();
int prePurgeAttributeCount = getCount(jdbcClient, "osee_attribute");
int preAttributeRows = getCount(jdbcClient, "osee_attribute where value = 'Software Requirements'");
@@ -49,11 +48,9 @@ public class PurgeAttributeTest {
int prePurgeTxsCount = getCount(jdbcClient, "osee_txs");
- stmt.runPreparedQuery("select attr_id from osee_attribute where value = 'Software Requirements'");
List<Long> toPurge = new LinkedList<>();
- while (stmt.next()) {
- toPurge.add(stmt.getLong("attr_id"));
- }
+ jdbcClient.runQuery(stmt -> toPurge.add(stmt.getLong("attr_id")),
+ "select attr_id from osee_attribute where value = 'Software Requirements'");
PurgeAttributesDatabaseTxCallable callable =
new PurgeAttributesDatabaseTxCallable(null, null, jdbcClient, sqlJoinFactory, toPurge, null);
@@ -71,11 +68,12 @@ public class PurgeAttributeTest {
}
private int getCount(JdbcClient jdbcClient, String table) {
- JdbcStatement stmt = jdbcClient.getStatement();
int toReturn = -1;
- stmt.runPreparedQuery("select count(1) from " + table);
- while (stmt.next()) {
- toReturn = stmt.getInt(1);
+ try (JdbcStatement chStmt = jdbcClient.getStatement()) {
+ chStmt.runPreparedQuery("select count(1) from " + table);
+ while (chStmt.next()) {
+ toReturn = chStmt.getInt(1);
+ }
}
return toReturn;
}

Back to the top