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