MgcpCall { public boolean removeConnection(String endpointId, int connectionId) { boolean removed = this.entries.remove(endpointId, connectionId); if (removed && log.isDebugEnabled()) { int left = this.entries.get(endpointId).size(); log.debug("Call " + getCallIdHex() + " unregistered connection " + Integer.toHexString(connectionId) + " from endpoint " + endpointId + ". Connection count: " + left); } return removed; } MgcpCall(int callId); int getCallId(); String getCallIdHex(); Set<String> getEndpoints(); Set<Integer> getConnections(String endpointId); boolean addConnection(String endpointId, int connectionId); boolean removeConnection(String endpointId, int connectionId); Set<Integer> removeConnections(String endpointId);  }
@Test public void testRemoveConnection() { final int callId = 10; final int bridgeConnection1 = 1; final int bridgeConnection2 = 2; final int bridgeConnection3 = 3; final String bridgeEndpoint = "mobicents/bridge/1"; final MgcpCall call = new MgcpCall(callId); final Set<String> endpoints = call.getEndpoints(); final Set<Integer> bridgeConnections = call.getConnections(bridgeEndpoint); call.addConnection(bridgeEndpoint, bridgeConnection1); call.addConnection(bridgeEndpoint, bridgeConnection2); call.addConnection(bridgeEndpoint, bridgeConnection3); call.removeConnection(bridgeEndpoint, bridgeConnection1); call.removeConnection(bridgeEndpoint, bridgeConnection3); assertEquals(1, endpoints.size()); assertTrue(endpoints.contains(bridgeEndpoint)); assertEquals(1, bridgeConnections.size()); assertTrue(bridgeConnections.contains(Integer.valueOf(bridgeConnection2))); call.removeConnection(bridgeEndpoint, bridgeConnection2); assertTrue(endpoints.isEmpty()); assertTrue(bridgeConnections.isEmpty()); }