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 UniqueTstampOption sets the correct option map values. 013 * @author aito 014 * 015 */ 016 public class TestUniqueTstampOption { 017 /** The instances tested in this test class. */ 018 private Option uniqueOption = 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.uniqueOption = OptionFactory.getInstance(this.controller, 026 UniqueTstampOption.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 Assert.assertEquals("The UniqueTimestamp option object was not false.", Boolean.FALSE, 033 this.controller.getOptionObject(Options.UNIQUE_TSTAMP)); 034 this.uniqueOption.process(); 035 Assert.assertEquals("The UniqueTimestamp option object was not set to true.", 036 Boolean.TRUE, this.controller.getOptionObject(Options.UNIQUE_TSTAMP)); 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 UniqueTstampOption(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.uniqueOption.isValid()); 051 } 052 }