MgcpCall { public Set<Integer> removeConnections(String endpointId) { Set<Integer> removed = this.entries.removeAll(endpointId); if (!removed.isEmpty() && log.isDebugEnabled()) { log.debug("Call " + getCallIdHex() + " unregistered connections " + Arrays.toString(convertToHex(removed)) + " from endpoint " + endpointId); } 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 testRemoveConnections() { 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); final Set<Integer> removed = call.removeConnections(bridgeEndpoint); assertTrue(endpoints.isEmpty()); assertTrue(bridgeConnections.isEmpty()); assertEquals(3, removed.size()); assertTrue(removed.contains(Integer.valueOf(bridgeConnection1))); assertTrue(removed.contains(Integer.valueOf(bridgeConnection2))); assertTrue(removed.contains(Integer.valueOf(bridgeConnection3))); }
@Test(expected = UnsupportedOperationException.class) public void testUnmodifiableRemoveConnections() { final int callId = 10; final int bridgeConnection1 = 1; final String bridgeEndpoint = "mobicents/bridge/1"; final MgcpCall call = new MgcpCall(callId); final Set<Integer> removed = call.removeConnections(bridgeEndpoint); removed.add(Integer.valueOf(bridgeConnection1)); }