@Test
public void testSendPingAgent_normal_rootsAreDeployed() throws Exception {

	TestApplication app = new TestApplication();
	ManagedApplication ma = new ManagedApplication( app );
	Mockito.verifyZeroInteractions( this.messagingMngr );
	// Ping all the root instances.
	// None of them is not deployed.
	app.getMySqlVm().setStatus( InstanceStatus.DEPLOYED_STARTED );
	app.getTomcatVm().setStatus( InstanceStatus.PROBLEM );
	for( Instance i : app.getRootInstances())
		Assert.assertEquals( 0, this.mngr.pingAgent( ma, i, "TEST " + i.getName()));
	// Now check the DM has sent a ping to every agent.
	int inv = app.getRootInstances().size();
	ArgumentCaptor<Message> argMsg = ArgumentCaptor.forClass( Message.class );
	ArgumentCaptor<ManagedApplication> argApp = ArgumentCaptor.forClass( ManagedApplication.class );
	Mockito.verify( this.messagingMngr, Mockito.times( inv )).sendMessageDirectly(
			argApp.capture(),
			Mockito.any( Instance.class ),
			argMsg.capture());
	List<Message> sentMessages = argMsg.getAllValues();
	Assert.assertEquals( app.getRootInstances().size(), sentMessages.size());
	int index = 0;
	for( Instance i : app.getRootInstances()) {
		Message message = sentMessages.get( index++ );
		Assert.assertTrue( message instanceof MsgEcho );
		MsgEcho echo = (MsgEcho) message;
		Assert.assertEquals( "PING:TEST " + i.getName(), echo.getContent());
	}
	for( ManagedApplication t : argApp.getAllValues()) {
		Assert.assertEquals( ma, t );
	}
}