Repository: incubator-unomi
Updated Branches:
  refs/heads/master 0c7225710 -> 777b13e95


UNOMI-118 : Surfers delete test, profile import


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

Branch: refs/heads/master
Commit: 777b13e95efb5582fadfb5781a1e71413a1a5983
Parents: 0c72257
Author: Abdelkader Midani <amid...@apache.org>
Authored: Fri Aug 11 08:04:40 2017 +0200
Committer: Abdelkader Midani <amid...@apache.org>
Committed: Fri Aug 11 08:04:40 2017 +0200

----------------------------------------------------------------------
 .../java/org/apache/unomi/itests/AllITs.java    |   3 +-
 .../java/org/apache/unomi/itests/BaseIT.java    |   2 +
 .../itests/ProfileImportSurfersDeleteIT.java    | 132 +++++++++++++++++++
 .../unomi/itests/ProfileImportSurfersIT.java    |  28 +---
 .../test/resources/3-surfers-delete-test.csv    |  37 ++++++
 5 files changed, 180 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/777b13e9/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 225513e..d32e627 100644
--- a/itests/src/test/java/org/apache/unomi/itests/AllITs.java
+++ b/itests/src/test/java/org/apache/unomi/itests/AllITs.java
@@ -34,7 +34,8 @@ import org.junit.runners.Suite.SuiteClasses;
         SegmentIT.class,
         ProfileServiceIT.class,
         ProfileImportBasicIT.class,
-        ProfileImportSurfersIT.class
+        ProfileImportSurfersIT.class,
+        ProfileImportSurfersDeleteIT.class
     })
 public class AllITs {
 }

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/777b13e9/itests/src/test/java/org/apache/unomi/itests/BaseIT.java
----------------------------------------------------------------------
diff --git a/itests/src/test/java/org/apache/unomi/itests/BaseIT.java 
b/itests/src/test/java/org/apache/unomi/itests/BaseIT.java
index 38a2415..465f3b5 100644
--- a/itests/src/test/java/org/apache/unomi/itests/BaseIT.java
+++ b/itests/src/test/java/org/apache/unomi/itests/BaseIT.java
@@ -99,6 +99,8 @@ public abstract class BaseIT {
                         "src/test/resources/1-basic-test.csv")),
                 
replaceConfigurationFile("data/tmp/recurrent_import/2-surfers-test.csv", new 
File(
                         "src/test/resources/2-surfers-test.csv")),
