AutonomicMngrImpl implements IAutonomicMngr { @Override public void notifyVmWasDeletedByHand( Instance rootInstance ) { if( rootInstance.data.remove( AUTONOMIC_MARKER ) != null ) this.autonomicVmCount.decrementAndGet(); } AutonomicMngrImpl( ICommandsMngr commandsMngr ); void setPreferencesMngr( IPreferencesMngr preferencesMngr ); @Override void loadApplicationRules( Application app ); @Override void refreshApplicationRules( Application app, String ruleFileName ); @Override void unloadApplicationRules( Application app ); @Override void notifyVmWasDeletedByHand( Instance rootInstance ); @Override int getAutonomicInstancesCount(); @Override void handleEvent( ManagedApplication ma, MsgNotifAutonomic event );  }
@Test public void testNotifyVmWasDeletedByHand() throws Exception { AtomicInteger vmCount = this.autonomicMngr.autonomicVmCount; Assert.assertEquals( 0, vmCount.get()); vmCount.set( 5 ); Instance rootInstance = new Instance( "inst" );; this.autonomicMngr.notifyVmWasDeletedByHand( rootInstance ); Assert.assertEquals( 5, vmCount.get()); rootInstance.data.put( AutonomicMngrImpl.AUTONOMIC_MARKER, "whatever" ); this.autonomicMngr.notifyVmWasDeletedByHand( rootInstance ); Assert.assertEquals( 4, vmCount.get()); this.autonomicMngr.notifyVmWasDeletedByHand( rootInstance ); Assert.assertEquals( 4, vmCount.get()); }