Coverage Report - org.apache.maven.archetype.ui.generation.DefaultArchetypeGenerationQueryer
 
Classes in this File Line Coverage Branch Coverage Complexity
DefaultArchetypeGenerationQueryer
9%
1/11
0%
0/6
2.5
 
 1  
 package org.apache.maven.archetype.ui.generation;
 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.archetype.ui.ArchetypeConfiguration;
 23  
 import org.codehaus.plexus.component.annotations.Component;
 24  
 import org.codehaus.plexus.component.annotations.Requirement;
 25  
 import org.codehaus.plexus.components.interactivity.Prompter;
 26  
 import org.codehaus.plexus.components.interactivity.PrompterException;
 27  
 import org.codehaus.plexus.logging.AbstractLogEnabled;
 28  
 
 29  
 @Component( role = ArchetypeGenerationQueryer.class )
 30  6
 public class DefaultArchetypeGenerationQueryer
 31  
     extends AbstractLogEnabled
 32  
     implements ArchetypeGenerationQueryer
 33  
 {
 34  
     @Requirement
 35  
     private Prompter prompter;
 36  
 
 37  
     public boolean confirmConfiguration( ArchetypeConfiguration archetypeConfiguration )
 38  
         throws PrompterException
 39  
     {
 40  0
         StringBuilder query = new StringBuilder( "Confirm properties configuration:\n" );
 41  
 
 42  0
         for ( String property : archetypeConfiguration.getRequiredProperties() )
 43  
         {
 44  0
             query.append( property + ": " + archetypeConfiguration.getProperty( property ) + "\n" );
 45  
         }
 46  
 
 47  0
         String answer = prompter.prompt( query.toString(), "Y" );
 48  
 
 49  0
         return "Y".equalsIgnoreCase( answer );
 50  
     }
 51  
 
 52  
     public String getPropertyValue( String requiredProperty, String defaultValue )
 53  
         throws PrompterException
 54  
     {
 55  0
         String query = "Define value for property '" + requiredProperty + "': ";
 56  
         String answer;
 57  
 
 58  0
         if ( ( defaultValue != null ) && !defaultValue.equals( "null" ) )
 59  
         {
 60  0
             answer = prompter.prompt( query, defaultValue );
 61  
         }
 62  
         else
 63  
         {
 64  0
             answer = prompter.prompt( query );
 65  
         }
 66  0
         return answer;
 67  
     }
 68  
 }