syncope-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ashaki...@apache.org
Subject svn commit: r1435132 - in /syncope/trunk/core/src/test/java/org/apache/syncope/core/rest: TaskTestITCase.java UserTestITCase.java
Date Fri, 18 Jan 2013 13:41:35 GMT
Author: ashakirin
Date: Fri Jan 18 13:41:34 2013
New Revision: 1435132

URL: http://svn.apache.org/viewvc?rev=1435132&view=rev
Log:
[SYNCOPE-268] Make rest integration tests re-runnable

Modified:
    syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/TaskTestITCase.java
    syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java

Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/TaskTestITCase.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/TaskTestITCase.java?rev=1435132&r1=1435131&r2=1435132&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/TaskTestITCase.java (original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/TaskTestITCase.java Fri
Jan 18 13:41:34 2013
@@ -427,7 +427,9 @@ public class TaskTestITCase extends Abst
 
     @Test
     public void issueSYNCOPE81() {
-    	NotificationTaskTO taskTO = taskService.read(TaskType.NOTIFICATION, 8L);
+
+        String sender = createNotificationTask();
+        NotificationTaskTO taskTO = findNotificationTaskBySender(sender);
         assertNotNull(taskTO);
 
         int executions = taskTO.getExecutions().size();
@@ -465,8 +467,47 @@ public class TaskTestITCase extends Abst
 
     @Test
     public void issueSYNCOPE86() {
-        // 1. create suitable notification for subsequent tests
-        NotificationTO notification = new NotificationTO();
+        // 1. create notification task
+        String sender = createNotificationTask();
+
+        // 2. get NotificationTaskTO for user just created
+        NotificationTaskTO taskTO = findNotificationTaskBySender(sender);
+        assertNotNull(taskTO);
+        assertTrue(taskTO.getExecutions().isEmpty());
+
+        try {
+            // 3. execute the generated NotificationTask
+            TaskExecTO execution = taskService.execute(taskTO.getId(), false);
+            assertNotNull(execution);
+
+            // 4. verify
+            taskTO = taskService.read(TaskType.NOTIFICATION, taskTO.getId());
+            assertNotNull(taskTO);
+            assertEquals(1, taskTO.getExecutions().size());
+        } finally {
+        	// Remove execution to make test re-runnable
+        	TaskExecTO taskExecTO = taskService.deleteExecution(taskTO.getExecutions().get(0).getId());
+        	assertNotNull(taskExecTO);
+        }
+    }
+
+	private NotificationTaskTO findNotificationTaskBySender(String sender) {		
+        List<NotificationTaskTO> tasks = taskService.list(TaskType.NOTIFICATION);
+        assertNotNull(tasks);
+        assertFalse(tasks.isEmpty());
+
+        NotificationTaskTO taskTO = null;
+        for (NotificationTaskTO task : tasks) {
+            if (sender.equals(task.getSender())) {
+                taskTO = task;
+            }
+        }
+		return taskTO;
+	}
+
+	private String createNotificationTask() {
+		// 1. Create notification
+		NotificationTO notification = new NotificationTO();
         notification.setTraceLevel(TraceLevel.FAILURES);
         notification.addEvent("create");
 
@@ -499,36 +540,8 @@ public class TaskTestITCase extends Abst
 
         userTO = userService.create(userTO);
         assertNotNull(userTO);
-
-        // 3. get NotificationTaskTO for user just created
-        List<NotificationTaskTO> tasks = taskService.list(TaskType.NOTIFICATION);
-        assertNotNull(tasks);
-        assertFalse(tasks.isEmpty());
-
-        NotificationTaskTO taskTO = null;
-        for (NotificationTaskTO task : tasks) {
-            if (sender.equals(task.getSender())) {
-                taskTO = task;
-            }
-        }
-        assertNotNull(taskTO);
-        assertTrue(taskTO.getExecutions().isEmpty());
-
-        try {
-            // 4. execute the generated NotificationTask
-            TaskExecTO execution = taskService.execute(taskTO.getId(), false);
-            assertNotNull(execution);
-
-            // 5. verify
-            taskTO = taskService.read(TaskType.NOTIFICATION, taskTO.getId());
-            assertNotNull(taskTO);
-            assertEquals(1, taskTO.getExecutions().size());
-        } finally {
-        	// Remove execution to make test re-runnable
-        	TaskExecTO taskExecTO = taskService.deleteExecution(taskTO.getExecutions().get(0).getId());
-        	assertNotNull(taskExecTO);
-        }
-    }
+		return sender;
+	}
 
     @Test
     public void issueSYNCOPE68() {
@@ -601,6 +614,13 @@ public class TaskTestITCase extends Abst
         	UserTO dUserTO = userService.delete(userTO.getId());
         	assertNotNull(dUserTO);
         }
+    	System.out.println("After");
+        List<PropagationTaskTO> tasksA = taskService.list(TaskType.PROPAGATION);
+        for (PropagationTaskTO task : tasksA) {
+        	System.out.println(task.getId());
+        	System.out.println(task.getAccountId());
+        	System.out.println(task.getOldAccountId());
+        }
     }
 
     @Test

Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java?rev=1435132&r1=1435131&r2=1435132&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java (original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java Fri
Jan 18 13:41:34 2013
@@ -1835,7 +1835,7 @@ public class UserTestITCase extends Abst
 
     @Test
     public void issueSYNCOPE266() {
-        UserTO userTO = getSampleTO("syncope266@apache.org");
+        UserTO userTO = getUniqueSampleTO("syncope266@apache.org");
         userTO.getResources().clear();
 
         userTO = userService.create(userTO);



Mime
View raw message