UserUtility { public static List<Map<String, Object>> encryptUserAddressData( List<Map<String, Object>> addressList) throws Exception { EncryptionService service = ServiceFactory.getEncryptionServiceInstance(null); for (Map<String, Object> map : addressList) { for (String key : addressKeyToEncrypt) { if (map.containsKey(key)) { map.put(key, service.encryptData((String) map.get(key))); } } } return addressList; } private  UserUtility(); static Map<String, Object> encryptUserData(Map<String, Object> userMap); @SuppressWarnings("unchecked") static Map<String, Object> encryptSpecificUserData(
      Map<String, Object> userMap, List<String> fieldsToEncrypt); static List<Map<String, Object>> encryptUserAddressData(
      List<Map<String, Object>> addressList); static Map<String, Object> decryptUserData(Map<String, Object> userMap); static Map<String, Object> decryptSpecificUserData(
      Map<String, Object> userMap, List<String> fieldsToDecrypt); static Map<String, Object> decryptUserDataFrmES(Map<String, Object> userMap); static List<Map<String, Object>> decryptUserAddressData(
      List<Map<String, Object>> addressList); static Map<String, Object> encryptUserSearchFilterQueryData(Map<String, Object> map); static String encryptData(String data); static String maskEmailOrPhone(String encryptedEmailOrPhone, String type);  }
@Test public void encryptUserAddressDataSuccess() { String city = "Bangalore"; String addressLine1 = "xyz"; String state = "Karnataka"; List<Map<String, Object>> addressList = new ArrayList<Map<String, Object>>(); Map<String, Object> address = new HashMap<String, Object>(); address.put(JsonKey.COUNTRY, "India"); address.put(JsonKey.CITY, city); address.put(JsonKey.ADDRESS_LINE1, addressLine1); address.put(JsonKey.STATE, state); addressList.add(address); List<Map<String, Object>> response = null; try { response = UserUtility.encryptUserAddressData(addressList); } catch (Exception e) { e.printStackTrace(); } assertNotEquals("India", response.get(0).get(JsonKey.COUNTRY)); assertNotEquals(addressLine1, response.get(0).get(JsonKey.ADDRESS_LINE1)); assertNotEquals(state, response.get(0).get(JsonKey.STATE)); }