GlobalMgcpCallManager implements MgcpCallManager { @Override public MgcpCall unregisterCall(int callId) { MgcpCall call = this.calls.remove(callId); boolean removed = (call != null); if (removed && log.isDebugEnabled()) { log.debug("Unregistered call " + call.getCallIdHex() +". Call count: " + this.calls.size()); } return call; } GlobalMgcpCallManager(); @Override MgcpCall getCall(int callId); @Override boolean registerCall(MgcpCall call); @Override MgcpCall unregisterCall(int callId); @Override Set<MgcpCall> unregisterCalls();  }
@Test public void testUnregisterCall() { final MgcpCall call = mock(MgcpCall.class); final MgcpCallManager callManager = new GlobalMgcpCallManager(); when(call.getCallId()).thenReturn(1); when(call.getCallIdHex()).thenReturn("1"); final boolean isRegistered = callManager.registerCall(call); final MgcpCall unregisteredCall = callManager.unregisterCall(call.getCallId()); final MgcpCall retirevedCall = callManager.getCall(call.getCallId()); assertTrue(isRegistered); assertEquals(call, unregisteredCall); assertNull(retirevedCall); }