mil.dod.th.ose.gui.webapp/test/mil/dod/th/ose/gui/webapp/mp/TestMissionArgumentModel.java
@Test
    public void testGetValue()
    {
        m_SUT.setType(MissionVariableTypesEnum.STRING);
        String value = "";
        m_SUT.setCurrentValue(value);
        assertThat((String)m_SUT.getCurrentValue(), is(""));
        
        value = null;
        m_SUT.setCurrentValue(value);
        assertThat((String)m_SUT.getCurrentValue(), nullValue());
        
        //set type to integer, then set value
        m_SUT.setType(MissionVariableTypesEnum.INTEGER);
        //all information from text boxes on pages are strings
        value = "9";
        m_SUT.setCurrentValue(value);
        //verify
        assertThat(Integer.valueOf(m_SUT.getCurrentValue().toString()), is(9));
        assertThat(m_SUT.getCurrentValue(), instanceOf(Integer.class));
        
        //set type to double, then set value
        m_SUT.setType(MissionVariableTypesEnum.DOUBLE);
        //all information from text boxes on pages are strings
        value = "9.9987";
        m_SUT.setCurrentValue(value);
        //verify
        assertThat(Double.valueOf(m_SUT.getCurrentValue().toString()), is(9.9987));
        assertThat(m_SUT.getCurrentValue(), instanceOf(Double.class));
        
        m_SUT.setType(MissionVariableTypesEnum.LONG);
        value = "109203839";
        m_SUT.setCurrentValue(value);
        assertThat(Long.valueOf(m_SUT.getCurrentValue().toString()), is(Long.valueOf(value)));
        assertThat(m_SUT.getCurrentValue(), instanceOf(Long.class));
        
        m_SUT.setType(MissionVariableTypesEnum.FLOAT);
        value = "109.2";
        m_SUT.setCurrentValue(value);
        assertThat(Float.valueOf(m_SUT.getCurrentValue().toString()), is(Float.valueOf(value)));
        assertThat(m_SUT.getCurrentValue(), instanceOf(Float.class));
        
        m_SUT.setType(MissionVariableTypesEnum.BYTE);
        value = "102";
        m_SUT.setCurrentValue(value);
        Byte byteValue = 102;
        assertThat(Byte.valueOf(m_SUT.getCurrentValue().toString()), is(byteValue));
        assertThat(m_SUT.getCurrentValue(), instanceOf(Byte.class));
        
        m_SUT.setType(MissionVariableTypesEnum.SHORT);
        value = "100";
        m_SUT.setCurrentValue(value);
        assertThat(Short.valueOf(m_SUT.getCurrentValue().toString()), is(Short.valueOf(value)));
        assertThat(m_SUT.getCurrentValue(), instanceOf(Short.class));
        
        m_SUT.setType(MissionVariableTypesEnum.STRING);
        value = "some string";
        m_SUT.setCurrentValue(value);
        assertThat((String)m_SUT.getCurrentValue(), is(value));
        assertThat(m_SUT.getCurrentValue(), instanceOf(String.class));
        
        //Verify that the string representation of false is returned as the boolean representation.
        m_SUT.setType(MissionVariableTypesEnum.BOOLEAN);
        value = "false";
        m_SUT.setCurrentValue(value);
        assertThat((Boolean)m_SUT.getCurrentValue(), is(false));
        assertThat(m_SUT.getCurrentValue(), instanceOf(Boolean.class));
        
        //Verify that the string representation of true is returned as the boolean representation.
        m_SUT.setType(MissionVariableTypesEnum.BOOLEAN);
        value = "true";
        m_SUT.setCurrentValue(value);
        assertThat((Boolean)m_SUT.getCurrentValue(), is(true));
        assertThat(m_SUT.getCurrentValue(), instanceOf(Boolean.class));
        
        //Verify that a string that does not represent a boolean type throws an illegal argument exception.
        m_SUT.setType(MissionVariableTypesEnum.BOOLEAN);
        value = "not a boolean";
        try
        {
            m_SUT.setCurrentValue(value);
            fail("Illegal argument exception should be thrown.");
        }
        catch (IllegalArgumentException e)
        {
            //Expected exception.
        }
        
        //Test all types that should return a string below.
        m_SUT.setType(MissionVariableTypesEnum.ASSET);
        value = "Asset";
        m_SUT.setCurrentValue(value);
        assertThat((String)m_SUT.getCurrentValue(), is(value));
        assertThat(m_SUT.getCurrentValue(), instanceOf(String.class));
        
        m_SUT.setType(MissionVariableTypesEnum.LINK_LAYER);
        value = "link layer";
        m_SUT.setCurrentValue(value);
        assertThat((String)m_SUT.getCurrentValue(), is(value));
        assertThat(m_SUT.getCurrentValue(), instanceOf(String.class));
        
        m_SUT.setType(MissionVariableTypesEnum.PHYSICAL_LINK);
        value = "physical link";
        m_SUT.setCurrentValue(value);
        assertThat((String)m_SUT.getCurrentValue(), is(value));
        assertThat(m_SUT.getCurrentValue(), instanceOf(String.class));
        
        m_SUT.setType(MissionVariableTypesEnum.PROGRAM_DEPENDENCIES);
        value = "program dependencies";
        m_SUT.setCurrentValue(value);
        assertThat((String)m_SUT.getCurrentValue(), is(value));
        assertThat(m_SUT.getCurrentValue(), instanceOf(String.class));
        
        m_SUT.setType(MissionVariableTypesEnum.TRANSPORT_LAYER);
        value = "transport layer";
        m_SUT.setCurrentValue(value);
        assertThat((String)m_SUT.getCurrentValue(), is(value));
        assertThat(m_SUT.getCurrentValue(), instanceOf(String.class));
    }
