Repository: incubator-unomi
Updated Branches:
  refs/heads/master ed5604f7f -> 12db34b0a


Fix IT timing problem with camel routes


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

Branch: refs/heads/master
Commit: 12db34b0a1af390aff369698577f6eb742663e28
Parents: ed5604f
Author: Abdelkader Midani <[email protected]>
Authored: Wed Nov 8 19:40:09 2017 +0100
Committer: Abdelkader Midani <[email protected]>
Committed: Wed Nov 8 19:40:16 2017 +0100

----------------------------------------------------------------------
 .../java/org/apache/unomi/itests/AllITs.java    |   2 -
 .../apache/unomi/itests/ProfileExportIT.java    |  31 ++--
 .../unomi/itests/ProfileImportActorsIT.java     |  75 +++-------
 .../unomi/itests/ProfileImportBasicIT.java      |  23 +--
 .../unomi/itests/ProfileImportRankingIT.java    |  58 ++------
 .../itests/ProfileImportSurfersDeleteIT.java    | 109 --------------
 .../unomi/itests/ProfileImportSurfersIT.java    | 122 +++++++++++-----
 .../itests/ProfileImportSurfersOverwriteIT.java | 141 -------------------
 8 files changed, 133 insertions(+), 428 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/12db34b0/itests/src/test/java/org/apache/unomi/itests/AllITs.java
----------------------------------------------------------------------
diff --git a/itests/src/test/java/org/apache/unomi/itests/AllITs.java 
b/itests/src/test/java/org/apache/unomi/itests/AllITs.java
index a919483..4eb8733 100644
--- a/itests/src/test/java/org/apache/unomi/itests/AllITs.java
+++ b/itests/src/test/java/org/apache/unomi/itests/AllITs.java
@@ -35,8 +35,6 @@ import org.junit.runners.Suite.SuiteClasses;
         ProfileServiceIT.class,
         //ProfileImportBasicIT.class,
         ProfileImportSurfersIT.class,
