mil.dod.th.ose.core/test/mil/dod/th/ose/core/impl/mp/TestProgramImpl.java
@Test
    public void testProgramStatusChangeEventPosted()
    {
        ProgramImpl program = createProgram("statusEventProgram");
        
        // Test that event is posted correctly if status is changed.
        program.changeStatus(ProgramStatus.WAITING_INITIALIZED);
        
        ArgumentCaptor<Event> eventCaptor = ArgumentCaptor.forClass(Event.class);
        verify(m_EventAdmin, atLeastOnce()).postEvent(eventCaptor.capture());
 
        Event event = EventAdminVerifier.assertEventByTopicOnly(eventCaptor, Program.TOPIC_PROGRAM_STATUS_CHANGED);

        assertThat((String)event.getProperty(Program.EVENT_PROP_PROGRAM_NAME), is("statusEventProgram"));
        assertThat((String)event.getProperty(Program.EVENT_PROP_PROGRAM_STATUS), 
            is(ProgramStatus.WAITING_INITIALIZED.toString()));
        
        //test that an attempted change that causes an illegal state does not post a status changed event
        //because the status is not changed in this case.
        try
        {
            program.changeStatus(ProgramStatus.UNSATISFIED);
            fail("Expecting exception because the script should not go from initialized to unsatisfied.");
        }
        catch (IllegalStateException e)
        {
            //expected exception
        }
        
        // Only one event should have been captured from previous change to WAITING_INITIALIZED.
        // Verify that no event was posted for attempted but failed change to UNSATISFIED
        EventAdminVerifier.assertEventByTopicOnly(eventCaptor, Program.TOPIC_PROGRAM_STATUS_CHANGED, 1);
    }
/**
     * Verifies that an event is posted when the program status is changed.
     */
Verifies that an event is posted when the program status is changed.
Verifies that an event is posted when the program status is changed .
@Test
    public void testProgramStatusChangeEventPosted()
    {
        ProgramImpl program = createProgram("statusEventProgram");
        program.changeStatus(ProgramStatus.WAITING_INITIALIZED);
        ArgumentCaptor<Event> eventCaptor = ArgumentCaptor.forClass(Event.class);
        verify(m_EventAdmin, atLeastOnce()).postEvent(eventCaptor.capture());
        Event event = EventAdminVerifier.assertEventByTopicOnly(eventCaptor, Program.TOPIC_PROGRAM_STATUS_CHANGED);
        assertThat((String)event.getProperty(Program.EVENT_PROP_PROGRAM_NAME), is("statusEventProgram"));
        assertThat((String)event.getProperty(Program.EVENT_PROP_PROGRAM_STATUS), 
            is(ProgramStatus.WAITING_INITIALIZED.toString()));
        try
        {
            program.changeStatus(ProgramStatus.UNSATISFIED);
            fail("Expecting exception because the script should not go from initialized to unsatisfied.");
        }
        catch (IllegalStateException e)
        {
        }
        EventAdminVerifier.assertEventByTopicOnly(eventCaptor, Program.TOPIC_PROGRAM_STATUS_CHANGED, 1);
    }
@ Test public void testProgramStatusChangeEventPosted ( ) { ProgramImpl program = createProgram ( "statusEventProgram" ) ; program . changeStatus ( ProgramStatus . WAITING_INITIALIZED ) ; ArgumentCaptor < Event > eventCaptor = ArgumentCaptor . forClass ( Event . class ) ; verify ( m_EventAdmin , atLeastOnce ( ) ) . postEvent ( eventCaptor . capture ( ) ) ; Event event = EventAdminVerifier . assertEventByTopicOnly ( eventCaptor , Program . TOPIC_PROGRAM_STATUS_CHANGED ) ; assertThat ( ( String ) event . getProperty ( Program . EVENT_PROP_PROGRAM_NAME ) , is ( "statusEventProgram" ) ) ; assertThat ( ( String ) event . getProperty ( Program . EVENT_PROP_PROGRAM_STATUS ) , is ( ProgramStatus . WAITING_INITIALIZED . toString ( ) ) ) ; try { program . changeStatus ( ProgramStatus . UNSATISFIED ) ; fail ( "Expecting exception because the script should not go from initialized to unsatisfied." ) ; } catch ( IllegalStateException e ) { } EventAdminVerifier . assertEventByTopicOnly ( eventCaptor , Program . TOPIC_PROGRAM_STATUS_CHANGED , 1 ) ; }
Verifies that an event is posted when the program status is changed.
Verifies that an event is posted when the program status is changed .
// Test that event is posted correctly if status is changed. //test that an attempted change that causes an illegal state does not post a status changed event //because the status is not changed in this case. //expected exception // Only one event should have been captured from previous change to WAITING_INITIALIZED. // Verify that no event was posted for attempted but failed change to UNSATISFIED