UNOMI-118 Add integration tests for profile import

Signed-off-by: Serge Huber <shu...@apache.org>


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

Branch: refs/heads/feature-UNOMI-117
Commit: cad95f81bbbf41ad92ad849c16ee8ce4f93a0557
Parents: 684e898
Author: Serge Huber <shu...@apache.org>
Authored: Tue Aug 29 13:00:00 2017 +0200
Committer: Serge Huber <shu...@apache.org>
Committed: Tue Aug 29 13:00:00 2017 +0200

----------------------------------------------------------------------
 .../router/core/processor/LineSplitProcessor.java      | 13 ++++++++++---
 .../rest/ExportConfigurationServiceEndPoint.java       |  2 +-
 .../rest/ImportConfigurationServiceEndPoint.java       |  4 ++--
 itests/pom.xml                                         |  6 ++++++
 .../conditions/ConditionContextHelper.java             |  6 +++++-
 .../services/services/ConfigSharingServiceImpl.java    |  2 +-
 6 files changed, 25 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/cad95f81/extensions/router/router-core/src/main/java/org/apache/unomi/router/core/processor/LineSplitProcessor.java
----------------------------------------------------------------------
diff --git 
a/extensions/router/router-core/src/main/java/org/apache/unomi/router/core/processor/LineSplitProcessor.java
 
