mil.dod.th.ose.gui.webapp/test/mil/dod/th/ose/gui/webapp/utils/TestArgumentValidatorUtil.java
@Test
    public void testIsValidValue()
    {
        //Test to make sure valid integer returns true.
        Object value = 10;
        String minValue = "5";
        String maxValue = "20";
        assertThat(ArgumentValidatorUtil.isValidValue(value.toString(), minValue, maxValue, Integer.class), 
                is(ValidationEnum.PASSED));
        //Test to make sure non-valid integer returns false.
        value = 10.11;
        assertThat(ArgumentValidatorUtil.isValidValue(value.toString(), minValue, maxValue, Integer.class), 
                is(ValidationEnum.PARSING_FAILURE));
        
        //Test to make sure valid double returns true.
        value = 25.55;
        minValue="5.55";
        maxValue = "100.25";
        assertThat(ArgumentValidatorUtil.isValidValue(value.toString(), minValue, maxValue, Double.class), 
                 is(ValidationEnum.PASSED));
        //Test to make sure invalid double returns false.
        value = "not a double";
        assertThat(ArgumentValidatorUtil.isValidValue(value.toString(), minValue, maxValue, Double.class), 
                is(ValidationEnum.PARSING_FAILURE));
        
        //Test to make sure valid float returns true.
        value = (float) 25.5;
        minValue="5.5";
        maxValue = "100.2";
        assertThat(ArgumentValidatorUtil.isValidValue(value.toString(), minValue, maxValue, Float.class), 
                is(ValidationEnum.PASSED));
        //Test to make sure invalid float returns false.
        value = "not a float";
        assertThat(ArgumentValidatorUtil.isValidValue(value.toString(), minValue, maxValue, Float.class), 
                is(ValidationEnum.PARSING_FAILURE));
        
        //Test to make sure valid long returns true.
        value = 123456789L;
        minValue="20000";
        maxValue = "987654321";
        assertThat(ArgumentValidatorUtil.isValidValue(value.toString(), minValue, maxValue, Long.class), 
                is(ValidationEnum.PASSED));
        //Test to make sure invalid long returns false.
        value = "not a long";
        assertThat(ArgumentValidatorUtil.isValidValue(value.toString(), minValue, maxValue, Long.class), 
                is(ValidationEnum.PARSING_FAILURE));
        
        //Test to make sure valid short returns true.
        value = (short) 2312;
        minValue="2000";
        maxValue = null;
        assertThat(ArgumentValidatorUtil.isValidValue(value.toString(), minValue, maxValue, Short.class), 
                is(ValidationEnum.PASSED));
        //Test to make sure invalid short returns false.
        value = "75000";
        assertThat(ArgumentValidatorUtil.isValidValue(value.toString(), minValue, maxValue, Short.class), 
                is(ValidationEnum.PARSING_FAILURE));
        
        //Test to make sure valid byte returns true.
        value = (byte) 100;
        minValue= "-25";
        maxValue = null;
        assertThat(ArgumentValidatorUtil.isValidValue(value.toString(), minValue, maxValue, Byte.class), 
                is(ValidationEnum.PASSED));
        //Test to make sure invalid short returns false.
        value = "129";
        assertThat(ArgumentValidatorUtil.isValidValue(value.toString(), minValue, maxValue, Byte.class), 
                is(ValidationEnum.PARSING_FAILURE));
    }
/**
     * Verify that the validator will correctly return pass or fail given a range of acceptable values. 
     */
Verify that the validator will correctly return pass or fail given a range of acceptable values.
Verify that the validator will correctly return pass or fail given a range of acceptable values .
@Test
    public void testIsValidValue()
    {
        Object value = 10;
        String minValue = "5";
        String maxValue = "20";
        assertThat(ArgumentValidatorUtil.isValidValue(value.toString(), minValue, maxValue, Integer.class), 
                is(ValidationEnum.PASSED));
        value = 10.11;
        assertThat(ArgumentValidatorUtil.isValidValue(value.toString(), minValue, maxValue, Integer.class), 
                is(ValidationEnum.PARSING_FAILURE));
        value = 25.55;
        minValue="5.55";
        maxValue = "100.25";
        assertThat(ArgumentValidatorUtil.isValidValue(value.toString(), minValue, maxValue, Double.class), 
                 is(ValidationEnum.PASSED));
        value = "not a double";
        assertThat(ArgumentValidatorUtil.isValidValue(value.toString(), minValue, maxValue, Double.class), 
                is(ValidationEnum.PARSING_FAILURE));
        value = (float) 25.5;
        minValue="5.5";
        maxValue = "100.2";
        assertThat(ArgumentValidatorUtil.isValidValue(value.toString(), minValue, maxValue, Float.class), 
                is(ValidationEnum.PASSED));
        value = "not a float";
        assertThat(ArgumentValidatorUtil.isValidValue(value.toString(), minValue, maxValue, Float.class), 
                is(ValidationEnum.PARSING_FAILURE));
        value = 123456789L;
        minValue="20000";
        maxValue = "987654321";
        assertThat(ArgumentValidatorUtil.isValidValue(value.toString(), minValue, maxValue, Long.class), 
                is(ValidationEnum.PASSED));
        value = "not a long";
        assertThat(ArgumentValidatorUtil.isValidValue(value.toString(), minValue, maxValue, Long.class), 
                is(ValidationEnum.PARSING_FAILURE));
        value = (short) 2312;
        minValue="2000";
        maxValue = null;
        assertThat(ArgumentValidatorUtil.isValidValue(value.toString(), minValue, maxValue, Short.class), 
                is(ValidationEnum.PASSED));
        value = "75000";
        assertThat(ArgumentValidatorUtil.isValidValue(value.toString(), minValue, maxValue, Short.class), 
                is(ValidationEnum.PARSING_FAILURE));
        value = (byte) 100;
        minValue= "-25";
        maxValue = null;
        assertThat(ArgumentValidatorUtil.isValidValue(value.toString(), minValue, maxValue, Byte.class), 
                is(ValidationEnum.PASSED));
        value = "129";
        assertThat(ArgumentValidatorUtil.isValidValue(value.toString(), minValue, maxValue, Byte.class), 
                is(ValidationEnum.PARSING_FAILURE));
    }
