RCUtils { public static void validateConnectionParms(HashMap<String, Object> parameters) throws RCException { if (!parameters.containsKey(RCConnection.ParameterKeys.CONNECTION_PEER) || parameters.get(RCConnection.ParameterKeys.CONNECTION_PEER).equals("")) { throw new RCException(RCClient.ErrorCodes.ERROR_CONNECTION_MISSING_PEER); } if (parameters.containsKey(RCConnection.ParameterKeys.CONNECTION_VIDEO_ENABLED) && (boolean)parameters.get(RCConnection.ParameterKeys.CONNECTION_VIDEO_ENABLED)) { if (!parameters.containsKey(RCConnection.ParameterKeys.CONNECTION_LOCAL_VIDEO) || parameters.get(RCConnection.ParameterKeys.CONNECTION_LOCAL_VIDEO) == null || !parameters.containsKey(RCConnection.ParameterKeys.CONNECTION_REMOTE_VIDEO) || parameters.get(RCConnection.ParameterKeys.CONNECTION_REMOTE_VIDEO) == null) { throw new RCException(RCClient.ErrorCodes.ERROR_CONNECTION_VIDEO_CALL_VIEWS_MANDATORY); } } else { if (parameters.containsKey(RCConnection.ParameterKeys.CONNECTION_LOCAL_VIDEO)) { RCLogger.w(TAG, "validateConnectionParms(): WARN, local video doesn't take effect since the call is audio-only" + parameters.toString()); } if (parameters.containsKey(RCConnection.ParameterKeys.CONNECTION_REMOTE_VIDEO)) { RCLogger.w(TAG, "validateConnectionParms(): WARN, remote video doesn't take effect since the call is audio-only" + parameters.toString()); } if (parameters.containsKey(RCConnection.ParameterKeys.CONNECTION_PREFERRED_VIDEO_CODEC)) { RCLogger.w(TAG, "validateConnectionParms(): WARN, video codec doesn't take effect since the call is audio-only" + parameters.toString()); } if (parameters.containsKey(RCConnection.ParameterKeys.CONNECTION_PREFERRED_VIDEO_RESOLUTION)) { RCLogger.w(TAG, "validateConnectionParms(): WARN, video resolution doesn't take effect since the call is audio-only" + parameters.toString()); } if (parameters.containsKey(RCConnection.ParameterKeys.CONNECTION_PREFERRED_VIDEO_FRAME_RATE)) { RCLogger.w(TAG, "validateConnectionParms(): WARN, video frame rate doesn't take effect since the call is audio-only" + parameters.toString()); } } }  static void validateDeviceParms(HashMap<String, Object> parameters); @SuppressWarnings("unchecked") static void validateSettingsParms(HashMap<String, Object> parameters); static void validateConnectionParms(HashMap<String, Object> parameters); static boolean shouldRegisterForPush(HashMap<String, Object> parameters, StorageManagerInterface storageManagerInterface);  }
@Test public void validateConnectionParams_Invalid() { HashMap<String, Object> connectParams = new HashMap<String, Object>(); try { RCUtils.validateConnectionParms(connectParams); } catch (RCException ex) { assertThat(ex.errorCode).isEqualTo(RCClient.ErrorCodes.ERROR_CONNECTION_MISSING_PEER); } connectParams = new HashMap<String, Object>(); try { connectParams.put(RCConnection.ParameterKeys.CONNECTION_PEER, ""); RCUtils.validateConnectionParms(connectParams); } catch (RCException ex) { assertThat(ex.errorCode).isEqualTo(RCClient.ErrorCodes.ERROR_CONNECTION_MISSING_PEER); } connectParams = new HashMap<String, Object>(); try { connectParams.put(RCConnection.ParameterKeys.CONNECTION_PEER, "restcomm"); RCUtils.validateConnectionParms(connectParams); } catch (RCException ex) { fail(ex.toString()); } connectParams = new HashMap<String, Object>(); try { connectParams.put(RCConnection.ParameterKeys.CONNECTION_PEER, "restcomm"); connectParams.put(RCConnection.ParameterKeys.CONNECTION_VIDEO_ENABLED, true); RCUtils.validateConnectionParms(connectParams); } catch (RCException ex) { assertThat(ex.errorCode).isEqualTo(RCClient.ErrorCodes.ERROR_CONNECTION_VIDEO_CALL_VIEWS_MANDATORY); } connectParams = new HashMap<String, Object>(); try { connectParams.put(RCConnection.ParameterKeys.CONNECTION_PEER, "restcomm"); connectParams.put(RCConnection.ParameterKeys.CONNECTION_VIDEO_ENABLED, true); connectParams.put(RCConnection.ParameterKeys.CONNECTION_LOCAL_VIDEO, new PercentFrameLayout(context)); RCUtils.validateConnectionParms(connectParams); } catch (RCException ex) { assertThat(ex.errorCode).isEqualTo(RCClient.ErrorCodes.ERROR_CONNECTION_VIDEO_CALL_VIEWS_MANDATORY); } }
@Test public void validateConnectionParams_Valid() { HashMap<String, Object> connectParams = new HashMap<String, Object>(); connectParams.put(RCConnection.ParameterKeys.CONNECTION_PEER, "restcomm"); connectParams.put(RCConnection.ParameterKeys.CONNECTION_VIDEO_ENABLED, true); connectParams.put(RCConnection.ParameterKeys.CONNECTION_VIDEO_ENABLED, true); connectParams.put(RCConnection.ParameterKeys.CONNECTION_LOCAL_VIDEO, new PercentFrameLayout(context)); connectParams.put(RCConnection.ParameterKeys.CONNECTION_LOCAL_VIDEO, new PercentFrameLayout(context)); connectParams.put(RCConnection.ParameterKeys.CONNECTION_REMOTE_VIDEO, new PercentFrameLayout(context)); try { connectParams.put(RCConnection.ParameterKeys.CONNECTION_VIDEO_ENABLED, false); RCUtils.validateConnectionParms(connectParams); } catch (RCException ex) { fail(ex.toString()); } }