This question is sort of a continuation to this question. I have this method:
public static void sendMail(List<Object> selectedRows) {
if (selectedRows.size() > 0) {
for (Object obj : selectedRows) {
Map<Object, Object> mapJson = (Map<Object, Object>)obj;
String title = (String)mapJson.get('title');
String link = (String)mapJson.get('link');
}
}
}
I wanted to mock selectedRows
list for testing. I did this:
List<Object> selectedRows = (List<Object>)JSON.deserializeUntyped('[{"title":"Title1","link":"https://www.google.com"}]');
based on the answer. Also, I converted Map<Object, Object>
to Map<String, Object>
based on the suggestion in the answer. But, after that when I run the code, i am getting this error: Invalid conversion from runtime type Map<ANY,ANY> to Map<String,ANY>
. So, I changed it back to Map<Object, Object>
. Then, the test code throws this error: Invalid conversion from runtime type Map<String,ANY> to Map<ANY,ANY>
.
So, the current situation is either the code works or the test works, but not both. How can I solve this issue?