Coverage Report - org.apache.maven.usability.ProfileActivationDiagnoser
 
Classes in this File Line Coverage Branch Coverage Complexity
ProfileActivationDiagnoser
0 %
0/12
0 %
0/2
1,5
 
 1  
 package org.apache.maven.usability;
 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  
 
 22  
 import org.apache.maven.profiles.activation.ProfileActivationException;
 23  
 import org.apache.maven.usability.diagnostics.DiagnosisUtils;
 24  
 import org.apache.maven.usability.diagnostics.ErrorDiagnoser;
 25  
 import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
 26  
 
 27  0
 public class ProfileActivationDiagnoser
 28  
     implements ErrorDiagnoser
 29  
 {
 30  
 
 31  
     public boolean canDiagnose( Throwable error )
 32  
     {
 33  0
         return DiagnosisUtils.containsInCausality( error, ProfileActivationException.class );
 34  
     }
 35  
 
 36  
     public String diagnose( Throwable error )
 37  
     {
 38  0
         ProfileActivationException activationException =
 39  
             (ProfileActivationException) DiagnosisUtils.getFromCausality( error, ProfileActivationException.class );
 40  
 
 41  0
         StringBuffer messageBuffer = new StringBuffer();
 42  
 
 43  0
         messageBuffer.append( "Error activating profiles." );
 44  0
         messageBuffer.append( "\n\nReason: " ).append( activationException.getMessage() );
 45  
 
 46  0
         if ( DiagnosisUtils.containsInCausality( activationException, ComponentLookupException.class ) )
 47  
         {
 48  0
             ComponentLookupException cle = (ComponentLookupException) DiagnosisUtils.getFromCausality(
 49  
                 activationException, ComponentLookupException.class );
 50  
 
 51  0
             messageBuffer.append( "\n\nThere was a problem retrieving one or more profile activators." );
 52  0
             messageBuffer.append( "\n" ).append( cle.getMessage() );
 53  
         }
 54  
 
 55  0
         messageBuffer.append( "\n" );
 56  
 
 57  0
         return messageBuffer.toString();
 58  
     }
 59  
 
 60  
 }