continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eveni...@apache.org
Subject svn commit: r495567 - in /maven/continuum/trunk/continuum-core/src: main/java/org/apache/maven/continuum/execution/maven/m2/ main/java/org/apache/maven/continuum/project/builder/maven/ test/java/org/apache/maven/continuum/ test/java/org/apache/maven/co...
Date Fri, 12 Jan 2007 13:26:55 GMT
Author: evenisse
Date: Fri Jan 12 05:26:52 2007
New Revision: 495567

URL: http://svn.apache.org/viewvc?view=rev&rev=495567
Log:
[CONTINUUM-1105] Remove duplicated notification when the notifier is defined in the pom.
Submitted by: Maria Odea Ching

Modified:
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/DefaultMavenBuilderHelper.java
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilder.java
    maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/DefaultContinuumTest.java
    maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilderTest.java

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/DefaultMavenBuilderHelper.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/DefaultMavenBuilderHelper.java?view=diff&rev=495567&r1=495566&r2=495567
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/DefaultMavenBuilderHelper.java
(original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/DefaultMavenBuilderHelper.java
Fri Jan 12 05:26:52 2007
@@ -276,59 +276,54 @@
 
         // ----------------------------------------------------------------------
         // Notifiers
-        //
-        // if its a groupPom, then notifiers have been taken care of
         // ----------------------------------------------------------------------
 
-        if ( !groupPom )
-        {
-            List userNotifiers = new ArrayList();
+        List userNotifiers = new ArrayList();
 
-            if ( continuumProject.getNotifiers() != null )
+        if ( continuumProject.getNotifiers() != null )
+        {
+            for ( int i = 0; i < continuumProject.getNotifiers().size(); i++ )
             {
-                for ( int i = 0; i < continuumProject.getNotifiers().size(); i++ )
-                {
-                    ProjectNotifier notifier = (ProjectNotifier) continuumProject.getNotifiers().get(
i );
+                ProjectNotifier notifier = (ProjectNotifier) continuumProject.getNotifiers().get(
i );
 
-                    if ( notifier.isFromUser() )
-                    {
-                        ProjectNotifier userNotifier = new ProjectNotifier();
+                if ( notifier.isFromUser() )
+                {
+                    ProjectNotifier userNotifier = new ProjectNotifier();
 
-                        userNotifier.setType( notifier.getType() );
+                    userNotifier.setType( notifier.getType() );
 
-                        userNotifier.setEnabled( notifier.isEnabled() );
+                    userNotifier.setEnabled( notifier.isEnabled() );
 
-                        userNotifier.setConfiguration( notifier.getConfiguration() );
+                    userNotifier.setConfiguration( notifier.getConfiguration() );
 
-                        userNotifier.setFrom( notifier.getFrom() );
+                    userNotifier.setFrom( notifier.getFrom() );
 
-                        userNotifier.setRecipientType( notifier.getRecipientType() );
+                    userNotifier.setRecipientType( notifier.getRecipientType() );
 
-                        userNotifier.setSendOnError( notifier.isSendOnError() );
+                    userNotifier.setSendOnError( notifier.isSendOnError() );
 
-                        userNotifier.setSendOnFailure( notifier.isSendOnFailure() );
+                    userNotifier.setSendOnFailure( notifier.isSendOnFailure() );
 
-                        userNotifier.setSendOnSuccess( notifier.isSendOnSuccess() );
+                    userNotifier.setSendOnSuccess( notifier.isSendOnSuccess() );
 
-                        userNotifier.setSendOnWarning( notifier.isSendOnWarning() );
+                    userNotifier.setSendOnWarning( notifier.isSendOnWarning() );
 
-                        userNotifiers.add( userNotifier );
-                    }
+                    userNotifiers.add( userNotifier );
                 }
             }
+        }
 
-            List notifiers = getNotifiers( result, mavenProject, continuumProject );
-            if ( notifiers != null )
-            {
-                continuumProject.setNotifiers( notifiers );
-            }
+        List notifiers = getNotifiers( result, mavenProject, continuumProject );
+        if ( notifiers != null )
+        {
+            continuumProject.setNotifiers( notifiers );
+        }
 
-            for ( Iterator i = userNotifiers.iterator(); i.hasNext(); )
-            {
-                ProjectNotifier notifier = (ProjectNotifier) i.next();
+        for ( Iterator i = userNotifiers.iterator(); i.hasNext(); )
+        {
+            ProjectNotifier notifier = (ProjectNotifier) i.next();
 
-                continuumProject.addNotifier( notifier );
-            }
+            continuumProject.addNotifier( notifier );
         }
     }
 

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilder.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilder.java?view=diff&rev=495567&r1=495566&r2=495567
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilder.java
(original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilder.java
Fri Jan 12 05:26:52 2007
@@ -25,7 +25,6 @@
 import org.apache.maven.continuum.model.project.BuildDefinition;
 import org.apache.maven.continuum.model.project.Project;
 import org.apache.maven.continuum.model.project.ProjectGroup;
-import org.apache.maven.continuum.model.project.ProjectNotifier;
 import org.apache.maven.continuum.model.project.Schedule;
 import org.apache.maven.continuum.project.builder.AbstractContinuumProjectBuilder;
 import org.apache.maven.continuum.project.builder.ContinuumProjectBuilder;
@@ -33,7 +32,6 @@
 import org.apache.maven.continuum.project.builder.ContinuumProjectBuildingResult;
 import org.apache.maven.continuum.store.ContinuumStore;
 import org.apache.maven.continuum.store.ContinuumStoreException;
-import org.apache.maven.model.Notifier;
 import org.apache.maven.project.MavenProject;
 import org.codehaus.plexus.util.StringUtils;
 
@@ -310,51 +308,6 @@
         // ----------------------------------------------------------------------
 
         projectGroup.setDescription( mavenProject.getDescription() );
-
-        //
-        // group lvl notifiers
-        //
-        if ( mavenProject.getCiManagement() != null && mavenProject.getCiManagement().getNotifiers()
!= null )
-        {
-            List notifiers = new ArrayList();
-
-            for ( Iterator i = mavenProject.getCiManagement().getNotifiers().iterator();
i.hasNext(); )
-            {
-                Notifier projectNotifier = (Notifier) i.next();
-
-                ProjectNotifier notifier = new ProjectNotifier();
-
-                if ( StringUtils.isEmpty( projectNotifier.getType() ) )
-                {
-                    result.addError( ContinuumProjectBuildingResult.ERROR_MISSING_NOTIFIER_TYPE
);
-                    return null;
-                }
-
-                notifier.setType( projectNotifier.getType() );
-
-                if ( projectNotifier.getConfiguration() == null )
-                {
-                    result.addError( ContinuumProjectBuildingResult.ERROR_MISSING_NOTIFIER_CONFIGURATION
);
-                    return null;
-                }
-
-                notifier.setConfiguration( projectNotifier.getConfiguration() );
-
-                notifier.setFrom( ProjectNotifier.FROM_PROJECT );
-
-                notifier.setSendOnSuccess( projectNotifier.isSendOnSuccess() );
-
-                notifier.setSendOnFailure( projectNotifier.isSendOnFailure() );
-
-                notifier.setSendOnError( projectNotifier.isSendOnError() );
-
-                notifier.setSendOnWarning( projectNotifier.isSendOnWarning() );
-
-                notifiers.add( notifier );
-            }
-
-            projectGroup.setNotifiers( notifiers );
-        }
 
         return projectGroup;
     }

Modified: maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/DefaultContinuumTest.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/DefaultContinuumTest.java?view=diff&rev=495567&r1=495566&r2=495567
==============================================================================
--- maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/DefaultContinuumTest.java
(original)
+++ maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/DefaultContinuumTest.java
Fri Jan 12 05:26:52 2007
@@ -25,9 +25,9 @@
 import org.apache.maven.continuum.model.project.ProjectGroup;
 import org.apache.maven.continuum.model.project.ProjectNotifier;
 import org.apache.maven.continuum.project.builder.ContinuumProjectBuildingResult;
+import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
 import org.codehaus.plexus.taskqueue.TaskQueue;
 import org.codehaus.plexus.taskqueue.execution.TaskQueueExecutor;
-import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
 
 import java.io.File;
 import java.util.Collection;
@@ -48,12 +48,12 @@
     {
         try
         {
-           lookup( Continuum.ROLE );
+            lookup( Continuum.ROLE );
         }
         catch ( ComponentLookupException e )
         {
-           e.printStackTrace();
-           throw e;
+            e.printStackTrace();
+            throw e;
         }
 
     }
@@ -109,7 +109,8 @@
             projects.put( project.getName(), project );
 
             // validate project in project group
-            assertTrue( "project not in project group", getStore().getProjectGroupByProjectId(
project.getId() ) != null );
+            assertTrue( "project not in project group",
+                        getStore().getProjectGroupByProjectId( project.getId() ) != null
);
         }
 
         assertTrue( "no irc notifier", projects.containsKey( "Continuum IRC Notifier" ) );
@@ -117,7 +118,6 @@
         assertTrue( "no jabber notifier", projects.containsKey( "Continuum Jabber Notifier"
) );
 
 
-
     }
 
     public void testUpdateMavenTwoProject()
