@Test public void testValidateRequestMissingCallId() throws MgcpException { final StringBuilder builder = new StringBuilder(); builder.append("MDCX 147483653 mobicents/bridge/1@127.0.0.1:2427 MGCP 1.0").append(System.lineSeparator()); builder.append("I:1").append(System.lineSeparator()); builder.append("M:sendrecv").append(System.lineSeparator()); builder.append(System.lineSeparator()); final MgcpMessageParser parser = new MgcpMessageParser(); final MgcpRequest request = parser.parseRequest(builder.toString()); final MgcpEndpointManager endpointManager = mock(MgcpEndpointManager.class); final ModifyConnectionCommand mdcx = new ModifyConnectionCommand(request.getTransactionId(), request.getParameters(), endpointManager); MgcpCommandResult result = mdcx.call(); assertNotNull(result); assertEquals(MgcpResponseCode.INCORRECT_CALL_ID.code(), result.getCode()); Parameters<MgcpParameterType> parameters = result.getParameters(); assertEquals(0, parameters.size()); }
@Override public MgcpCommandResult call() { MdcxContext context = new MdcxContext(); 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.error("Unexpected error occurred during tx=" + this.transactionId + " execution. Rolling back."); context.code = MgcpResponseCode.PROTOCOL_ERROR.code(); context.message = MgcpResponseCode.PROTOCOL_ERROR.message(); } catch (MgcpCommandException e) { log.error("Protocol error occurred during tx=" + this.transactionId + " execution: " + e.getMessage()); context.code = e.getCode(); context.message = e.getMessage(); } return respond(context); }
ModifyConnectionCommand extends AbstractMgcpCommand { @Override public MgcpCommandResult call() { MdcxContext context = new MdcxContext(); 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.error("Unexpected error occurred during tx=" + this.transactionId + " execution. Rolling back."); context.code = MgcpResponseCode.PROTOCOL_ERROR.code(); context.message = MgcpResponseCode.PROTOCOL_ERROR.message(); } catch (MgcpCommandException e) { log.error("Protocol error occurred during tx=" + this.transactionId + " execution: " + e.getMessage()); context.code = e.getCode(); context.message = e.getMessage(); } return respond(context); } }
ModifyConnectionCommand extends AbstractMgcpCommand { @Override public MgcpCommandResult call() { MdcxContext context = new MdcxContext(); 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.error("Unexpected error occurred during tx=" + this.transactionId + " execution. Rolling back."); context.code = MgcpResponseCode.PROTOCOL_ERROR.code(); context.message = MgcpResponseCode.PROTOCOL_ERROR.message(); } catch (MgcpCommandException e) { log.error("Protocol error occurred during tx=" + this.transactionId + " execution: " + e.getMessage()); context.code = e.getCode(); context.message = e.getMessage(); } return respond(context); } ModifyConnectionCommand(int transactionId, Parameters<MgcpParameterType> parameters, MgcpEndpointManager endpointManager); }
ModifyConnectionCommand extends AbstractMgcpCommand { @Override public MgcpCommandResult call() { MdcxContext context = new MdcxContext(); 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.error("Unexpected error occurred during tx=" + this.transactionId + " execution. Rolling back."); context.code = MgcpResponseCode.PROTOCOL_ERROR.code(); context.message = MgcpResponseCode.PROTOCOL_ERROR.message(); } catch (MgcpCommandException e) { log.error("Protocol error occurred during tx=" + this.transactionId + " execution: " + e.getMessage()); context.code = e.getCode(); context.message = e.getMessage(); } return respond(context); } ModifyConnectionCommand(int transactionId, Parameters<MgcpParameterType> parameters, MgcpEndpointManager endpointManager); @Override MgcpCommandResult call(); }
ModifyConnectionCommand extends AbstractMgcpCommand { @Override public MgcpCommandResult call() { MdcxContext context = new MdcxContext(); 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.error("Unexpected error occurred during tx=" + this.transactionId + " execution. Rolling back."); context.code = MgcpResponseCode.PROTOCOL_ERROR.code(); context.message = MgcpResponseCode.PROTOCOL_ERROR.message(); } catch (MgcpCommandException e) { log.error("Protocol error occurred during tx=" + this.transactionId + " execution: " + e.getMessage()); context.code = e.getCode(); context.message = e.getMessage(); } return respond(context); } ModifyConnectionCommand(int transactionId, Parameters<MgcpParameterType> parameters, MgcpEndpointManager endpointManager); @Override MgcpCommandResult call();  }