Any ideas how I can test this one - only the DMLException and Exception parts
@future
public static void updateUserFlags(Set<Id> userIds ) {
Logger.log(ShGl_Constants.INFO, 'ShMa_AveretekOptInUser.updateUserFlags', 'Start user update', null);
// Create empty map for user updates
Map<Id, User> userUpdateMap = new Map<Id, User>();
// Iterate users for ids passed into future method
for (User u2 : [SELECT Id, ShMa_OptInAveretek__c,
Is_Integrated__c, Contact.ShMa_OptInAveretek__c FROM User WHERE Id in: userIds]) {
// Set user fields
User u3 = new User( Id = u2.Id, Is_Integrated__c = false,
ShMa_OptInAveretek__c = u2.Contact.ShMa_OptInAveretek__c);
userUpdateMap.put(u2.Id, u3); // add intsance of user to map
}
try {
if (userUpdateMap.size() > 0) {
update userUpdateMap.values(); // update user records in map
Logger.log(ShGl_Constants.INFO, 'ShMa_AveretekOptInUser.updateUserFlags', 'End user update', null);
}
}
// Start exception handing
catch (DmlException e) {
for (Integer i = 0; i < e.getNumDml(); i++) {
Logger.log(ShGl_Constants.ERROR, 'ShMa_AveretekOptInUser.updateUserFlags', e.getDmlMessage(i), e.getDmlId(i));
}
} catch (Exception e) {
Logger.log(ShGl_Constants.FATAL, 'ShMa_AveretekOptInUser.updateUserFlags', e.getMessage(), null);
}
}