Author: andreapatricelli
Date: Tue May 20 14:26:57 2014
New Revision: 1596264

URL: http://svn.apache.org/r1596264
Log:
[SYNCOPE-492] provided notification object with field to enable/disable it, 
updated tests and console accordingly

Modified:
    
syncope/trunk/common/src/main/java/org/apache/syncope/common/to/NotificationTO.java
    
syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/Configuration.java
    
syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/NotificationModalPage.java
    
syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/Configuration.properties
    
syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/Configuration_it.properties
    
syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/Configuration_pt_BR.properties
    
syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/NotificationModalPage.html
    
syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/NotificationModalPage.properties
    
syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/NotificationModalPage_it.properties
    
syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/NotificationModalPage_pt_BR.properties
    
syncope/trunk/console/src/test/java/org/apache/syncope/console/ConfigurationTestITCase.java
    
syncope/trunk/core/src/main/java/org/apache/syncope/core/notification/NotificationManager.java
    
syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/Notification.java
    
syncope/trunk/core/src/test/java/org/apache/syncope/core/notification/NotificationTest.java
    
syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/TaskTestITCase.java
    syncope/trunk/core/src/test/resources/content.xml

Modified: 
syncope/trunk/common/src/main/java/org/apache/syncope/common/to/NotificationTO.java
URL: 
http://svn.apache.org/viewvc/syncope/trunk/common/src/main/java/org/apache/syncope/common/to/NotificationTO.java?rev=1596264&r1=1596263&r2=1596264&view=diff
==============================================================================
--- 
syncope/trunk/common/src/main/java/org/apache/syncope/common/to/NotificationTO.java
 (original)
+++ 
syncope/trunk/common/src/main/java/org/apache/syncope/common/to/NotificationTO.java
 Tue May 20 14:26:57 2014
@@ -60,6 +60,8 @@ public class NotificationTO extends Abst
     private String template;
 
     private TraceLevel traceLevel;
+    
+    private boolean active;
 
     public String getAbout() {
         return about;
@@ -154,4 +156,12 @@ public class NotificationTO extends Abst
     public void setTraceLevel(TraceLevel traceLevel) {
         this.traceLevel = traceLevel;
     }
+
+    public boolean isActive() {
+        return active;
+    }
+
+    public void setActive(boolean active) {
+        this.active = active;
+    }
 }

Modified: 
syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/Configuration.java
URL: 
http://svn.apache.org/viewvc/syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/Configuration.java?rev=1596264&r1=1596263&r2=1596264&view=diff
==============================================================================
--- 
syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/Configuration.java
 (original)
+++ 
syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/Configuration.java
 Tue May 20 14:26:57 2014
@@ -416,6 +416,8 @@ public class Configuration extends BaseP
                 new ResourceModel("template"), "template", "template"));
         notificationCols.add(new PropertyColumn<NotificationTO, String>(
                 new ResourceModel("traceLevel"), "traceLevel", "traceLevel"));
