mil.dod.th.ose.remote/test/mil/dod/th/ose/remote/messaging/TestMessageSenderImpl.java
@Test
    public void testSendBaseMessageRemoteSystemEncryptionService() throws IOException
    {
        //set the service
        m_SUT.setRemoteSystemEncryption(m_RemoteSystemEncryption);
        when(m_RemoteSystemEncryption.getEncryptType(m_RemoteId)).thenReturn(EncryptType.AES_ECDH_ECDSA);
        when(m_RemoteSettings.getEncryptionMode()).thenReturn(EncryptionMode.AES_ECDH_ECDSA);
        
        // construct data message to send
        ControllerInfoData systemInfoData = ControllerInfoData.newBuilder().setName("blah").build();
        BaseNamespace baseNamespace = BaseNamespace.newBuilder().
                setType(BaseMessageType.ControllerInfo).
                setData(systemInfoData.toByteString()).build();
        
        TerraHarvestMessage request = 
                createMessageWithDestSource(m_LocalId, m_RemoteId, 0 , Namespace.Base, baseNamespace);
        
        TerraHarvestPayload payload = TerraHarvestPayload.parseFrom(request.getTerraHarvestPayload());
        
        when(m_EncryptService.encryptMessage(Mockito.any(Builder.class), Mockito.any(TerraHarvestPayload.class))).
            thenReturn(request);
        
        m_SUT.trySendMessage(m_RemoteId, payload);
        
        //capture the message being sent to the encryption service
        ArgumentCaptor<TerraHarvestMessage.Builder> builderCaptor = 
                ArgumentCaptor.forClass(TerraHarvestMessage.Builder.class);
        verify(m_EncryptService).encryptMessage(builderCaptor.capture(), eq(payload));
        assertThat(builderCaptor.getValue().getEncryptType(), is(EncryptType.AES_ECDH_ECDSA));
    }
/**
     * Verify that the send base message method will pass the correct message based on the destination id.
     * Verify that given no encryption level that the appropriate level is obtained from the service.
     */
Verify that the send base message method will pass the correct message based on the destination id.
Verify that given no encryption level that the appropriate level is obtained from the service.
Verify that the send base message method will pass the correct message based on the destination id . Verify that given no encryption level that the appropriate level is obtained from the service .
@Test
    public void testSendBaseMessageRemoteSystemEncryptionService() throws IOException
    {
        m_SUT.setRemoteSystemEncryption(m_RemoteSystemEncryption);
        when(m_RemoteSystemEncryption.getEncryptType(m_RemoteId)).thenReturn(EncryptType.AES_ECDH_ECDSA);
        when(m_RemoteSettings.getEncryptionMode()).thenReturn(EncryptionMode.AES_ECDH_ECDSA);
        ControllerInfoData systemInfoData = ControllerInfoData.newBuilder().setName("blah").build();
        BaseNamespace baseNamespace = BaseNamespace.newBuilder().
                setType(BaseMessageType.ControllerInfo).
                setData(systemInfoData.toByteString()).build();
        TerraHarvestMessage request = 
                createMessageWithDestSource(m_LocalId, m_RemoteId, 0 , Namespace.Base, baseNamespace);
        TerraHarvestPayload payload = TerraHarvestPayload.parseFrom(request.getTerraHarvestPayload());
        when(m_EncryptService.encryptMessage(Mockito.any(Builder.class), Mockito.any(TerraHarvestPayload.class))).
            thenReturn(request);
        m_SUT.trySendMessage(m_RemoteId, payload);
        ArgumentCaptor<TerraHarvestMessage.Builder> builderCaptor = 
                ArgumentCaptor.forClass(TerraHarvestMessage.Builder.class);
        verify(m_EncryptService).encryptMessage(builderCaptor.capture(), eq(payload));
        assertThat(builderCaptor.getValue().getEncryptType(), is(EncryptType.AES_ECDH_ECDSA));
    }
@ Test public void testSendBaseMessageRemoteSystemEncryptionService ( ) throws IOException { m_SUT . setRemoteSystemEncryption ( m_RemoteSystemEncryption ) ; when ( m_RemoteSystemEncryption . getEncryptType ( m_RemoteId ) ) . thenReturn ( EncryptType . AES_ECDH_ECDSA ) ; when ( m_RemoteSettings . getEncryptionMode ( ) ) . thenReturn ( EncryptionMode . AES_ECDH_ECDSA ) ; ControllerInfoData systemInfoData = ControllerInfoData . newBuilder ( ) . setName ( "blah" ) . build ( ) ; BaseNamespace baseNamespace = BaseNamespace . newBuilder ( ) . setType ( BaseMessageType . ControllerInfo ) . setData ( systemInfoData . toByteString ( ) ) . build ( ) ; TerraHarvestMessage request = createMessageWithDestSource ( m_LocalId , m_RemoteId , 0 , Namespace . Base , baseNamespace ) ; TerraHarvestPayload payload = TerraHarvestPayload . parseFrom ( request . getTerraHarvestPayload ( ) ) ; when ( m_EncryptService . encryptMessage ( Mockito . any ( Builder . class ) , Mockito . any ( TerraHarvestPayload . class ) ) ) . thenReturn ( request ) ; m_SUT . trySendMessage ( m_RemoteId , payload ) ; ArgumentCaptor < TerraHarvestMessage . Builder > builderCaptor = ArgumentCaptor . forClass ( TerraHarvestMessage . Builder . class ) ; verify ( m_EncryptService ) . encryptMessage ( builderCaptor . capture ( ) , eq ( payload ) ) ; assertThat ( builderCaptor . getValue ( ) . getEncryptType ( ) , is ( EncryptType . AES_ECDH_ECDSA ) ) ; }
Verify that the send base message method will pass the correct message based on the destination id.
Verify that the send base message method will pass the correct message based on the destination id .
//set the service // construct data message to send //capture the message being sent to the encryption service