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 SetRuntimeOption takes no parameters and is processed correctly.
013     * @author aito
014     * 
015     */
016    public class TestSetRuntimeOption {
017      /** The instances tested in this test class. */
018      private Option runtimeOption = 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.runtimeOption = OptionFactory.getInstance(this.controller,
026            SetRuntimeOption.OPTION_NAME, new ArrayList<String>());
027      }
028    
029      /** Tests if the process method sets the correct option values. */
030      @Test
031      public void testProcess() {
032        this.runtimeOption.process();
033        Assert.assertEquals("The SetRuntimeOption object was not set to true.", Boolean.TRUE,
034            this.controller.getOptionObject(Options.SET_RUNTIME));
035      }
036    
037      /**
038       * Tests if the isValid method always returns true when no arguments are
039       * specified.
040       */
041      @Test
042      public void testIsValid() {
043        List<String> parameters = new ArrayList<String>();
044        parameters.add("true");
045        Option incorrectOption = new SetRuntimeOption(this.controller, parameters);
046        Assert.assertFalse("The incorrect option is not valid.", incorrectOption.isValid());
047        Assert.assertTrue("The correct option with no parameters returned false.",
048            this.runtimeOption.isValid());
049      }
050    }