+        notificationCols.add(new PropertyColumn<NotificationTO, String>(
+                new ResourceModel("active"), "active", "active"));
 
         notificationCols.add(new AbstractColumn<NotificationTO, String>(new 
ResourceModel("actions", "")) {
 

Modified: 
syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/NotificationModalPage.java
URL: 
http://svn.apache.org/viewvc/syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/NotificationModalPage.java?rev=1596264&r1=1596263&r2=1596264&view=diff
==============================================================================
--- 
syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/NotificationModalPage.java
 (original)
+++ 
syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/NotificationModalPage.java
 Tue May 20 14:26:57 2014
@@ -94,6 +94,13 @@ class NotificationModalPage extends Base
         traceLevel.addRequiredLabel();
         form.add(traceLevel);
 
+        final AjaxCheckBoxPanel isActive = new AjaxCheckBoxPanel("isActive",
+                getString("isActive"), new 
PropertyModel<Boolean>(notificationTO, "active"));
+        if (createFlag) {
+            isActive.getField().setDefaultModelObject(Boolean.TRUE);
+        }
+        form.add(isActive);
+
         final WebMarkupContainer aboutContainer = new 
WebMarkupContainer("aboutContainer");
         aboutContainer.setOutputMarkupId(true);
 
@@ -205,7 +212,7 @@ class NotificationModalPage extends Base
 
         final UserSearchPanel recipients
                 = new 
UserSearchPanel.Builder("recipients").fiql(notificationTO.getRecipients()).build();
-        
+
         recipients.setEnabled(checkRecipients.getModelObject());
         recipientsContainer.add(recipients);
 
@@ -216,7 +223,7 @@ class NotificationModalPage extends Base
         if (createFlag) {
             selfAsRecipient.getField().setDefaultModelObject(Boolean.FALSE);
         }
- 
+
         selfAsRecipient.getField().add(new 
AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {
 
             private static final long serialVersionUID = -1107858522700306810L;

Modified: 
syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/Configuration.properties
URL: 
http://svn.apache.org/viewvc/syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/Configuration.properties?rev=1596264&r1=1596263&r2=1596264&view=diff
==============================================================================
--- 
syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/Configuration.properties
 (original)
+++ 
syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/Configuration.properties
 Tue May 20 14:26:57 2014
@@ -38,3 +38,4 @@ subject=Subject
 noActivitiEnabledForUsers=Activiti not enabled for users
 policies=Policies
 logs=Logs
+active=Enabled

Modified: 
syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/Configuration_it.properties
URL: 
http://svn.apache.org/viewvc/syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/Configuration_it.properties?rev=1596264&r1=1596263&r2=1596264&view=diff
==============================================================================
--- 
syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/Configuration_it.properties
 (original)
+++ 
syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/Configuration_it.properties
 Tue May 20 14:26:57 2014
@@ -38,3 +38,4 @@ subject=Oggetto
 noActivitiEnabledForUsers=Activiti non configurato per gli utenti
 policies=Politiche
 logs=Logs
+active=Abilitata

Modified: 
syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/Configuration_pt_BR.properties
URL: 
http://svn.apache.org/viewvc/syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/Configuration_pt_BR.properties?rev=1596264&r1=1596263&r2=1596264&view=diff
==============================================================================
--- 
syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/Configuration_pt_BR.properties
 (original)
+++ 
syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/Configuration_pt_BR.properties
 Tue May 20 14:26:57 2014
@@ -38,3 +38,4 @@ subject=Assunto
 noActivitiEnabledForUsers=Activiti n\u00e3o habilitado para usu\u00e1rios
 policies=Pol\u00edticas
 logs=Logs
+active=Ativada

Modified: 
syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/NotificationModalPage.html
URL: 
http://svn.apache.org/viewvc/syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/NotificationModalPage.html?rev=1596264&r1=1596263&r2=1596264&view=diff
==============================================================================
--- 
syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/NotificationModalPage.html
 (original)
+++ 
syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/NotificationModalPage.html
 Tue May 20 14:26:57 2014
@@ -113,6 +113,14 @@ under the License.
                   <span wicket:id="traceLevel">[traceLevel]</span>
                 </div>
               </div>
+              <div class="tablerow alt">
+                <div class="tablecolumn_label medium_fixedsize">
+                  <label for="isActive"><wicket:message 
key="isActive"/></label>
+                </div>
+                <div class="tablecolumn_field medium_dynamicsize">
+                  <span wicket:id="isActive">[isActive]</span>
+                </div>
+              </div>
             </div>
           </div>
 

Modified: 
syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/NotificationModalPage.properties
URL: 
http://svn.apache.org/viewvc/syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/NotificationModalPage.properties?rev=1596264&r1=1596263&r2=1596264&view=diff
==============================================================================
--- 
syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/NotificationModalPage.properties
 (original)
+++ 
syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/NotificationModalPage.properties
 Tue May 20 14:26:57 2014
@@ -33,3 +33,4 @@ userFilter=User filter
 userFilterWarning=Do not use this filter unless events are not targeted at 
users
 userNotifications=User notifications
 userNotificationsWarning=Do not select this checkbox unless events are not 
targeted at users
+isActive=Enabled

Modified: 
syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/NotificationModalPage_it.properties
URL: 
http://svn.apache.org/viewvc/syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/NotificationModalPage_it.properties?rev=1596264&r1=1596263&r2=1596264&view=diff
==============================================================================
--- 
syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/NotificationModalPage_it.properties
 (original)
+++ 
syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/NotificationModalPage_it.properties
 Tue May 20 14:26:57 2014
@@ -33,3 +33,4 @@ userFilter=Filtro utenti
 userFilterWarning=Non usare questo filtro se gli eventi catturati non 
riguardano espressamente utenti
 userNotifications=Notifiche utente
 userNotificationsWarning=Non selezionare questa checkbox se gli eventi 
catturati non riguardano espressamente utenti
+isActive=Abilitata

Modified: 
syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/NotificationModalPage_pt_BR.properties
URL: 
http://svn.apache.org/viewvc/syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/NotificationModalPage_pt_BR.properties?rev=1596264&r1=1596263&r2=1596264&view=diff
==============================================================================
--- 
syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/NotificationModalPage_pt_BR.properties
 (original)
+++ 
syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/NotificationModalPage_pt_BR.properties
 Tue May 20 14:26:57 2014
@@ -32,4 +32,5 @@ checkAbout=Todos
 userFilter=User filter
 userFilterWarning=N\u00e3o use este filtro n\u00e3o ser que os eventos 
n\u00e3o s\u00e3o direcionados a usu\u00e1rios
 userNotifications=Notifica\u00e7\u00f5es do usu\u00e1rio
-userNotificationsWarning=N\u00e3o selecione esta op\u00e7\u00e3o a menos que 
os eventos n\u00e3o s\u00e3o direcionados a usu\u00e1rios
\ No newline at end of file
+userNotificationsWarning=N\u00e3o selecione esta op\u00e7\u00e3o a menos que 
os eventos n\u00e3o s\u00e3o direcionados a usu\u00e1rios
+isActive=Ativada
\ No newline at end of file

Modified: 
syncope/trunk/console/src/test/java/org/apache/syncope/console/ConfigurationTestITCase.java
URL: 
http://svn.apache.org/viewvc/syncope/trunk/console/src/test/java/org/apache/syncope/console/ConfigurationTestITCase.java?rev=1596264&r1=1596263&r2=1596264&view=diff
==============================================================================
--- 
syncope/trunk/console/src/test/java/org/apache/syncope/console/ConfigurationTestITCase.java
 (original)
+++ 
syncope/trunk/console/src/test/java/org/apache/syncope/console/ConfigurationTestITCase.java
 Tue May 20 14:26:57 2014
@@ -204,6 +204,94 @@ public class ConfigurationTestITCase ext
     }
 
     @Test
+    public void createDisabledNotification() {
+        selenium.click("css=img[alt=\"Configuration\"]");
+
+        
selenium.waitForCondition("selenium.isElementPresent(\"//div[@id='tabs']\");", 
"30000");
+
+        selenium.click("//div[@id='tabs']/ul/li[3]/a");
+
+        selenium.click("//a[contains(text(),'Create new notification')]");
+
+        selenium.waitForCondition("selenium.isElementPresent("
+                + "\"//div[2]/form/div[3]/div/div/div/div/label\");", "30000");
+
+        
selenium.waitForCondition("selenium.isElementPresent(\"//input[@name='sender:textField']\");",
 "30000");
+
+        selenium.waitForCondition("selenium.isElementPresent(\"//iframe\");", 
"30000");
+        selenium.selectFrame("index=0");
+
+        selenium.type("name=sender:textField", "[email protected]");
+
+        selenium.type("name=sender:textField", "[email protected]");
+
+        
selenium.select("//div[2]/form/div[3]/div/div/div[3]/div[2]/span/select", 
"label=UserSchema");
+
+        selenium.waitForCondition("selenium.isElementPresent("
+                + 
"\"//div[2]/form/div[3]/div/div/div[4]/div[2]/span/select/option[2]\");", 
"30000");
+
+        
selenium.select("//div[2]/form/div[3]/div/div/div[4]/div[2]/span/select", 
"label=fullname");
+
+        
selenium.select("//div[2]/form/div[3]/div/div/div[5]/div[2]/span/select", 
"label=optin");
+
+        
selenium.select("//div[2]/form/div[3]/div/div/div[6]/div[2]/span/select", 
"label=ALL");
+
+        // disable notification
+        
selenium.click("//div[2]/form/div[3]/div/div/div[7]/div[2]/span/input");
+        
+        selenium.click("//div[2]/form/div[3]/ul/li[3]/a/span");
+
+        selenium.click("//div[2]/form/div[3]/ul/li[2]/a/span");
+
+        selenium.waitForCondition("selenium.isElementPresent(\""
+                + 
"//select[@name='eventSelection:categoryContainer:type:dropDownChoiceField']"
+                + "/option[text()='PROPAGATION']\");",
+                "30000");
+
+        selenium.select(
+                
"//select[@name='eventSelection:categoryContainer:type:dropDownChoiceField']",
+                "label=PROPAGATION");
+
+        selenium.waitForCondition("selenium.isElementPresent(\""
+                + 
"//select[@name='eventSelection:categoryContainer:category:dropDownChoiceField']"
+                + "/option[text()='role']\");",
+                "30000");
+        
+        selenium.select(
+                
"//select[@name='eventSelection:categoryContainer:category:dropDownChoiceField']",
+                "label=role");
+
+        selenium.waitForCondition("selenium.isElementPresent(\""
+                + 
"//select[@name='eventSelection:categoryContainer:subcategory:dropDownChoiceField']"
+                + "/option[text()='resource-db-sync']\");",
+                "30000");
+
+        selenium.select(
+                
"//select[@name='eventSelection:categoryContainer:subcategory:dropDownChoiceField']",
+                "label=resource-db-sync");
+
+        selenium.waitForCondition("selenium.isElementPresent("
+                + 
"\"//input[@name='eventSelection:eventsContainer:eventsPanel:failureGroup']\");",
+                "30000");
+
+        
selenium.click("//div[@class='eventSelectionWidzard']/div[2]/div[3]/span/div/input");
+
+        selenium.click("//div[2]/form/div[3]/ul/li[4]/a/span");
+        
+        selenium.click("//div[2]/form/div[3]/div[4]/div/div/span/input");
+
+        selenium.type(
+                
"name=staticRecipients:multiValueContainer:view:0:panel:textField", 
"[email protected]");
+
+        selenium.waitForCondition("selenium.isElementPresent("
+                + "\"//div[2]/form/div[3]/div[4]/div/div[2]/label\");", 
"30000");
+
+        selenium.click("//div[2]/form/div[4]/input");
+
+        seleniumDriver.switchTo().defaultContent();
+    }
+    
+    @Test
     public void issueSYNCOPE189() {
         selenium.click("css=img[alt=\"Configuration\"]");
 

Modified: 
syncope/trunk/core/src/main/java/org/apache/syncope/core/notification/NotificationManager.java
URL: 
http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/notification/NotificationManager.java?rev=1596264&r1=1596263&r2=1596264&view=diff
==============================================================================
--- 
syncope/trunk/core/src/main/java/org/apache/syncope/core/notification/NotificationManager.java
 (original)
+++ 
syncope/trunk/core/src/main/java/org/apache/syncope/core/notification/NotificationManager.java
 Tue May 20 14:26:57 2014
@@ -269,35 +269,40 @@ public class NotificationManager {
 
         for (Notification notification : notificationDAO.findAll()) {
             LOG.debug("Notification available about {}", 
notification.getAbout());
+            if (notification.isActive()) {
 
-            final Set<String> events = new 
HashSet<String>(notification.getEvents());
-            
events.retainAll(Collections.<String>singleton(LoggerEventUtils.buildEvent(
-                    type, category, subcategory, event, condition)));
-
-            if (events.isEmpty()) {
-                LOG.debug("No events found about {}", attributable);
-            } else if (attributableType == null || attributable == null || 
notification.getAbout() == null
-                    || searchDAO.matches(attributable,
-                            
SearchCondConverter.convert(notification.getAbout()),
-                            AttributableUtil.getInstance(attributableType))) {
-
-                LOG.debug("Creating notification task for events {} about {}", 
events, attributable);
-
-                final Map<String, Object> model = new HashMap<String, 
Object>();
-                model.put("type", type);
-                model.put("category", category);
-                model.put("subcategory", subcategory);
-                model.put("event", event);
-                model.put("condition", condition);
-                model.put("before", before);
-                model.put("output", output);
-                model.put("input", input);
+                final Set<String> events = new 
HashSet<String>(notification.getEvents());
+                
events.retainAll(Collections.<String>singleton(LoggerEventUtils.buildEvent(
+                        type, category, subcategory, event, condition)));
+
+                if (events.isEmpty()) {
+                    LOG.debug("No events found about {}", attributable);
+                } else if (attributableType == null || attributable == null || 
notification.
+                        getAbout() == null || searchDAO.matches(attributable,
+                                
SearchCondConverter.convert(notification.getAbout()),
+                                
AttributableUtil.getInstance(attributableType))) {
+
+                    LOG.debug("Creating notification task for events {} about 
{}", events, attributable);
+
+                    final Map<String, Object> model = new HashMap<String, 
Object>();
+                    model.put("type", type);
+                    model.put("category", category);
+                    model.put("subcategory", subcategory);
+                    model.put("event", event);
+                    model.put("condition", condition);
+                    model.put("before", before);
+                    model.put("output", output);
+                    model.put("input", input);
+
+                    if (attributable instanceof SyncopeUser) {
+                        model.put("user", 
userDataBinder.getUserTO((SyncopeUser) attributable));
+                    }
 
-                if (attributable instanceof SyncopeUser) {
-                    model.put("user", userDataBinder.getUserTO((SyncopeUser) 
attributable));
+                    taskDAO.save(getNotificationTask(notification, 
attributable, model));
                 }
-
-                taskDAO.save(getNotificationTask(notification, attributable, 
model));
+            } else {
+                LOG.debug("Notification {}, about {} is deactivated, 
notification task will not be created",
+                        notification.getId(), notification.getAbout());
             }
         }
     }

Modified: 
syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/Notification.java
URL: 
http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/Notification.java?rev=1596264&r1=1596263&r2=1596264&view=diff
==============================================================================
--- 
syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/Notification.java
 (original)
+++ 
syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/Notification.java
 Tue May 20 14:26:57 2014
@@ -83,11 +83,18 @@ public class Notification extends Abstra
     @NotNull
     @Enumerated(EnumType.STRING)
     private TraceLevel traceLevel;
+    
+    @Column(nullable = false)
+    @Basic
+    @Min(0)
+    @Max(1)
+    private Integer active;
 
     public Notification() {
         events = new ArrayList<String>();
         staticRecipients = new ArrayList<String>();
         selfAsRecipient = getBooleanAsInteger(false);
+        active = getBooleanAsInteger(true);
         traceLevel = TraceLevel.ALL;
     }
 
@@ -204,4 +211,12 @@ public class Notification extends Abstra
     public void setTraceLevel(TraceLevel traceLevel) {
         this.traceLevel = traceLevel;
     }
+
+    public boolean isActive() {
+        return isBooleanAsInteger(active);
+    }
+
+    public void setActive(final boolean active) {
+        this.active = getBooleanAsInteger(active);
+    }
 }

Modified: 
syncope/trunk/core/src/test/java/org/apache/syncope/core/notification/NotificationTest.java
URL: 
http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/notification/NotificationTest.java?rev=1596264&r1=1596263&r2=1596264&view=diff
==============================================================================
--- 
syncope/trunk/core/src/test/java/org/apache/syncope/core/notification/NotificationTest.java
 (original)
+++ 
syncope/trunk/core/src/test/java/org/apache/syncope/core/notification/NotificationTest.java
 Tue May 20 14:26:57 2014
@@ -441,7 +441,7 @@ public class NotificationTest {
 
         notification.setRecipientAttrName("email");
         notification.setRecipientAttrType(IntMappingType.UserSchema);
-        
+
         
notification.getStaticRecipients().add("[email protected]");
 
         Random random = new Random(System.currentTimeMillis());
@@ -479,13 +479,56 @@ public class NotificationTest {
                 recipients = task.getRecipients();
             }
         }
-        
+
         assertNotNull(taskId);
         assertNotNull(textBody);
         assertTrue(recipients.contains("[email protected]"));
-        
+
         // 5. execute Notification task and verify e-mail
         taskController.execute(taskId, false);
         assertTrue(verifyMail(sender, subject));
     }
+
+    @Test
+    public void issueSYNCOPE492() throws Exception {
+        // 1. create suitable disabled notification for subsequent tests
+        Notification notification = new Notification();
+        notification.addEvent("[REST]:[UserController]:[]:[create]:[SUCCESS]");
+        
notification.setAbout(SyncopeClient.getUserSearchConditionBuilder().hasRoles(7L).query());
+        notification.setSelfAsRecipient(true);
+
+        notification.setRecipientAttrName("email");
+        notification.setRecipientAttrType(IntMappingType.UserSchema);
+
+        
notification.getStaticRecipients().add("[email protected]");
+
+        Random random = new Random(System.currentTimeMillis());
+        String sender = "syncopetest-" + random.nextLong() + 
"@syncope.apache.org";
+        notification.setSender(sender);
+        String subject = "Test notification " + random.nextLong();
+        notification.setSubject(subject);
+        notification.setTemplate("optin");
+        notification.setActive(false);
+
+        Notification actual = notificationDAO.save(notification);
+        assertNotNull(actual);
+
+        notificationDAO.flush();
+
+        final int tasksNumberBefore = 
taskDAO.findAll(NotificationTask.class).size();
+
+        // 2. create user
+        UserTO userTO = UserTestITCase.getUniqueSampleTO(mailAddress);
+        MembershipTO membershipTO = new MembershipTO();
+        membershipTO.setRoleId(7);
+        userTO.getMemberships().add(membershipTO);
+
+        userController.create(userTO);
+
+        // 3. force Quartz job execution
+        notificationJob.execute(null);
+
+        // 4. check if number of tasks is not incremented
+        assertEquals(tasksNumberBefore, 
taskDAO.findAll(NotificationTask.class).size());
+    }
 }

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=1596264&r1=1596263&r2=1596264&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
 Tue May 20 14:26:57 2014
@@ -550,6 +550,7 @@ public class TaskTestITCase extends Abst
         String subject = "Test notification";
         notification.setSubject(subject);
         notification.setTemplate("optin");
+        notification.setActive(true);
 
         Response response = notificationService.create(notification);
         notification = getObject(response.getLocation(), 
NotificationService.class, NotificationTO.class);

Modified: syncope/trunk/core/src/test/resources/content.xml
URL: 
http://svn.apache.org/viewvc/syncope/trunk/core/src/test/resources/content.xml?rev=1596264&r1=1596263&r2=1596264&view=diff
==============================================================================
--- syncope/trunk/core/src/test/resources/content.xml (original)
+++ syncope/trunk/core/src/test/resources/content.xml Tue May 20 14:26:57 2014
@@ -847,7 +847,7 @@ under the License.
   <Notification id="1" sender="[email protected]" subject="Test subject" 
template="test" selfAsRecipient="0" traceLevel="ALL"
                 about="fullname==*o*;fullname==*i*"
                 recipients="$roles==7"
-                recipientAttrType="UserSchema" recipientAttrName="email"/>
+                recipientAttrType="UserSchema" recipientAttrName="email" 
active="1"/>
   <Notification_events Notification_id="1" 
events="[CUSTOM]:[]:[]:[unexisting1]:[FAILURE]"/>
   <Notification_events Notification_id="1" 
events="[CUSTOM]:[]:[]:[unexisting2]:[SUCCESS]"/>
     


Reply via email to