### Question:
StripeNetworkUtils { @SuppressWarnings("unchecked") public static void removeNullAndEmptyParams(@NonNull Map<String, Object> mapToEdit) { for (String key : new HashSet<>(mapToEdit.keySet())) { if (mapToEdit.get(key) == null) { mapToEdit.remove(key); } if (mapToEdit.get(key) instanceof CharSequence) { CharSequence sequence = (CharSequence) mapToEdit.get(key); if (TextUtils.isEmpty(sequence)) { mapToEdit.remove(key); } } if (mapToEdit.get(key) instanceof Map) { Map<String, Object> stringObjectMap = (Map<String, Object>) mapToEdit.get(key); removeNullAndEmptyParams(stringObjectMap); } } }  @SuppressWarnings("unchecked") static void removeNullAndEmptyParams(@NonNull Map<String, Object> mapToEdit);  }### Answer:
@Test public void removeNullAndEmptyParams_removesNullParams() { Map<String, Object> testMap = new HashMap<>(); testMap.put("a", null); testMap.put("b", "not null"); StripeNetworkUtils.removeNullAndEmptyParams(testMap); assertEquals(1, testMap.size()); assertTrue(testMap.containsKey("b")); }
@Test public void removeNullAndEmptyParams_removesEmptyStringParams() { Map<String, Object> testMap = new HashMap<>(); testMap.put("a", "fun param"); testMap.put("b", "not null"); testMap.put("c", ""); StripeNetworkUtils.removeNullAndEmptyParams(testMap); assertEquals(2, testMap.size()); assertTrue(testMap.containsKey("a")); assertTrue(testMap.containsKey("b")); }
@Test public void removeNullAndEmptyParams_removesNestedEmptyParams() { Map<String, Object> testMap = new HashMap<>(); Map<String, Object> firstNestedMap = new HashMap<>(); Map<String, Object> secondNestedMap = new HashMap<>(); testMap.put("a", "fun param"); testMap.put("b", "not null"); firstNestedMap.put("1a", "something"); firstNestedMap.put("1b", null); secondNestedMap.put("2a", ""); secondNestedMap.put("2b", "hello world"); firstNestedMap.put("1c", secondNestedMap); testMap.put("c", firstNestedMap); StripeNetworkUtils.removeNullAndEmptyParams(testMap); assertEquals(3, testMap.size()); assertTrue(testMap.containsKey("a")); assertTrue(testMap.containsKey("b")); assertTrue(testMap.containsKey("c")); assertEquals(2, firstNestedMap.size()); assertTrue(firstNestedMap.containsKey("1a")); assertTrue(firstNestedMap.containsKey("1c")); assertEquals(1, secondNestedMap.size()); assertTrue(secondNestedMap.containsKey("2b")); }