mil.dod.th.ose.gui.webapp/test/mil/dod/th/ose/gui/webapp/advanced/configuration/TestConfigurationWrapperImpl.java
@SuppressWarnings("unchecked")
    @Test
    public void testSetConfigurationValue()
    {
        final String key = "name";

        //Replay setting values.
        List<ModifiablePropertyModel> properties = new ArrayList<ModifiablePropertyModel>();
        properties.add(ModelFactory.createPropModel("name", "doesn't matter"));
        m_SUT.setConfigurationValueAsync(25, "some PID", properties);
        properties.set(0, ModelFactory.createPropModel(key, "some name"));
        m_SUT.setConfigurationValueAsync(25, "some PID", properties);
        properties.set(0, ModelFactory.createPropModel(key, "doesn't matter 2"));
        m_SUT.setConfigurationValueAsync(25, "some PID2", properties);
        properties.set(0, ModelFactory.createPropModel(key, "test"));
        m_SUT.setConfigurationValueAsync(25, "some PID2", properties);
        properties.set(0, ModelFactory.createPropModel(key, "doesn't matter 3"));
        m_SUT.setConfigurationValueAsync(25, "some PID3", properties);
        
        ArgumentCaptor<String> pidCaptor = ArgumentCaptor.forClass(String.class);
        @SuppressWarnings("rawtypes")
        ArgumentCaptor<List> listCaptor = ArgumentCaptor.forClass(List.class);
        //Verify three values were set.
        verify(m_SysConfigMgr, times(3)).setConfigurationValueAsync(eq(25), pidCaptor.capture(), listCaptor.capture());
        verify(m_GrowlUtil, times(2)).createLocalFacesMessage(eq(FacesMessage.SEVERITY_INFO), 
                eq("No Property Altered:"), eq("Please alter a property before saving."));
        
        //Verify that the value the were set are correct.
        String pid = pidCaptor.getAllValues().get(0);
        List<ModifiablePropertyModel> value = listCaptor.getAllValues().get(0);
        assertThat(pid, is("some PID"));
        assertThat(value.get(0).getValue(), is((Object)"doesn't matter"));
        
        pid = pidCaptor.getAllValues().get(1);
        value = listCaptor.getAllValues().get(1);
        assertThat(pid, is("some PID2"));
        assertThat(value.get(0).getValue(), is((Object)"doesn't matter 2"));
        
        pid = pidCaptor.getAllValues().get(2);
        value = listCaptor.getAllValues().get(2);
        assertThat(pid, is("some PID3"));
        assertThat(value.get(0).getValue(), is((Object)"doesn't matter 3"));
        
        //Exception should be thrown if no meta type information exists for the specified value being set.
        try
        {
            properties.set(0, ModelFactory.createPropModel(key, "blah"));
            m_SUT.setConfigurationValueAsync(25, "non-existent", properties);
            fail("Illegal argument exception expected!");
        }
        catch (IllegalArgumentException exception)
        {
            //expected exception
        }
    }
/**
     * Test the setConfigurationValue method.
     * Verify that the setConfigurationValue method in the system configuration manager is called with appropriate
     * parameters.
     */
Test the setConfigurationValue method.
Verify that the setConfigurationValue method in the system configuration manager is called with appropriate
parameters.
Test the setConfigurationValue method . Verify that the setConfigurationValue method in the system configuration manager is called with appropriate parameters .
@SuppressWarnings("unchecked")
    @Test
    public void testSetConfigurationValue()
    {
        final String key = "name";
        List<ModifiablePropertyModel> properties = new ArrayList<ModifiablePropertyModel>();
        properties.add(ModelFactory.createPropModel("name", "doesn't matter"));
        m_SUT.setConfigurationValueAsync(25, "some PID", properties);
        properties.set(0, ModelFactory.createPropModel(key, "some name"));
        m_SUT.setConfigurationValueAsync(25, "some PID", properties);
        properties.set(0, ModelFactory.createPropModel(key, "doesn't matter 2"));
        m_SUT.setConfigurationValueAsync(25, "some PID2", properties);
        properties.set(0, ModelFactory.createPropModel(key, "test"));
        m_SUT.setConfigurationValueAsync(25, "some PID2", properties);
        properties.set(0, ModelFactory.createPropModel(key, "doesn't matter 3"));
        m_SUT.setConfigurationValueAsync(25, "some PID3", properties);
        ArgumentCaptor<String> pidCaptor = ArgumentCaptor.forClass(String.class);
        @SuppressWarnings("rawtypes")
        ArgumentCaptor<List> listCaptor = ArgumentCaptor.forClass(List.class);
        verify(m_SysConfigMgr, times(3)).setConfigurationValueAsync(eq(25), pidCaptor.capture(), listCaptor.capture());
        verify(m_GrowlUtil, times(2)).createLocalFacesMessage(eq(FacesMessage.SEVERITY_INFO), 
                eq("No Property Altered:"), eq("Please alter a property before saving."));
        String pid = pidCaptor.getAllValues().get(0);
        List<ModifiablePropertyModel> value = listCaptor.getAllValues().get(0);
        assertThat(pid, is("some PID"));
        assertThat(value.get(0).getValue(), is((Object)"doesn't matter"));
        pid = pidCaptor.getAllValues().get(1);
        value = listCaptor.getAllValues().get(1);
        assertThat(pid, is("some PID2"));
        assertThat(value.get(0).getValue(), is((Object)"doesn't matter 2"));
        pid = pidCaptor.getAllValues().get(2);
        value = listCaptor.getAllValues().get(2);
        assertThat(pid, is("some PID3"));
        assertThat(value.get(0).getValue(), is((Object)"doesn't matter 3"));
        try
        {
            properties.set(0, ModelFactory.createPropModel(key, "blah"));
            m_SUT.setConfigurationValueAsync(25, "non-existent", properties);
            fail("Illegal argument exception expected!");
        }
        catch (IllegalArgumentException exception)
        {
        }
    }
