mil.dod.th.ose.remote.integration/src/mil/dod/th/ose/remote/integration/namespace/TestMissionProgrammingNamespace.java
@Test
    public void testGetProgramLastTestResult() throws UnknownHostException, IOException, InterruptedException
    {
        //message listener
        MessageListener listener = new MessageListener(m_Socket);
        
        m_MissionName = "testResultProgram";
        
        RemoteEventRegistration.regRemoteEventMessages(m_Socket, Program.TOPIC_PROGRAM_TESTED, 
                String.format("(%s=%s)", Program.EVENT_PROP_PROGRAM_NAME, m_MissionName));
                
        //create schedule
        MissionProgramParametersGen.MissionProgramSchedule schedule = MissionProgramParametersGen.
                MissionProgramSchedule.newBuilder().setActive(true).setImmediately(false).
                setIndefiniteInterval(false).build();
        
        //create mission program parameters
        MissionProgramParametersGen.MissionProgramParameters params = 
            MissionProgramNamespaceUtils.genTimedDataLoopParams(schedule, ASSET_NAME, m_MissionName);
        
        //load the parameters
        MissionProgramNamespaceUtils.loadParameters(m_Socket, params);
        
        //create execution message
        ExecuteTestRequestData requestMessage = ExecuteTestRequestData.newBuilder().
                setMissionName(m_MissionName).build();

        TerraHarvestMessage message = 
                createMissionProgramMessage(MissionProgrammingMessageType.ExecuteTestRequest, requestMessage);
        
        // send out message
        message.writeDelimitedTo(m_Socket.getOutputStream());
        
        //wait for execution and response, response is from the actual thread executing the mission program
        listener.waitForMessages(2000, new BasicMessageMatcher(Namespace.MissionProgramming, 
                MissionProgrammingMessageType.ExecuteTestResponse), 
                new MessageMatchers.EventMessageMatcher(Program.TOPIC_PROGRAM_TESTED));
        
        //create mission program message
        GetLastTestResultsRequestData request = GetLastTestResultsRequestData.newBuilder().
                setMissionName(m_MissionName).build();
        
        //create terra harvest message   
        message = createMissionProgramMessage(
                MissionProgrammingMessageType.GetLastTestResultsRequest, request);
        
        // send out message
        message.writeDelimitedTo(m_Socket.getOutputStream());
        
        //wait for execution and response, response is from the actual thread executing the mission program
        MissionProgrammingNamespace namespace = (MissionProgrammingNamespace)listener.waitForMessage(
                Namespace.MissionProgramming,  MissionProgrammingMessageType.GetLastTestResultsResponse, 500);
        
        GetLastTestResultsResponseData responseDataResult = 
                GetLastTestResultsResponseData.parseFrom(namespace.getData());

        //verify success
        assertThat(responseDataResult.getResult(), isOneOf(MissionTestResult.PASSED)); 
        assertThat(responseDataResult.getMissionName(), is(m_MissionName));
    }
/**
     * Test requesting the last test results of a program.
     */