@@ -175,15 +175,15 @@
         // reattach
         project = continuum.getProject( project.getId() );
 
-        ProjectGroup projectGroup  = getStore().getProjectGroupByProjectId( project.getId()
);
+        ProjectGroup projectGroup = getStore().getProjectGroupByProjectId( project.getId()
);
 
         projectGroup = getStore().getProjectGroupWithBuildDetails( projectGroup.getId() );
 
         List buildDefs = projectGroup.getBuildDefinitions();
 
-        assertTrue ("missing project group build definition", !buildDefs.isEmpty() );
+        assertTrue( "missing project group build definition", !buildDefs.isEmpty() );
 
-        assertTrue ("more then one project group build definition on add project", buildDefs.size()
== 1 );
+        assertTrue( "more then one project group build definition on add project", buildDefs.size()
== 1 );
 
         BuildDefinition pgbd = (BuildDefinition) buildDefs.get( 0 );
 
@@ -191,34 +191,37 @@
 
         continuum.updateBuildDefinitionForProjectGroup( projectGroup.getId(), pgbd );
 
-        pgbd = continuum.getBuildDefinition(  pgbd.getId() );
+        pgbd = continuum.getBuildDefinition( pgbd.getId() );
 
-        assertTrue ( "update failed for project group build definition", "foo".equals( pgbd.getGoals()
) );
+        assertTrue( "update failed for project group build definition", "foo".equals( pgbd.getGoals()
) );
 