@ Test public void testIsValidValue ( ) { Object value = 10 ; String minValue = "5" ; String maxValue = "20" ; assertThat ( ArgumentValidatorUtil . isValidValue ( value . toString ( ) , minValue , maxValue , Integer . class ) , is ( ValidationEnum . PASSED ) ) ; value = 10.11 ; assertThat ( ArgumentValidatorUtil . isValidValue ( value . toString ( ) , minValue , maxValue , Integer . class ) , is ( ValidationEnum . PARSING_FAILURE ) ) ; value = 25.55 ; minValue = "5.55" ; maxValue = "100.25" ; assertThat ( ArgumentValidatorUtil . isValidValue ( value . toString ( ) , minValue , maxValue , Double . class ) , is ( ValidationEnum . PASSED ) ) ; value = "not a double" ; assertThat ( ArgumentValidatorUtil . isValidValue ( value . toString ( ) , minValue , maxValue , Double . class ) , is ( ValidationEnum . PARSING_FAILURE ) ) ; value = ( float ) 25.5 ; minValue = "5.5" ; maxValue = "100.2" ; assertThat ( ArgumentValidatorUtil . isValidValue ( value . toString ( ) , minValue , maxValue , Float . class ) , is ( ValidationEnum . PASSED ) ) ; value = "not a float" ; assertThat ( ArgumentValidatorUtil . isValidValue ( value . toString ( ) , minValue , maxValue , Float . class ) , is ( ValidationEnum . PARSING_FAILURE ) ) ; value = 123456789L ; minValue = "20000" ; maxValue = "987654321" ; assertThat ( ArgumentValidatorUtil . isValidValue ( value . toString ( ) , minValue , maxValue , Long . class ) , is ( ValidationEnum . PASSED ) ) ; value = "not a long" ; assertThat ( ArgumentValidatorUtil . isValidValue ( value . toString ( ) , minValue , maxValue , Long . class ) , is ( ValidationEnum . PARSING_FAILURE ) ) ; value = ( short ) 2312 ; minValue = "2000" ; maxValue = null ; assertThat ( ArgumentValidatorUtil . isValidValue ( value . toString ( ) , minValue , maxValue , Short . class ) , is ( ValidationEnum . PASSED ) ) ; value = "75000" ; assertThat ( ArgumentValidatorUtil . isValidValue ( value . toString ( ) , minValue , maxValue , Short . class ) , is ( ValidationEnum . PARSING_FAILURE ) ) ; value = ( byte ) 100 ; minValue = "-25" ; maxValue = null ; assertThat ( ArgumentValidatorUtil . isValidValue ( value . toString ( ) , minValue , maxValue , Byte . class ) , is ( ValidationEnum . PASSED ) ) ; value = "129" ; assertThat ( ArgumentValidatorUtil . isValidValue ( value . toString ( ) , minValue , maxValue , Byte . class ) , is ( ValidationEnum . PARSING_FAILURE ) ) ; }
Verify that the validator will correctly return pass or fail given a range of acceptable values.
Verify that the validator will correctly return pass or fail given a range of acceptable values .
//Test to make sure valid integer returns true. //Test to make sure non-valid integer returns false. //Test to make sure valid double returns true. //Test to make sure invalid double returns false. //Test to make sure valid float returns true. //Test to make sure invalid float returns false. //Test to make sure valid long returns true. //Test to make sure invalid long returns false. //Test to make sure valid short returns true. //Test to make sure invalid short returns false. //Test to make sure valid byte returns true. //Test to make sure invalid short returns false.