Coverage Report - org.apache.maven.archetype.ui.DefaultArchetypeGenerationQueryer
 
Classes in this File Line Coverage Branch Coverage Complexity
DefaultArchetypeGenerationQueryer
7%
1/14
0%
0/6
2
 
 1  
 /*
 2  
  * Licensed to the Apache Software Foundation (ASF) under one
 3  
  * or more contributor license agreements.  See the NOTICE file
 4  
  * distributed with this work for additional information
 5  
  * regarding copyright ownership.  The ASF licenses this file
 6  
  * to you under the Apache License, Version 2.0 (the
 7  
  * "License"); you may not use this file except in compliance
 8  
  * with the License.  You may obtain a copy of the License at
 9  
  *
 10  
  *   http://www.apache.org/licenses/LICENSE-2.0
 11  
  *
 12  
  * Unless required by applicable law or agreed to in writing,
 13  
  * software distributed under the License is distributed on an
 14  
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 15  
  * KIND, either express or implied.  See the License for the
 16  
  * specific language governing permissions and limitations
 17  
  * under the License.
 18  
  */
 19  
 
 20  
 package org.apache.maven.archetype.ui;
 21  
 
 22  
 import org.apache.maven.archetype.common.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  
 import java.util.Iterator;
 28  
 
 29  
 /** @plexus.component */
 30  9
 public class DefaultArchetypeGenerationQueryer
 31  
     extends AbstractLogEnabled
 32  
     implements ArchetypeGenerationQueryer
 33  
 {
 34  
     /** @plexus.requirement */
 35  
     private Prompter prompter;
 36  
 
 37  
     public boolean confirmConfiguration( ArchetypeConfiguration archetypeConfiguration )
 38  
         throws
 39  
         PrompterException
 40  
     {
 41  0
         String query = "Confirm properties configuration:\n";
 42  
 
 43  0
         Iterator requiredPropertiesIter =
 44  
             archetypeConfiguration.getRequiredProperties().iterator();
 45  
 
 46  0
         while ( requiredPropertiesIter.hasNext() )
 47  
         {
 48  0
             String property = (String) requiredPropertiesIter.next();
 49  0
             query += property + ": " + archetypeConfiguration.getProperty( property ) + "\n";
 50  0
         }
 51  
 
 52  0
         String answer = prompter.prompt( query, "Y" );
 53  
 
 54  0
         return "Y".equalsIgnoreCase( answer );
 55  
     }
 56  
 
 57  
     public String getPropertyValue( String requiredProperty,
 58  
                                     String defaultValue )
 59  
         throws
 60  
         PrompterException
 61  
     {
 62  0
         String query = "Define value for " + requiredProperty + ": ";
 63  
         String answer;
 64  
 
 65  0
         if ( ( defaultValue != null ) && !defaultValue.equals( "null" ) )
 66  
         {
 67  0
             answer = prompter.prompt( query, defaultValue );
 68  
         }
 69  
         else
 70  
         {
 71  0
             answer = prompter.prompt( query );
 72  
         }
 73  0
         return answer;
 74  
     }
 75  
 }