UNOMI-118 Add integration tests for profile import
- Fix NPE when running integration tests.

Signed-off-by: Serge Huber <[email protected]>


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

Branch: refs/heads/feature-UNOMI-117
Commit: cdaa8613c3f8341b91014f313fc2aa134c22d038
Parents: cad95f8
Author: Serge Huber <[email protected]>
Authored: Wed Aug 30 11:23:37 2017 +0200
Committer: Serge Huber <[email protected]>
Committed: Wed Aug 30 11:23:37 2017 +0200

----------------------------------------------------------------------
 .../unomi/router/core/processor/LineSplitProcessor.java      | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/cdaa8613/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 d11e0a9..4d128a4 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
@@ -105,7 +105,11 @@ public class LineSplitProcessor implements Processor {
             for (String fieldMappingKey : fieldsMapping.keySet()) {
                 PropertyType propertyType = 
RouterUtils.getPropertyTypeById(profileService.getAllPropertyTypes("profiles"), 
fieldMappingKey);
 
-                logger.debug("$$$$ : LineSplitProcessor : PropType value : 
{}", profileData[fieldsMapping.get(fieldMappingKey)].trim());
+                if (fieldMappingKey != null && 
fieldsMapping.get(fieldMappingKey) != null && profileData != null && 
profileData[fieldsMapping.get(fieldMappingKey)] != null) {
+                    logger.debug("$$$$ : LineSplitProcessor : PropType value : 
{}", profileData[fieldsMapping.get(fieldMappingKey)].trim());
+                } else {
+                    logger.debug("$$$$ : LineSplitProcessor : no profileData 
found for fieldMappingKey=" + fieldMappingKey);
+                }
 
                 if (profileData.length > fieldsMapping.get(fieldMappingKey)) {
                     try {
@@ -136,7 +140,7 @@ public class LineSplitProcessor implements Processor {
                         }
                     } catch (Exception e) {
                         logger.error("Error converting profileData", e);
-                        if (fieldMappingKey != null && 
fieldsMapping.get(fieldMappingKey) != null && 
profileData[fieldsMapping.get(fieldMappingKey)] != null) {
+                        if (fieldMappingKey != null && 
fieldsMapping.get(fieldMappingKey) != null && profileData != 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"));

Reply via email to