Coverage Report - org.mule.tck.testmodels.fruit.FruitBowl
 
Classes in this File Line Coverage Branch Coverage Complexity
FruitBowl
0%
0/29
0%
0/11
1.25
 
 1  
 /*
 2  
  * $Id: FruitBowl.java 7976 2007-08-21 14:26:13Z dirk.olmes $
 3  
  * --------------------------------------------------------------------------------------
 4  
  * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.com
 5  
  *
 6  
  * The software in this package is published under the terms of the CPAL v1.0
 7  
  * license, a copy of which has been included with this distribution in the
 8  
  * LICENSE.txt file.
 9  
  */
 10  
 
 11  
 package org.mule.tck.testmodels.fruit;
 12  
 
 13  
 import java.util.Collections;
 14  
 import java.util.HashMap;
 15  
 import java.util.Iterator;
 16  
 import java.util.List;
 17  
 import java.util.Map;
 18  
 
 19  
 import org.apache.commons.logging.Log;
 20  
 import org.apache.commons.logging.LogFactory;
 21  
 
 22  
 public class FruitBowl
 23  
 {
 24  
     /**
 25  
      * logger used by this class
 26  
      */
 27  0
     private static final Log logger = LogFactory.getLog(FruitBowl.class);
 28  
 
 29  0
     private final Map bowl = Collections.synchronizedMap(new HashMap());
 30  
 
 31  
     public FruitBowl()
 32  
     {
 33  0
         super();
 34  0
     }
 35  
 
 36  
     public FruitBowl(Fruit fruit[])
 37  0
     {
 38  0
         for (int i = 0; i < fruit.length; i++)
 39  
         {
 40  0
             bowl.put(fruit[i].getClass(), fruit[i]);
 41  
         }
 42  0
     }
 43  
 
 44  
     public FruitBowl(Apple apple, Banana banana)
 45  0
     {
 46  0
         bowl.put(Apple.class, apple);
 47  0
         bowl.put(Banana.class, banana);
 48  0
     }
 49  
 
 50  
     public boolean hasApple()
 51  
     {
 52  0
         return bowl.get(Apple.class) != null;
 53  
     }
 54  
 
 55  
     public boolean hasBanana()
 56  
     {
 57  0
         return bowl.get(Banana.class) != null;
 58  
     }
 59  
 
 60  
     public Object consumeFruit(FruitLover fruitlover)
 61  
     {
 62  0
         logger.debug("Got a fruit lover who says: " + fruitlover.speak());
 63  0
         for (Iterator iter = bowl.values().iterator(); iter.hasNext();)
 64  
         {
 65  0
             ((Fruit) iter.next()).bite();
 66  
         }
 67  0
         return fruitlover;
 68  
     }
 69  
 
 70  
     public void setFruit(Fruit[] fruit)
 71  
     {
 72  0
         for (int i = 0; i < fruit.length; i++)
 73  
         {
 74  0
             bowl.put(fruit[i].getClass(), fruit[i]);
 75  
         }
 76  0
     }
 77  
 
 78  
     public void setFruit(List fruit)
 79  
     {
 80  0
         this.setFruit((Fruit[]) fruit.toArray(new Fruit[fruit.size()]));
 81  0
     }
 82  
 
 83  
     public Apple getApple()
 84  
     {
 85  0
         return (Apple) bowl.get(Apple.class);
 86  
     }
 87  
 
 88  
     public void setApple(Apple apple)
 89  
     {
 90  0
         bowl.put(Apple.class, apple);
 91  0
     }
 92  
 
 93  
     public Banana getBanana()
 94  
     {
 95  0
         return (Banana) bowl.get(Banana.class);
 96  
     }
 97  
 
 98  
     public void setBanana(Banana banana)
 99  
     {
 100  0
         bowl.put(Banana.class, banana);
 101  0
     }
 102  
 
 103  
 }