mil.dod.th.ose.gui.webapp/test/mil/dod/th/ose/gui/webapp/asset/TestCommandNodeModel.java
@Test
    public void testSetValue() throws ReflectionsUtilException
    {
        PowerMockito.mockStatic(ArgumentValidatorUtil.class);
        
        //Testing setting standard value.
        assertThat(m_TestObject.getIntField(), is(5));
        PowerMockito.when(ArgumentValidatorUtil.convertToActualType("2", int.class)).thenReturn(2);
        m_SUT.setValue("2");
        assertThat(m_TestObject.getIntField(), is(2));
        
        //Test setting enumeration value.
        m_SUT.setType(TestEnum.class);
        m_SUT.setName("enumField");
        assertThat(m_TestObject.getEnumField(), is(TestEnum.TestEnum1));
        PowerMockito.when(ArgumentValidatorUtil.convertToActualType(TestEnum.TestEnum2.toString(), 
                TestEnum.class)).thenReturn(TestEnum.TestEnum2);
        m_SUT.setValue(TestEnum.TestEnum2.toString());
        assertThat(m_TestObject.getEnumField(), is(TestEnum.TestEnum2));
        
        //Test setting nullable field.
        m_SUT.setType(Float.class);
        m_SUT.setName("nullableField");
        assertThat(m_TestObject.getNullableField(), is(5.2f));
        m_SUT.setValue(null);
        assertThat(m_TestObject.getNullableField(), is(nullValue()));
        m_SUT.setValue("");
        assertThat(m_TestObject.getNullableField(), is(nullValue()));
        
        //Test setting a list value.
        m_SUT = new CommandNodeModel("listField", Integer.class, false, m_IntList, m_GrowlUtil);
        m_SUT.setIndex(2);
        assertThat(m_IntList.get(2), is(12));
        PowerMockito.when(ArgumentValidatorUtil.convertToActualType("125", Integer.class)).thenReturn(125);
        m_SUT.setValue("125");
        assertThat(m_IntList.get(2), is(125));
        assertThat(m_TestObject.getListField(), is(m_IntList));
        
        //Test setting an optional integer that has getter/setter methods that take a primitive int value.
        m_SUT = new CommandNodeModel("wrapIntField", Integer.class, false, m_TestObject, m_GrowlUtil);
        assertThat(m_SUT.getValue(), is((Object)""));
        PowerMockito.when(ArgumentValidatorUtil.convertToActualType("25", Integer.class)).thenReturn(25);
        m_SUT.setValue("25");
        assertThat(m_SUT.getValue(), is((Object)25));
        m_SUT.setValue(null);
        assertThat(m_SUT.getValue(), is((Object)""));
    }
/**
     * Test the set value method.
     * Verify that set value method handles the various class types appropriately.
     */
Test the set value method.
Verify that set value method handles the various class types appropriately.
Test the set value method . Verify that set value method handles the various class types appropriately .
@Test
    public void testSetValue() throws ReflectionsUtilException
    {
        PowerMockito.mockStatic(ArgumentValidatorUtil.class);
        assertThat(m_TestObject.getIntField(), is(5));
        PowerMockito.when(ArgumentValidatorUtil.convertToActualType("2", int.class)).thenReturn(2);
        m_SUT.setValue("2");
        assertThat(m_TestObject.getIntField(), is(2));
        m_SUT.setType(TestEnum.class);
        m_SUT.setName("enumField");
        assertThat(m_TestObject.getEnumField(), is(TestEnum.TestEnum1));
        PowerMockito.when(ArgumentValidatorUtil.convertToActualType(TestEnum.TestEnum2.toString(), 
                TestEnum.class)).thenReturn(TestEnum.TestEnum2);
        m_SUT.setValue(TestEnum.TestEnum2.toString());
        assertThat(m_TestObject.getEnumField(), is(TestEnum.TestEnum2));
        m_SUT.setType(Float.class);
        m_SUT.setName("nullableField");
        assertThat(m_TestObject.getNullableField(), is(5.2f));
        m_SUT.setValue(null);
        assertThat(m_TestObject.getNullableField(), is(nullValue()));
        m_SUT.setValue("");
        assertThat(m_TestObject.getNullableField(), is(nullValue()));
        m_SUT = new CommandNodeModel("listField", Integer.class, false, m_IntList, m_GrowlUtil);
        m_SUT.setIndex(2);
        assertThat(m_IntList.get(2), is(12));
        PowerMockito.when(ArgumentValidatorUtil.convertToActualType("125", Integer.class)).thenReturn(125);
        m_SUT.setValue("125");
        assertThat(m_IntList.get(2), is(125));
        assertThat(m_TestObject.getListField(), is(m_IntList));
        m_SUT = new CommandNodeModel("wrapIntField", Integer.class, false, m_TestObject, m_GrowlUtil);
        assertThat(m_SUT.getValue(), is((Object)""));
        PowerMockito.when(ArgumentValidatorUtil.convertToActualType("25", Integer.class)).thenReturn(25);
        m_SUT.setValue("25");
        assertThat(m_SUT.getValue(), is((Object)25));
        m_SUT.setValue(null);
        assertThat(m_SUT.getValue(), is((Object)""));
    }
