001    package org.hackystat.sensor.xmldata.option;
002    
003    import java.util.ArrayList;
004    import java.util.List;
005    
006    import org.hackystat.sensor.xmldata.XmlDataController;
007    import org.junit.Assert;
008    import org.junit.Before;
009    import org.junit.Test;
010    
011    /**
012     * Tests if the verbose option sets the correct option map parameters.
013     * @author aito
014     * 
015     */
016    public class TestVerboseOption {
017      /** The instances tested in this test class. */
018      private Option verboseOption = null;
019      private XmlDataController controller = null;
020    
021      /** Sets each test case up. */
022      @Before
023      public void setUp() {
024        this.controller = new XmlDataController();
025        this.verboseOption = OptionFactory.getInstance(this.controller, VerboseOption.OPTION_NAME,
026            new ArrayList<String>());
027      }
028    
029      /** Tests if the process method sets the correct option values. */
030      @Test
031      public void testProcess() {
032        Assert.assertEquals("The Verbose option object was pre-set.", null, this.controller
033            .getOptionObject(Options.VERBOSE));
034        this.verboseOption.process();
035        Assert.assertEquals("The Verbose option object was not set to true.", Boolean.TRUE,
036            this.controller.getOptionObject(Options.VERBOSE));
037      }
038    
039      /**
040       * Tests if the isValid method always returns true when no arguments are
041       * specified.
042       */
043      @Test
044      public void testIsValid() {
045        List<String> parameters = new ArrayList<String>();
046        parameters.add("true");
047        Option incorrectOption = new VerboseOption(this.controller, parameters);
048        Assert.assertFalse("The incorrect option is not valid.", incorrectOption.isValid());
049        Assert.assertTrue("The correct option with no parameters returned false.",
050            this.verboseOption.isValid());
051      }
052    }