mil.dod.th.ose.gui.webapp/test/mil/dod/th/ose/gui/webapp/mp/TestMissionLoadSelected.java
@Test
    public void testSyncedLoadMission() throws ObjectConverterException
    {
        //mock schedule
        MissionProgramSchedule schedule = getSchedule();
        MissionModel model = getModelB();      
        //mock mission manager behavior
        when(m_MissionManager.getMission()).thenReturn(model);
        when(m_MissionManager.getSchedule()).thenReturn(schedule);
        when(m_MissionManager.getProgramName()).thenReturn("name");
        
        //mock controller
        ControllerModel controller = mock(ControllerModel.class);
        when(controller.getId()).thenReturn(123);
        //mock active controller
        when(m_ActiveController.isActiveControllerSet()).thenReturn(true);
        when(m_ActiveController.getActiveController()).thenReturn(controller);
        
        MissionProgramParametersGen.MissionProgramSchedule genSched = 
            MissionProgramParametersGen.MissionProgramSchedule.
            newBuilder().setActive(false).setAtReset(true).setImmediately(true).setIndefiniteInterval(true).build();
        Multitype value = Multitype.newBuilder().setStringValue("Money").setType(Type.STRING).build();
        MapEntry entry = MapEntry.newBuilder().setKey("Currency").setValue(value).build();
        MissionProgramParametersGen.MissionProgramParameters parametersGen = 
            MissionProgramParametersGen.MissionProgramParameters.newBuilder().
                addParameters(entry).
                setProgramName("name").
                setSchedule(genSched).
                setTemplateName("Bueller").build();
        //mock converters behavior
        when(m_Converter.convertToProto(Mockito.any())).thenReturn(parametersGen);
        
        //try to load mock mission, capture string returned
        String outcome = m_SUT.loadMission();
        //verify parameter values that are not strings
        ArgumentCaptor<MissionProgramParameters> paramsCap = ArgumentCaptor.forClass(MissionProgramParameters.class);
        verify(m_Converter).convertToProto(paramsCap.capture());
        //see the model for the values set, should be an integer, double and short, verify that 
        //schedule is set as active
        assertThat((Integer)paramsCap.getValue().getParameters().get(2).getValue(), is(321));
        assertThat((Double)paramsCap.getValue().getParameters().get(3).getValue(), is(321.908));
        assertThat((Short)paramsCap.getValue().getParameters().get(4).getValue(), is((short) 321));
        assertThat(paramsCap.getValue().getSchedule().isActive(), is(true));
        
        //verify message sender sent message for params 
        ArgumentCaptor<Message> captor = ArgumentCaptor.
            forClass(Message.class);
        verify(m_MissionProgMgr, times(1)).queueMessage(eq(123), captor.capture(), 
                eq(MissionProgrammingMessageType.LoadParametersRequest));
        //verify growl message to user
        verify(m_GrowlUtil).createLocalFacesMessage(eq(FacesMessage.SEVERITY_INFO), Mockito.anyString(), 
                Mockito.anyString());
        
        //verify parameters
        assertThat(((LoadParametersRequestData)captor.getValue()).getParameters(), is(parametersGen));
        
        //verify outcome
        assertThat(outcome, is(""));
    }
/**
     * Test loading synced mission.
     * 
     * Verify message sender sends parameters.
     * 
     * Verify that parameters are of the correct type (ie., integer, double, etc...)
     */
Test loading synced mission.

Verify message sender sends parameters.

Verify that parameters are of the correct type
Test loading synced mission . Verify message sender sends parameters . Verify that parameters are of the correct type
@Test
    public void testSyncedLoadMission() throws ObjectConverterException
    {
        MissionProgramSchedule schedule = getSchedule();
        MissionModel model = getModelB();      
        when(m_MissionManager.getMission()).thenReturn(model);
        when(m_MissionManager.getSchedule()).thenReturn(schedule);
        when(m_MissionManager.getProgramName()).thenReturn("name");
        ControllerModel controller = mock(ControllerModel.class);
        when(controller.getId()).thenReturn(123);
        when(m_ActiveController.isActiveControllerSet()).thenReturn(true);
        when(m_ActiveController.getActiveController()).thenReturn(controller);
        MissionProgramParametersGen.MissionProgramSchedule genSched = 
            MissionProgramParametersGen.MissionProgramSchedule.
            newBuilder().setActive(false).setAtReset(true).setImmediately(true).setIndefiniteInterval(true).build();
        Multitype value = Multitype.newBuilder().setStringValue("Money").setType(Type.STRING).build();
        MapEntry entry = MapEntry.newBuilder().setKey("Currency").setValue(value).build();
        MissionProgramParametersGen.MissionProgramParameters parametersGen = 
            MissionProgramParametersGen.MissionProgramParameters.newBuilder().
                addParameters(entry).
                setProgramName("name").
                setSchedule(genSched).
                setTemplateName("Bueller").build();
        when(m_Converter.convertToProto(Mockito.any())).thenReturn(parametersGen);
        String outcome = m_SUT.loadMission();
        ArgumentCaptor<MissionProgramParameters> paramsCap = ArgumentCaptor.forClass(MissionProgramParameters.class);
        verify(m_Converter).convertToProto(paramsCap.capture());
        assertThat((Integer)paramsCap.getValue().getParameters().get(2).getValue(), is(321));
        assertThat((Double)paramsCap.getValue().getParameters().get(3).getValue(), is(321.908));
        assertThat((Short)paramsCap.getValue().getParameters().get(4).getValue(), is((short) 321));
        assertThat(paramsCap.getValue().getSchedule().isActive(), is(true));
        ArgumentCaptor<Message> captor = ArgumentCaptor.
            forClass(Message.class);
        verify(m_MissionProgMgr, times(1)).queueMessage(eq(123), captor.capture(), 
                eq(MissionProgrammingMessageType.LoadParametersRequest));
        verify(m_GrowlUtil).createLocalFacesMessage(eq(FacesMessage.SEVERITY_INFO), Mockito.anyString(), 
                Mockito.anyString());
        assertThat(((LoadParametersRequestData)captor.getValue()).getParameters(), is(parametersGen));
        assertThat(outcome, is(""));
    }
