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.components.interactivity.Prompter;
 24  
 import org.codehaus.plexus.components.interactivity.PrompterException;
 25  
 import org.codehaus.plexus.logging.AbstractLogEnabled;
 26  
 
 27  
 /** @plexus.component */
 28  3
 public class DefaultArchetypeGenerationQueryer
 29  
     extends AbstractLogEnabled
 30  
     implements ArchetypeGenerationQueryer
 31  
 {
 32  
     /** @plexus.requirement */
 33  
     private Prompter prompter;
 34  
 
 35  
     public boolean confirmConfiguration( ArchetypeConfiguration archetypeConfiguration )
 36  
         throws PrompterException
 37  
     {
 38  0
         StringBuilder query = new StringBuilder( "Confirm properties configuration:\n" );
 39  
 
 40  0
         for ( String property : archetypeConfiguration.getRequiredProperties() )
 41  
         {
 42  0
             query.append( property + ": " + archetypeConfiguration.getProperty( property ) + "\n" );
 43  
         }
 44  
 
 45  0
         String answer = prompter.prompt( query.toString(), "Y" );
 46  
 
 47  0
         return "Y".equalsIgnoreCase( answer );
 48  
     }
 49  
 
 50  
     public String getPropertyValue( String requiredProperty, String defaultValue )
 51  
         throws PrompterException
 52  
     {
 53  0
         String query = "Define value for property '" + requiredProperty + "': ";
 54  
         String answer;
 55  
 
 56  0
         if ( ( defaultValue != null ) && !defaultValue.equals( "null" ) )
 57  
         {
 58  0
             answer = prompter.prompt( query, defaultValue );
 59  
         }
 60  
         else
 61  
         {
 62  0
             answer = prompter.prompt( query );
 63  
         }
 64  0
         return answer;
 65  
     }
 66  
 }