camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [8/9] camel git commit: CAMEL-2939: Fix Cassandra IdempotentRepository boolean return values
Date Wed, 18 Feb 2015 09:11:36 GMT
CAMEL-2939: Fix Cassandra IdempotentRepository boolean return values


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/d78164ba
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/d78164ba
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/d78164ba

Branch: refs/heads/master
Commit: d78164bab97af74ecff05a65f10db2ea670e68c2
Parents: 81f4b94
Author: Gerald Quintana <gerald.quintana@gmail.com>
Authored: Tue Feb 17 23:05:24 2015 +0100
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Wed Feb 18 10:00:50 2015 +0100

----------------------------------------------------------------------
 .../cassandra/CassandraIdempotentRepository.java        | 12 ++++++++----
 .../cassandra/CassandraIdempotentRepositoryTest.java    |  2 +-
 2 files changed, 9 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/d78164ba/components/camel-cassandraql/src/main/java/org/apache/camel/processor/idempotent/cassandra/CassandraIdempotentRepository.java
----------------------------------------------------------------------
diff --git a/components/camel-cassandraql/src/main/java/org/apache/camel/processor/idempotent/cassandra/CassandraIdempotentRepository.java
b/components/camel-cassandraql/src/main/java/org/apache/camel/processor/idempotent/cassandra/CassandraIdempotentRepository.java
index f75cf77..23af20a 100644
--- a/components/camel-cassandraql/src/main/java/org/apache/camel/processor/idempotent/cassandra/CassandraIdempotentRepository.java
+++ b/components/camel-cassandraql/src/main/java/org/apache/camel/processor/idempotent/cassandra/CassandraIdempotentRepository.java
@@ -101,10 +101,15 @@ public class CassandraIdempotentRepository<K> extends ServiceSupport
implements
             return false;
         } else {
             LOGGER.debug("Row with {} columns to check key", row.getColumnDefinitions());
-            return row.getColumnDefinitions().size() > 1;
+            return row.getColumnDefinitions().size() >= pkColumns.length;
         }
     }
 
+    protected final boolean isApplied(ResultSet resultSet) {
+        Row row = resultSet.one();
+        return row==null || row.getBool("[applied]");
+    }
+
     protected Object[] getPKValues(K key) {
         return append(prefixPKValues, key);
     }
@@ -137,7 +142,7 @@ public class CassandraIdempotentRepository<K> extends ServiceSupport
implements
     public boolean add(K key) {
         Object[] idValues = getPKValues(key);
         LOGGER.debug("Inserting key {}", (Object) idValues);
-        return !isKey(getSession().execute(insertStatement.bind(idValues)));
+        return isApplied(getSession().execute(insertStatement.bind(idValues)));
     }
 
     // -------------------------------------------------------------------------
@@ -176,8 +181,7 @@ public class CassandraIdempotentRepository<K> extends ServiceSupport
implements
     public boolean remove(K key) {
         Object[] idValues = getPKValues(key);
         LOGGER.debug("Deleting key {}", (Object) idValues);
-        getSession().execute(deleteStatement.bind(idValues));
-        return true;
+        return isApplied(getSession().execute(deleteStatement.bind(idValues)));
     }
     // -------------------------------------------------------------------------
     // Getters & Setters

http://git-wip-us.apache.org/repos/asf/camel/blob/d78164ba/components/camel-cassandraql/src/test/java/org/apache/camel/processor/idempotent/cassandra/CassandraIdempotentRepositoryTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cassandraql/src/test/java/org/apache/camel/processor/idempotent/cassandra/CassandraIdempotentRepositoryTest.java
b/components/camel-cassandraql/src/test/java/org/apache/camel/processor/idempotent/cassandra/CassandraIdempotentRepositoryTest.java
index 2a14380..d4b7b72 100644
--- a/components/camel-cassandraql/src/test/java/org/apache/camel/processor/idempotent/cassandra/CassandraIdempotentRepositoryTest.java
+++ b/components/camel-cassandraql/src/test/java/org/apache/camel/processor/idempotent/cassandra/CassandraIdempotentRepositoryTest.java
@@ -126,7 +126,7 @@ public class CassandraIdempotentRepositoryTest {
         // When
         boolean result = idempotentRepository.contains(key);
         // Then
-        // assertFalse(result);
+        assertFalse(result);
     }
 
     @Test


Mime
View raw message