@ Test public void testSyncedLoadMission ( ) throws ObjectConverterException { MissionProgramSchedule schedule = getSchedule ( ) ; MissionModel model = getModelB ( ) ; when ( m_MissionManager . getMission ( ) ) . thenReturn ( model ) ; when ( m_MissionManager . getSchedule ( ) ) . thenReturn ( schedule ) ; when ( m_MissionManager . getProgramName ( ) ) . thenReturn ( "name" ) ; ControllerModel controller = mock ( ControllerModel . class ) ; when ( controller . getId ( ) ) . thenReturn ( 123 ) ; when ( m_ActiveController . isActiveControllerSet ( ) ) . thenReturn ( true ) ; when ( m_ActiveController . getActiveController ( ) ) . thenReturn ( controller ) ; MissionProgramParametersGen . MissionProgramSchedule genSched = MissionProgramParametersGen . MissionProgramSchedule . newBuilder ( ) . setActive ( false ) . setAtReset ( true ) . setImmediately ( true ) . setIndefiniteInterval ( true ) . build ( ) ; Multitype value = Multitype . newBuilder ( ) . setStringValue ( "Money" ) . setType ( Type . STRING ) . build ( ) ; MapEntry entry = MapEntry . newBuilder ( ) . setKey ( "Currency" ) . setValue ( value ) . build ( ) ; MissionProgramParametersGen . MissionProgramParameters parametersGen = MissionProgramParametersGen . MissionProgramParameters . newBuilder ( ) . addParameters ( entry ) . setProgramName ( "name" ) . setSchedule ( genSched ) . setTemplateName ( "Bueller" ) . build ( ) ; when ( m_Converter . convertToProto ( Mockito . any ( ) ) ) . thenReturn ( parametersGen ) ; String outcome = m_SUT . loadMission ( ) ; ArgumentCaptor < MissionProgramParameters > paramsCap = ArgumentCaptor . forClass ( MissionProgramParameters . class ) ; verify ( m_Converter ) . convertToProto ( paramsCap . capture ( ) ) ; assertThat ( ( Integer ) paramsCap . getValue ( ) . getParameters ( ) . get ( 2 ) . getValue ( ) , is ( 321 ) ) ; assertThat ( ( Double ) paramsCap . getValue ( ) . getParameters ( ) . get ( 3 ) . getValue ( ) , is ( 321.908 ) ) ; assertThat ( ( Short ) paramsCap . getValue ( ) . getParameters ( ) . get ( 4 ) . getValue ( ) , is ( ( short ) 321 ) ) ; assertThat ( paramsCap . getValue ( ) . getSchedule ( ) . isActive ( ) , is ( true ) ) ; ArgumentCaptor < Message > captor = ArgumentCaptor . forClass ( Message . class ) ; verify ( m_MissionProgMgr , times ( 1 ) ) . queueMessage ( eq ( 123 ) , captor . capture ( ) , eq ( MissionProgrammingMessageType . LoadParametersRequest ) ) ; verify ( m_GrowlUtil ) . createLocalFacesMessage ( eq ( FacesMessage . SEVERITY_INFO ) , Mockito . anyString ( ) , Mockito . anyString ( ) ) ; assertThat ( ( ( LoadParametersRequestData ) captor . getValue ( ) ) . getParameters ( ) , is ( parametersGen ) ) ; assertThat ( outcome , is ( "" ) ) ; }
Test loading synced mission.
Test loading synced mission .
//mock schedule //mock mission manager behavior //mock controller //mock active controller //mock converters behavior //try to load mock mission, capture string returned //verify parameter values that are not strings //see the model for the values set, should be an integer, double and short, verify that  //schedule is set as active //verify message sender sent message for params  //verify growl message to user //verify parameters //verify outcome