MgcpCommandProvider { public MgcpCommand provide(MgcpRequestType type, int transactionId, Parameters<MgcpParameterType> parameters) { switch (type) { case CRCX: return new CreateConnectionCommand(transactionId, parameters, this.endpointManager); case MDCX: return new ModifyConnectionCommand(transactionId, parameters, this.endpointManager); case DLCX: return new DeleteConnectionCommand(transactionId, parameters, this.endpointManager); case RQNT: return new RequestNotificationCommand(transactionId, parameters, this.endpointManager, this.packageManager, this.signalProvider); case AUCX: return new AuditConnectionCommand(transactionId, parameters, this.endpointManager); case AUEP: return new AuditEndpointCommand(transactionId, parameters, this.endpointManager); default: throw new IllegalArgumentException("Unsupported command type " + type.name()); } } MgcpCommandProvider(MgcpEndpointManager endpointManager, MgcpPackageManager packageManager, MgcpSignalProvider signalProvider, MgcpCallManager callManager); MgcpCommand provide(MgcpRequestType type, int transactionId, Parameters<MgcpParameterType> parameters);  }
@Test public void testProvideCrcx() { final int transactionId = 12345; final Parameters<MgcpParameterType> parameters = new Parameters<>(); final MgcpEndpointManager endpointManager = mock(MgcpEndpointManager.class); final MgcpSignalProvider signalProvider = mock(MgcpSignalProvider.class); final MgcpPackageManager packageManager = mock(MgcpPackageManager.class); final MgcpCallManager callManager = mock(MgcpCallManager.class); final MgcpCommandProvider commandProvider = new MgcpCommandProvider(endpointManager, packageManager, signalProvider, callManager); MgcpCommand command = commandProvider.provide(MgcpRequestType.CRCX, transactionId, parameters); Assert.assertTrue(command instanceof CreateConnectionCommand); }
@Test public void testProvideMdcx() { final int transactionId = 12345; final Parameters<MgcpParameterType> parameters = new Parameters<>(); final MgcpEndpointManager endpointManager = mock(MgcpEndpointManager.class); final MgcpPackageManager packageManager = mock(MgcpPackageManager.class); final MgcpCallManager callManager = mock(MgcpCallManager.class); final MgcpSignalProvider signalProvider = mock(MgcpSignalProvider.class); final MgcpCommandProvider commandProvider = new MgcpCommandProvider(endpointManager, packageManager, signalProvider, callManager); MgcpCommand command = commandProvider.provide(MgcpRequestType.MDCX, transactionId, parameters); Assert.assertTrue(command instanceof ModifyConnectionCommand); }
@Test public void testProvideDlcx() { final int transactionId = 12345; final Parameters<MgcpParameterType> parameters = new Parameters<>(); final MgcpEndpointManager endpointManager = mock(MgcpEndpointManager.class); final MgcpPackageManager packageManager = mock(MgcpPackageManager.class); final MgcpCallManager callManager = mock(MgcpCallManager.class); final MgcpSignalProvider signalProvider = mock(MgcpSignalProvider.class); final MgcpCommandProvider commandProvider = new MgcpCommandProvider(endpointManager, packageManager, signalProvider, callManager); MgcpCommand command = commandProvider.provide(MgcpRequestType.DLCX, transactionId, parameters); Assert.assertTrue(command instanceof DeleteConnectionCommand); }
@Test public void testProvideAucx() { final int transactionId = 12345; final Parameters<MgcpParameterType> parameters = new Parameters<>(); final MgcpEndpointManager endpointManager = mock(MgcpEndpointManager.class); final MgcpPackageManager packageManager = mock(MgcpPackageManager.class); final MgcpCallManager callManager = mock(MgcpCallManager.class); final MgcpSignalProvider signalProvider = mock(MgcpSignalProvider.class); final MgcpCommandProvider commandProvider = new MgcpCommandProvider(endpointManager, packageManager, signalProvider, callManager); MgcpCommand command = commandProvider.provide(MgcpRequestType.AUCX, transactionId, parameters); Assert.assertTrue(command instanceof AuditConnectionCommand); }
@Test public void testProvideAuep() { final int transactionId = 12345; final Parameters<MgcpParameterType> parameters = new Parameters<>(); final MgcpEndpointManager endpointManager = mock(MgcpEndpointManager.class); final MgcpPackageManager packageManager = mock(MgcpPackageManager.class); final MgcpCallManager callManager = mock(MgcpCallManager.class); final MgcpSignalProvider signalProvider = mock(MgcpSignalProvider.class); final MgcpCommandProvider commandProvider = new MgcpCommandProvider(endpointManager, packageManager, signalProvider, callManager); MgcpCommand command = commandProvider.provide(MgcpRequestType.AUEP, transactionId, parameters); Assert.assertTrue(command instanceof AuditEndpointCommand); }
@Test public void testProvideRqnt() { final int transactionId = 12345; final Parameters<MgcpParameterType> parameters = new Parameters<>(); final MgcpEndpointManager endpointManager = mock(MgcpEndpointManager.class); final MgcpPackageManager packageManager = mock(MgcpPackageManager.class); final MgcpCallManager callManager = mock(MgcpCallManager.class); final MgcpSignalProvider signalProvider = mock(MgcpSignalProvider.class); final MgcpCommandProvider commandProvider = new MgcpCommandProvider(endpointManager, packageManager, signalProvider, callManager); MgcpCommand command = commandProvider.provide(MgcpRequestType.RQNT, transactionId, parameters); Assert.assertTrue(command instanceof RequestNotificationCommand); }