function readOnly(count){ }
Don't have an account?
Search for an answer or ask a question of the zone or Customer Support.
You need to sign in to do that
Sign in to start searching questions
Signup for a Developer Edition
Sign in to start a discussion
@IsTest public with sharing class batchmirftest { static testMethod void test1(){ List<Interaction_Settings__c>iSttgsList = [select Number_of_sections__c,Display_Attendees_Type__c, Display_Attendees__c,Default_Page_Layout__c, Use_Default_Page_Layout__c, Full_Access__c,Functional_Area_Full_World_Header__c,Functional_Area_Full_World_Restricted__c, Functional_Area_Header_World_Restrict__c from Interaction_Settings__c limit 1]; Category__c categoryAssociated = new Category__c(Name = 'Interaction', API_Name__c = Utils.getNameSpace()+'Interaction__c'); insert categoryAssociated; Page_Layout__c pageLayouts = new Page_Layout__c(Name = 'Interaction', Category__c = categoryAssociated.Id, Record_Type_Name__c = 'Normal'); insert pageLayouts; Interaction_Settings__c isttgs=new Interaction_Settings__c(); isttgs.Name='Interaction_Settings'; isttgs.Full_Access__c=true; isttgs.Display_Attendees_Type__c = true; isttgs.Display_Attendees__c = true; isttgs.Default_Page_Layout__c = pageLayouts.id; isttgs.Use_Default_Page_Layout__c = true; isttgs.Number_Of_Sections__c = 2; insert isttgs; Profile p = [SELECT Id FROM Profile WHERE Name='Standard User']; User u2; List<User> usl = new List<User>(); for(Integer i = 0; i <40;i++){ u2 = new User(Alias = 'newUser' , Email= i+'@openqtestorg.com' ,EmailEncodingKey='UTF-8', LastName='Testing '+ i , LanguageLocaleKey='en_US', LocaleSidKey='en_US', ProfileId = p.Id, TimeZoneSidKey='America/Los_Angeles', UserName= i +'@openqtestorg.com'); u2.Group_Type__c = null; u2.Functional_Area__c =( Math.mod(i, 2) == 0)?'Med InfoS':'MLSs'; usl.add(u2); } Test.startTest(); User curr = [select id from User where id = :UserInfo.getUserId() limit 1]; System.runAs(curr){ insert usl; } batchmirftest.changeSettingsFullRestricted(iSttgsList); EnvironmentClass_TestMethods ect= new EnvironmentClass_TestMethods(); List<Interaction__c> intList = new List<Interaction__c>(); intList.add(ect.createInteraction()); intList.add(ect.createInteraction()); insert intList; System.runAs(u2) { system.assert([select id from Interaction__c].size()==0); } batchmirftest.changeSettingsFullAccess(iSttgsList); ScheduleInteractionBatch sm = new ScheduleInteractionBatch(false); Test.stopTest(); System.runAs(u2) { system.assert([select id from Group where Type = 'Organization'].size()>0); system.assert([select id from Interaction__c].size()>0); } } public static void changeSettingsFullRestricted(List<Interaction_Settings__c> iSttgsList){ Interaction_Settings__c iSttgs; if(!iSttgsList.isEmpty()){ iSttgs = iSttgsList.get(0); iSttgs.Functional_Area_Full_World_Restricted__c = true; iSttgs.Full_Access__c = false; upsert iSttgs; } } public static void changeSettingsFullAccess(List<Interaction_Settings__c>iSttgsList){ Interaction_Settings__c iSttgs; if(!iSttgsList.isEmpty()){ iSttgs = iSttgsList.get(0); iSttgs.Functional_Area_Full_World_Restricted__c = false; iSttgs.Full_Access__c = true; upsert iSttgs; } } public static void changeSettingsDoNotUseVisibilityScope(List<Interaction_Settings__c>iSttgsList){ Interaction_Settings__c iSttgs; if(!iSttgsList.isEmpty()){ iSttgs = iSttgsList.get(0); iSttgs.Full_Access__c = false; iSttgs.Functional_Area_Full_World_Restricted__c = false; iSttgs.Do_Not_Use_Visibility_Scope__c = true; upsert iSttgs; } } }
@IsTest public with sharing class batchmirftest { static testMethod void test1(){ List<Interaction_Settings__c>iSttgsList = [select Number_of_sections__c,Display_Attendees_Type__c, Display_Attendees__c,Default_Page_Layout__c, Use_Default_Page_Layout__c, Full_Access__c,Functional_Area_Full_World_Header__c,Functional_Area_Full_World_Restricted__c, Functional_Area_Header_World_Restrict__c from Interaction_Settings__c limit 1]; Category__c categoryAssociated = new Category__c(Name = 'Interaction', API_Name__c = Utils.getNameSpace()+'Interaction__c'); insert categoryAssociated; Page_Layout__c pageLayouts = new Page_Layout__c(Name = 'Interaction', Category__c = categoryAssociated.Id, Record_Type_Name__c = 'Normal'); insert pageLayouts; Interaction_Settings__c isttgs=new Interaction_Settings__c(); isttgs.Name='Interaction_Settings'; isttgs.Full_Access__c=true; isttgs.Display_Attendees_Type__c = true; isttgs.Display_Attendees__c = true; isttgs.Default_Page_Layout__c = pageLayouts.id; isttgs.Use_Default_Page_Layout__c = true; isttgs.Number_Of_Sections__c = 2; insert isttgs; Profile p = [SELECT Id FROM Profile WHERE Name='Standard User']; User u2; List<User> usl = new List<User>(); for(Integer i = 0; i <40;i++){ u2 = new User(Alias = 'newUser' , Email= i+'@openqtestorg.com' ,EmailEncodingKey='UTF-8', LastName='Testing '+ i , LanguageLocaleKey='en_US', LocaleSidKey='en_US', ProfileId = p.Id, TimeZoneSidKey='America/Los_Angeles', UserName= i +'@openqtestorg.com'); u2.Group_Type__c = null; u2.Functional_Area__c =( Math.mod(i, 2) == 0)?'Med InfoS':'MLSs'; usl.add(u2); } Test.startTest(); User curr = [select id from User where id = :UserInfo.getUserId() limit 1]; System.runAs(curr){ insert usl; } batchmirftest.changeSettingsFullRestricted(iSttgsList); EnvironmentClass_TestMethods ect= new EnvironmentClass_TestMethods(); List<Interaction__c> intList = new List<Interaction__c>(); intList.add(ect.createInteraction()); intList.add(ect.createInteraction()); insert intList; System.runAs(u2) { system.assert([select id from Interaction__c].size()==1); } batchmirftest.changeSettingsFullAccess(iSttgsList); ScheduleInteractionBatch sm = new ScheduleInteractionBatch(false); Test.stopTest(); System.runAs(u2) { system.assert([select id from Group where Type = 'Organization'].size()>0); system.assert([select id from Interaction__c].size()>0); } } public static void changeSettingsFullRestricted(List<Interaction_Settings__c> iSttgsList){ Interaction_Settings__c iSttgs; if(!iSttgsList.isEmpty()){ iSttgs = iSttgsList.get(0); iSttgs.Functional_Area_Full_World_Restricted__c = true; iSttgs.Full_Access__c = false; upsert iSttgs; } } public static void changeSettingsFullAccess(List<Interaction_Settings__c>iSttgsList){ Interaction_Settings__c iSttgs; if(!iSttgsList.isEmpty()){ iSttgs = iSttgsList.get(0); iSttgs.Functional_Area_Full_World_Restricted__c = false; iSttgs.Full_Access__c = true; upsert iSttgs; } } public static void changeSettingsDoNotUseVisibilityScope(List<Interaction_Settings__c>iSttgsList){ Interaction_Settings__c iSttgs; if(!iSttgsList.isEmpty()){ iSttgs = iSttgsList.get(0); iSttgs.Full_Access__c = false; iSttgs.Functional_Area_Full_World_Restricted__c = false; iSttgs.Do_Not_Use_Visibility_Scope__c = true; upsert iSttgs; } } }
All Answers