mil.dod.th.ose.remote/test/mil/dod/th/ose/remote/base/TestBaseMessageService.java
@Test
    public void testObjectConverterExceptionGetControllerCap() 
        throws IOException, UnmarshalException, ObjectConverterException
    
    {
        BundleContext bundleContext = mock(BundleContext.class);
        when(bundleContext.getBundle(0)).thenReturn(Mockito.any(Bundle.class));
        m_SUT.activate(bundleContext);
 
        mil.dod.th.core.controller.capability.ControllerCapabilities capabilities = 
                mock (mil.dod.th.core.controller.capability.ControllerCapabilities.class);
        when(m_TerraHarvestController.getCapabilities()).thenReturn(capabilities);
        when(m_Converter.convertToProto(capabilities)).
            thenThrow(new ObjectConverterException("Object Converter Error"));

        BaseNamespace baseNamespaceMessage = BaseNamespace.newBuilder().
                setType(BaseMessageType.GetControllerCapabilitiesRequest).build();
        TerraHarvestPayload payload = createPayload(baseNamespaceMessage);
        
        TerraHarvestMessage message = createBaseMessage(baseNamespaceMessage);
        
        // mock the channel the message came from
        RemoteChannel channel = mock(RemoteChannel.class);

        m_SUT.handleMessage(message, payload, channel);
        
        verify(m_MessageFactory).createBaseErrorMessage(message, ErrorCode.CONVERTER_ERROR, 
                "Unable to convert from java object to google protocol buffer message. " +
                "Object Converter Error");
        verify(m_ResponseWrapper).queue(channel);  
    }
/**
     *  
     * Verify remote error message when there is unmarshal exception thrown.
     */
Verify remote error message when there is unmarshal exception thrown.
Verify remote error message when there is unmarshal exception thrown .
@Test
    public void testObjectConverterExceptionGetControllerCap() 
        throws IOException, UnmarshalException, ObjectConverterException
    {
        BundleContext bundleContext = mock(BundleContext.class);
        when(bundleContext.getBundle(0)).thenReturn(Mockito.any(Bundle.class));
        m_SUT.activate(bundleContext);
        mil.dod.th.core.controller.capability.ControllerCapabilities capabilities = 
                mock (mil.dod.th.core.controller.capability.ControllerCapabilities.class);
        when(m_TerraHarvestController.getCapabilities()).thenReturn(capabilities);
        when(m_Converter.convertToProto(capabilities)).
            thenThrow(new ObjectConverterException("Object Converter Error"));
        BaseNamespace baseNamespaceMessage = BaseNamespace.newBuilder().
                setType(BaseMessageType.GetControllerCapabilitiesRequest).build();
        TerraHarvestPayload payload = createPayload(baseNamespaceMessage);
        TerraHarvestMessage message = createBaseMessage(baseNamespaceMessage);
        RemoteChannel channel = mock(RemoteChannel.class);
        m_SUT.handleMessage(message, payload, channel);
        verify(m_MessageFactory).createBaseErrorMessage(message, ErrorCode.CONVERTER_ERROR, 
                "Unable to convert from java object to google protocol buffer message. " +
                "Object Converter Error");
        verify(m_ResponseWrapper).queue(channel);  
    }
@ Test public void testObjectConverterExceptionGetControllerCap ( ) throws IOException , UnmarshalException , ObjectConverterException { BundleContext bundleContext = mock ( BundleContext . class ) ; when ( bundleContext . getBundle ( 0 ) ) . thenReturn ( Mockito . any ( Bundle . class ) ) ; m_SUT . activate ( bundleContext ) ; mil . dod . th . core . controller . capability . ControllerCapabilities capabilities = mock ( mil . dod . th . core . controller . capability . ControllerCapabilities . class ) ; when ( m_TerraHarvestController . getCapabilities ( ) ) . thenReturn ( capabilities ) ; when ( m_Converter . convertToProto ( capabilities ) ) . thenThrow ( new ObjectConverterException ( "Object Converter Error" ) ) ; BaseNamespace baseNamespaceMessage = BaseNamespace . newBuilder ( ) . setType ( BaseMessageType . GetControllerCapabilitiesRequest ) . build ( ) ; TerraHarvestPayload payload = createPayload ( baseNamespaceMessage ) ; TerraHarvestMessage message = createBaseMessage ( baseNamespaceMessage ) ; RemoteChannel channel = mock ( RemoteChannel . class ) ; m_SUT . handleMessage ( message , payload , channel ) ; verify ( m_MessageFactory ) . createBaseErrorMessage ( message , ErrorCode . CONVERTER_ERROR , "Unable to convert from java object to google protocol buffer message. " + "Object Converter Error" ) ; verify ( m_ResponseWrapper ) . queue ( channel ) ; }
Verify remote error message when there is unmarshal exception thrown.
Verify remote error message when there is unmarshal exception thrown .
// mock the channel the message came from