MgcpCall { public boolean addConnection(String endpointId, int connectionId) { boolean added = this.entries.put(endpointId, connectionId); if (added && log.isDebugEnabled()) { int left = this.entries.get(endpointId).size(); log.debug("Call " + getCallIdHex() + " registered connection " + Integer.toHexString(connectionId) + " at endpoint " + endpointId + ". Connection count: " + left); } return added; } 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 testAddConnection() { final int callId = 10; final int ivrConnection1 = 1; final int bridgeConnection1 = 1; final int bridgeConnection2 = 2; final int bridgeConnection3 = 3; final String ivrEndpoint = "mobicents/ivr/1"; final String bridgeEndpoint = "mobicents/bridge/1"; final MgcpCall call = new MgcpCall(callId); final boolean addedBridge1 = call.addConnection(bridgeEndpoint, bridgeConnection1); final boolean addedBridge2 = call.addConnection(bridgeEndpoint, bridgeConnection2); final boolean addedBridge3 = call.addConnection(bridgeEndpoint, bridgeConnection3); final boolean addedIvr1 = call.addConnection(ivrEndpoint, ivrConnection1); final Set<String> endpoints = call.getEndpoints(); final Set<Integer> ivrConnections = call.getConnections(ivrEndpoint); final Set<Integer> bridgeConnections = call.getConnections(bridgeEndpoint); assertTrue(addedBridge1); assertTrue(addedBridge2); assertTrue(addedBridge3); assertTrue(addedIvr1); assertEquals(2, endpoints.size()); assertTrue(endpoints.contains(bridgeEndpoint)); assertTrue(endpoints.contains(ivrEndpoint)); assertEquals(1, ivrConnections.size()); assertTrue(ivrConnections.contains(Integer.valueOf(ivrConnection1))); assertEquals(3, bridgeConnections.size()); assertTrue(bridgeConnections.contains(Integer.valueOf(bridgeConnection1))); assertTrue(bridgeConnections.contains(Integer.valueOf(bridgeConnection2))); assertTrue(bridgeConnections.contains(Integer.valueOf(bridgeConnection3))); }