@Test public void testSendMessageSafely_theMessageIsSentWhenTheMachineIsThere() throws Exception { TestApplication app = new TestApplication(); ManagedApplication ma = new ManagedApplication( app ); Message msg = new MsgCmdRemoveInstance( "/" ); app.getMySqlVm().setStatus( InstanceStatus.DEPLOYED_STARTED ); Mockito.when( this.msgClient.isConnected()).thenReturn( true ); Mockito.verifyZeroInteractions( this.msgClient ); this.mngr.sendMessageSafely( ma, app.getMySqlVm(), msg ); Mockito.verify( this.msgClient, Mockito.times( 1 )).isConnected(); Mockito.verify( this.msgClient, Mockito.times( 1 )).sendMessageToAgent( Mockito.eq( app ), Mockito.eq( app.getMySqlVm()), Mockito.eq( msg )); Assert.assertEquals( 0, ma.removeAwaitingMessages( app.getMySqlVm()).size()); }
@Override public void sendMessageSafely( ManagedApplication ma, Instance instance, Message message ) { ma.storeAwaitingMessage( instance, message ); sendStoredMessages( ma, instance ); }
MessagingMngrImpl implements IMessagingMngr { @Override public void sendMessageSafely( ManagedApplication ma, Instance instance, Message message ) { ma.storeAwaitingMessage( instance, message ); sendStoredMessages( ma, instance ); } }
MessagingMngrImpl implements IMessagingMngr { @Override public void sendMessageSafely( ManagedApplication ma, Instance instance, Message message ) { ma.storeAwaitingMessage( instance, message ); sendStoredMessages( ma, instance ); }  }
MessagingMngrImpl implements IMessagingMngr { @Override public void sendMessageSafely( ManagedApplication ma, Instance instance, Message message ) { ma.storeAwaitingMessage( instance, message ); sendStoredMessages( ma, instance ); }  void setMessagingClient( RCDm messagingClient ); @Override void sendMessageSafely( ManagedApplication ma, Instance instance, Message message ); @Override void sendMessageDirectly( ManagedApplication ma, Instance scopedInstance, Message message ); @Override void sendStoredMessages( ManagedApplication ma, Instance instance ); @Override void sendMessageToTheDm( Message message ); @Override IDmClient getMessagingClient(); @Override void checkMessagingConfiguration(); }
MessagingMngrImpl implements IMessagingMngr { @Override public void sendMessageSafely( ManagedApplication ma, Instance instance, Message message ) { ma.storeAwaitingMessage( instance, message ); sendStoredMessages( ma, instance ); }  void setMessagingClient( RCDm messagingClient ); @Override void sendMessageSafely( ManagedApplication ma, Instance instance, Message message ); @Override void sendMessageDirectly( ManagedApplication ma, Instance scopedInstance, Message message ); @Override void sendStoredMessages( ManagedApplication ma, Instance instance ); @Override void sendMessageToTheDm( Message message ); @Override IDmClient getMessagingClient(); @Override void checkMessagingConfiguration();  }