I have a class with the code below that I am trying to test. I am still very new to Apex and not sure I understand what I am supposed to do with the "(Object data)" part. I tried testing by inserting a new user as "usr" and then calling
String res = UserSearch.updateUser(usr);
But then I got a malformed JSON error message - "System.JSONException: Malformed JSON: Expected '[' at the beginning of List/Set".
How do I test this?
public inherited sharing class UserSearch {
@AuraEnabled
public static string updateUser(Object data){
system.debug(data);
List<User> v1 = (List<User>) JSON.deserialize(
JSON.serialize(data),
List<User>.class
);
List<User> userForUpdate = v1;
try{
update userForUpdate;
return 'Success: Users Updated Successfully';
}
catch(Exception e){
//return 'The Following exceptions have occured:' +e.getMessage();
throw new AuraHandledException(e.getMessage());
}
}
}