RCUtils { @SuppressWarnings("unchecked") public static void validateSettingsParms(HashMap<String, Object> parameters) throws RCException { validatePushSettings(parameters); if (!parameters.containsKey(RCDevice.ParameterKeys.SIGNALING_USERNAME) || parameters.get(RCDevice.ParameterKeys.SIGNALING_USERNAME).equals("")) { throw new RCException(RCClient.ErrorCodes.ERROR_DEVICE_MISSING_USERNAME); } if (!parameters.containsKey(RCDevice.ParameterKeys.MEDIA_ICE_SERVERS_DISCOVERY_TYPE)) { parameters.put(RCDevice.ParameterKeys.MEDIA_ICE_SERVERS_DISCOVERY_TYPE, RCDevice.MediaIceServersDiscoveryType.ICE_SERVERS_CONFIGURATION_URL_XIRSYS_V2); } else { RCDevice.MediaIceServersDiscoveryType iceServersDiscoveryType; if (parameters.get(RCDevice.ParameterKeys.MEDIA_ICE_SERVERS_DISCOVERY_TYPE) instanceof Enum){ iceServersDiscoveryType = (RCDevice.MediaIceServersDiscoveryType)parameters.get(RCDevice.ParameterKeys.MEDIA_ICE_SERVERS_DISCOVERY_TYPE); } else { int discoveryType = (int)parameters.get(RCDevice.ParameterKeys.MEDIA_ICE_SERVERS_DISCOVERY_TYPE); if (discoveryType >= RCDevice.MediaIceServersDiscoveryType.values().length || discoveryType < 0){ throw new RCException(RCClient.ErrorCodes.ERROR_DEVICE_INVALID_ICE_SERVER_DISCOVERY_TYPE); }else { iceServersDiscoveryType = RCDevice.MediaIceServersDiscoveryType.values()[discoveryType]; } } if (iceServersDiscoveryType == RCDevice.MediaIceServersDiscoveryType.ICE_SERVERS_CUSTOM) { if (!parameters.containsKey(RCDevice.ParameterKeys.MEDIA_ICE_SERVERS) || parameters.get(RCDevice.ParameterKeys.MEDIA_ICE_SERVERS) == null || ((List<Map<String,String>>) parameters.get(RCDevice.ParameterKeys.MEDIA_ICE_SERVERS)).size() == 0) { throw new RCException(RCClient.ErrorCodes.ERROR_DEVICE_INVALID_CUSTOM_DISCOVERY_NO_ICE_SERVERS); } List<Map<String, String>> iceServers = (List<Map<String, String>>)parameters.get(RCDevice.ParameterKeys.MEDIA_ICE_SERVERS); for (Map<String, String> iceServer : iceServers) { if (!iceServer.containsKey(RCConnection.IceServersKeys.ICE_SERVER_URL) || iceServer.get(RCConnection.IceServersKeys.ICE_SERVER_URL).equals("")) { throw new RCException(RCClient.ErrorCodes.ERROR_DEVICE_INVALID_CUSTOM_DISCOVERY); } } if (parameters.containsKey(RCDevice.ParameterKeys.MEDIA_ICE_URL) || parameters.containsKey(RCDevice.ParameterKeys.MEDIA_ICE_USERNAME) || parameters.containsKey(RCDevice.ParameterKeys.MEDIA_ICE_PASSWORD) || parameters.containsKey(RCDevice.ParameterKeys.MEDIA_ICE_DOMAIN)) { throw new RCException(RCClient.ErrorCodes.ERROR_DEVICE_INVALID_CUSTOM_DISCOVERY); } } else { if (parameters.containsKey(RCDevice.ParameterKeys.MEDIA_ICE_SERVERS)) { throw new RCException(RCClient.ErrorCodes.ERROR_DEVICE_INVALID_ICE_SERVERS_NOT_CUSTOM_DISCOVERY); } if (!parameters.containsKey(RCDevice.ParameterKeys.MEDIA_ICE_URL) || parameters.get(RCDevice.ParameterKeys.MEDIA_ICE_URL).equals("")) { throw new RCException(RCClient.ErrorCodes.ERROR_DEVICE_MISSING_ICE_URL); } if (!parameters.containsKey(RCDevice.ParameterKeys.MEDIA_ICE_USERNAME) || parameters.get(RCDevice.ParameterKeys.MEDIA_ICE_USERNAME).equals("")) { throw new RCException(RCClient.ErrorCodes.ERROR_DEVICE_MISSING_ICE_USERNAME); } if (!parameters.containsKey(RCDevice.ParameterKeys.MEDIA_ICE_PASSWORD) || parameters.get(RCDevice.ParameterKeys.MEDIA_ICE_PASSWORD).equals("")) { throw new RCException(RCClient.ErrorCodes.ERROR_DEVICE_MISSING_ICE_PASSWORD); } if (!parameters.containsKey(RCDevice.ParameterKeys.MEDIA_ICE_DOMAIN) || parameters.get(RCDevice.ParameterKeys.MEDIA_ICE_DOMAIN).equals("")) { throw new RCException(RCClient.ErrorCodes.ERROR_DEVICE_MISSING_ICE_DOMAIN); } } } }  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 validatePushParams_Invalid() { HashMap<String, Object> settingParams = new HashMap<String, Object>(); try { RCUtils.validateSettingsParms(settingParams); } catch (RCException ex) { assertThat(ex.errorCode).isEqualTo(RCClient.ErrorCodes.ERROR_DEVICE_MISSING_USERNAME); } try { settingParams = new HashMap<String, Object>(); settingParams.put(RCDevice.ParameterKeys.PUSH_NOTIFICATIONS_ENABLE_PUSH_FOR_ACCOUNT, true); RCUtils.validateSettingsParms(settingParams); } catch (RCException ex) { assertThat(ex.errorCode).isEqualTo(RCClient.ErrorCodes.ERROR_DEVICE_PUSH_NOTIFICATION_FCM_SERVER_KEY_MISSING); } try { settingParams = new HashMap<String, Object>(); settingParams.put(RCDevice.ParameterKeys.PUSH_NOTIFICATIONS_ENABLE_PUSH_FOR_ACCOUNT, true); settingParams.put(RCDevice.ParameterKeys.PUSH_NOTIFICATIONS_FCM_SERVER_KEY, null); RCUtils.validateSettingsParms(settingParams); } catch (RCException ex) { assertThat(ex.errorCode).isEqualTo(RCClient.ErrorCodes.ERROR_DEVICE_PUSH_NOTIFICATION_FCM_SERVER_KEY_MISSING); } try { settingParams = new HashMap<String, Object>(); settingParams.put(RCDevice.ParameterKeys.PUSH_NOTIFICATIONS_ENABLE_PUSH_FOR_ACCOUNT, true); settingParams.put(RCDevice.ParameterKeys.PUSH_NOTIFICATIONS_FCM_SERVER_KEY, ""); RCUtils.validateSettingsParms(settingParams); } catch (RCException ex) { assertThat(ex.errorCode).isEqualTo(RCClient.ErrorCodes.ERROR_DEVICE_PUSH_NOTIFICATION_FCM_SERVER_KEY_MISSING); } try { settingParams = new HashMap<String, Object>(); settingParams.put(RCDevice.ParameterKeys.PUSH_NOTIFICATIONS_ENABLE_PUSH_FOR_ACCOUNT, true); settingParams.put(RCDevice.ParameterKeys.PUSH_NOTIFICATIONS_FCM_SERVER_KEY, "restcomm"); RCUtils.validateSettingsParms(settingParams); } catch (RCException ex) { assertThat(ex.errorCode).isEqualTo(RCClient.ErrorCodes.ERROR_DEVICE_PUSH_NOTIFICATION_APPLICATION_NAME_MISSING); } try { settingParams = new HashMap<String, Object>(); settingParams.put(RCDevice.ParameterKeys.PUSH_NOTIFICATIONS_ENABLE_PUSH_FOR_ACCOUNT, true); settingParams.put(RCDevice.ParameterKeys.PUSH_NOTIFICATIONS_FCM_SERVER_KEY, "restcomm"); settingParams.put(RCDevice.ParameterKeys.PUSH_NOTIFICATIONS_APPLICATION_NAME, null); RCUtils.validateSettingsParms(settingParams); } catch (RCException ex) { assertThat(ex.errorCode).isEqualTo(RCClient.ErrorCodes.ERROR_DEVICE_PUSH_NOTIFICATION_APPLICATION_NAME_MISSING); } try { settingParams = new HashMap<String, Object>(); settingParams.put(RCDevice.ParameterKeys.PUSH_NOTIFICATIONS_ENABLE_PUSH_FOR_ACCOUNT, true); settingParams.put(RCDevice.ParameterKeys.PUSH_NOTIFICATIONS_FCM_SERVER_KEY, "restcomm"); settingParams.put(RCDevice.ParameterKeys.PUSH_NOTIFICATIONS_APPLICATION_NAME, ""); RCUtils.validateSettingsParms(settingParams); } catch (RCException ex) { assertThat(ex.errorCode).isEqualTo(RCClient.ErrorCodes.ERROR_DEVICE_PUSH_NOTIFICATION_APPLICATION_NAME_MISSING); } try { settingParams = new HashMap<String, Object>(); settingParams.put(RCDevice.ParameterKeys.PUSH_NOTIFICATIONS_ENABLE_PUSH_FOR_ACCOUNT, true); settingParams.put(RCDevice.ParameterKeys.PUSH_NOTIFICATIONS_FCM_SERVER_KEY, "restcomm"); settingParams.put(RCDevice.ParameterKeys.PUSH_NOTIFICATIONS_APPLICATION_NAME, "test app"); RCUtils.validateSettingsParms(settingParams); } catch (RCException ex) { assertThat(ex.errorCode).isEqualTo(RCClient.ErrorCodes.ERROR_DEVICE_PUSH_NOTIFICATION_ACCOUNT_EMAIL_MISSING); } try { settingParams = new HashMap<String, Object>(); settingParams.put(RCDevice.ParameterKeys.PUSH_NOTIFICATIONS_ENABLE_PUSH_FOR_ACCOUNT, true); settingParams.put(RCDevice.ParameterKeys.PUSH_NOTIFICATIONS_FCM_SERVER_KEY, "restcomm"); settingParams.put(RCDevice.ParameterKeys.PUSH_NOTIFICATIONS_APPLICATION_NAME, "test app"); settingParams.put(RCDevice.ParameterKeys.PUSH_NOTIFICATIONS_ACCOUNT_EMAIL, null); RCUtils.validateSettingsParms(settingParams); } catch (RCException ex) { assertThat(ex.errorCode).isEqualTo(RCClient.ErrorCodes.ERROR_DEVICE_PUSH_NOTIFICATION_ACCOUNT_EMAIL_MISSING); } try { settingParams = new HashMap<String, Object>(); settingParams.put(RCDevice.ParameterKeys.PUSH_NOTIFICATIONS_ENABLE_PUSH_FOR_ACCOUNT, true); settingParams.put(RCDevice.ParameterKeys.PUSH_NOTIFICATIONS_FCM_SERVER_KEY, "restcomm"); settingParams.put(RCDevice.ParameterKeys.PUSH_NOTIFICATIONS_APPLICATION_NAME, "test app"); settingParams.put(RCDevice.ParameterKeys.PUSH_NOTIFICATIONS_ACCOUNT_EMAIL, ""); RCUtils.validateSettingsParms(settingParams); } catch (RCException ex) { assertThat(ex.errorCode).isEqualTo(RCClient.ErrorCodes.ERROR_DEVICE_PUSH_NOTIFICATION_ACCOUNT_EMAIL_MISSING); } try { settingParams = new HashMap<String, Object>(); settingParams.put(RCDevice.ParameterKeys.PUSH_NOTIFICATIONS_ENABLE_PUSH_FOR_ACCOUNT, true); settingParams.put(RCDevice.ParameterKeys.PUSH_NOTIFICATIONS_FCM_SERVER_KEY, "restcomm"); settingParams.put(RCDevice.ParameterKeys.PUSH_NOTIFICATIONS_APPLICATION_NAME, "test app"); settingParams.put(RCDevice.ParameterKeys.PUSH_NOTIFICATIONS_ACCOUNT_EMAIL, "test@test.com"); RCUtils.validateSettingsParms(settingParams); } catch (RCException ex) { assertThat(ex.errorCode).isEqualTo(RCClient.ErrorCodes.ERROR_DEVICE_PUSH_NOTIFICATION_ACCOUNT_PASSWORD_MISSING); } try { settingParams = new HashMap<String, Object>(); settingParams.put(RCDevice.ParameterKeys.PUSH_NOTIFICATIONS_ENABLE_PUSH_FOR_ACCOUNT, true); settingParams.put(RCDevice.ParameterKeys.PUSH_NOTIFICATIONS_FCM_SERVER_KEY, "restcomm"); settingParams.put(RCDevice.ParameterKeys.PUSH_NOTIFICATIONS_APPLICATION_NAME, "test app"); settingParams.put(RCDevice.ParameterKeys.PUSH_NOTIFICATIONS_ACCOUNT_EMAIL, "test@test.com"); settingParams.put(RCDevice.ParameterKeys.PUSH_NOTIFICATIONS_ACCOUNT_PASSWORD, null); RCUtils.validateSettingsParms(settingParams); } catch (RCException ex) { assertThat(ex.errorCode).isEqualTo(RCClient.ErrorCodes.ERROR_DEVICE_PUSH_NOTIFICATION_ACCOUNT_PASSWORD_MISSING); } try { settingParams = new HashMap<String, Object>(); settingParams.put(RCDevice.ParameterKeys.PUSH_NOTIFICATIONS_ENABLE_PUSH_FOR_ACCOUNT, true); settingParams.put(RCDevice.ParameterKeys.PUSH_NOTIFICATIONS_FCM_SERVER_KEY, "restcomm"); settingParams.put(RCDevice.ParameterKeys.PUSH_NOTIFICATIONS_APPLICATION_NAME, "test app"); settingParams.put(RCDevice.ParameterKeys.PUSH_NOTIFICATIONS_ACCOUNT_EMAIL, "test@test.com"); settingParams.put(RCDevice.ParameterKeys.PUSH_NOTIFICATIONS_ACCOUNT_PASSWORD, ""); RCUtils.validateSettingsParms(settingParams); } catch (RCException ex) { assertThat(ex.errorCode).isEqualTo(RCClient.ErrorCodes.ERROR_DEVICE_PUSH_NOTIFICATION_ACCOUNT_PASSWORD_MISSING); } try { settingParams = new HashMap<String, Object>(); settingParams.put(RCDevice.ParameterKeys.PUSH_NOTIFICATIONS_ENABLE_PUSH_FOR_ACCOUNT, true); settingParams.put(RCDevice.ParameterKeys.PUSH_NOTIFICATIONS_FCM_SERVER_KEY, "restcomm"); settingParams.put(RCDevice.ParameterKeys.PUSH_NOTIFICATIONS_APPLICATION_NAME, "test app"); settingParams.put(RCDevice.ParameterKeys.PUSH_NOTIFICATIONS_ACCOUNT_EMAIL, "test@test.com"); settingParams.put(RCDevice.ParameterKeys.PUSH_NOTIFICATIONS_ACCOUNT_PASSWORD, "pass"); RCUtils.validateSettingsParms(settingParams); } catch (RCException ex) { assertThat(ex.errorCode).isEqualTo(RCClient.ErrorCodes.ERROR_DEVICE_PUSH_NOTIFICATION_PUSH_DOMAIN_MISSING); } try { settingParams = new HashMap<String, Object>(); settingParams.put(RCDevice.ParameterKeys.PUSH_NOTIFICATIONS_ENABLE_PUSH_FOR_ACCOUNT, true); settingParams.put(RCDevice.ParameterKeys.PUSH_NOTIFICATIONS_FCM_SERVER_KEY, "restcomm"); settingParams.put(RCDevice.ParameterKeys.PUSH_NOTIFICATIONS_APPLICATION_NAME, "test app"); settingParams.put(RCDevice.ParameterKeys.PUSH_NOTIFICATIONS_ACCOUNT_EMAIL, "test@test.com"); settingParams.put(RCDevice.ParameterKeys.PUSH_NOTIFICATIONS_ACCOUNT_PASSWORD, "pass"); settingParams.put(RCDevice.ParameterKeys.PUSH_NOTIFICATIONS_PUSH_DOMAIN, null); RCUtils.validateSettingsParms(settingParams); } catch (RCException ex) { assertThat(ex.errorCode).isEqualTo(RCClient.ErrorCodes.ERROR_DEVICE_PUSH_NOTIFICATION_PUSH_DOMAIN_MISSING); } try { settingParams = new HashMap<String, Object>(); settingParams.put(RCDevice.ParameterKeys.PUSH_NOTIFICATIONS_ENABLE_PUSH_FOR_ACCOUNT, true); settingParams.put(RCDevice.ParameterKeys.PUSH_NOTIFICATIONS_FCM_SERVER_KEY, "restcomm"); settingParams.put(RCDevice.ParameterKeys.PUSH_NOTIFICATIONS_APPLICATION_NAME, "test app"); settingParams.put(RCDevice.ParameterKeys.PUSH_NOTIFICATIONS_ACCOUNT_EMAIL, "test@test.com"); settingParams.put(RCDevice.ParameterKeys.PUSH_NOTIFICATIONS_ACCOUNT_PASSWORD, "pass"); settingParams.put(RCDevice.ParameterKeys.PUSH_NOTIFICATIONS_PUSH_DOMAIN, ""); RCUtils.validateSettingsParms(settingParams); } catch (RCException ex) { assertThat(ex.errorCode).isEqualTo(RCClient.ErrorCodes.ERROR_DEVICE_PUSH_NOTIFICATION_PUSH_DOMAIN_MISSING); } try { settingParams = new HashMap<String, Object>(); settingParams.put(RCDevice.ParameterKeys.PUSH_NOTIFICATIONS_ENABLE_PUSH_FOR_ACCOUNT, true); settingParams.put(RCDevice.ParameterKeys.PUSH_NOTIFICATIONS_FCM_SERVER_KEY, "restcomm"); settingParams.put(RCDevice.ParameterKeys.PUSH_NOTIFICATIONS_APPLICATION_NAME, "test app"); settingParams.put(RCDevice.ParameterKeys.PUSH_NOTIFICATIONS_ACCOUNT_EMAIL, "test@test.com"); settingParams.put(RCDevice.ParameterKeys.PUSH_NOTIFICATIONS_ACCOUNT_PASSWORD, "pass"); settingParams.put(RCDevice.ParameterKeys.PUSH_NOTIFICATIONS_PUSH_DOMAIN, "pushdomain"); RCUtils.validateSettingsParms(settingParams); } catch (RCException ex) { assertThat(ex.errorCode).isEqualTo(RCClient.ErrorCodes.ERROR_DEVICE_PUSH_NOTIFICATION_RESTCOMM_DOMAIN_MISSING); } try { settingParams = new HashMap<String, Object>(); settingParams.put(RCDevice.ParameterKeys.PUSH_NOTIFICATIONS_ENABLE_PUSH_FOR_ACCOUNT, true); settingParams.put(RCDevice.ParameterKeys.PUSH_NOTIFICATIONS_FCM_SERVER_KEY, "restcomm"); settingParams.put(RCDevice.ParameterKeys.PUSH_NOTIFICATIONS_APPLICATION_NAME, "test app"); settingParams.put(RCDevice.ParameterKeys.PUSH_NOTIFICATIONS_ACCOUNT_EMAIL, "test@test.com"); settingParams.put(RCDevice.ParameterKeys.PUSH_NOTIFICATIONS_ACCOUNT_PASSWORD, "pass"); settingParams.put(RCDevice.ParameterKeys.PUSH_NOTIFICATIONS_PUSH_DOMAIN, "pushdomain"); settingParams.put(RCDevice.ParameterKeys.PUSH_NOTIFICATIONS_HTTP_DOMAIN, null); RCUtils.validateSettingsParms(settingParams); } catch (RCException ex) { assertThat(ex.errorCode).isEqualTo(RCClient.ErrorCodes.ERROR_DEVICE_PUSH_NOTIFICATION_RESTCOMM_DOMAIN_MISSING); } try { settingParams = new HashMap<String, Object>(); settingParams.put(RCDevice.ParameterKeys.PUSH_NOTIFICATIONS_ENABLE_PUSH_FOR_ACCOUNT, true); settingParams.put(RCDevice.ParameterKeys.PUSH_NOTIFICATIONS_FCM_SERVER_KEY, "restcomm"); settingParams.put(RCDevice.ParameterKeys.PUSH_NOTIFICATIONS_APPLICATION_NAME, "test app"); settingParams.put(RCDevice.ParameterKeys.PUSH_NOTIFICATIONS_ACCOUNT_EMAIL, "test@test.com"); settingParams.put(RCDevice.ParameterKeys.PUSH_NOTIFICATIONS_ACCOUNT_PASSWORD, "pass"); settingParams.put(RCDevice.ParameterKeys.PUSH_NOTIFICATIONS_PUSH_DOMAIN, "pushdomain"); settingParams.put(RCDevice.ParameterKeys.PUSH_NOTIFICATIONS_HTTP_DOMAIN, ""); RCUtils.validateSettingsParms(settingParams); } catch (RCException ex) { assertThat(ex.errorCode).isEqualTo(RCClient.ErrorCodes.ERROR_DEVICE_PUSH_NOTIFICATION_RESTCOMM_DOMAIN_MISSING); } }
@Test public void validateSignalingParams_Invalid() { HashMap<String, Object> settingParams = new HashMap<String, Object>(); try { getFilledHashMapWithValidPush(settingParams); RCUtils.validateSettingsParms(settingParams); } catch (RCException ex) { assertThat(ex.errorCode).isEqualTo(RCClient.ErrorCodes.ERROR_DEVICE_MISSING_USERNAME); } try { settingParams = new HashMap<String, Object>(); settingParams = getFilledHashMapWithValidPush(settingParams); settingParams.put(RCDevice.ParameterKeys.SIGNALING_USERNAME, ""); RCUtils.validateSettingsParms(settingParams); } catch (RCException ex) { assertThat(ex.errorCode).isEqualTo(RCClient.ErrorCodes.ERROR_DEVICE_MISSING_USERNAME); } try { settingParams = new HashMap<String, Object>(); settingParams = getFilledHashMapWithValidPush(settingParams); settingParams.put(RCDevice.ParameterKeys.SIGNALING_USERNAME, "username"); settingParams.put(RCDevice.ParameterKeys.MEDIA_ICE_SERVERS_DISCOVERY_TYPE, 10); RCUtils.validateSettingsParms(settingParams); } catch (RCException ex) { assertThat(ex.errorCode).isEqualTo(RCClient.ErrorCodes.ERROR_DEVICE_INVALID_ICE_SERVER_DISCOVERY_TYPE); } try { settingParams = new HashMap<String, Object>(); settingParams = getFilledHashMapWithValidPush(settingParams); settingParams.put(RCDevice.ParameterKeys.SIGNALING_USERNAME, "username"); settingParams.put(RCDevice.ParameterKeys.MEDIA_ICE_SERVERS_DISCOVERY_TYPE, RCDevice.MediaIceServersDiscoveryType.ICE_SERVERS_CUSTOM); RCUtils.validateSettingsParms(settingParams); } catch (RCException ex) { assertThat(ex.errorCode).isEqualTo(RCClient.ErrorCodes.ERROR_DEVICE_INVALID_CUSTOM_DISCOVERY_NO_ICE_SERVERS); } try { settingParams = new HashMap<String, Object>(); settingParams = getFilledHashMapWithValidPush(settingParams); settingParams.put(RCDevice.ParameterKeys.SIGNALING_USERNAME, "username"); settingParams.put(RCDevice.ParameterKeys.MEDIA_ICE_SERVERS_DISCOVERY_TYPE, RCDevice.MediaIceServersDiscoveryType.ICE_SERVERS_CUSTOM); List<Map<String, String>> listMediaIceServers = new ArrayList<>(); settingParams.put(RCDevice.ParameterKeys.MEDIA_ICE_SERVERS, listMediaIceServers); RCUtils.validateSettingsParms(settingParams); } catch (RCException ex) { assertThat(ex.errorCode).isEqualTo(RCClient.ErrorCodes.ERROR_DEVICE_INVALID_CUSTOM_DISCOVERY_NO_ICE_SERVERS); } try { settingParams = new HashMap<String, Object>(); settingParams = getFilledHashMapWithValidPush(settingParams); settingParams.put(RCDevice.ParameterKeys.SIGNALING_USERNAME, "username"); settingParams.put(RCDevice.ParameterKeys.MEDIA_ICE_SERVERS_DISCOVERY_TYPE, RCDevice.MediaIceServersDiscoveryType.ICE_SERVERS_CUSTOM); List<Map<String, String>> listMediaIceServers = new ArrayList<>(); Map<String, String> value = new HashMap<>(); value.put("", ""); listMediaIceServers.add(value); settingParams.put(RCDevice.ParameterKeys.MEDIA_ICE_SERVERS, listMediaIceServers); RCUtils.validateSettingsParms(settingParams); } catch (RCException ex) { assertThat(ex.errorCode).isEqualTo(RCClient.ErrorCodes.ERROR_DEVICE_INVALID_CUSTOM_DISCOVERY); } try { settingParams = new HashMap<String, Object>(); settingParams = getFilledWithMediaParams(settingParams); settingParams.put(RCDevice.ParameterKeys.MEDIA_ICE_URL, "media_ice_url"); RCUtils.validateSettingsParms(settingParams); } catch (RCException ex) { assertThat(ex.errorCode).isEqualTo(RCClient.ErrorCodes.ERROR_DEVICE_INVALID_CUSTOM_DISCOVERY); } try { settingParams = new HashMap<String, Object>(); settingParams = getFilledWithMediaParams(settingParams); settingParams.put(RCDevice.ParameterKeys.MEDIA_ICE_USERNAME, "media_ice_username"); RCUtils.validateSettingsParms(settingParams); } catch (RCException ex) { assertThat(ex.errorCode).isEqualTo(RCClient.ErrorCodes.ERROR_DEVICE_INVALID_CUSTOM_DISCOVERY); } try { settingParams = new HashMap<String, Object>(); settingParams = getFilledWithMediaParams(settingParams); settingParams.put(RCDevice.ParameterKeys.MEDIA_ICE_PASSWORD, "media_ice_password"); RCUtils.validateSettingsParms(settingParams); } catch (RCException ex) { assertThat(ex.errorCode).isEqualTo(RCClient.ErrorCodes.ERROR_DEVICE_INVALID_CUSTOM_DISCOVERY); } try { settingParams = new HashMap<String, Object>(); settingParams = getFilledWithMediaParams(settingParams); settingParams.put(RCDevice.ParameterKeys.MEDIA_ICE_DOMAIN, "media_ice_domain"); RCUtils.validateSettingsParms(settingParams); } catch (RCException ex) { assertThat(ex.errorCode).isEqualTo(RCClient.ErrorCodes.ERROR_DEVICE_INVALID_CUSTOM_DISCOVERY); } try { settingParams = new HashMap<String, Object>(); getFilledHashMapWithValidPush(settingParams); settingParams.put(RCDevice.ParameterKeys.SIGNALING_USERNAME, "username"); List<Map<String, String>> listMediaIceServers = new ArrayList<>(); settingParams.put(RCDevice.ParameterKeys.MEDIA_ICE_SERVERS, listMediaIceServers); settingParams.put(RCDevice.ParameterKeys.MEDIA_ICE_SERVERS_DISCOVERY_TYPE, RCDevice.MediaIceServersDiscoveryType.ICE_SERVERS_CONFIGURATION_URL_XIRSYS_V3); RCUtils.validateSettingsParms(settingParams); } catch (RCException ex) { assertThat(ex.errorCode).isEqualTo(RCClient.ErrorCodes.ERROR_DEVICE_INVALID_ICE_SERVERS_NOT_CUSTOM_DISCOVERY); } try { settingParams = new HashMap<String, Object>(); settingParams = getFilledHashMapWithValidPush(settingParams); settingParams.put(RCDevice.ParameterKeys.SIGNALING_USERNAME, "username"); settingParams.put(RCDevice.ParameterKeys.MEDIA_ICE_SERVERS_DISCOVERY_TYPE, RCDevice.MediaIceServersDiscoveryType.ICE_SERVERS_CONFIGURATION_URL_XIRSYS_V3); RCUtils.validateSettingsParms(settingParams); } catch (RCException ex) { assertThat(ex.errorCode).isEqualTo(RCClient.ErrorCodes.ERROR_DEVICE_MISSING_ICE_URL); } try { settingParams = new HashMap<String, Object>(); settingParams = getFilledHashMapWithValidPush(settingParams); settingParams.put(RCDevice.ParameterKeys.SIGNALING_USERNAME, "username"); settingParams.put(RCDevice.ParameterKeys.MEDIA_ICE_SERVERS_DISCOVERY_TYPE, RCDevice.MediaIceServersDiscoveryType.ICE_SERVERS_CONFIGURATION_URL_XIRSYS_V3); settingParams.put(RCDevice.ParameterKeys.MEDIA_ICE_URL, "media_ice_url"); RCUtils.validateSettingsParms(settingParams); } catch (RCException ex) { assertThat(ex.errorCode).isEqualTo(RCClient.ErrorCodes.ERROR_DEVICE_MISSING_ICE_USERNAME); } try { settingParams = new HashMap<String, Object>(); settingParams = getFilledHashMapWithValidPush(settingParams); settingParams.put(RCDevice.ParameterKeys.SIGNALING_USERNAME, "username"); settingParams.put(RCDevice.ParameterKeys.MEDIA_ICE_SERVERS_DISCOVERY_TYPE, RCDevice.MediaIceServersDiscoveryType.ICE_SERVERS_CONFIGURATION_URL_XIRSYS_V3); settingParams.put(RCDevice.ParameterKeys.MEDIA_ICE_URL, "media_ice_url"); settingParams.put(RCDevice.ParameterKeys.MEDIA_ICE_USERNAME, "media_ice_username"); RCUtils.validateSettingsParms(settingParams); } catch (RCException ex) { assertThat(ex.errorCode).isEqualTo(RCClient.ErrorCodes.ERROR_DEVICE_MISSING_ICE_PASSWORD); } try { settingParams = new HashMap<String, Object>(); settingParams = getFilledHashMapWithValidPush(settingParams); settingParams.put(RCDevice.ParameterKeys.SIGNALING_USERNAME, "username"); settingParams.put(RCDevice.ParameterKeys.MEDIA_ICE_SERVERS_DISCOVERY_TYPE, RCDevice.MediaIceServersDiscoveryType.ICE_SERVERS_CONFIGURATION_URL_XIRSYS_V3); settingParams.put(RCDevice.ParameterKeys.MEDIA_ICE_URL, "media_ice_url"); settingParams.put(RCDevice.ParameterKeys.MEDIA_ICE_USERNAME, "media_ice_username"); settingParams.put(RCDevice.ParameterKeys.MEDIA_ICE_PASSWORD, "media_ice_password"); RCUtils.validateSettingsParms(settingParams); } catch (RCException ex) { assertThat(ex.errorCode).isEqualTo(RCClient.ErrorCodes.ERROR_DEVICE_MISSING_ICE_DOMAIN); } }
@Test public void validateSignalingAndPushParams_Valid() { HashMap<String, Object> settingParams = new HashMap<String, Object>(); try { settingParams = getFilledHashMapWithValidPush(settingParams); getFilledWithMediaParams(settingParams); RCUtils.validateSettingsParms(settingParams); } catch (RCException ex) { fail(ex.toString()); } }