Class Name :
public class FutureUserUpdate {
@future
public static void AcivateUsers(List <ID> newUs)
{
List <User> LstUsr=[select id,isActive,isPortalEnabled From User where id in:newUs ];
List <User> updatedUsers=new List<User>();
for (User oUsr: LstUsr )
{
USer u = new User(id=oUsr.id);
u.isActive = true;
updatedUsers.add(u);
}
system.debug('Updated User'+updatedUsers);
update updatedUsers;
}
@future
public static void DeActivateUsers(List <ID> newUs)
{
List <User> LstUsr=[select id,isActive,isPortalEnabled From User where id in:newUs ];
List <User> updatedUsers=new List<User>();
for (User oUsr: LstUsr )
{
USer u = new User(id=oUsr.id);
u.isActive = false;
updatedUsers.add(u);
}
system.debug('Updated User'+updatedUsers);
update updatedUsers;
}
}
==========================================================================
Test Class Name:
@isTest(Seealldata=true)
private class FutureUserUpdateTest{
static testMethod void testFutureUserSuccess(){
List<Id>UserId=new List<Id>();
Profile p = [SELECT Id FROM Profile WHERE Name='Standard User'];
User UserObj= new User(Alias = 'standt', Email='standarduser2323@testorg.com',
EmailEncodingKey='UTF-8', LastName='Testinguser23', LanguageLocaleKey='en_US',
LocaleSidKey='en_US', ProfileId = p.Id,
TimeZoneSidKey='America/Los_Angeles', UserName='standarduser2323@testorg.com',Default_Origin__c = 'SG');
Insert UserObj;
UserId.add(UserObj.id);
UserObj.LastName='Testing';
Update UserObj;
//AWACS_FutureUserUpdate FuUpdate=new AWACS_FutureUserUpdate();
AWACS_FutureUserUpdate.AcivateUsers(UserId);
AWACS_FutureUserUpdate.DeActivateUsers(UserId);
}
}
public class FutureUserUpdate {
@future
public static void AcivateUsers(List <ID> newUs)
{
List <User> LstUsr=[select id,isActive,isPortalEnabled From User where id in:newUs ];
List <User> updatedUsers=new List<User>();
for (User oUsr: LstUsr )
{
USer u = new User(id=oUsr.id);
u.isActive = true;
updatedUsers.add(u);
}
system.debug('Updated User'+updatedUsers);
update updatedUsers;
}
@future
public static void DeActivateUsers(List <ID> newUs)
{
List <User> LstUsr=[select id,isActive,isPortalEnabled From User where id in:newUs ];
List <User> updatedUsers=new List<User>();
for (User oUsr: LstUsr )
{
USer u = new User(id=oUsr.id);
u.isActive = false;
updatedUsers.add(u);
}
system.debug('Updated User'+updatedUsers);
update updatedUsers;
}
}
==========================================================================
Test Class Name:
@isTest(Seealldata=true)
private class FutureUserUpdateTest{
static testMethod void testFutureUserSuccess(){
List<Id>UserId=new List<Id>();
Profile p = [SELECT Id FROM Profile WHERE Name='Standard User'];
User UserObj= new User(Alias = 'standt', Email='standarduser2323@testorg.com',
EmailEncodingKey='UTF-8', LastName='Testinguser23', LanguageLocaleKey='en_US',
LocaleSidKey='en_US', ProfileId = p.Id,
TimeZoneSidKey='America/Los_Angeles', UserName='standarduser2323@testorg.com',Default_Origin__c = 'SG');
Insert UserObj;
UserId.add(UserObj.id);
UserObj.LastName='Testing';
Update UserObj;
//AWACS_FutureUserUpdate FuUpdate=new AWACS_FutureUserUpdate();
AWACS_FutureUserUpdate.AcivateUsers(UserId);
AWACS_FutureUserUpdate.DeActivateUsers(UserId);
}
}
No comments:
Post a Comment