mil.dod.th.ose.remote/test/mil/dod/th/ose/remote/mp/TestMissionProgrammingMessageService.java
@Test
    public void testGetProgramLastTestResultNull() throws IllegalArgumentException, IOException
    {
        //mock the program
        Program program = mock(Program.class);
        when(program.getLastTestResult()).thenReturn(null);
        when(program.getLastTestExceptionCause()).thenReturn("");
        when(m_Manager.getProgram("man")).thenReturn(program);
        
        //request
        GetLastTestResultsRequestData request = GetLastTestResultsRequestData.newBuilder().
                setMissionName("man").build();
        MissionProgrammingNamespace missionMessage = MissionProgrammingNamespace.newBuilder().
                setType(MissionProgrammingMessageType.GetLastTestResultsRequest).
                setData(request.toByteString()).build();
        TerraHarvestMessage message = createMissionProgrammingMessage(missionMessage);
        
        // mock the channel the message came from
        RemoteChannel channel = mock(RemoteChannel.class);
        
        // replay
        m_SUT.handleMessage(message, createPayload(missionMessage), channel);
        
        ArgumentCaptor<GetLastTestResultsResponseData> responseCaptor = 
                ArgumentCaptor.forClass(GetLastTestResultsResponseData.class);
        verify(m_MessageFactory).createMissionProgrammingResponseMessage(eq(message), 
                eq(MissionProgrammingMessageType.GetLastTestResultsResponse), responseCaptor.capture());
        verify(m_ResponseWrapper).queue(channel);
        
        GetLastTestResultsResponseData response = responseCaptor.getValue();
        assertThat(response.getMissionName(), is("man"));
        assertThat(response.hasResult(), is(false));
    }
/**
     * Test the handling of a request to get a program's last test results where the result does not exist.
     */
Test the handling of a request to get a program's last test results where the result does not exist.
Test the handling of a request to get a program ' s last test results where the result does not exist .
@Test
    public void testGetProgramLastTestResultNull() throws IllegalArgumentException, IOException
    {
        Program program = mock(Program.class);
        when(program.getLastTestResult()).thenReturn(null);
        when(program.getLastTestExceptionCause()).thenReturn("");
        when(m_Manager.getProgram("man")).thenReturn(program);
        GetLastTestResultsRequestData request = GetLastTestResultsRequestData.newBuilder().
                setMissionName("man").build();
        MissionProgrammingNamespace missionMessage = MissionProgrammingNamespace.newBuilder().
                setType(MissionProgrammingMessageType.GetLastTestResultsRequest).
                setData(request.toByteString()).build();
        TerraHarvestMessage message = createMissionProgrammingMessage(missionMessage);
        RemoteChannel channel = mock(RemoteChannel.class);
        m_SUT.handleMessage(message, createPayload(missionMessage), channel);
        ArgumentCaptor<GetLastTestResultsResponseData> responseCaptor = 
                ArgumentCaptor.forClass(GetLastTestResultsResponseData.class);
        verify(m_MessageFactory).createMissionProgrammingResponseMessage(eq(message), 
                eq(MissionProgrammingMessageType.GetLastTestResultsResponse), responseCaptor.capture());
        verify(m_ResponseWrapper).queue(channel);
        GetLastTestResultsResponseData response = responseCaptor.getValue();
        assertThat(response.getMissionName(), is("man"));
        assertThat(response.hasResult(), is(false));
    }
@ Test public void testGetProgramLastTestResultNull ( ) throws IllegalArgumentException , IOException { Program program = mock ( Program . class ) ; when ( program . getLastTestResult ( ) ) . thenReturn ( null ) ; when ( program . getLastTestExceptionCause ( ) ) . thenReturn ( "" ) ; when ( m_Manager . getProgram ( "man" ) ) . thenReturn ( program ) ; GetLastTestResultsRequestData request = GetLastTestResultsRequestData . newBuilder ( ) . setMissionName ( "man" ) . build ( ) ; MissionProgrammingNamespace missionMessage = MissionProgrammingNamespace . newBuilder ( ) . setType ( MissionProgrammingMessageType . GetLastTestResultsRequest ) . setData ( request . toByteString ( ) ) . build ( ) ; TerraHarvestMessage message = createMissionProgrammingMessage ( missionMessage ) ; RemoteChannel channel = mock ( RemoteChannel . class ) ; m_SUT . handleMessage ( message , createPayload ( missionMessage ) , channel ) ; ArgumentCaptor < GetLastTestResultsResponseData > responseCaptor = ArgumentCaptor . forClass ( GetLastTestResultsResponseData . class ) ; verify ( m_MessageFactory ) . createMissionProgrammingResponseMessage ( eq ( message ) , eq ( MissionProgrammingMessageType . GetLastTestResultsResponse ) , responseCaptor . capture ( ) ) ; verify ( m_ResponseWrapper ) . queue ( channel ) ; GetLastTestResultsResponseData response = responseCaptor . getValue ( ) ; assertThat ( response . getMissionName ( ) , is ( "man" ) ) ; assertThat ( response . hasResult ( ) , is ( false ) ) ; }
Test the handling of a request to get a program's last test results where the result does not exist.
Test the handling of a request to get a program ' s last test results where the result does not exist .
//mock the program //request // mock the channel the message came from // replay