function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
stuart gaganstuart gagan 

AssertException:Assertion Failed

Class.openq.batchmirftest.test1: line 56, column 1
Best Answer chosen by stuart gagan
stuart gaganstuart gagan
Thank you Raj, issue is resolved, This is due to changed permission to the object .

All Answers

stuart gaganstuart gagan
@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;
		}
	}
    
}

 
Raj VakatiRaj Vakati
Try this code .. your set is one 
 
@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;
		}
	}
    
}

 
stuart gaganstuart gagan
Thank you Raj, issue is resolved, This is due to changed permission to the object .
This was selected as the best answer