UserUtility { public static Map<String, Object> encryptUserData(Map<String, Object> userMap) throws Exception { return encryptSpecificUserData(userMap, userKeyToEncrypt); } 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 encryptSpecificUserDataSuccess() { String email = "test@test.com"; String userName = "test_user"; String city = "Bangalore"; String addressLine1 = "xyz"; Map<String, Object> userMap = new HashMap<String, Object>(); userMap.put(JsonKey.FIRST_NAME, "test user"); userMap.put(JsonKey.EMAIL, email); userMap.put(JsonKey.USER_NAME, userName); 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); addressList.add(address); userMap.put(JsonKey.ADDRESS, addressList); Map<String, Object> response = null; try { response = UserUtility.encryptUserData(userMap); } catch (Exception e) { e.printStackTrace(); } assertEquals(userMap.get(JsonKey.FIRST_NAME), response.get(JsonKey.FIRST_NAME)); assertNotEquals(email, response.get(JsonKey.EMAIL)); assertNotEquals( "India", ((List<Map<String, Object>>) response.get(JsonKey.ADDRESS)).get(0).get(JsonKey.COUNTRY)); assertNotEquals( addressLine1, ((List<Map<String, Object>>) response.get(JsonKey.ADDRESS)) .get(0) .get(JsonKey.ADDRESS_LINE1)); }