@ SuppressWarnings ( "unchecked" ) @ Test public void testSetConfigurationValue ( ) { final String key = "name" ; List < ModifiablePropertyModel > properties = new ArrayList < ModifiablePropertyModel > ( ) ; properties . add ( ModelFactory . createPropModel ( "name" , "doesn't matter" ) ) ; m_SUT . setConfigurationValueAsync ( 25 , "some PID" , properties ) ; properties . set ( 0 , ModelFactory . createPropModel ( key , "some name" ) ) ; m_SUT . setConfigurationValueAsync ( 25 , "some PID" , properties ) ; properties . set ( 0 , ModelFactory . createPropModel ( key , "doesn't matter 2" ) ) ; m_SUT . setConfigurationValueAsync ( 25 , "some PID2" , properties ) ; properties . set ( 0 , ModelFactory . createPropModel ( key , "test" ) ) ; m_SUT . setConfigurationValueAsync ( 25 , "some PID2" , properties ) ; properties . set ( 0 , ModelFactory . createPropModel ( key , "doesn't matter 3" ) ) ; m_SUT . setConfigurationValueAsync ( 25 , "some PID3" , properties ) ; ArgumentCaptor < String > pidCaptor = ArgumentCaptor . forClass ( String . class ) ; @ SuppressWarnings ( "rawtypes" ) ArgumentCaptor < List > listCaptor = ArgumentCaptor . forClass ( List . class ) ; verify ( m_SysConfigMgr , times ( 3 ) ) . setConfigurationValueAsync ( eq ( 25 ) , pidCaptor . capture ( ) , listCaptor . capture ( ) ) ; verify ( m_GrowlUtil , times ( 2 ) ) . createLocalFacesMessage ( eq ( FacesMessage . SEVERITY_INFO ) , eq ( "No Property Altered:" ) , eq ( "Please alter a property before saving." ) ) ; String pid = pidCaptor . getAllValues ( ) . get ( 0 ) ; List < ModifiablePropertyModel > value = listCaptor . getAllValues ( ) . get ( 0 ) ; assertThat ( pid , is ( "some PID" ) ) ; assertThat ( value . get ( 0 ) . getValue ( ) , is ( ( Object ) "doesn't matter" ) ) ; pid = pidCaptor . getAllValues ( ) . get ( 1 ) ; value = listCaptor . getAllValues ( ) . get ( 1 ) ; assertThat ( pid , is ( "some PID2" ) ) ; assertThat ( value . get ( 0 ) . getValue ( ) , is ( ( Object ) "doesn't matter 2" ) ) ; pid = pidCaptor . getAllValues ( ) . get ( 2 ) ; value = listCaptor . getAllValues ( ) . get ( 2 ) ; assertThat ( pid , is ( "some PID3" ) ) ; assertThat ( value . get ( 0 ) . getValue ( ) , is ( ( Object ) "doesn't matter 3" ) ) ; try { properties . set ( 0 , ModelFactory . createPropModel ( key , "blah" ) ) ; m_SUT . setConfigurationValueAsync ( 25 , "non-existent" , properties ) ; fail ( "Illegal argument exception expected!" ) ; } catch ( IllegalArgumentException exception ) { } }
Test the setConfigurationValue method.
Test the setConfigurationValue method .
//Replay setting values. //Verify three values were set. //Verify that the value the were set are correct. //Exception should be thrown if no meta type information exists for the specified value being set. //expected exception