mil.dod.th.ose.core/test/mil/dod/th/ose/core/impl/mp/TestMissionProgramManagerImpl.java
@Test
    public void testTestExecuteProgramFail() 
        throws Exception
    {
        // mock mission script object
        MissionScript missionMock = mock(MissionScript.class);
        when(missionMock.test()).thenReturn(TestResult.FAILED);

        //mock program
        ProgramImpl program = mock(ProgramImpl.class);
        when(program.getMissionScript()).thenReturn(missionMock);
        when(program.getProgramName()).thenReturn("Random message!");
       
        AssetDirectoryService assetDirectoryService = mock(AssetDirectoryService.class);
        m_SUT.setAssetDirectoryService(assetDirectoryService);
        setScriptEngineAndActivate();

        //behavior from scheduler
        @SuppressWarnings("unchecked")
        Future<TestResult> future = mock(Future.class);
        when(future.get()).thenReturn(TestResult.FAILED);
        
        doReturn(future).when(m_Scheduler).testProgram(program);
        
        //call the method
        Future<TestResult> result = m_SUT.testProgram(program);

        //verify result
        assertThat(result.get(), is(TestResult.FAILED));
    }
/**
     * Test the 'test' execution of a mission script where the test fails.
     * Verify event posted.
     */
Test the 'test' execution of a mission script where the test fails.
Verify event posted.
Test the ' test ' execution of a mission script where the test fails . Verify event posted .
@Test
    public void testTestExecuteProgramFail() 
        throws Exception
    {
        MissionScript missionMock = mock(MissionScript.class);
        when(missionMock.test()).thenReturn(TestResult.FAILED);
        ProgramImpl program = mock(ProgramImpl.class);
        when(program.getMissionScript()).thenReturn(missionMock);
        when(program.getProgramName()).thenReturn("Random message!");
        AssetDirectoryService assetDirectoryService = mock(AssetDirectoryService.class);
        m_SUT.setAssetDirectoryService(assetDirectoryService);
        setScriptEngineAndActivate();
        @SuppressWarnings("unchecked")
        Future<TestResult> future = mock(Future.class);
        when(future.get()).thenReturn(TestResult.FAILED);
        doReturn(future).when(m_Scheduler).testProgram(program);
        Future<TestResult> result = m_SUT.testProgram(program);
        assertThat(result.get(), is(TestResult.FAILED));
    }
@ Test public void testTestExecuteProgramFail ( ) throws Exception { MissionScript missionMock = mock ( MissionScript . class ) ; when ( missionMock . test ( ) ) . thenReturn ( TestResult . FAILED ) ; ProgramImpl program = mock ( ProgramImpl . class ) ; when ( program . getMissionScript ( ) ) . thenReturn ( missionMock ) ; when ( program . getProgramName ( ) ) . thenReturn ( "Random message!" ) ; AssetDirectoryService assetDirectoryService = mock ( AssetDirectoryService . class ) ; m_SUT . setAssetDirectoryService ( assetDirectoryService ) ; setScriptEngineAndActivate ( ) ; @ SuppressWarnings ( "unchecked" ) Future < TestResult > future = mock ( Future . class ) ; when ( future . get ( ) ) . thenReturn ( TestResult . FAILED ) ; doReturn ( future ) . when ( m_Scheduler ) . testProgram ( program ) ; Future < TestResult > result = m_SUT . testProgram ( program ) ; assertThat ( result . get ( ) , is ( TestResult . FAILED ) ) ; }
Test the 'test' execution of a mission script where the test fails.
Test the ' test ' execution of a mission script where the test fails .
// mock mission script object //mock program //behavior from scheduler //call the method //verify result