mil.dod.th.ose.gui.webapp/test/mil/dod/th/ose/gui/webapp/asset/TestCommandHandlerMgrImpl.java
@Test
    public void testSendCommandWithNoCommandInstance() throws ObjectConverterException, ClassNotFoundException, 
        InstantiationException, IllegalAccessException
    {
        UUID assetUuid = UUID.randomUUID();
        Message testMessage = mock(Message.class);
        ByteString testByteString = ByteString.copyFrom(new byte[1024]);
        
        //Mock converter behavior.
        when(m_Converter.convertToProto(Mockito.any(Command.class))).thenReturn(testMessage);
        when(testMessage.toByteString()).thenReturn(testByteString);
        
        m_SUT.sendCommand(CONTROLLER_ID, assetUuid, CommandTypeEnum.GET_VERSION_COMMAND);
        
        //Capture messages being sent out by remote message sender.
        ArgumentCaptor<Message> messageCaptor = ArgumentCaptor.forClass(Message.class);
        
        //Verify four messages were sent by the remote message sender, one for each command type.
        verify(m_MessageFactory).createAssetMessage(eq(AssetMessageType.ExecuteCommandRequest), 
                messageCaptor.capture());
        verify(m_MessageWrapper).queue(eq(CONTROLLER_ID), Mockito.any(ResponseHandler.class));
        
        ExecuteCommandRequestData msg = (ExecuteCommandRequestData)messageCaptor.getValue();
        assertThat(msg.getCommandType(), is(CommandTypesGen.CommandType.Enum.GET_VERSION_COMMAND));
    }
/**
     * Verify that send command method without a command parameter works correctly.
     */
Verify that send command method without a command parameter works correctly.
Verify that send command method without a command parameter works correctly .
@Test
    public void testSendCommandWithNoCommandInstance() throws ObjectConverterException, ClassNotFoundException, 
        InstantiationException, IllegalAccessException
    {
        UUID assetUuid = UUID.randomUUID();
        Message testMessage = mock(Message.class);
        ByteString testByteString = ByteString.copyFrom(new byte[1024]);
        when(m_Converter.convertToProto(Mockito.any(Command.class))).thenReturn(testMessage);
        when(testMessage.toByteString()).thenReturn(testByteString);
        m_SUT.sendCommand(CONTROLLER_ID, assetUuid, CommandTypeEnum.GET_VERSION_COMMAND);
        ArgumentCaptor<Message> messageCaptor = ArgumentCaptor.forClass(Message.class);
        verify(m_MessageFactory).createAssetMessage(eq(AssetMessageType.ExecuteCommandRequest), 
                messageCaptor.capture());
        verify(m_MessageWrapper).queue(eq(CONTROLLER_ID), Mockito.any(ResponseHandler.class));
        ExecuteCommandRequestData msg = (ExecuteCommandRequestData)messageCaptor.getValue();
        assertThat(msg.getCommandType(), is(CommandTypesGen.CommandType.Enum.GET_VERSION_COMMAND));
    }
@ Test public void testSendCommandWithNoCommandInstance ( ) throws ObjectConverterException , ClassNotFoundException , InstantiationException , IllegalAccessException { UUID assetUuid = UUID . randomUUID ( ) ; Message testMessage = mock ( Message . class ) ; ByteString testByteString = ByteString . copyFrom ( new byte [ 1024 ] ) ; when ( m_Converter . convertToProto ( Mockito . any ( Command . class ) ) ) . thenReturn ( testMessage ) ; when ( testMessage . toByteString ( ) ) . thenReturn ( testByteString ) ; m_SUT . sendCommand ( CONTROLLER_ID , assetUuid , CommandTypeEnum . GET_VERSION_COMMAND ) ; ArgumentCaptor < Message > messageCaptor = ArgumentCaptor . forClass ( Message . class ) ; verify ( m_MessageFactory ) . createAssetMessage ( eq ( AssetMessageType . ExecuteCommandRequest ) , messageCaptor . capture ( ) ) ; verify ( m_MessageWrapper ) . queue ( eq ( CONTROLLER_ID ) , Mockito . any ( ResponseHandler . class ) ) ; ExecuteCommandRequestData msg = ( ExecuteCommandRequestData ) messageCaptor . getValue ( ) ; assertThat ( msg . getCommandType ( ) , is ( CommandTypesGen . CommandType . Enum . GET_VERSION_COMMAND ) ) ; }
Verify that send command method without a command parameter works correctly.
Verify that send command method without a command parameter works correctly .
//Mock converter behavior. //Capture messages being sent out by remote message sender. //Verify four messages were sent by the remote message sender, one for each command type.