-        assertTrue ( "project group build definition is not default", pgbd.isDefaultForProject()
);
+        assertTrue( "project group build definition is not default", pgbd.isDefaultForProject()
);
 
-        assertTrue ( "project group build definition not default for project", continuum.getDefaultBuildDefinition(
project.getId() ).getId() == pgbd.getId() );
+        assertTrue( "project group build definition not default for project",
+                    continuum.getDefaultBuildDefinition( project.getId() ).getId() == pgbd.getId()
);
 
         BuildDefinition nbd = new BuildDefinition();
-        nbd.setGoals("clean");
-        nbd.setArguments("");
+        nbd.setGoals( "clean" );
+        nbd.setArguments( "" );
         nbd.setDefaultForProject( true );
         nbd.setSchedule( getStore().getScheduleByName( DefaultContinuumInitializer.DEFAULT_SCHEDULE_NAME
) );
 
         continuum.addBuildDefinitionToProject( project.getId(), nbd );
 
-        assertTrue ( "project lvl build definition not default for project", continuum.getDefaultBuildDefinition(
project.getId() ).getId() == nbd.getId() );
+        assertTrue( "project lvl build definition not default for project",
+                    continuum.getDefaultBuildDefinition( project.getId() ).getId() == nbd.getId()
);
 
         continuum.removeBuildDefinitionFromProject( project.getId(), nbd.getId() );
 
-        assertTrue ( "default build definition didn't toggle back to project group level",
continuum.getDefaultBuildDefinition( project.getId() ).getId() == pgbd.getId() );
+        assertTrue( "default build definition didn't toggle back to project group level",
+                    continuum.getDefaultBuildDefinition( project.getId() ).getId() == pgbd.getId()
);
 
         try
         {
             continuum.removeBuildDefinitionFromProjectGroup( projectGroup.getId(), pgbd.getId()
);
-            fail("we were able to remove the default build definition, and that is bad");
+            fail( "we were able to remove the default build definition, and that is bad"
);
         }
-        catch (ContinuumException expected)
+        catch ( ContinuumException expected )
         {
 
         }
@@ -226,6 +229,7 @@
 
     /**
      * todo add another project group to test
+     *
      * @throws Exception
      */
     public void testProjectGroups()
@@ -267,10 +271,9 @@
         assertEquals( "Remove project group failed", projectGroupsBefore, projectGroupList.size()
);
     }
 
-
     /**
      * test the logic for notifiers
-     * 
+     *
      * @throws Exception
      */
     public void testProjectAndGroupNotifiers()
