mil.dod.th.ose.gui.webapp/test/mil/dod/th/ose/gui/webapp/mp/TestCurrentMissionMgrImpl.java
@Test
    public void testEventHelperMissions()
    {
        //verify for some other message topic nothing is done
        Event event = mockAnEvent(123, MissionProgrammingMessageType.CancelProgramRequest.toString(), null);
        
        m_MissionEventHelper.handleEvent(event);
        verify(m_EventAdmin, never()).postEvent(Mockito.any(Event.class));
        
        //verify for right message a mission is added
        Event eventRightMsgType = mockAnEvent(123, 
                MissionProgrammingMessageType.GetProgramInformationResponse.toString(),
                mockGetProgramInfoResponse());
        
        m_MissionEventHelper.handleEvent(eventRightMsgType);
        
        //verify that since there is no record of controller 123 none of the missions are saved
        List<CurrentMissionModel> currentMissions = m_SUT.getCurrentMissionsForControllerAsync(123);
        
        assertThat(currentMissions.size(), is(0));
        
        //verify that now missions will be saved
        m_MissionEventHelper.handleEvent(eventRightMsgType);
        
        currentMissions = m_SUT.getCurrentMissionsForControllerAsync(123);
        assertThat(currentMissions.size(), is(3));
        
        for(CurrentMissionModel missionModel : currentMissions)
        {
            if (!missionModel.getMissionName().equals("Mission 1") 
                    && !missionModel.getMissionName().equals("Mission 2") 
                    && !missionModel.getMissionName().equals("Mission 3"))
            {
                fail("Received a mission back that was not expected. The mission name was " 
                        + missionModel.getMissionName());
            }
        }
        
        //verify push event is posted 
        ArgumentCaptor<Event> eventCaptor = ArgumentCaptor.forClass(Event.class);
        verify(m_EventAdmin, times(2)).postEvent(eventCaptor.capture());
        
        //first is posted after second call to handleEvent
        Event capturedEvent1 = eventCaptor.getAllValues().get(0);
        
        assertThat((String)capturedEvent1.getProperty(EventConstants.EVENT_TOPIC), 
                is(CurrentMissionMgr.TOPIC_MISSION_UPDATED));
        
        //this is posted on the second call 
        Event capturedEvent2 = eventCaptor.getAllValues().get(1);
        
        assertThat((String)capturedEvent2.getProperty(EventConstants.EVENT_TOPIC), 
                is(CurrentMissionMgr.TOPIC_MISSION_UPDATED));
    }
/**
     * Verify mission event helper properly handles mission events.
     */
Verify mission event helper properly handles mission events.
Verify mission event helper properly handles mission events .
@Test
    public void testEventHelperMissions()
    {
        Event event = mockAnEvent(123, MissionProgrammingMessageType.CancelProgramRequest.toString(), null);
        m_MissionEventHelper.handleEvent(event);
        verify(m_EventAdmin, never()).postEvent(Mockito.any(Event.class));
        Event eventRightMsgType = mockAnEvent(123, 
                MissionProgrammingMessageType.GetProgramInformationResponse.toString(),
                mockGetProgramInfoResponse());
        m_MissionEventHelper.handleEvent(eventRightMsgType);
        List<CurrentMissionModel> currentMissions = m_SUT.getCurrentMissionsForControllerAsync(123);
        assertThat(currentMissions.size(), is(0));
        m_MissionEventHelper.handleEvent(eventRightMsgType);
        currentMissions = m_SUT.getCurrentMissionsForControllerAsync(123);
        assertThat(currentMissions.size(), is(3));
        for(CurrentMissionModel missionModel : currentMissions)
        {
            if (!missionModel.getMissionName().equals("Mission 1") 
                    && !missionModel.getMissionName().equals("Mission 2") 
                    && !missionModel.getMissionName().equals("Mission 3"))
            {
                fail("Received a mission back that was not expected. The mission name was " 
                        + missionModel.getMissionName());
            }
        }
        ArgumentCaptor<Event> eventCaptor = ArgumentCaptor.forClass(Event.class);
        verify(m_EventAdmin, times(2)).postEvent(eventCaptor.capture());
        Event capturedEvent1 = eventCaptor.getAllValues().get(0);
        assertThat((String)capturedEvent1.getProperty(EventConstants.EVENT_TOPIC), 
                is(CurrentMissionMgr.TOPIC_MISSION_UPDATED));
        Event capturedEvent2 = eventCaptor.getAllValues().get(1);
        assertThat((String)capturedEvent2.getProperty(EventConstants.EVENT_TOPIC), 
                is(CurrentMissionMgr.TOPIC_MISSION_UPDATED));
    }
@ Test public void testEventHelperMissions ( ) { Event event = mockAnEvent ( 123 , MissionProgrammingMessageType . CancelProgramRequest . toString ( ) , null ) ; m_MissionEventHelper . handleEvent ( event ) ; verify ( m_EventAdmin , never ( ) ) . postEvent ( Mockito . any ( Event . class ) ) ; Event eventRightMsgType = mockAnEvent ( 123 , MissionProgrammingMessageType . GetProgramInformationResponse . toString ( ) , mockGetProgramInfoResponse ( ) ) ; m_MissionEventHelper . handleEvent ( eventRightMsgType ) ; List < CurrentMissionModel > currentMissions = m_SUT . getCurrentMissionsForControllerAsync ( 123 ) ; assertThat ( currentMissions . size ( ) , is ( 0 ) ) ; m_MissionEventHelper . handleEvent ( eventRightMsgType ) ; currentMissions = m_SUT . getCurrentMissionsForControllerAsync ( 123 ) ; assertThat ( currentMissions . size ( ) , is ( 3 ) ) ; for ( CurrentMissionModel missionModel : currentMissions ) { if ( ! missionModel . getMissionName ( ) . equals ( "Mission 1" ) && ! missionModel . getMissionName ( ) . equals ( "Mission 2" ) && ! missionModel . getMissionName ( ) . equals ( "Mission 3" ) ) { fail ( "Received a mission back that was not expected. The mission name was " + missionModel . getMissionName ( ) ) ; } } ArgumentCaptor < Event > eventCaptor = ArgumentCaptor . forClass ( Event . class ) ; verify ( m_EventAdmin , times ( 2 ) ) . postEvent ( eventCaptor . capture ( ) ) ; Event capturedEvent1 = eventCaptor . getAllValues ( ) . get ( 0 ) ; assertThat ( ( String ) capturedEvent1 . getProperty ( EventConstants . EVENT_TOPIC ) , is ( CurrentMissionMgr . TOPIC_MISSION_UPDATED ) ) ; Event capturedEvent2 = eventCaptor . getAllValues ( ) . get ( 1 ) ; assertThat ( ( String ) capturedEvent2 . getProperty ( EventConstants . EVENT_TOPIC ) , is ( CurrentMissionMgr . TOPIC_MISSION_UPDATED ) ) ; }
Verify mission event helper properly handles mission events.
Verify mission event helper properly handles mission events .
//verify for some other message topic nothing is done //verify for right message a mission is added //verify that since there is no record of controller 123 none of the missions are saved //verify that now missions will be saved //verify push event is posted  //first is posted after second call to handleEvent //this is posted on the second call 