@Test
@SuppressWarnings( "unchecked" )
public void testRun_appWithAllStates() throws Exception {

	TestApplication app = new TestApplication();
	ManagedApplication ma = new ManagedApplication( app );
	TestUtils.getInternalField( this.appManager, "nameToManagedApplication", Map.class ).put( ma.getName(), ma );
	InstanceStatus[] statuses = new InstanceStatus[] {
			InstanceStatus.NOT_DEPLOYED,
			InstanceStatus.DEPLOYING,
			InstanceStatus.DEPLOYED_STARTED,
			InstanceStatus.DEPLOYED_STOPPED,
			InstanceStatus.PROBLEM
	};
	for( InstanceStatus status : statuses ) {
		Mockito.reset( this.messagingMngr );
		CheckerForStoredMessagesTask task = new CheckerForStoredMessagesTask( this.appManager, this.messagingMngr );
		app.getMySqlVm().setStatus( status );
		Mockito.verifyZeroInteractions( this.messagingMngr );
		task.run();
		Mockito.verify( this.messagingMngr, Mockito.times( 1 )).sendStoredMessages(
				Mockito.eq( ma ),
				Mockito.eq( app.getMySqlVm()));
		Mockito.verify( this.messagingMngr, Mockito.times( 1 )).sendStoredMessages(
				Mockito.eq( ma ),
				Mockito.eq( app.getTomcatVm()));
	}
}