Coverage Report - org.org.usurper.springframework.UsurperListFactoryBean
 
Classes in this File Line Coverage Branch Coverage Complexity
UsurperListFactoryBean
75 %
12/16
50 %
1/2
0
 
 1  
 /*
 2  
  ORG Usurper is a random value object generator library 
 3  
  Copyright (C) 2007  Pierre-Antoine GrĂ©goire
 4  
  
 5  
  This library is free software; you can redistribute it and/or
 6  
  modify it under the terms of the GNU Lesser General Public
 7  
  License as published by the Free Software Foundation; either
 8  
  version 2.1 of the License, or (at your option) any later version.
 9  
  
 10  
  This library is distributed in the hope that it will be useful,
 11  
  but WITHOUT ANY WARRANTY; without even the implied warranty of
 12  
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 13  
  Lesser General Public License for more details.
 14  
  
 15  
  You should have received a copy of the GNU Lesser General Public
 16  
  License along with this library; if not, write to the Free Software
 17  
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 18  
  */
 19  
 package org.org.usurper.springframework;
 20  
 
 21  
 import java.util.List;
 22  
 
 23  
 import org.org.usurper.UsurperGenerator;
 24  
 import org.org.usurper.setup.UsurperGeneratorSetup;
 25  
 import org.springframework.beans.factory.FactoryBean;
 26  
 import org.springframework.beans.factory.InitializingBean;
 27  
 import org.springframework.beans.factory.annotation.Required;
 28  
 
 29  
 /**
 30  
  * The Class UsurperListFactoryBean is a Spring compliant FactoryBean and InitializingBean.
 31  
  * As such, it can be used as any other Spring Factory Bean.
 32  
  * It generates Lists of Usurpers for a given class.
 33  
  */
 34  2
 public class UsurperListFactoryBean implements FactoryBean, InitializingBean {
 35  
 
 36  
         private UsurperGenerator<?> usurperGenerator;
 37  
         private String usurpedClassName;
 38  2
         private Integer count = UsurperSpringConstants.DEFAULT_ENTRIES_COUNT;
 39  
         @SuppressWarnings("unchecked")
 40  
         private Class usurpedClass;
 41  
         
 42  
         private UsurperGeneratorSetup usurperGeneratorSetup;
 43  
 
 44  
     public void setUsurperGeneratorSetup(UsurperGeneratorSetup usurperGeneratorSetup) {
 45  0
         this.usurperGeneratorSetup = usurperGeneratorSetup;
 46  0
     }
 47  
     
 48  
     @Required
 49  
         public void setUsurpedClassName(String usurpedClassName) {
 50  2
                 this.usurpedClassName = usurpedClassName;
 51  2
         }
 52  
 
 53  
         public Object getObject() throws Exception {
 54  2
                 return usurperGenerator.generateUsurperList(count);
 55  
         }
 56  
 
 57  
         @SuppressWarnings("unchecked")
 58  
         public Class getObjectType() {
 59  0
                 return List.class;
 60  
         }
 61  
 
 62  
         public boolean isSingleton() {
 63  1
                 return false;
 64  
         }
 65  
 
 66  
         @SuppressWarnings("unchecked")
 67  
         public void afterPropertiesSet() throws Exception {
 68  2
                 usurpedClass = Class.forName(usurpedClassName);
 69  2
                 if (usurperGeneratorSetup == null) {
 70  2
             usurperGenerator = new UsurperGenerator(usurpedClass);
 71  
         } else {
 72  0
             usurperGenerator = new UsurperGenerator(usurpedClass, usurperGeneratorSetup);
 73  
         }
 74  2
         }
 75  
 
 76  
         public void setCount(Integer count) {
 77  2
                 this.count = count;
 78  2
         }
 79  
 
 80  
 }