RCUtils { public static void validateDeviceParms(HashMap<String, Object> parameters) throws RCException { validateSettingsParms(parameters); if (!parameters.containsKey(RCDevice.ParameterKeys.INTENT_INCOMING_CALL)) { throw new RCException(RCClient.ErrorCodes.ERROR_DEVICE_MISSING_CALL_INTENT); } else { if (parameters.get(RCDevice.ParameterKeys.INTENT_INCOMING_CALL) instanceof String){ try { Intent.parseUri((String) parameters.get(RCDevice.ParameterKeys.INTENT_INCOMING_CALL), Intent.URI_INTENT_SCHEME); } catch (URISyntaxException e) { throw new RCException(RCClient.ErrorCodes.ERROR_DEVICE_MISSING_CALL_INTENT); } } } if (!parameters.containsKey(RCDevice.ParameterKeys.INTENT_INCOMING_MESSAGE)) { RCLogger.w(TAG, "validateDeviceParms(): Intent missing for incoming text messages, your App will work but won't be able to be notified on such event"); } }  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 validateDeviceParams_Invalid() { HashMap<String, Object> settingParams = new HashMap<String, Object>(); try { settingParams = getFilledHashMapWithValidPush(settingParams); getFilledWithMediaParams(settingParams); RCUtils.validateDeviceParms(settingParams); } catch (RCException ex) { assertThat(ex.errorCode).isEqualTo(RCClient.ErrorCodes.ERROR_DEVICE_MISSING_CALL_INTENT); } try { settingParams = getFilledHashMapWithValidPush(settingParams); getFilledWithMediaParams(settingParams); settingParams.put(RCDevice.ParameterKeys.INTENT_INCOMING_CALL, "intent"); RCUtils.validateDeviceParms(settingParams); } catch (RCException ex) { assertThat(ex.errorCode).isEqualTo(RCClient.ErrorCodes.ERROR_DEVICE_MISSING_CALL_INTENT); } }
@Test public void validateDeviceParams_Valid() { HashMap<String, Object> settingParams = new HashMap<String, Object>(); try { settingParams = getFilledHashMapWithValidPush(settingParams); getFilledWithMediaParams(settingParams); settingParams.put(RCDevice.ParameterKeys.INTENT_INCOMING_CALL, new Intent()); RCUtils.validateDeviceParms(settingParams); } catch (RCException ex) { fail(ex.toString()); } }