b/extensions/router/router-core/src/main/java/org/apache/unomi/router/core/processor/LineSplitProcessor.java
index 5b753c9..d11e0a9 100644
--- 
a/extensions/router/router-core/src/main/java/org/apache/unomi/router/core/processor/LineSplitProcessor.java
+++ 
b/extensions/router/router-core/src/main/java/org/apache/unomi/router/core/processor/LineSplitProcessor.java
@@ -33,7 +33,10 @@ import 
org.apache.unomi.router.api.exceptions.BadProfileDataFormatException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.util.*;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
 
 /**
  * Created by amidani on 29/12/2016.
@@ -132,8 +135,12 @@ public class LineSplitProcessor implements Processor {
                             properties.put(fieldMappingKey, new 
Integer(profileData[fieldsMapping.get(fieldMappingKey)].trim()));
                         }
                     } catch (Exception e) {
-                        e.printStackTrace();
-                        throw new BadProfileDataFormatException("Unable to 
convert '" + profileData[fieldsMapping.get(fieldMappingKey)].trim() + "' to " + 
propertyType!=null?propertyType.getValueTypeId():"Null propertyType ", new 
Throwable("DATA_TYPE"));
+                        logger.error("Error converting profileData", e);
+                        if (fieldMappingKey != null && 
fieldsMapping.get(fieldMappingKey) != null && 
profileData[fieldsMapping.get(fieldMappingKey)] != null) {
+                            throw new BadProfileDataFormatException("Unable to 
convert '" + profileData[fieldsMapping.get(fieldMappingKey)].trim() + "' to " + 
propertyType!=null?propertyType.getValueTypeId():"Null propertyType ", new 
Throwable("DATA_TYPE"));
+                        } else {
+                            throw new BadProfileDataFormatException("Unable to 
find profile data for key " + fieldMappingKey, new Throwable("DATA_TYPE"));
+                        }
                     }
 
                 }

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/cad95f81/extensions/router/router-rest/src/main/java/org/apache/unomi/router/rest/ExportConfigurationServiceEndPoint.java
----------------------------------------------------------------------
diff --git 
a/extensions/router/router-rest/src/main/java/org/apache/unomi/router/rest/ExportConfigurationServiceEndPoint.java
 
b/extensions/router/router-rest/src/main/java/org/apache/unomi/router/rest/ExportConfigurationServiceEndPoint.java
index bd28b1d..72070df 100644
--- 
a/extensions/router/router-rest/src/main/java/org/apache/unomi/router/rest/ExportConfigurationServiceEndPoint.java
+++ 
b/extensions/router/router-rest/src/main/java/org/apache/unomi/router/rest/ExportConfigurationServiceEndPoint.java
@@ -99,7 +99,7 @@ public class ExportConfigurationServiceEndPoint extends 
AbstractConfigurationSer
             }
         } catch (Exception e) {
             logger.warn("Unable to update Camel route [{}]", 
exportConfiguration.getItemId());
-            e.printStackTrace();
+            logger.debug("Unable to update Camel route", e);
             throw new PartialContentException("RUNNING_CONFIG_UPDATE_FAILED");
 
         }

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/cad95f81/extensions/router/router-rest/src/main/java/org/apache/unomi/router/rest/ImportConfigurationServiceEndPoint.java
----------------------------------------------------------------------
diff --git 
a/extensions/router/router-rest/src/main/java/org/apache/unomi/router/rest/ImportConfigurationServiceEndPoint.java
 
b/extensions/router/router-rest/src/main/java/org/apache/unomi/router/rest/ImportConfigurationServiceEndPoint.java
index 1d13e7f..594d8f2 100644
--- 
a/extensions/router/router-rest/src/main/java/org/apache/unomi/router/rest/ImportConfigurationServiceEndPoint.java
+++ 
b/extensions/router/router-rest/src/main/java/org/apache/unomi/router/rest/ImportConfigurationServiceEndPoint.java
@@ -89,7 +89,7 @@ public class ImportConfigurationServiceEndPoint extends 
AbstractConfigurationSer
             }
         } catch (Exception e) {
             logger.warn("Unable to update Camel route [{}]", 
importConfiguration.getItemId());
-            e.printStackTrace();
+            logger.debug("Unable to update Camel route", e);
             throw new PartialContentException("RUNNING_CONFIG_UPDATE_FAILED");
 
         }
@@ -116,7 +116,7 @@ public class ImportConfigurationServiceEndPoint extends 
AbstractConfigurationSer
             Files.copy(in, path);
 
         } catch (IOException e) {
-            e.printStackTrace();
+            logger.error("Error processing one shot configuration CSV", e);
             return Response.serverError().build();
         }
         return Response.ok().build();

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/cad95f81/itests/pom.xml
----------------------------------------------------------------------
diff --git a/itests/pom.xml b/itests/pom.xml
index a5b4338..7b5c5e6 100644
--- a/itests/pom.xml
+++ b/itests/pom.xml
@@ -196,8 +196,14 @@
                 </configuration>
                 <executions>
                     <execution>
+                        <id>integration-test</id>
                         <goals>
                             <goal>integration-test</goal>
+                        </goals>
+                    </execution>
+                    <execution>
+                        <id>verify</id>
+                        <goals>
                             <goal>verify</goal>
                         </goals>
                     </execution>

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/cad95f81/persistence-elasticsearch/core/src/main/java/org/apache/unomi/persistence/elasticsearch/conditions/ConditionContextHelper.java
----------------------------------------------------------------------
diff --git 
a/persistence-elasticsearch/core/src/main/java/org/apache/unomi/persistence/elasticsearch/conditions/ConditionContextHelper.java
 
b/persistence-elasticsearch/core/src/main/java/org/apache/unomi/persistence/elasticsearch/conditions/ConditionContextHelper.java
index e9b3c70..d6b18b4 100644
--- 
a/persistence-elasticsearch/core/src/main/java/org/apache/unomi/persistence/elasticsearch/conditions/ConditionContextHelper.java
+++ 
b/persistence-elasticsearch/core/src/main/java/org/apache/unomi/persistence/elasticsearch/conditions/ConditionContextHelper.java
@@ -27,6 +27,8 @@ import org.apache.unomi.api.conditions.Condition;
 import org.mvel2.MVEL;
 import org.mvel2.ParserConfiguration;
 import org.mvel2.ParserContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import java.io.IOException;
 import java.io.Reader;
@@ -39,6 +41,8 @@ import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
 public class ConditionContextHelper {
+    private static final Logger logger = 
LoggerFactory.getLogger(ConditionContextHelper.class);
+
     private static Map<String,Serializable> mvelExpressions = new 
ConcurrentHashMap<>();
 
     private static MappingCharFilterFactory mappingCharFilterFactory;
@@ -145,7 +149,7 @@ public class ConditionContextHelper {
             try {
                 return IOUtils.toString(foldedStringReader);
             } catch (IOException e) {
-                e.printStackTrace();
+                logger.error("Error folding to ASCII string " + s, e);
             }
         }
         return null;

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/cad95f81/services/src/main/java/org/apache/unomi/services/services/ConfigSharingServiceImpl.java
----------------------------------------------------------------------
diff --git 
a/services/src/main/java/org/apache/unomi/services/services/ConfigSharingServiceImpl.java
 
b/services/src/main/java/org/apache/unomi/services/services/ConfigSharingServiceImpl.java
index 6583910..cc69b29 100644
--- 
a/services/src/main/java/org/apache/unomi/services/services/ConfigSharingServiceImpl.java
+++ 
b/services/src/main/java/org/apache/unomi/services/services/ConfigSharingServiceImpl.java
@@ -142,7 +142,7 @@ public class ConfigSharingServiceImpl implements 
ConfigSharingService, Synchrono
                 }
             }
         } catch (InvalidSyntaxException e) {
-            e.printStackTrace();
+            logger.error("Error retrieving listeners", e);
             return listeners;
         }
         return listeners;

Reply via email to