-        ProfileImportSurfersOverwriteIT.class,
-        ProfileImportSurfersDeleteIT.class,
         ProfileImportRankingIT.class,
         ProfileImportActorsIT.class,
         ProfileExportIT.class,

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/12db34b0/itests/src/test/java/org/apache/unomi/itests/ProfileExportIT.java
----------------------------------------------------------------------
diff --git a/itests/src/test/java/org/apache/unomi/itests/ProfileExportIT.java 
b/itests/src/test/java/org/apache/unomi/itests/ProfileExportIT.java
index 1f43b08..c02f79e 100644
--- a/itests/src/test/java/org/apache/unomi/itests/ProfileExportIT.java
+++ b/itests/src/test/java/org/apache/unomi/itests/ProfileExportIT.java
@@ -73,9 +73,8 @@ public class ProfileExportIT extends BaseIT {
 
     File exportDir;
 
-
-    @Before
-    public void setUp() throws IOException, InterruptedException {
+    @Test
+    public void testExport() throws InterruptedException {
 
         Condition condition = new Condition();
         
condition.setConditionType(definitionsService.getConditionType("profilePropertyCondition"));
@@ -90,7 +89,12 @@ public class ProfileExportIT extends BaseIT {
 
         segmentService.setSegmentDefinition(segment);
 
-        Thread.sleep(2000);
+        Thread.sleep(10000);
+
+        segment = segmentService.getSegmentDefinition("exportItSeg");
+
+        Assert.assertNotNull(segment);
+        Assert.assertEquals("Export IT Segment", 
segment.getMetadata().getName());
 
         /*** Export Test ***/
         ExportConfiguration exportConfiguration = new ExportConfiguration();
@@ -114,29 +118,12 @@ public class ProfileExportIT extends BaseIT {
 
         exportConfigurationService.save(exportConfiguration, true);
 
-    }
 
-    @Test
-    public void testCheckSegment() {
-        Segment segment = segmentService.getSegmentDefinition("exportItSeg");
-
-        Assert.assertNotNull(segment);
-        Assert.assertEquals("Export IT Segment", 
segment.getMetadata().getName());
-    }
-
-    @Test
-    public void testCheckExportConfigList() {
+        Thread.sleep(10000);
 
         List<ExportConfiguration> exportConfigurations = 
exportConfigurationService.getAll();
         Assert.assertEquals(1, exportConfigurations.size());
 
-    }
-
-    @Test
-    public void testExport() throws InterruptedException {
-
-        Thread.sleep(5000);
-
         File exportResult = new File(exportDir+"/profiles-actors-export.csv");
         logger.info("PATH : {}", exportResult.getAbsolutePath());
         Assert.assertTrue(exportResult.exists());

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/12db34b0/itests/src/test/java/org/apache/unomi/itests/ProfileImportActorsIT.java
----------------------------------------------------------------------
diff --git 
a/itests/src/test/java/org/apache/unomi/itests/ProfileImportActorsIT.java 
b/itests/src/test/java/org/apache/unomi/itests/ProfileImportActorsIT.java
index e145ac3..c90df77 100644
--- a/itests/src/test/java/org/apache/unomi/itests/ProfileImportActorsIT.java
+++ b/itests/src/test/java/org/apache/unomi/itests/ProfileImportActorsIT.java
@@ -16,12 +16,6 @@
  */
 package org.apache.unomi.itests;
 
-import com.fasterxml.jackson.databind.ObjectMapper;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.methods.HttpPut;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClients;
 import org.apache.unomi.api.Metadata;
 import org.apache.unomi.api.PartialList;
 import org.apache.unomi.api.Profile;
@@ -31,25 +25,17 @@ import org.apache.unomi.router.api.ImportConfiguration;
 import org.apache.unomi.router.api.RouterConstants;
 import org.apache.unomi.router.api.services.ImportExportConfigurationService;
 import org.junit.Assert;
-import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.ops4j.pax.exam.junit.PaxExam;
 import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
 import org.ops4j.pax.exam.spi.reactors.PerSuite;
 import org.ops4j.pax.exam.util.Filter;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 import javax.inject.Inject;
-import javax.ws.rs.core.MediaType;
 import java.io.File;
-import java.io.IOException;
 import java.util.*;
 
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.hamcrest.MatcherAssert.assertThat;
-
 /**
  * Created by amidani on 14/08/2017.
  */
@@ -63,11 +49,9 @@ public class ProfileImportActorsIT extends BaseIT {
 
     @Inject
     protected ProfileService profileService;
-    private Logger logger = 
LoggerFactory.getLogger(ProfileImportActorsIT.class);
-
 
-    @Before
-    public void setUp() throws IOException {
+    @Test
+    public void testImportActors() throws InterruptedException {
 
         /*** Create Missing Properties ***/
         PropertyType propertyTypeTwitterId = new PropertyType(new 
Metadata("integration", "twitterId", "Twitter ID", "Twitter ID"));
@@ -81,8 +65,19 @@ public class ProfileImportActorsIT extends BaseIT {
         
propertyTypeActorsGenres.getMetadata().setSystemTags(Collections.singleton("basicProfileProperties"));
         propertyTypeActorsGenres.setTarget("profiles");
 
+        profileService.setPropertyType(propertyTypeTwitterId);
         profileService.setPropertyType(propertyTypeActorsGenres);
 
+        //Wait for data to be processed
+        Thread.sleep(10000);
+
+        PropertyType propTwitterId = 
profileService.getPropertyType("twitterId");
+        Assert.assertNotNull(propTwitterId);
+
+        PropertyType propActorsGenre = 
profileService.getPropertyType("movieGenres");
+        Assert.assertNotNull(propActorsGenre);
+
+
         /*** Actors Test ***/
         ImportConfiguration importConfigActors = new ImportConfiguration();
         importConfigActors.setItemId("6-actors-test");
@@ -108,61 +103,25 @@ public class ProfileImportActorsIT extends BaseIT {
 
         importConfigurationService.save(importConfigActors, true);
 
-    }
-
-    @Test
-    public void testCheckImportConfigListActors() {
-
-        List<ImportConfiguration> importConfigurations = 
importConfigurationService.getAll();
-        Assert.assertEquals(5, importConfigurations.size());
-
-    }
-
-
-    @Test
-    public void testCheckAddedPropertiesActors() throws IOException, 
InterruptedException {
-
         //Wait for data to be processed
-        Thread.sleep(1000);
-
-        PropertyType propTwitterId = 
profileService.getPropertyType("twitterId");
-        Assert.assertNotNull(propTwitterId);
-
-        PropertyType propActorsGenre = 
profileService.getPropertyType("movieGenres");
-        Assert.assertNotNull(propActorsGenre);
-
-    }
-
-    @Test
-    public void testImportActors() throws InterruptedException {
-
-        //Wait for data to be processed
-        //Check import config status
-        ImportConfiguration importConfiguration = 
importConfigurationService.load("6-actors-test");
-        while (importConfiguration != null && 
!RouterConstants.CONFIG_STATUS_COMPLETE_SUCCESS.equals(importConfiguration.getStatus()))
 {
-            logger.info("$$$$ : testImportActors : Waiting for data to be 
processed ...");
-            Thread.sleep(1000);
-            importConfiguration = 
importConfigurationService.load("6-actors-test");
-        }
         Thread.sleep(10000);
 
-        Assert.assertEquals(1, importConfiguration.getExecutions().size());
-
-        //Assert.assertEquals(34, profileService.getAllProfilesCount());
+        List<ImportConfiguration> importConfigurations = 
importConfigurationService.getAll();
+        Assert.assertEquals(5, importConfigurations.size());
 
         PartialList<Profile> jeanneProfile = 
profileService.findProfilesByPropertyValue("properties.twitterId", "4", 0, 10, 
null);
         Assert.assertEquals(1, jeanneProfile.getList().size());
         Assert.assertNotNull(jeanneProfile.get(0));
         Assert.assertEquals("Jeanne; D'arc", 
jeanneProfile.get(0).getProperty("lastName"));
         Assert.assertEquals("[email protected]", 
jeanneProfile.get(0).getProperty("email"));
-        Assert.assertArrayEquals(new String[]{}, 
((List)jeanneProfile.get(0).getProperty("movieGenres")).toArray());
+        Assert.assertArrayEquals(new String[]{}, ((List) 
jeanneProfile.get(0).getProperty("movieGenres")).toArray());
 
         PartialList<Profile> rockProfile = 
profileService.findProfilesByPropertyValue("properties.twitterId", "6", 0, 10, 
null);
         Assert.assertEquals(1, rockProfile.getList().size());
         Assert.assertNotNull(rockProfile.get(0));
         Assert.assertEquals("The Rock", 
rockProfile.get(0).getProperty("lastName"));
         Assert.assertEquals("[email protected]", 
rockProfile.get(0).getProperty("email"));
-        
Assert.assertEquals(Arrays.asList("Adventure","Action","Romance","Comedy"), 
rockProfile.get(0).getProperty("movieGenres"));
+        Assert.assertEquals(Arrays.asList("Adventure", "Action", "Romance", 
"Comedy"), rockProfile.get(0).getProperty("movieGenres"));
 
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/12db34b0/itests/src/test/java/org/apache/unomi/itests/ProfileImportBasicIT.java
----------------------------------------------------------------------
diff --git 
a/itests/src/test/java/org/apache/unomi/itests/ProfileImportBasicIT.java 
b/itests/src/test/java/org/apache/unomi/itests/ProfileImportBasicIT.java
index 513c839..9245d2c 100644
--- a/itests/src/test/java/org/apache/unomi/itests/ProfileImportBasicIT.java
+++ b/itests/src/test/java/org/apache/unomi/itests/ProfileImportBasicIT.java
@@ -24,15 +24,12 @@ import org.apache.unomi.router.api.RouterConstants;
 import org.apache.unomi.router.api.services.ImportExportConfigurationService;
 import org.junit.After;
 import org.junit.Assert;
-import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.ops4j.pax.exam.junit.PaxExam;
 import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
 import org.ops4j.pax.exam.spi.reactors.PerSuite;
 import org.ops4j.pax.exam.util.Filter;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 import javax.inject.Inject;
 import java.io.IOException;
@@ -53,11 +50,9 @@ public class ProfileImportBasicIT extends BaseIT {
 
     @Inject
     protected ProfileService profileService;
-    private Logger logger = 
LoggerFactory.getLogger(ProfileImportBasicIT.class);
 
-
-    @Before
-    public void setUp() {
+    @Test
+    public void testImportBasic() throws IOException, InterruptedException {
 
         /*** Basic Test ***/
         ImportConfiguration importConfiguration = new ImportConfiguration();
@@ -76,19 +71,11 @@ public class ProfileImportBasicIT extends BaseIT {
 
         importConfigurationService.save(importConfiguration, true);
 
-    }
+        //Wait for the csv to be processed
+        Thread.sleep(5000);
 
-    @Test
-    public void testCheckImportConfigList() {
         List<ImportConfiguration> importConfigurations = 
importConfigurationService.getAll();
         Assert.assertEquals(1, importConfigurations.size());
-    }
-
-    @Test
-    public void testImportBasic() throws IOException, InterruptedException {
-
-        //Wait for the csv to be processed
-        Thread.sleep(10000);
 
         //Check saved profiles
         PartialList<Profile> profiles = 
profileService.findProfilesByPropertyValue("properties.email", 
"[email protected]", 0, 10, null);
@@ -99,7 +86,7 @@ public class ProfileImportBasicIT extends BaseIT {
         Assert.assertEquals("User1", profiles.get(0).getProperty("lastName"));
 
         //Check import config status
-        ImportConfiguration importConfiguration = 
importConfigurationService.load("1-basic-test");
+        importConfiguration = importConfigurationService.load("1-basic-test");
         Assert.assertEquals(RouterConstants.CONFIG_STATUS_COMPLETE_SUCCESS, 
importConfiguration.getStatus());
         Assert.assertEquals(1, importConfiguration.getExecutions().size());
 

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/12db34b0/itests/src/test/java/org/apache/unomi/itests/ProfileImportRankingIT.java
----------------------------------------------------------------------
diff --git 
a/itests/src/test/java/org/apache/unomi/itests/ProfileImportRankingIT.java 
b/itests/src/test/java/org/apache/unomi/itests/ProfileImportRankingIT.java
index 7e6a0db..5617401 100644
--- a/itests/src/test/java/org/apache/unomi/itests/ProfileImportRankingIT.java
+++ b/itests/src/test/java/org/apache/unomi/itests/ProfileImportRankingIT.java
@@ -16,12 +16,6 @@
  */
 package org.apache.unomi.itests;
 
-import com.fasterxml.jackson.databind.ObjectMapper;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.methods.HttpPut;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClients;
 import org.apache.unomi.api.Metadata;
 import org.apache.unomi.api.PartialList;
 import org.apache.unomi.api.Profile;
@@ -31,28 +25,20 @@ import org.apache.unomi.router.api.ImportConfiguration;
 import org.apache.unomi.router.api.RouterConstants;
 import org.apache.unomi.router.api.services.ImportExportConfigurationService;
 import org.junit.Assert;
-import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.ops4j.pax.exam.junit.PaxExam;
 import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
 import org.ops4j.pax.exam.spi.reactors.PerSuite;
 import org.ops4j.pax.exam.util.Filter;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 import javax.inject.Inject;
-import javax.ws.rs.core.MediaType;
 import java.io.File;
-import java.io.IOException;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.hamcrest.MatcherAssert.assertThat;
-
 /**
  * Created by amidani on 09/08/2017.
  */
@@ -66,11 +52,9 @@ public class ProfileImportRankingIT extends BaseIT {
 
     @Inject
     protected ProfileService profileService;
-    private Logger logger = 
LoggerFactory.getLogger(ProfileImportRankingIT.class);
-
 
-    @Before
-    public void setUp() throws IOException {
+    @Test
+    public void testImportRanking() throws InterruptedException {
 
         /*** Create Missing Properties ***/
         PropertyType propertyTypeUciId = new PropertyType(new 
Metadata("integration", "uciId", "UCI ID", "UCI ID"));
@@ -87,6 +71,16 @@ public class ProfileImportRankingIT extends BaseIT {
 
         profileService.setPropertyType(propertyTypeRank);
 
+        //Wait for data to be processed
+        Thread.sleep(10000);
+
+        PropertyType propUciId = profileService.getPropertyType("uciId");
+        Assert.assertNotNull(propUciId);
+
+        PropertyType propRankId = profileService.getPropertyType("rank");
+        Assert.assertNotNull(propRankId);
+
+
         /*** Surfers Test ***/
         ImportConfiguration importConfigRanking = new ImportConfiguration();
         importConfigRanking.setItemId("5-ranking-test");
@@ -111,37 +105,13 @@ public class ProfileImportRankingIT extends BaseIT {
 
         importConfigurationService.save(importConfigRanking, true);
 
-    }
 
-    @Test
-    public void testCheckImportConfigListRanking() {
+        //Wait for data to be processed
+        Thread.sleep(10000);
 
         List<ImportConfiguration> importConfigurations = 
importConfigurationService.getAll();
         Assert.assertEquals(4, importConfigurations.size());
 
-    }
-
-
-    @Test
-    public void testCheckAddedPropertiesRanking() throws IOException, 
InterruptedException {
-
-        //Wait for data to be processed
-        Thread.sleep(1000);
-
-        PropertyType propUciId = profileService.getPropertyType("uciId");
-        Assert.assertNotNull(propUciId);
-
-        PropertyType propRankId = profileService.getPropertyType("rank");
-        Assert.assertNotNull(propRankId);
-
-    }
-
-    @Test
-    public void testImportRanking() throws InterruptedException {
-
-        //Wait for data to be processed
-        Thread.sleep(10000);
-
         PartialList<Profile> gregProfile = 
profileService.findProfilesByPropertyValue("properties.uciId", "10004451371", 
0, 10, null);
         Assert.assertEquals(1, gregProfile.getList().size());
         Assert.assertNotNull(gregProfile.get(0));

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/12db34b0/itests/src/test/java/org/apache/unomi/itests/ProfileImportSurfersDeleteIT.java
----------------------------------------------------------------------
diff --git 
a/itests/src/test/java/org/apache/unomi/itests/ProfileImportSurfersDeleteIT.java
 
b/itests/src/test/java/org/apache/unomi/itests/ProfileImportSurfersDeleteIT.java
deleted file mode 100644
index 39a9fc6..0000000
--- 
a/itests/src/test/java/org/apache/unomi/itests/ProfileImportSurfersDeleteIT.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License
- */
-package org.apache.unomi.itests;
-
-import org.apache.unomi.api.PartialList;
-import org.apache.unomi.api.Profile;
-import org.apache.unomi.api.services.ProfileService;
-import org.apache.unomi.router.api.ImportConfiguration;
-import org.apache.unomi.router.api.RouterConstants;
-import org.apache.unomi.router.api.services.ImportExportConfigurationService;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.junit.PaxExam;
-import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
-import org.ops4j.pax.exam.spi.reactors.PerSuite;
-import org.ops4j.pax.exam.util.Filter;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.inject.Inject;
-import java.io.File;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Created by amidani on 11/08/2017.
- */
-@RunWith(PaxExam.class)
-@ExamReactorStrategy(PerSuite.class)
-public class ProfileImportSurfersDeleteIT extends BaseIT {
-
-    @Inject
-    @Filter("(configDiscriminator=IMPORT)")
-    protected ImportExportConfigurationService<ImportConfiguration> 
importConfigurationService;
-
-    @Inject
-    protected ProfileService profileService;
-    private Logger logger = 
LoggerFactory.getLogger(ProfileImportSurfersDeleteIT.class);
-
-    @Before
-    public void setUp() throws IOException {
-
-        Map mappingSurfers = new HashMap();
-        mappingSurfers.put("linkedInId", 0);
-        mappingSurfers.put("lastName", 1);
-        mappingSurfers.put("email", 2);
-        mappingSurfers.put("facebookId", 3);
-        mappingSurfers.put("gender", 4);
-        mappingSurfers.put("alive", 5);
-
-        File importSurfersFile = new File("data/tmp/recurrent_import/");
-
-        /*** Surfers Delete Test ***/
-        ImportConfiguration importConfigSurfersDelete = new 
ImportConfiguration();
-        importConfigSurfersDelete.setItemId("4-surfers-delete-test");
-        
importConfigSurfersDelete.setConfigType(RouterConstants.IMPORT_EXPORT_CONFIG_TYPE_RECURRENT);
-        importConfigSurfersDelete.setMergingProperty("linkedInId");
-        importConfigSurfersDelete.setOverwriteExistingProfiles(true);
-        importConfigSurfersDelete.setColumnSeparator(";");
-        importConfigSurfersDelete.setHasHeader(true);
-        importConfigSurfersDelete.setHasDeleteColumn(true);
-
-        importConfigSurfersDelete.getProperties().put("mapping", 
mappingSurfers);
-
-        importConfigSurfersDelete.getProperties().put("source", "file://" + 
importSurfersFile.getAbsolutePath() + 
"?fileName=4-surfers-delete-test.csv&consumer.delay=10m&move=.done");
-        importConfigSurfersDelete.setActive(true);
-
-        importConfigurationService.save(importConfigSurfersDelete, true);
-
-    }
-
-    @Test
-    public void testCheckImportConfigListSurfers() {
-
-        List<ImportConfiguration> importConfigurations = 
importConfigurationService.getAll();
-        Assert.assertEquals(3, importConfigurations.size());
-
-    }
-
-    @Test
-    public void testImportSurfersDelete() throws IOException, 
InterruptedException {
-
-        //Wait for data to be processed
-        Thread.sleep(10000);
-
-        //Assert.assertEquals(3, profileService.getAllProfilesCount());
-        PartialList<Profile> jordyProfile = 
profileService.findProfilesByPropertyValue("properties.email", 
"[email protected]", 0, 10, null);
-        Assert.assertEquals(0, jordyProfile.getList().size());
-
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/12db34b0/itests/src/test/java/org/apache/unomi/itests/ProfileImportSurfersIT.java
----------------------------------------------------------------------
diff --git 
a/itests/src/test/java/org/apache/unomi/itests/ProfileImportSurfersIT.java 
b/itests/src/test/java/org/apache/unomi/itests/ProfileImportSurfersIT.java
index f9589c5..8e2a4cc 100644
--- a/itests/src/test/java/org/apache/unomi/itests/ProfileImportSurfersIT.java
+++ b/itests/src/test/java/org/apache/unomi/itests/ProfileImportSurfersIT.java
@@ -16,12 +16,6 @@
  */
 package org.apache.unomi.itests;
 
-import com.fasterxml.jackson.databind.ObjectMapper;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.methods.HttpPut;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClients;
 import org.apache.unomi.api.Metadata;
 import org.apache.unomi.api.PartialList;
 import org.apache.unomi.api.Profile;
@@ -31,7 +25,6 @@ import org.apache.unomi.router.api.ImportConfiguration;
 import org.apache.unomi.router.api.RouterConstants;
 import org.apache.unomi.router.api.services.ImportExportConfigurationService;
 import org.junit.Assert;
-import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.ops4j.pax.exam.junit.PaxExam;
@@ -42,16 +35,13 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import javax.inject.Inject;
-import javax.ws.rs.core.MediaType;
 import java.io.File;
 import java.io.IOException;
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.hamcrest.MatcherAssert.assertThat;
-
 /**
  * Created by amidani on 09/08/2017.
  */
@@ -67,9 +57,8 @@ public class ProfileImportSurfersIT extends BaseIT {
     protected ProfileService profileService;
     private Logger logger = 
LoggerFactory.getLogger(ProfileImportSurfersIT.class);
 
-
-    @Before
-    public void setUp() throws IOException, InterruptedException {
+    @Test
+    public void testImportSurfers() throws IOException, InterruptedException {
 
         /*** Create Missing Properties ***/
         PropertyType propertyType = new PropertyType(new 
Metadata("integration", "alive", "Alive", "Is the person alive?"));
@@ -79,6 +68,16 @@ public class ProfileImportSurfersIT extends BaseIT {
 
         profileService.setPropertyType(propertyType);
 
+        //Wait for data to be processed
+        Thread.sleep(1000);
+
+        PropertyType propAlive = profileService.getPropertyType("alive");
+
+        Assert.assertNotNull(propAlive);
+
+        //Wait for data to be processed
+        Thread.sleep(5000);
+
         /*** Surfers Test ***/
         ImportConfiguration importConfigSurfers = new ImportConfiguration();
         importConfigSurfers.setItemId("2-surfers-test");
@@ -105,30 +104,13 @@ public class ProfileImportSurfersIT extends BaseIT {
 
         importConfigurationService.save(importConfigSurfers, true);
 
-        //Wait for data to be processed
-        Thread.sleep(10000);
-
-    }
-
-    @Test
-    public void testCheckAddedPropertiesSurfers() throws IOException, 
InterruptedException {
-
-        //Wait for data to be processed
-        Thread.sleep(1000);
-
-        PropertyType propAlive = profileService.getPropertyType("alive");
-
-        Assert.assertNotNull(propAlive);
-
-    }
-
-    @Test
-    public void testImportSurfers() throws IOException, InterruptedException {
+        logger.info("ProfileImportSurfersIT setup successfully.");
 
         //Wait for data to be processed
         Thread.sleep(10000);
 
-        //Assert.assertEquals(37, profileService.getAllProfilesCount());
+        List<ImportConfiguration> importConfigurations = 
importConfigurationService.getAll();
+        Assert.assertEquals(1, importConfigurations.size());
 
         //Profile not to delete
         PartialList<Profile> jordyProfile = 
profileService.findProfilesByPropertyValue("properties.email", 
"[email protected]", 0, 10, null);
@@ -149,6 +131,78 @@ public class ProfileImportSurfersIT extends BaseIT {
         Assert.assertEquals(RouterConstants.CONFIG_STATUS_COMPLETE_SUCCESS, 
importConfiguration.getStatus());
         Assert.assertEquals(1, importConfiguration.getExecutions().size());
 
+        //Wait for data to be processed
+        Thread.sleep(10000);
+
+        /*** Surfers Test OVERWRITE ***/
+        ImportConfiguration importConfigSurfersOverwrite = new 
ImportConfiguration();
+        importConfigSurfersOverwrite.setItemId("3-surfers-overwrite-test");
+        
importConfigSurfersOverwrite.setConfigType(RouterConstants.IMPORT_EXPORT_CONFIG_TYPE_RECURRENT);
+        importConfigSurfersOverwrite.setMergingProperty("linkedInId");
+        importConfigSurfersOverwrite.setOverwriteExistingProfiles(true);
+        importConfigSurfersOverwrite.setColumnSeparator(";");
+        importConfigSurfersOverwrite.setHasHeader(true);
+        importConfigSurfersOverwrite.setHasDeleteColumn(true);
+
+        importConfigSurfersOverwrite.getProperties().put("mapping", 
mappingSurfers);
+        importConfigSurfersOverwrite.getProperties().put("source", "file://" + 
importSurfersFile.getAbsolutePath() + 
"?fileName=3-surfers-overwrite-test.csv&consumer.delay=10m&move=.done");
+        importConfigSurfersOverwrite.setActive(true);
+
+        importConfigurationService.save(importConfigSurfersOverwrite, true);
+
+        logger.info("ProfileImportSurfersOverwriteIT setup successfully.");
+
+        //Wait for data to be processed
+        Thread.sleep(10000);
+
+
+        importConfigurations = importConfigurationService.getAll();
+        Assert.assertEquals(2, importConfigurations.size());
+
+        //Profile not to delete
+        PartialList<Profile> aliveProfiles = 
profileService.findProfilesByPropertyValue("properties.alive", "true", 0, 50, 
null);
+        PartialList<Profile> deadProfiles = 
profileService.findProfilesByPropertyValue("properties.alive", "false", 0, 50, 
null);
+
+        Assert.assertEquals(0, aliveProfiles.getList().size());
+        Assert.assertEquals(36, deadProfiles.getList().size());
+
+        //Profile to delete = false, was to delete
+        PartialList<Profile> paulineProfileOverwrite = 
profileService.findProfilesByPropertyValue("properties.lastName", "Pauline 
Ado", 0, 10, null);
+        Assert.assertEquals(1, paulineProfileOverwrite.getList().size());
+
+        //Wait for data to be processed
+        Thread.sleep(10000);
+
+        /*** Surfers Delete Test ***/
+
+        ImportConfiguration importConfigSurfersDelete = new 
ImportConfiguration();
+        importConfigSurfersDelete.setItemId("4-surfers-delete-test");
+        
importConfigSurfersDelete.setConfigType(RouterConstants.IMPORT_EXPORT_CONFIG_TYPE_RECURRENT);
+        importConfigSurfersDelete.setMergingProperty("linkedInId");
+        importConfigSurfersDelete.setOverwriteExistingProfiles(true);
+        importConfigSurfersDelete.setColumnSeparator(";");
+        importConfigSurfersDelete.setHasHeader(true);
+        importConfigSurfersDelete.setHasDeleteColumn(true);
+
+        importConfigSurfersDelete.getProperties().put("mapping", 
mappingSurfers);
+
+        importConfigSurfersDelete.getProperties().put("source", "file://" + 
importSurfersFile.getAbsolutePath() + 
"?fileName=4-surfers-delete-test.csv&consumer.delay=10m&move=.done");
+        importConfigSurfersDelete.setActive(true);
+
+        importConfigurationService.save(importConfigSurfersDelete, true);
+
+        logger.info("ProfileImportSurfersDeleteIT setup successfully.");
+
+        //Wait for data to be processed
+        Thread.sleep(10000);
+
+        importConfigurations = importConfigurationService.getAll();
+        Assert.assertEquals(3, importConfigurations.size());
+
+        PartialList<Profile> jordyProfileDelete = 
profileService.findProfilesByPropertyValue("properties.email", 
"[email protected]", 0, 10, null);
+        Assert.assertEquals(0, jordyProfileDelete.getList().size());
+
+
     }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/12db34b0/itests/src/test/java/org/apache/unomi/itests/ProfileImportSurfersOverwriteIT.java
----------------------------------------------------------------------
diff --git 
a/itests/src/test/java/org/apache/unomi/itests/ProfileImportSurfersOverwriteIT.java
 
b/itests/src/test/java/org/apache/unomi/itests/ProfileImportSurfersOverwriteIT.java
deleted file mode 100644
index d837f4c..0000000
--- 
a/itests/src/test/java/org/apache/unomi/itests/ProfileImportSurfersOverwriteIT.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License
- */
-package org.apache.unomi.itests;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.methods.HttpPut;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClients;
-import org.apache.unomi.api.PartialList;
-import org.apache.unomi.api.Profile;
-import org.apache.unomi.api.PropertyType;
-import org.apache.unomi.api.services.ProfileService;
-import org.apache.unomi.router.api.ImportConfiguration;
-import org.apache.unomi.router.api.RouterConstants;
-import org.apache.unomi.router.api.services.ImportExportConfigurationService;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.junit.PaxExam;
-import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
-import org.ops4j.pax.exam.spi.reactors.PerSuite;
-import org.ops4j.pax.exam.util.Filter;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.inject.Inject;
-import javax.ws.rs.core.MediaType;
-import java.io.File;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-/**
- * Created by amidani on 09/08/2017.
- */
-@RunWith(PaxExam.class)
-@ExamReactorStrategy(PerSuite.class)
-public class ProfileImportSurfersOverwriteIT extends BaseIT {
-
-    @Inject
-    @Filter("(configDiscriminator=IMPORT)")
-    protected ImportExportConfigurationService<ImportConfiguration> 
importConfigurationService;
-
-    @Inject
-    protected ProfileService profileService;
-    private Logger logger = 
LoggerFactory.getLogger(ProfileImportSurfersOverwriteIT.class);
-
-
-    @Before
-    public void setUp() throws IOException {
-
-        /*** Surfers Test ***/
-        ImportConfiguration importConfigSurfers = new ImportConfiguration();
-        importConfigSurfers.setItemId("3-surfers-overwrite-test");
-        
importConfigSurfers.setConfigType(RouterConstants.IMPORT_EXPORT_CONFIG_TYPE_RECURRENT);
-        importConfigSurfers.setMergingProperty("linkedInId");
-        importConfigSurfers.setOverwriteExistingProfiles(true);
-        importConfigSurfers.setColumnSeparator(";");
-        importConfigSurfers.setHasHeader(true);
-        importConfigSurfers.setHasDeleteColumn(true);
-
-        Map mappingSurfers = new HashMap();
-        mappingSurfers.put("linkedInId", 0);
-        mappingSurfers.put("lastName", 1);
-        mappingSurfers.put("email", 2);
-        mappingSurfers.put("facebookId", 3);
-        mappingSurfers.put("gender", 4);
-        mappingSurfers.put("alive", 5);
-
-        importConfigSurfers.getProperties().put("mapping", mappingSurfers);
-        File importSurfersFile = new File("data/tmp/recurrent_import/");
-        importConfigSurfers.getProperties().put("source", "file://" + 
importSurfersFile.getAbsolutePath() + 
"?fileName=3-surfers-overwrite-test.csv&consumer.delay=10m&move=.done");
-        importConfigSurfers.setActive(true);
-
-        importConfigurationService.save(importConfigSurfers, true);
-
-    }
-
-    @Test
-    public void testCheckImportConfigListSurfersOverwrite() {
-
-        List<ImportConfiguration> importConfigurations = 
importConfigurationService.getAll();
-        Assert.assertEquals(2, importConfigurations.size());
-
-    }
-
-    @Test
-    public void testCheckAddedPropertiesSurfersOverwrite() throws IOException, 
InterruptedException {
-
-        //Wait for data to be processed
-        Thread.sleep(1000);
-
-        PropertyType propAlive = profileService.getPropertyType("alive");
-
-        Assert.assertNotNull(propAlive);
-
-    }
-
-    @Test
-    public void testImportSurfersOverwrite() throws IOException, 
InterruptedException {
-
-        //Wait for data to be processed
-        Thread.sleep(10000);
-
-        //Assert.assertEquals(39, profileService.getAllProfilesCount());
-
-        //Profile not to delete
-        PartialList<Profile> aliveProfiles = 
profileService.findProfilesByPropertyValue("properties.alive", "true", 0, 50, 
null);
-        PartialList<Profile> deadProfiles = 
profileService.findProfilesByPropertyValue("properties.alive", "false", 0, 50, 
null);
-
-        Assert.assertEquals(0, aliveProfiles.getList().size());
-        Assert.assertEquals(36, deadProfiles.getList().size());
-
-        //Profile to delete = false, was to delete
-        PartialList<Profile> paulineProfile = 
profileService.findProfilesByPropertyValue("properties.lastName", "Pauline 
Ado", 0, 10, null);
-        Assert.assertEquals(1, paulineProfile.getList().size());
-
-    }
-
-}


Reply via email to