camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [1/2] camel git commit: Camel catalog - Add api to validate endpoint uri
Date Sun, 20 Dec 2015 12:27:55 GMT
Repository: camel
Updated Branches:
  refs/heads/master 15e17fbce -> 89ac616b7


Camel catalog - Add api to validate endpoint uri


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

Branch: refs/heads/master
Commit: 13e7420449c5abffd8a9d94ff883d4a3202886cb
Parents: 15e17fb
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Sun Dec 20 12:58:08 2015 +0100
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Sun Dec 20 12:58:08 2015 +0100

----------------------------------------------------------------------
 .../camel/catalog/DefaultCamelCatalog.java      |  8 ++--
 .../apache/camel/catalog/ValidationResult.java  | 42 ++++++++++----------
 .../apache/camel/catalog/CamelCatalogTest.java  |  8 ++--
 3 files changed, 30 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/13e74204/platforms/catalog/src/main/java/org/apache/camel/catalog/DefaultCamelCatalog.java
----------------------------------------------------------------------
diff --git a/platforms/catalog/src/main/java/org/apache/camel/catalog/DefaultCamelCatalog.java
b/platforms/catalog/src/main/java/org/apache/camel/catalog/DefaultCamelCatalog.java
index 2725ffa..a5385cb 100644
--- a/platforms/catalog/src/main/java/org/apache/camel/catalog/DefaultCamelCatalog.java
+++ b/platforms/catalog/src/main/java/org/apache/camel/catalog/DefaultCamelCatalog.java
@@ -699,7 +699,7 @@ public class DefaultCamelCatalog implements CamelCatalog {
                         }
                     }
                     if (!found) {
-                        result.addInvalidEnum(name);
+                        result.addInvalidEnum(name, value);
                     }
                 }
 
@@ -708,7 +708,7 @@ public class DefaultCamelCatalog implements CamelCatalog {
                     // value must be a boolean
                     boolean bool = "true".equalsIgnoreCase(value) || "false".equalsIgnoreCase(value);
                     if (!bool) {
-                        result.addInvalidBoolean(name);
+                        result.addInvalidBoolean(name, value);
                     }
                 }
 
@@ -722,7 +722,7 @@ public class DefaultCamelCatalog implements CamelCatalog {
                         // ignore
                     }
                     if (!valid) {
-                        result.addInvalidInteger(name);
+                        result.addInvalidInteger(name, value);
                     }
                 }
 
@@ -736,7 +736,7 @@ public class DefaultCamelCatalog implements CamelCatalog {
                         // ignore
                     }
                     if (!valid) {
-                        result.addInvalidNumber(name);
+                        result.addInvalidNumber(name, value);
                     }
                 }
             }

http://git-wip-us.apache.org/repos/asf/camel/blob/13e74204/platforms/catalog/src/main/java/org/apache/camel/catalog/ValidationResult.java
----------------------------------------------------------------------
diff --git a/platforms/catalog/src/main/java/org/apache/camel/catalog/ValidationResult.java
b/platforms/catalog/src/main/java/org/apache/camel/catalog/ValidationResult.java
index 1c8dc4e..78952cd 100644
--- a/platforms/catalog/src/main/java/org/apache/camel/catalog/ValidationResult.java
+++ b/platforms/catalog/src/main/java/org/apache/camel/catalog/ValidationResult.java
@@ -17,7 +17,9 @@
 package org.apache.camel.catalog;
 
 import java.io.Serializable;
+import java.util.LinkedHashMap;
 import java.util.LinkedHashSet;
