ManagedApplication { public List<Message> removeAwaitingMessages( Instance instance ) { Instance scopedInstance = InstanceHelpers.findScopedInstance( instance ); List<Message> result = null; synchronized( this.scopedInstanceToAwaitingMessages ) { result = this.scopedInstanceToAwaitingMessages.remove( scopedInstance ); } return result != null ? result : new ArrayList<Message>( 0 ); } ManagedApplication( Application application ); Map<Instance,List<Message>> getScopedInstanceToAwaitingMessages(); Application getApplication(); File getDirectory(); String getName(); Graphs getGraphs(); File getTemplateDirectory(); @Override String toString(); void storeAwaitingMessage( Instance instance, Message msg ); List<Message> removeAwaitingMessages( Instance instance ); void acknowledgeHeartBeat( Instance scopedInstance ); void checkStates( INotificationMngr notificationMngr );  }
@Test public void testRemoveAwaitingMessages() { Assert.assertEquals( 0, this.ma.getScopedInstanceToAwaitingMessages().size()); Assert.assertEquals( 0, this.ma.removeAwaitingMessages( new Instance( "whatever" )).size()); Instance rootInstance = new Instance( "root" ); this.ma.storeAwaitingMessage( rootInstance, new MsgCmdSendInstances()); Assert.assertEquals( 1, this.ma.getScopedInstanceToAwaitingMessages().size()); Assert.assertEquals( 1, this.ma.removeAwaitingMessages( rootInstance ).size()); Assert.assertEquals( 0, this.ma.getScopedInstanceToAwaitingMessages().size()); Assert.assertEquals( 0, this.ma.removeAwaitingMessages( rootInstance ).size()); }