@Test public void testNotificationRequestWithUnrecognizedAction() throws MgcpParseException { final StringBuilder builder = new StringBuilder("RQNT 12345 mobicents/ivr/10@127.0.0.1:2427 MGCP 1.0").append("\n"); builder.append("N:restcomm@10.229.72.130:2727").append("\n"); builder.append("X:10").append("\n"); builder.append("S:AU/pa(an=http: builder.append("R:AU/oc(XYZ),AU/of(N)"); final MgcpMessageParser parser = new MgcpMessageParser(); final MgcpRequest request = parser.parseRequest(builder.toString()); final MgcpEndpointManager endpointManager = mock(MgcpEndpointManager.class); final MgcpPackageManager packageManager = mock(MgcpPackageManager.class); final MgcpPackage mgcpPackage = mock(MgcpPackage.class); final MgcpEventType eventType = mock(MgcpEventType.class); final MgcpEndpoint endpoint = mock(MgcpEndpoint.class); final MgcpSignalProvider signalProvider = mock(MgcpSignalProvider.class); final RequestNotificationCommand rqnt = new RequestNotificationCommand(request.getTransactionId(), request.getParameters(), endpointManager, packageManager, signalProvider); when(endpointManager.getEndpoint("mobicents/ivr/10@127.0.0.1:2427")).thenReturn(endpoint); when(packageManager.getPackage("AU")).thenReturn(mgcpPackage); when(mgcpPackage.getEventDetails(any(String.class))).thenReturn(eventType); when(eventType.parameterized()).thenReturn(false); MgcpCommandResult result = rqnt.call(); Assert.assertNotNull(result); Assert.assertEquals(MgcpResponseCode.EVENT_OR_SIGNAL_PARAMETER_ERROR.code(), result.getCode()); }
@Override public MgcpCommandResult call() { RqntContext context = new RqntContext(); try { validateParameters(this.requestParameters, context); executeCommand(context); context.code = MgcpResponseCode.TRANSACTION_WAS_EXECUTED.code(); context.message = MgcpResponseCode.TRANSACTION_WAS_EXECUTED.message(); } catch (RuntimeException e) { log.warn("Unexpected error occurred during tx=" + this.transactionId + " execution. Reason:", e); context.code = MgcpResponseCode.PROTOCOL_ERROR.code(); context.message = MgcpResponseCode.PROTOCOL_ERROR.message(); } catch (MgcpCommandException e) { log.warn("Protocol error occurred during tx=" + this.transactionId + " execution. Reason:", e); context.code = e.getCode(); context.message = e.getMessage(); } return respond(context); }
RequestNotificationCommand extends AbstractMgcpCommand { @Override public MgcpCommandResult call() { RqntContext context = new RqntContext(); try { validateParameters(this.requestParameters, context); executeCommand(context); context.code = MgcpResponseCode.TRANSACTION_WAS_EXECUTED.code(); context.message = MgcpResponseCode.TRANSACTION_WAS_EXECUTED.message(); } catch (RuntimeException e) { log.warn("Unexpected error occurred during tx=" + this.transactionId + " execution. Reason:", e); context.code = MgcpResponseCode.PROTOCOL_ERROR.code(); context.message = MgcpResponseCode.PROTOCOL_ERROR.message(); } catch (MgcpCommandException e) { log.warn("Protocol error occurred during tx=" + this.transactionId + " execution. Reason:", e); context.code = e.getCode(); context.message = e.getMessage(); } return respond(context); } }
RequestNotificationCommand extends AbstractMgcpCommand { @Override public MgcpCommandResult call() { RqntContext context = new RqntContext(); try { validateParameters(this.requestParameters, context); executeCommand(context); context.code = MgcpResponseCode.TRANSACTION_WAS_EXECUTED.code(); context.message = MgcpResponseCode.TRANSACTION_WAS_EXECUTED.message(); } catch (RuntimeException e) { log.warn("Unexpected error occurred during tx=" + this.transactionId + " execution. Reason:", e); context.code = MgcpResponseCode.PROTOCOL_ERROR.code(); context.message = MgcpResponseCode.PROTOCOL_ERROR.message(); } catch (MgcpCommandException e) { log.warn("Protocol error occurred during tx=" + this.transactionId + " execution. Reason:", e); context.code = e.getCode(); context.message = e.getMessage(); } return respond(context); } RequestNotificationCommand(int transactionId, Parameters<MgcpParameterType> parameters, MgcpEndpointManager endpointManager, MgcpPackageManager packageManager, MgcpSignalProvider signalProvider); }
RequestNotificationCommand extends AbstractMgcpCommand { @Override public MgcpCommandResult call() { RqntContext context = new RqntContext(); try { validateParameters(this.requestParameters, context); executeCommand(context); context.code = MgcpResponseCode.TRANSACTION_WAS_EXECUTED.code(); context.message = MgcpResponseCode.TRANSACTION_WAS_EXECUTED.message(); } catch (RuntimeException e) { log.warn("Unexpected error occurred during tx=" + this.transactionId + " execution. Reason:", e); context.code = MgcpResponseCode.PROTOCOL_ERROR.code(); context.message = MgcpResponseCode.PROTOCOL_ERROR.message(); } catch (MgcpCommandException e) { log.warn("Protocol error occurred during tx=" + this.transactionId + " execution. Reason:", e); context.code = e.getCode(); context.message = e.getMessage(); } return respond(context); } RequestNotificationCommand(int transactionId, Parameters<MgcpParameterType> parameters, MgcpEndpointManager endpointManager, MgcpPackageManager packageManager, MgcpSignalProvider signalProvider); @Override MgcpCommandResult call(); }
RequestNotificationCommand extends AbstractMgcpCommand { @Override public MgcpCommandResult call() { RqntContext context = new RqntContext(); try { validateParameters(this.requestParameters, context); executeCommand(context); context.code = MgcpResponseCode.TRANSACTION_WAS_EXECUTED.code(); context.message = MgcpResponseCode.TRANSACTION_WAS_EXECUTED.message(); } catch (RuntimeException e) { log.warn("Unexpected error occurred during tx=" + this.transactionId + " execution. Reason:", e); context.code = MgcpResponseCode.PROTOCOL_ERROR.code(); context.message = MgcpResponseCode.PROTOCOL_ERROR.message(); } catch (MgcpCommandException e) { log.warn("Protocol error occurred during tx=" + this.transactionId + " execution. Reason:", e); context.code = e.getCode(); context.message = e.getMessage(); } return respond(context); } RequestNotificationCommand(int transactionId, Parameters<MgcpParameterType> parameters, MgcpEndpointManager endpointManager, MgcpPackageManager packageManager, MgcpSignalProvider signalProvider); @Override MgcpCommandResult call();  }