Test requesting the last test results of a program.
Test requesting the last test results of a program .
@Test
    public void testGetProgramLastTestResult() throws UnknownHostException, IOException, InterruptedException
    {
        MessageListener listener = new MessageListener(m_Socket);
        m_MissionName = "testResultProgram";
        RemoteEventRegistration.regRemoteEventMessages(m_Socket, Program.TOPIC_PROGRAM_TESTED, 
                String.format("(%s=%s)", Program.EVENT_PROP_PROGRAM_NAME, m_MissionName));
        MissionProgramParametersGen.MissionProgramSchedule schedule = MissionProgramParametersGen.
                MissionProgramSchedule.newBuilder().setActive(true).setImmediately(false).
                setIndefiniteInterval(false).build();
        MissionProgramParametersGen.MissionProgramParameters params = 
            MissionProgramNamespaceUtils.genTimedDataLoopParams(schedule, ASSET_NAME, m_MissionName);
        MissionProgramNamespaceUtils.loadParameters(m_Socket, params);
        ExecuteTestRequestData requestMessage = ExecuteTestRequestData.newBuilder().
                setMissionName(m_MissionName).build();
        TerraHarvestMessage message = 
                createMissionProgramMessage(MissionProgrammingMessageType.ExecuteTestRequest, requestMessage);
        message.writeDelimitedTo(m_Socket.getOutputStream());
        listener.waitForMessages(2000, new BasicMessageMatcher(Namespace.MissionProgramming, 
                MissionProgrammingMessageType.ExecuteTestResponse), 
                new MessageMatchers.EventMessageMatcher(Program.TOPIC_PROGRAM_TESTED));
        GetLastTestResultsRequestData request = GetLastTestResultsRequestData.newBuilder().
                setMissionName(m_MissionName).build();
        message = createMissionProgramMessage(
                MissionProgrammingMessageType.GetLastTestResultsRequest, request);
        message.writeDelimitedTo(m_Socket.getOutputStream());
        MissionProgrammingNamespace namespace = (MissionProgrammingNamespace)listener.waitForMessage(
                Namespace.MissionProgramming,  MissionProgrammingMessageType.GetLastTestResultsResponse, 500);
        GetLastTestResultsResponseData responseDataResult = 
                GetLastTestResultsResponseData.parseFrom(namespace.getData());
        assertThat(responseDataResult.getResult(), isOneOf(MissionTestResult.PASSED)); 
        assertThat(responseDataResult.getMissionName(), is(m_MissionName));
    }
@ Test public void testGetProgramLastTestResult ( ) throws UnknownHostException , IOException , InterruptedException { MessageListener listener = new MessageListener ( m_Socket ) ; m_MissionName = "testResultProgram" ; RemoteEventRegistration . regRemoteEventMessages ( m_Socket , Program . TOPIC_PROGRAM_TESTED , String . format ( "(%s=%s)" , Program . EVENT_PROP_PROGRAM_NAME , m_MissionName ) ) ; MissionProgramParametersGen . MissionProgramSchedule schedule = MissionProgramParametersGen . MissionProgramSchedule . newBuilder ( ) . setActive ( true ) . setImmediately ( false ) . setIndefiniteInterval ( false ) . build ( ) ; MissionProgramParametersGen . MissionProgramParameters params = MissionProgramNamespaceUtils . genTimedDataLoopParams ( schedule , ASSET_NAME , m_MissionName ) ; MissionProgramNamespaceUtils . loadParameters ( m_Socket , params ) ; ExecuteTestRequestData requestMessage = ExecuteTestRequestData . newBuilder ( ) . setMissionName ( m_MissionName ) . build ( ) ; TerraHarvestMessage message = createMissionProgramMessage ( MissionProgrammingMessageType . ExecuteTestRequest , requestMessage ) ; message . writeDelimitedTo ( m_Socket . getOutputStream ( ) ) ; listener . waitForMessages ( 2000 , new BasicMessageMatcher ( Namespace . MissionProgramming , MissionProgrammingMessageType . ExecuteTestResponse ) , new MessageMatchers . EventMessageMatcher ( Program . TOPIC_PROGRAM_TESTED ) ) ; GetLastTestResultsRequestData request = GetLastTestResultsRequestData . newBuilder ( ) . setMissionName ( m_MissionName ) . build ( ) ; message = createMissionProgramMessage ( MissionProgrammingMessageType . GetLastTestResultsRequest , request ) ; message . writeDelimitedTo ( m_Socket . getOutputStream ( ) ) ; MissionProgrammingNamespace namespace = ( MissionProgrammingNamespace ) listener . waitForMessage ( Namespace . MissionProgramming , MissionProgrammingMessageType . GetLastTestResultsResponse , 500 ) ; GetLastTestResultsResponseData responseDataResult = GetLastTestResultsResponseData . parseFrom ( namespace . getData ( ) ) ; assertThat ( responseDataResult . getResult ( ) , isOneOf ( MissionTestResult . PASSED ) ) ; assertThat ( responseDataResult . getMissionName ( ) , is ( m_MissionName ) ) ; }
Test requesting the last test results of a program.
Test requesting the last test results of a program .
//message listener //create schedule //create mission program parameters //load the parameters //create execution message // send out message //wait for execution and response, response is from the actual thread executing the mission program //create mission program message //create terra harvest message    // send out message //wait for execution and response, response is from the actual thread executing the mission program //verify success