mil.dod.th.ose.gui.webapp/test/mil/dod/th/ose/gui/webapp/asset/TestAssetCommandViewImpl.java
@Test
    public void testAddField() throws SecurityException
    {
        ExampleClass testCommandObject = new ExampleClass();
        
        //Create fake node for a primitive list field.
        CommandNodeModel listNode = new CommandNodeModel("intWrapperListField", List.class, false, testCommandObject, 
                m_GrowlUtil);
        
        //Verify initial size of the integer list field.
        assertThat(testCommandObject.getIntWrapperListField().size(), is(3));
        //Add another integer to the list.
        m_SUT.addField(listNode);
        //Verify size of integer list has increased by one.
        assertThat(testCommandObject.getIntWrapperListField().size(), is(4));
        
        //Create fake node for a complex list field.
        listNode = new CommandNodeModel("complexListField", List.class, false, testCommandObject, 
                m_GrowlUtil);
        
        //Verify initial size of complex list field.
        assertThat(testCommandObject.getComplexListField().size(), is(1));
        //Add another complex object to the list.
        m_SUT.addField(listNode);
        //Verify size of complex list has increased by one.
        assertThat(testCommandObject.getComplexListField().size(), is(2));
        
        testCommandObject.setComplexField(null);
        
        //Create fake node for a complex field.
        CommandNodeModel complexNode = new CommandNodeModel("complexField", ExampleComplexClass.class, true, 
                testCommandObject, m_GrowlUtil);
        
        //Verify that the complex field is initially null.
        assertThat(testCommandObject.getComplexField(), is(nullValue()));
        //Add object to complex field.
        m_SUT.addField(complexNode);
        //Verify that the complex field is no longer null.
        assertThat(testCommandObject.getComplexField(), is(notNullValue()));
        
        //Test adding to a list field that does not exists.
        listNode = new CommandNodeModel("DNE_ListField", List.class, false, testCommandObject, 
                m_GrowlUtil);
        
        //Add item to list that does not exist.
        m_SUT.addField(listNode);
        
        //Verify that a growl message is displayed since the list field does not exist.
        verify(m_GrowlUtil).createLocalFacesMessage(FacesMessage.SEVERITY_ERROR, "Error Adding Object To List:", 
                "An exception has occurred while trying to add an object to the list with the field" 
                + "name: " + listNode.getName() + ". See the server logs for more detail.", null, true);
        
        //Test adding a complex object that does not exist.
        complexNode = new CommandNodeModel("DNE_ComplexField", ExampleComplexClass.class, true, 
                testCommandObject, m_GrowlUtil);
        
        //Add complex object that does not exist.
        m_SUT.addField(complexNode);
        
        //Verify that a growl message is displayed since the complex field does not exist.
        verify(m_GrowlUtil).createLocalFacesMessage(FacesMessage.SEVERITY_ERROR, "Error Adding Field:", 
                "An exception has occurred while trying to add an object of type: " + complexNode.getName() + ". " +
                        "See the server log for further details.", null, true);
    }
/**
     * Test the add field method.
     * Verify that the specified field was actually added to the object.
     */