+                
replaceConfigurationFile("data/tmp/recurrent_import/3-surfers-delete-test.csv", 
new File(
+                        "src/test/resources/3-surfers-delete-test.csv")),
                 keepRuntimeFolder(),
                 configureConsole().ignoreLocalConsole(),
                 logLevel(LogLevel.INFO),

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/777b13e9/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
new file mode 100644
index 0000000..d605693
--- /dev/null
+++ 
b/itests/src/test/java/org/apache/unomi/itests/ProfileImportSurfersDeleteIT.java
@@ -0,0 +1,132 @@
+/*
+ * 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.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 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("3-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=3-surfers-delete-test.csv&consumer.delay=10m&consumer.initialDelay=25s&move=.done");
+        importConfigSurfersDelete.setActive(true);
+
+        ImportConfiguration savedImportConfigDelete = 
importConfigurationService.save(importConfigSurfersDelete);
+
+        CloseableHttpClient httpclient = HttpClients.createDefault();
+        HttpPut httpPut = new HttpPut(URL + "/configUpdate/importConfigAdmin");
+
+        String jsonDelete = new 
ObjectMapper().writeValueAsString(savedImportConfigDelete);
+        StringEntity entityDelete = new StringEntity(jsonDelete);
+        entityDelete.setContentType(MediaType.APPLICATION_JSON);
+        httpPut.setEntity(entityDelete);
+
+        HttpResponse responseDelete = httpclient.execute(httpPut);
+        assertThat(responseDelete.getStatusLine().getStatusCode(), 
equalTo(200));
+
+        httpclient.close();
+
+    }
+
+    @Test
+    public void testCheckImportConfigList() {
+
+        List<ImportConfiguration> importConfigurations = 
importConfigurationService.getAll();
+        Assert.assertEquals(3, importConfigurations.size());
+
+    }
+
+    @Test
+    public void testImport3SurfersDelete() throws IOException, 
InterruptedException {
+
+        //Wait for data to be processed
+        Thread.sleep(30000);
+
+        Assert.assertEquals(3, profileService.getAllProfilesCount());
+        PartialList<Profile> jordyProfile = 
profileService.findProfilesByPropertyValue("properties.email", 
"jo...@smith.com", 0, 10, null);
+        Assert.assertEquals(0, jordyProfile.getList().size());
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/777b13e9/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 1be2a23..58347f5 100644
--- a/itests/src/test/java/org/apache/unomi/itests/ProfileImportSurfersIT.java
+++ b/itests/src/test/java/org/apache/unomi/itests/ProfileImportSurfersIT.java
@@ -17,19 +17,10 @@
 package org.apache.unomi.itests;
 
 import com.fasterxml.jackson.databind.ObjectMapper;
-import org.apache.http.HttpRequest;
 import org.apache.http.HttpResponse;
-import org.apache.http.auth.AuthenticationException;
-import org.apache.http.auth.UsernamePasswordCredentials;
-import org.apache.http.client.entity.UrlEncodedFormEntity;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpPost;
 import org.apache.http.client.methods.HttpPut;
-import org.apache.http.client.methods.HttpUriRequest;
 import org.apache.http.entity.StringEntity;
-import org.apache.http.impl.auth.BasicScheme;
 import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClientBuilder;
 import org.apache.http.impl.client.HttpClients;
 import org.apache.unomi.api.Metadata;
 import org.apache.unomi.api.PartialList;
@@ -54,7 +45,9 @@ import javax.inject.Inject;
 import javax.ws.rs.core.MediaType;
 import java.io.File;
 import java.io.IOException;
-import java.util.*;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
 
 import static org.hamcrest.CoreMatchers.equalTo;
 import static org.hamcrest.MatcherAssert.assertThat;
@@ -76,7 +69,7 @@ public class ProfileImportSurfersIT extends BaseIT {
 
 
     @Before
-    public void setUp() throws IOException, AuthenticationException {
+    public void setUp() throws IOException {
 
         /*** Create Missing Properties ***/
         PropertyType propertyType = new PropertyType(new 
Metadata("integration", "alive", "Alive", "Is the person alive?"));
@@ -86,7 +79,7 @@ public class ProfileImportSurfersIT extends BaseIT {
 
         profileService.setPropertyType(propertyType);
 
-        /*** Surfer Test ***/
+        /*** Surfers Test ***/
         ImportConfiguration importConfigSurfers = new ImportConfiguration();
         importConfigSurfers.setItemId("2-surfers-test");
         
importConfigSurfers.setConfigType(RouterConstants.IMPORT_EXPORT_CONFIG_TYPE_RECURRENT);
@@ -121,6 +114,7 @@ public class ProfileImportSurfersIT extends BaseIT {
 
         HttpResponse response = httpclient.execute(httpPut);
         assertThat(response.getStatusLine().getStatusCode(), equalTo(200));
+
         httpclient.close();
 
     }
@@ -138,15 +132,7 @@ public class ProfileImportSurfersIT extends BaseIT {
     }
 
     @Test
-    public void testCheckImportConfigList() {
-
-        List<ImportConfiguration> importConfigurations = 
importConfigurationService.getAll();
-        Assert.assertEquals(2, importConfigurations.size());
-
-    }
-
-    @Test
-    public void testImport2Surfers() throws IOException, InterruptedException  
{
+    public void testImport2Surfers() throws IOException, InterruptedException {
 
         //Wait for data to be processed
         Thread.sleep(10000);

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/777b13e9/itests/src/test/resources/3-surfers-delete-test.csv
----------------------------------------------------------------------
diff --git a/itests/src/test/resources/3-surfers-delete-test.csv 
b/itests/src/test/resources/3-surfers-delete-test.csv
new file mode 100644
index 0000000..f2d45ba
--- /dev/null
+++ b/itests/src/test/resources/3-surfers-delete-test.csv
@@ -0,0 +1,37 @@
+Linkedin ID;Last Name;Email;Facebook ID;Gender;Alive;To Delete
+1;Jordy Smith;jo...@smith.com;999;male;TRUE;TRUE
+2;Gabriel Medina;gabr...@medina.com;998;male;TRUE;TRUE
+3;Kolohe Andino;kol...@andino.com;997;male;TRUE;TRUE
+4;Matt Wilkinson;m...@wilkinson.com;996;male;TRUE;TRUE
+5;Michel Bourez;mic...@bourez.com;995;male;TRUE;TRUE
+6;Kelly Slater;ke...@slater.com;994;male;TRUE;TRUE
+7;Julian Wilson;jul...@wilson.com;993;male;TRUE;TRUE
+8;Joel Parkinson;j...@parkinson.com;992;male;TRUE;TRUE
+9;Filipe Toledo;fil...@toledo.com;991;male;TRUE;TRUE
+10;Adriano De Souza;adri...@souza.com;990;male;TRUE;TRUE
+11;Sebastian Zietz;sebast...@zietz.com;989;male;TRUE;TRUE
+12;Josh Kerr;jo...@kerr.com;988;male;TRUE;TRUE
+13;Adrian Buchan;adr...@buchan.com;987;male;TRUE;TRUE
+14;Italo Ferreira;it...@ferreiro.com;986;male;TRUE;TRUE
+15;Mick Fanning;m...@fanning.com;985;male;TRUE;TRUE
+16;Miguel Pupo;mig...@pupo.com;984;male;TRUE;TRUE
+17;Nat Young;n...@young.com;983;male;TRUE;TRUE
+18;Keanu Asing;;982;male;TRUE;TRUE
+19;Tyler Wright;;981;male;TRUE;TRUE
+20;Courtney Conlogue;;980;female;TRUE;TRUE
+21;Carissa Moore;;979;female;TRUE;TRUE
+22;Tatiana Weston-Webb;;978;female;TRUE;TRUE
+23;Johanne Defay;;977;female;TRUE;TRUE
+24;Stephanie Gilmore;;976;female;TRUE;TRUE
+25;Malia Manuel;;975;female;TRUE;TRUE
+26;Sally Fitzgibbons;;974;female;TRUE;TRUE
+27;Sage Erickson;;973;female;TRUE;TRUE
+28;Laura Enever;;972;female;TRUE;TRUE
+29;Nikki Van Dijk;;971;female;TRUE;TRUE
+30;Bianca Buitendag;;970;female;TRUE;TRUE
+31;Coco Ho;;969;female;TRUE;TRUE
+32;Alessa Quizon;;968;female;TRUE;TRUE
+33;Lakey Peterson;;967;female;TRUE;TRUE
+34;Bronte Macaulay;;966;female;TRUE;TRUE
+35;Pauline Ado;;965;female;TRUE;TRUE
+36;Silvana Lima;;964;female;TRUE;TRUE
\ No newline at end of file

Reply via email to