/**
     * Test getting the value of the argument. Should return the proper type if the variable type is numeric.
     */
Test getting the value of the argument. Should return the proper type if the variable type is numeric.
Test getting the value of the argument . Should return the proper type if the variable type is numeric .
@Test
    public void testGetValue()
    {
        m_SUT.setType(MissionVariableTypesEnum.STRING);
        String value = "";
        m_SUT.setCurrentValue(value);
        assertThat((String)m_SUT.getCurrentValue(), is(""));
        value = null;
        m_SUT.setCurrentValue(value);
        assertThat((String)m_SUT.getCurrentValue(), nullValue());
        m_SUT.setType(MissionVariableTypesEnum.INTEGER);
        value = "9";
        m_SUT.setCurrentValue(value);
        assertThat(Integer.valueOf(m_SUT.getCurrentValue().toString()), is(9));
        assertThat(m_SUT.getCurrentValue(), instanceOf(Integer.class));
        m_SUT.setType(MissionVariableTypesEnum.DOUBLE);
        value = "9.9987";
        m_SUT.setCurrentValue(value);
        assertThat(Double.valueOf(m_SUT.getCurrentValue().toString()), is(9.9987));
        assertThat(m_SUT.getCurrentValue(), instanceOf(Double.class));
        m_SUT.setType(MissionVariableTypesEnum.LONG);
        value = "109203839";
        m_SUT.setCurrentValue(value);
        assertThat(Long.valueOf(m_SUT.getCurrentValue().toString()), is(Long.valueOf(value)));
        assertThat(m_SUT.getCurrentValue(), instanceOf(Long.class));
        m_SUT.setType(MissionVariableTypesEnum.FLOAT);
        value = "109.2";
        m_SUT.setCurrentValue(value);
        assertThat(Float.valueOf(m_SUT.getCurrentValue().toString()), is(Float.valueOf(value)));
        assertThat(m_SUT.getCurrentValue(), instanceOf(Float.class));
        m_SUT.setType(MissionVariableTypesEnum.BYTE);
        value = "102";
        m_SUT.setCurrentValue(value);
        Byte byteValue = 102;
        assertThat(Byte.valueOf(m_SUT.getCurrentValue().toString()), is(byteValue));
        assertThat(m_SUT.getCurrentValue(), instanceOf(Byte.class));
        m_SUT.setType(MissionVariableTypesEnum.SHORT);
        value = "100";
        m_SUT.setCurrentValue(value);
        assertThat(Short.valueOf(m_SUT.getCurrentValue().toString()), is(Short.valueOf(value)));
        assertThat(m_SUT.getCurrentValue(), instanceOf(Short.class));
        m_SUT.setType(MissionVariableTypesEnum.STRING);
        value = "some string";
        m_SUT.setCurrentValue(value);
        assertThat((String)m_SUT.getCurrentValue(), is(value));
        assertThat(m_SUT.getCurrentValue(), instanceOf(String.class));
        m_SUT.setType(MissionVariableTypesEnum.BOOLEAN);
        value = "false";
        m_SUT.setCurrentValue(value);
        assertThat((Boolean)m_SUT.getCurrentValue(), is(false));
        assertThat(m_SUT.getCurrentValue(), instanceOf(Boolean.class));
        m_SUT.setType(MissionVariableTypesEnum.BOOLEAN);
        value = "true";
        m_SUT.setCurrentValue(value);
        assertThat((Boolean)m_SUT.getCurrentValue(), is(true));
        assertThat(m_SUT.getCurrentValue(), instanceOf(Boolean.class));
        m_SUT.setType(MissionVariableTypesEnum.BOOLEAN);
        value = "not a boolean";
        try
        {
            m_SUT.setCurrentValue(value);
            fail("Illegal argument exception should be thrown.");
        }
        catch (IllegalArgumentException e)
        {
        }
        m_SUT.setType(MissionVariableTypesEnum.ASSET);
        value = "Asset";
        m_SUT.setCurrentValue(value);
        assertThat((String)m_SUT.getCurrentValue(), is(value));
        assertThat(m_SUT.getCurrentValue(), instanceOf(String.class));
        m_SUT.setType(MissionVariableTypesEnum.LINK_LAYER);
        value = "link layer";
        m_SUT.setCurrentValue(value);
        assertThat((String)m_SUT.getCurrentValue(), is(value));
        assertThat(m_SUT.getCurrentValue(), instanceOf(String.class));
        m_SUT.setType(MissionVariableTypesEnum.PHYSICAL_LINK);
        value = "physical link";
        m_SUT.setCurrentValue(value);
        assertThat((String)m_SUT.getCurrentValue(), is(value));
        assertThat(m_SUT.getCurrentValue(), instanceOf(String.class));
        m_SUT.setType(MissionVariableTypesEnum.PROGRAM_DEPENDENCIES);
        value = "program dependencies";
        m_SUT.setCurrentValue(value);
        assertThat((String)m_SUT.getCurrentValue(), is(value));
        assertThat(m_SUT.getCurrentValue(), instanceOf(String.class));
        m_SUT.setType(MissionVariableTypesEnum.TRANSPORT_LAYER);
        value = "transport layer";
        m_SUT.setCurrentValue(value);
        assertThat((String)m_SUT.getCurrentValue(), is(value));
        assertThat(m_SUT.getCurrentValue(), instanceOf(String.class));
    }