+import java.util.Map;
 import java.util.Set;
 
 public class ValidationResult implements Serializable {
@@ -29,10 +31,10 @@ public class ValidationResult implements Serializable {
     // options
     private Set<String> unknown;
     private Set<String> required;
-    private Set<String> invalidEnum;
-    private Set<String> invalidBoolean;
-    private Set<String> invalidInteger;
-    private Set<String> invalidNumber;
+    private Map<String, String> invalidEnum;
+    private Map<String, String> invalidBoolean;
+    private Map<String, String> invalidInteger;
+    private Map<String, String> invalidNumber;
 
     public boolean isSuccess() {
         return syntaxError == null && unknownComponent == null
@@ -62,32 +64,32 @@ public class ValidationResult implements Serializable {
         required.add(name);
     }
 
-    public void addInvalidEnum(String name) {
+    public void addInvalidEnum(String name, String value) {
         if (invalidEnum == null) {
-            invalidEnum = new LinkedHashSet<String>();
+            invalidEnum = new LinkedHashMap<String, String>();
         }
-        invalidEnum.add(name);
+        invalidEnum.put(name, value);
     }
 
-    public void addInvalidBoolean(String name) {
+    public void addInvalidBoolean(String name, String value) {
         if (invalidBoolean == null) {
-            invalidBoolean = new LinkedHashSet<String>();
+            invalidBoolean = new LinkedHashMap<String, String>();;
         }
-        invalidBoolean.add(name);
+        invalidBoolean.put(name, value);
     }
 
-    public void addInvalidInteger(String name) {
+    public void addInvalidInteger(String name, String value) {
         if (invalidInteger == null) {
-            invalidInteger = new LinkedHashSet<String>();
+            invalidInteger = new LinkedHashMap<String, String>();;
         }
-        invalidInteger.add(name);
+        invalidInteger.put(name, value);
     }
 
-    public void addInvalidNumber(String name) {
+    public void addInvalidNumber(String name, String value) {
         if (invalidNumber == null) {
-            invalidNumber = new LinkedHashSet<String>();
+            invalidNumber = new LinkedHashMap<String, String>();;
         }
-        invalidNumber.add(name);
+        invalidNumber.put(name, value);
     }
 
     public String getSyntaxError() {
@@ -106,19 +108,19 @@ public class ValidationResult implements Serializable {
         return required;
     }
 
-    public Set<String> getInvalidEnum() {
+    public Map<String, String> getInvalidEnum() {
         return invalidEnum;
     }
 
-    public Set<String> getInvalidBoolean() {
+    public Map<String, String> getInvalidBoolean() {
         return invalidBoolean;
     }
 
-    public Set<String> getInvalidInteger() {
+    public Map<String, String> getInvalidInteger() {
         return invalidInteger;
     }
 
-    public Set<String> getInvalidNumber() {
+    public Map<String, String> getInvalidNumber() {
         return invalidNumber;
     }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/13e74204/platforms/catalog/src/test/java/org/apache/camel/catalog/CamelCatalogTest.java
----------------------------------------------------------------------
diff --git a/platforms/catalog/src/test/java/org/apache/camel/catalog/CamelCatalogTest.java
b/platforms/catalog/src/test/java/org/apache/camel/catalog/CamelCatalogTest.java
index f1fd778..6862fc8 100644
--- a/platforms/catalog/src/test/java/org/apache/camel/catalog/CamelCatalogTest.java
+++ b/platforms/catalog/src/test/java/org/apache/camel/catalog/CamelCatalogTest.java
@@ -401,7 +401,7 @@ public class CamelCatalogTest {
         // enum
         result = catalog.validateProperties("jms:unknown:myqueue");
         assertFalse(result.isSuccess());
-        assertTrue(result.getInvalidEnum().contains("destinationType"));
+        assertEquals("unknown", result.getInvalidEnum().get("destinationType"));
 
         // okay
         result = catalog.validateProperties("yammer:MESSAGES?accessToken=aaa&consumerKey=bbb&consumerSecret=ccc&useJson=true&initialDelay=500");
@@ -412,8 +412,8 @@ public class CamelCatalogTest {
         assertFalse(result.isSuccess());
         assertTrue(result.getRequired().contains("consumerKey"));
         assertTrue(result.getRequired().contains("consumerSecret"));
-        assertTrue(result.getInvalidBoolean().contains("useJson"));
-        assertTrue(result.getInvalidInteger().contains("initialDelay"));
+        assertEquals("no", result.getInvalidBoolean().get("useJson"));
+        assertEquals("five", result.getInvalidInteger().get("initialDelay"));
 
         // okay
         result = catalog.validateProperties("mqtt:myqtt?reconnectBackOffMultiplier=2.5");
@@ -422,7 +422,7 @@ public class CamelCatalogTest {
         // number
         result = catalog.validateProperties("mqtt:myqtt?reconnectBackOffMultiplier=five");
         assertFalse(result.isSuccess());
-        assertTrue(result.getInvalidNumber().contains("reconnectBackOffMultiplier"));
+        assertEquals("five", result.getInvalidNumber().get("reconnectBackOffMultiplier"));
 
         // unknown component
         result = catalog.validateProperties("foo:bar?me=you");


Mime
View raw message