@ Test public void testSetValue ( ) throws ReflectionsUtilException { PowerMockito . mockStatic ( ArgumentValidatorUtil . class ) ; assertThat ( m_TestObject . getIntField ( ) , is ( 5 ) ) ; PowerMockito . when ( ArgumentValidatorUtil . convertToActualType ( "2" , int . class ) ) . thenReturn ( 2 ) ; m_SUT . setValue ( "2" ) ; assertThat ( m_TestObject . getIntField ( ) , is ( 2 ) ) ; m_SUT . setType ( TestEnum . class ) ; m_SUT . setName ( "enumField" ) ; assertThat ( m_TestObject . getEnumField ( ) , is ( TestEnum . TestEnum1 ) ) ; PowerMockito . when ( ArgumentValidatorUtil . convertToActualType ( TestEnum . TestEnum2 . toString ( ) , TestEnum . class ) ) . thenReturn ( TestEnum . TestEnum2 ) ; m_SUT . setValue ( TestEnum . TestEnum2 . toString ( ) ) ; assertThat ( m_TestObject . getEnumField ( ) , is ( TestEnum . TestEnum2 ) ) ; m_SUT . setType ( Float . class ) ; m_SUT . setName ( "nullableField" ) ; assertThat ( m_TestObject . getNullableField ( ) , is ( 5.2f ) ) ; m_SUT . setValue ( null ) ; assertThat ( m_TestObject . getNullableField ( ) , is ( nullValue ( ) ) ) ; m_SUT . setValue ( "" ) ; assertThat ( m_TestObject . getNullableField ( ) , is ( nullValue ( ) ) ) ; m_SUT = new CommandNodeModel ( "listField" , Integer . class , false , m_IntList , m_GrowlUtil ) ; m_SUT . setIndex ( 2 ) ; assertThat ( m_IntList . get ( 2 ) , is ( 12 ) ) ; PowerMockito . when ( ArgumentValidatorUtil . convertToActualType ( "125" , Integer . class ) ) . thenReturn ( 125 ) ; m_SUT . setValue ( "125" ) ; assertThat ( m_IntList . get ( 2 ) , is ( 125 ) ) ; assertThat ( m_TestObject . getListField ( ) , is ( m_IntList ) ) ; m_SUT = new CommandNodeModel ( "wrapIntField" , Integer . class , false , m_TestObject , m_GrowlUtil ) ; assertThat ( m_SUT . getValue ( ) , is ( ( Object ) "" ) ) ; PowerMockito . when ( ArgumentValidatorUtil . convertToActualType ( "25" , Integer . class ) ) . thenReturn ( 25 ) ; m_SUT . setValue ( "25" ) ; assertThat ( m_SUT . getValue ( ) , is ( ( Object ) 25 ) ) ; m_SUT . setValue ( null ) ; assertThat ( m_SUT . getValue ( ) , is ( ( Object ) "" ) ) ; }
Test the set value method.
Test the set value method .
//Testing setting standard value. //Test setting enumeration value. //Test setting nullable field. //Test setting a list value. //Test setting an optional integer that has getter/setter methods that take a primitive int value.