@ Test public void testGetValue ( ) { m_SUT . setType ( MissionVariableTypesEnum . STRING ) ; String value = "" ; m_SUT . setCurrentValue ( value ) ; assertThat ( ( String ) m_SUT . getCurrentValue ( ) , is ( "" ) ) ; value = null ; m_SUT . setCurrentValue ( value ) ; assertThat ( ( String ) m_SUT . getCurrentValue ( ) , nullValue ( ) ) ; m_SUT . setType ( MissionVariableTypesEnum . INTEGER ) ; value = "9" ; m_SUT . setCurrentValue ( value ) ; assertThat ( Integer . valueOf ( m_SUT . getCurrentValue ( ) . toString ( ) ) , is ( 9 ) ) ; assertThat ( m_SUT . getCurrentValue ( ) , instanceOf ( Integer . class ) ) ; m_SUT . setType ( MissionVariableTypesEnum . DOUBLE ) ; value = "9.9987" ; m_SUT . setCurrentValue ( value ) ; assertThat ( Double . valueOf ( m_SUT . getCurrentValue ( ) . toString ( ) ) , is ( 9.9987 ) ) ; assertThat ( m_SUT . getCurrentValue ( ) , instanceOf ( Double . class ) ) ; m_SUT . setType ( MissionVariableTypesEnum . LONG ) ; value = "109203839" ; m_SUT . setCurrentValue ( value ) ; assertThat ( Long . valueOf ( m_SUT . getCurrentValue ( ) . toString ( ) ) , is ( Long . valueOf ( value ) ) ) ; assertThat ( m_SUT . getCurrentValue ( ) , instanceOf ( Long . class ) ) ; m_SUT . setType ( MissionVariableTypesEnum . FLOAT ) ; value = "109.2" ; m_SUT . setCurrentValue ( value ) ; assertThat ( Float . valueOf ( m_SUT . getCurrentValue ( ) . toString ( ) ) , is ( Float . valueOf ( value ) ) ) ; assertThat ( m_SUT . getCurrentValue ( ) , instanceOf ( Float . class ) ) ; m_SUT . setType ( MissionVariableTypesEnum . BYTE ) ; value = "102" ; m_SUT . setCurrentValue ( value ) ; Byte byteValue = 102 ; assertThat ( Byte . valueOf ( m_SUT . getCurrentValue ( ) . toString ( ) ) , is ( byteValue ) ) ; assertThat ( m_SUT . getCurrentValue ( ) , instanceOf ( Byte . class ) ) ; m_SUT . setType ( MissionVariableTypesEnum . SHORT ) ; value = "100" ; m_SUT . setCurrentValue ( value ) ; assertThat ( Short . valueOf ( m_SUT . getCurrentValue ( ) . toString ( ) ) , is ( Short . valueOf ( value ) ) ) ; assertThat ( m_SUT . getCurrentValue ( ) , instanceOf ( Short . class ) ) ; m_SUT . setType ( MissionVariableTypesEnum . STRING ) ; value = "some string" ; m_SUT . setCurrentValue ( value ) ; assertThat ( ( String ) m_SUT . getCurrentValue ( ) , is ( value ) ) ; assertThat ( m_SUT . getCurrentValue ( ) , instanceOf ( String . class ) ) ; m_SUT . setType ( MissionVariableTypesEnum . BOOLEAN ) ; value = "false" ; m_SUT . setCurrentValue ( value ) ; assertThat ( ( Boolean ) m_SUT . getCurrentValue ( ) , is ( false ) ) ; assertThat ( m_SUT . getCurrentValue ( ) , instanceOf ( Boolean . class ) ) ; m_SUT . setType ( MissionVariableTypesEnum . BOOLEAN ) ; value = "true" ; m_SUT . setCurrentValue ( value ) ; assertThat ( ( Boolean ) m_SUT . getCurrentValue ( ) , is ( true ) ) ; assertThat ( m_SUT . getCurrentValue ( ) , instanceOf ( Boolean . class ) ) ; m_SUT . setType ( MissionVariableTypesEnum . BOOLEAN ) ; value = "not a boolean" ; try { m_SUT . setCurrentValue ( value ) ; fail ( "Illegal argument exception should be thrown." ) ; } catch ( IllegalArgumentException e ) { } m_SUT . setType ( MissionVariableTypesEnum . ASSET ) ; value = "Asset" ; m_SUT . setCurrentValue ( value ) ; assertThat ( ( String ) m_SUT . getCurrentValue ( ) , is ( value ) ) ; assertThat ( m_SUT . getCurrentValue ( ) , instanceOf ( String . class ) ) ; m_SUT . setType ( MissionVariableTypesEnum . LINK_LAYER ) ; value = "link layer" ; m_SUT . setCurrentValue ( value ) ; assertThat ( ( String ) m_SUT . getCurrentValue ( ) , is ( value ) ) ; assertThat ( m_SUT . getCurrentValue ( ) , instanceOf ( String . class ) ) ; m_SUT . setType ( MissionVariableTypesEnum . PHYSICAL_LINK ) ; value = "physical link" ; m_SUT . setCurrentValue ( value ) ; assertThat ( ( String ) m_SUT . getCurrentValue ( ) , is ( value ) ) ; assertThat ( m_SUT . getCurrentValue ( ) , instanceOf ( String . class ) ) ; m_SUT . setType ( MissionVariableTypesEnum . PROGRAM_DEPENDENCIES ) ; value = "program dependencies" ; m_SUT . setCurrentValue ( value ) ; assertThat ( ( String ) m_SUT . getCurrentValue ( ) , is ( value ) ) ; assertThat ( m_SUT . getCurrentValue ( ) , instanceOf ( String . class ) ) ; m_SUT . setType ( MissionVariableTypesEnum . TRANSPORT_LAYER ) ; value = "transport layer" ; m_SUT . setCurrentValue ( value ) ; assertThat ( ( String ) m_SUT . getCurrentValue ( ) , is ( value ) ) ; assertThat ( m_SUT . getCurrentValue ( ) , instanceOf ( String . class ) ) ; }
Test getting the value of the argument.
Test getting the value of the argument .
//set type to integer, then set value //all information from text boxes on pages are strings //verify //set type to double, then set value //all information from text boxes on pages are strings //verify //Verify that the string representation of false is returned as the boolean representation. //Verify that the string representation of true is returned as the boolean representation. //Verify that a string that does not represent a boolean type throws an illegal argument exception. //Expected exception. //Test all types that should return a string below.