@@ -295,24 +298,22 @@
         ProjectGroup projectGroup = (ProjectGroup) result.getProjectGroups().get( 0 );
 
         continuum.addGroupNotifier( projectGroup.getId(), new ProjectNotifier() );
-       
+
         for ( Iterator i = projectGroup.getProjects().iterator(); i.hasNext(); )
         {
-            Project p = (Project)i.next();
-            continuum.addNotifier( p.getId(), new ProjectNotifier() );           
+            Project p = (Project) i.next();
+            continuum.addNotifier( p.getId(), new ProjectNotifier() );
         }
 
         projectGroup = continuum.getProjectGroup( projectGroup.getId() );
 
-
-        assertEquals( 2, projectGroup.getNotifiers().size() );
-
+        assertEquals( 1, projectGroup.getNotifiers().size() );
 
         for ( Iterator i = projectGroup.getProjects().iterator(); i.hasNext(); )
         {
-            Project p = (Project)i.next();
-            assertEquals( 1, p.getNotifiers().size() );
-        }        
+            Project p = (Project) i.next();
+            assertEquals( 2, p.getNotifiers().size() );
+        }
     }
 
     public void testExecuteAction()

Modified: maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilderTest.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilderTest.java?view=diff&rev=495567&r1=495566&r2=495567
==============================================================================
--- maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilderTest.java
(original)
+++ maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilderTest.java
Fri Jan 12 05:26:52 2007
@@ -61,19 +61,27 @@
 
         assertEquals( 1, result.getProjects().size() );
 
-        ProjectGroup pg = (ProjectGroup) result.getProjectGroups().get( 0 );
+        Project project = (Project) result.getProjects().get( 0 );
 
-        assertNotNull( pg );
+        assertNotNull( project );
 
-        assertNotNull( pg.getNotifiers() );
+        assertNotNull( project.getNotifiers() );
 
-        assertEquals( 1, pg.getNotifiers().size() );
+        assertEquals( 1, project.getNotifiers().size() );
 
-        ProjectNotifier notifier = (ProjectNotifier) pg.getNotifiers().get( 0 );
+        ProjectNotifier notifier = (ProjectNotifier) project.getNotifiers().get( 0 );
 
         assertEquals( "mail", notifier.getType() );
 
         assertEquals( "foo@bar", notifier.getConfiguration().get( "address" ) );
+
+        ProjectGroup pg = (ProjectGroup) result.getProjectGroups().get( 0 );
+
+        assertNotNull( pg );
+
+        assertNotNull( pg.getNotifiers() );
+
+        assertEquals( 0, pg.getNotifiers().size() );
     }
 
     public void testGetEmailAddressWhenTypeIsntSet()
@@ -94,19 +102,27 @@
 
         assertEquals( 1, result.getProjects().size() );
 
-        ProjectGroup pg = (ProjectGroup) result.getProjectGroups().get( 0 );
+        Project project = (Project) result.getProjects().get( 0 );
 
-        assertNotNull( pg );
+        assertNotNull( project );
 
-        assertNotNull( pg.getNotifiers() );
+        assertNotNull( project.getNotifiers() );
 
-        assertEquals( 1, pg.getNotifiers().size() );
+        assertEquals( 1, project.getNotifiers().size() );
 
-        ProjectNotifier notifier = (ProjectNotifier) pg.getNotifiers().get( 0 );
+        ProjectNotifier notifier = (ProjectNotifier) project.getNotifiers().get( 0 );
 
         assertEquals( "mail", notifier.getType() );
 
         assertEquals( "foo@bar", notifier.getConfiguration().get( "address" ) );
+
+        ProjectGroup pg = (ProjectGroup) result.getProjectGroups().get( 0 );
+
+        assertNotNull( pg );
+
+        assertNotNull( pg.getNotifiers() );
+
+        assertEquals( 0, pg.getNotifiers().size() );
     }
 
     public void testGetScmUrlWithParams()
@@ -130,16 +146,6 @@
         ProjectGroup pg = (ProjectGroup) result.getProjectGroups().get( 0 );
 
         assertNotNull( pg );
-
-        assertNotNull( pg.getNotifiers() );
-
-        assertEquals( 1, pg.getNotifiers().size() );
-
-        ProjectNotifier notifier = (ProjectNotifier) pg.getNotifiers().get( 0 );
-
-        assertEquals( "mail", notifier.getType() );
-
-        assertEquals( "foo@bar", notifier.getConfiguration().get( "address" ) );
 
         String username = System.getProperty( "user.name" );
 



Mime
View raw message