Clover coverage report - anttestsetgen - 1.1
Coverage timestamp: zo jan 4 2004 17:34:16 CET
file stats: LOC: 83   Methods: 2
NCLOC: 27   Classes: 1
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
 
 Source file Conditionals Statements Methods TOTAL
BroadBandValidator.java 83,3% 90% 100% 88,9%
coverage coverage
 1   
 /*
 2   
  * Copyright (C) 2003, Marco Jansen / Contrado Technologies  (http://www.contrado.nl)
 3   
  *
 4   
  * This program is free software; you can redistribute it and/or
 5   
  * modify it under the terms of the GNU General Public License as
 6   
  * published by the Free Software Foundation; either version 2 of the
 7   
  * License, or (at your option) any later version.
 8   
  *
 9   
  * This program is distributed in the hope that it will be useful, but
 10   
  * WITHOUT ANY WARRANTY; without even the implied warranty of
 11   
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 12   
  * General Public License for more details.
 13   
  */
 14   
 package net.sourceforge.anttestsetgen.sample;
 15   
 
 16   
 import net.sourceforge.anttestsetgen.TestSetValidator;
 17   
 import org.apache.tools.ant.BuildException;
 18   
 
 19   
 import java.util.HashMap;
 20   
 
 21   
 /**
 22   
  * Example of a TestSetValidator plug-in.
 23   
  * <p/>
 24   
  * The BroadBandValidator is a plug-in for the TestSetGenerator that demonstrates how to develop your own validator. With
 25   
  * this validator to parameters have to be set: <b>name</b> and <b>city</b>. Only when name contains the value '86 - 20th Ave.'
 26   
  * and city contains the value 'Dallas' the validator will return true.
 27   
  * <p/>
 28   
  * In case on of the parameters is not set an BuildException will be thrown during validation.
 29   
  * 
 30   
  * @author <a href="mailto:m.c.jansen.spam at planet.nl">Marco Jansen (Contrado Technologies)</a>
 31   
  * @version $Id: BroadBandValidator.java,v 1.1 2004/01/04 14:58:59 mcjansen Exp $
 32   
  */
 33   
 public class BroadBandValidator implements TestSetValidator {
 34   
 
 35   
   /** The street that supports ADSL. */
 36   
   public static final String VALID_STREET = "86 - 20th Ave.";
 37   
 
 38   
   /** The city that supports ADSL. */
 39   
   public static final String VALID_CITY = "Dallas";
 40   
 
 41   
   /** A map with parameters that needs to be validated. */
 42   
   HashMap parameters = new HashMap();
 43   
 
 44   
   /**
 45   
    * Set a parameter of the validator.
 46   
    * <p/>
 47   
    * The ADSL Validator expects two parameters: name and city.
 48   
    * 
 49   
    * @param name  The name of the parameter
 50   
    * @param value The value of the parameter
 51   
    */
 52  138
   public void setParameter(String name, String value) {
 53  138
     parameters.put(name, value);
 54   
   }
 55   
 
 56   
   /**
 57   
    * Validate the parameters.
 58   
    * <p/>
 59   
    * Only when name contains the value '86 - 20th Ave.' and city contains the value 'Dallas' the validator will return true.
 60   
    * 
 61   
    * @return True when valid, false when not valid.
 62   
    * @throws BuildException In case one of the parameters is not set.
 63   
    */
 64  70
   public boolean isValid() throws BuildException {
 65  70
     String street = (String) parameters.get("street");
 66  70
     if (street == null) {
 67  0
       throw new BuildException("Validation parameter Street not found for the BroadBand Validator");
 68   
     }
 69   
 
 70  70
     String city = (String) parameters.get("city");
 71  70
     if (city == null) {
 72  2
       throw new BuildException("Validation parameter houseNumber not found for the BroadBand Validator");
 73   
     }
 74   
 
 75  68
     if (VALID_STREET.equals(street.trim()) && VALID_CITY.equals(city.trim())) {
 76  8
       return true;
 77   
     } else {
 78  60
       return false;
 79   
     }
 80   
   }
 81   
 
 82   
 }
 83