EMMA Coverage Report (generated Sun Sep 18 11:34:27 PHT 2011)
[all classes][org.apache.maven.continuum.notification.console]

COVERAGE SUMMARY FOR SOURCE FILE [ConsoleNotifier.java]

nameclass, %method, %block, %line, %
ConsoleNotifier.java100% (1/1)23%  (3/13)4%   (9/234)6%   (3/51)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ConsoleNotifier100% (1/1)23%  (3/13)4%   (9/234)6%   (3/51)
buildComplete (Project, BuildResult): void 0%   (0/1)0%   (0/23)0%   (0/4)
buildStarted (Project): void 0%   (0/1)0%   (0/6)0%   (0/2)
checkoutComplete (Project): void 0%   (0/1)0%   (0/6)0%   (0/2)
checkoutStarted (Project): void 0%   (0/1)0%   (0/6)0%   (0/2)
goalsCompleted (Project, BuildResult): void 0%   (0/1)0%   (0/23)0%   (0/4)
out (Project, BuildResult, String): void 0%   (0/1)0%   (0/26)0%   (0/4)
out (ProjectScmRoot, String): void 0%   (0/1)0%   (0/26)0%   (0/5)
prepareBuildComplete (ProjectScmRoot): void 0%   (0/1)0%   (0/22)0%   (0/4)
runningGoals (Project, BuildResult): void 0%   (0/1)0%   (0/6)0%   (0/2)
sendMessage (String, MessageContext): void 0%   (0/1)0%   (0/81)0%   (0/19)
<static initializer> 100% (1/1)100% (4/4)100% (1/1)
ConsoleNotifier (): void 100% (1/1)100% (3/3)100% (1/1)
getType (): String 100% (1/1)100% (2/2)100% (1/1)

1package org.apache.maven.continuum.notification.console;
2 
3/*
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements.  See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership.  The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License.  You may obtain a copy of the License at
11 *
12 *   http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied.  See the License for the
18 * specific language governing permissions and limitations
19 * under the License.
20 */
21 
22import org.apache.continuum.model.project.ProjectScmRoot;
23import org.apache.maven.continuum.model.project.BuildResult;
24import org.apache.maven.continuum.model.project.Project;
25import org.apache.maven.continuum.notification.AbstractContinuumNotifier;
26import org.apache.maven.continuum.notification.ContinuumNotificationDispatcher;
27import org.apache.maven.continuum.notification.MessageContext;
28import org.apache.maven.continuum.notification.NotificationException;
29import org.codehaus.plexus.util.StringUtils;
30import org.slf4j.Logger;
31import org.slf4j.LoggerFactory;
32 
33/**
34 * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
35 * @version $Id: ConsoleNotifier.java 764863 2009-04-14 16:28:12Z evenisse $
36 * @plexus.component role="org.apache.maven.continuum.notification.Notifier"
37 * role-hint="console"
38 */
39public class ConsoleNotifier
40    extends AbstractContinuumNotifier
41{
42    private static final Logger log = LoggerFactory.getLogger( ConsoleNotifier.class );
43 
44    // ----------------------------------------------------------------------
45    // Notifier Implementation
46    // ----------------------------------------------------------------------
47 
48    public String getType()
49    {
50        return "console";
51    }
52 
53    public void sendMessage( String messageId, MessageContext context )
54        throws NotificationException
55    {
56        Project project = context.getProject();
57 
58        BuildResult build = context.getBuildResult();
59 
60        ProjectScmRoot projectScmRoot = context.getProjectScmRoot();
61 
62        if ( messageId.equals( ContinuumNotificationDispatcher.MESSAGE_ID_BUILD_STARTED ) )
63        {
64            buildStarted( project );
65        }
66        else if ( messageId.equals( ContinuumNotificationDispatcher.MESSAGE_ID_CHECKOUT_STARTED ) )
67        {
68            checkoutStarted( project );
69        }
70        else if ( messageId.equals( ContinuumNotificationDispatcher.MESSAGE_ID_CHECKOUT_COMPLETE ) )
71        {
72            checkoutComplete( project );
73        }
74        else if ( messageId.equals( ContinuumNotificationDispatcher.MESSAGE_ID_RUNNING_GOALS ) )
75        {
76            runningGoals( project, build );
77        }
78        else if ( messageId.equals( ContinuumNotificationDispatcher.MESSAGE_ID_GOALS_COMPLETED ) )
79        {
80            goalsCompleted( project, build );
81        }
82        else if ( messageId.equals( ContinuumNotificationDispatcher.MESSAGE_ID_BUILD_COMPLETE ) )
83        {
84            buildComplete( project, build );
85        }
86        else if ( messageId.equals( ContinuumNotificationDispatcher.MESSAGE_ID_PREPARE_BUILD_COMPLETE ) )
87        {
88            prepareBuildComplete( projectScmRoot );
89        }
90        else
91        {
92            log.warn( "Unknown messageId: '" + messageId + "'." );
93        }
94    }
95 
96    // ----------------------------------------------------------------------
97    //
98    // ----------------------------------------------------------------------
99 
100    private void buildStarted( Project project )
101    {
102        out( project, null, "Build started." );
103    }
104 
105    private void checkoutStarted( Project project )
106    {
107        out( project, null, "Checkout started." );
108    }
109 
110    private void checkoutComplete( Project project )
111    {
112        out( project, null, "Checkout complete." );
113    }
114 
115    private void runningGoals( Project project, BuildResult build )
116    {
117        out( project, build, "Running goals." );
118    }
119 
120    private void goalsCompleted( Project project, BuildResult build )
121    {
122        if ( build.getError() == null )
123        {
124            out( project, build, "Goals completed. state: " + build.getState() );
125        }
126        else
127        {
128            out( project, build, "Goals completed." );
129        }
130    }
131 
132    private void buildComplete( Project project, BuildResult build )
133    {
134        if ( build.getError() == null )
135        {
136            out( project, build, "Build complete. state: " + build.getState() );
137        }
138        else
139        {
140            out( project, build, "Build complete." );
141        }
142    }
143 
144    private void prepareBuildComplete( ProjectScmRoot projectScmRoot )
145    {
146        if ( StringUtils.isEmpty( projectScmRoot.getError() ) )
147        {
148            out( projectScmRoot, "Prepare build complete. state: " + projectScmRoot.getState() );
149        }
150        else
151        {
152            out( projectScmRoot, "Prepare build complete." );
153        }
154    }
155 
156    private void out( Project project, BuildResult build, String msg )
157    {
158        System.out.println( "Build event for project '" + project.getName() + "':" + msg );
159 
160        if ( build != null && !StringUtils.isEmpty( build.getError() ) )
161        {
162            System.out.println( build.getError() );
163        }
164    }
165 
166    private void out( ProjectScmRoot projectScmRoot, String msg )
167    {
168        if ( projectScmRoot != null )
169        {
170            System.out.println( "Prepare build event for '" + projectScmRoot.getScmRootAddress() + "':" + msg );
171 
172            if ( !StringUtils.isEmpty( projectScmRoot.getError() ) )
173            {
174                System.out.println( projectScmRoot.getError() );
175            }
176        }
177    }
178}

[all classes][org.apache.maven.continuum.notification.console]
EMMA 2.0.5312 (C) Vladimir Roubtsov