### Question:
LQModel implements Serializable { public static HashMap<String, Object> sanitizeAttributes(Map<String, Object> attributes, boolean raiseException) { if (attributes == null) { return null; } HashMap<String, Object> attrs = new HashMap<String, Object>(); for (String key : attributes.keySet()) { if (LQModel.validKey(key, raiseException) && LQModel.validValue(attributes.get(key), raiseException)) { attrs.put(key, attributes.get(key)); } } return attrs; }  static String newIdentifier(); static boolean validKey(String key, boolean raiseException); static boolean validValue(Object attribute, boolean raiseException); static HashMap<String, Object> sanitizeAttributes(Map<String, Object> attributes, boolean raiseException); void save(Context context, String path); static JSONObject retriveFromFile(Context context, String path); static List<Object> toList(JSONArray array, String[] excludedKeys); abstract JSONObject toJSON();  }### Answer:
@Test public void testSanitizeAttributesBecauseOfValues() { HashMap<String, Object> attributes = new HashMap<String, Object>(); for(Object o : validAttributes) { if(o == null) { attributes.put("null", o); } else { attributes.put(o.hashCode()+"", o); } } for(Object o : invalidAttributes) { attributes.put(o.toString(), o); } attributes = LQModel.sanitizeAttributes(attributes, false); assertTrue("Number of attributes should be " + validAttributes.length +", but its " + attributes.size(), validAttributes.length == attributes.size()); }
@Test public void testSanitizeAttributesBecauseOfKeys() { HashMap<String, Object> attributes = new HashMap<String, Object>(); attributes.put(dollarkey, validAttributes[0]); attributes.put(validkey, validAttributes[2]); attributes.put(dotkey, validAttributes[3]); attributes.put(nullcharkey, validAttributes[4]); attributes = LQModel.sanitizeAttributes(attributes, false); assertTrue("Number of attributes should be 1, but its " + attributes.size(), 1 == attributes.size()); }