Test the add field method.
Verify that the specified field was actually added to the object.
Test the add field method . Verify that the specified field was actually added to the object .
@Test
    public void testAddField() throws SecurityException
    {
        ExampleClass testCommandObject = new ExampleClass();
        CommandNodeModel listNode = new CommandNodeModel("intWrapperListField", List.class, false, testCommandObject, 
                m_GrowlUtil);
        assertThat(testCommandObject.getIntWrapperListField().size(), is(3));
        m_SUT.addField(listNode);
        assertThat(testCommandObject.getIntWrapperListField().size(), is(4));
        listNode = new CommandNodeModel("complexListField", List.class, false, testCommandObject, 
                m_GrowlUtil);
        assertThat(testCommandObject.getComplexListField().size(), is(1));
        m_SUT.addField(listNode);
        assertThat(testCommandObject.getComplexListField().size(), is(2));
        testCommandObject.setComplexField(null);
        CommandNodeModel complexNode = new CommandNodeModel("complexField", ExampleComplexClass.class, true, 
                testCommandObject, m_GrowlUtil);
        assertThat(testCommandObject.getComplexField(), is(nullValue()));
        m_SUT.addField(complexNode);
        assertThat(testCommandObject.getComplexField(), is(notNullValue()));
        listNode = new CommandNodeModel("DNE_ListField", List.class, false, testCommandObject, 
                m_GrowlUtil);
        m_SUT.addField(listNode);
        verify(m_GrowlUtil).createLocalFacesMessage(FacesMessage.SEVERITY_ERROR, "Error Adding Object To List:", 
                "An exception has occurred while trying to add an object to the list with the field" 
                + "name: " + listNode.getName() + ". See the server logs for more detail.", null, true);
        complexNode = new CommandNodeModel("DNE_ComplexField", ExampleComplexClass.class, true, 
                testCommandObject, m_GrowlUtil);
        m_SUT.addField(complexNode);
        verify(m_GrowlUtil).createLocalFacesMessage(FacesMessage.SEVERITY_ERROR, "Error Adding Field:", 
                "An exception has occurred while trying to add an object of type: " + complexNode.getName() + ". " +
                        "See the server log for further details.", null, true);
    }
@ Test public void testAddField ( ) throws SecurityException { ExampleClass testCommandObject = new ExampleClass ( ) ; CommandNodeModel listNode = new CommandNodeModel ( "intWrapperListField" , List . class , false , testCommandObject , m_GrowlUtil ) ; assertThat ( testCommandObject . getIntWrapperListField ( ) . size ( ) , is ( 3 ) ) ; m_SUT . addField ( listNode ) ; assertThat ( testCommandObject . getIntWrapperListField ( ) . size ( ) , is ( 4 ) ) ; listNode = new CommandNodeModel ( "complexListField" , List . class , false , testCommandObject , m_GrowlUtil ) ; assertThat ( testCommandObject . getComplexListField ( ) . size ( ) , is ( 1 ) ) ; m_SUT . addField ( listNode ) ; assertThat ( testCommandObject . getComplexListField ( ) . size ( ) , is ( 2 ) ) ; testCommandObject . setComplexField ( null ) ; CommandNodeModel complexNode = new CommandNodeModel ( "complexField" , ExampleComplexClass . class , true , testCommandObject , m_GrowlUtil ) ; assertThat ( testCommandObject . getComplexField ( ) , is ( nullValue ( ) ) ) ; m_SUT . addField ( complexNode ) ; assertThat ( testCommandObject . getComplexField ( ) , is ( notNullValue ( ) ) ) ; listNode = new CommandNodeModel ( "DNE_ListField" , List . class , false , testCommandObject , m_GrowlUtil ) ; m_SUT . addField ( listNode ) ; verify ( m_GrowlUtil ) . createLocalFacesMessage ( FacesMessage . SEVERITY_ERROR , "Error Adding Object To List:" , "An exception has occurred while trying to add an object to the list with the field" + "name: " + listNode . getName ( ) + ". See the server logs for more detail." , null , true ) ; complexNode = new CommandNodeModel ( "DNE_ComplexField" , ExampleComplexClass . class , true , testCommandObject , m_GrowlUtil ) ; m_SUT . addField ( complexNode ) ; verify ( m_GrowlUtil ) . createLocalFacesMessage ( FacesMessage . SEVERITY_ERROR , "Error Adding Field:" , "An exception has occurred while trying to add an object of type: " + complexNode . getName ( ) + ". " + "See the server log for further details." , null , true ) ; }
Test the add field method.
Test the add field method .
//Create fake node for a primitive list field. //Verify initial size of the integer list field. //Add another integer to the list. //Verify size of integer list has increased by one. //Create fake node for a complex list field. //Verify initial size of complex list field. //Add another complex object to the list. //Verify size of complex list has increased by one. //Create fake node for a complex field. //Verify that the complex field is initially null. //Add object to complex field. //Verify that the complex field is no longer null. //Test adding to a list field that does not exists. //Add item to list that does not exist. //Verify that a growl message is displayed since the list field does not exist. //Test adding a complex object that does not exist. //Add complex object that does not exist. //Verify that a growl message is displayed since the complex field does not exist.