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 

System.AssertException: Assertion Failed:

Hi I wrote an apex extension class to auto assign the record type looking at a parent record. However I'm getting Null value on assertion. Can someone please help me? I have been wrecking my brain and can't figure it out. 
//I'm inserting the parent - testJobObj
insert testJobObj; 
       ID jobId = testJobObj.Id;
       //System.currentPageReference().getParameters().put('retURL', jobId);
        Work_order__c order = new Work_Order__c(Job_Number__c =;
       insert order;
       ApexPages.StandardController sc = new ApexPages.standardController(order);
       WorkOrderRedirectExtension test = new WorkOrderRedirectExtension(sc);
       System.currentPageReference().getParameters().put('retURL','/'+ jobId);
       pageReference pr = test.redirect();

       System.assertEquals(system.currentPageReference().getParameters().get('RecordType'), '012Q00000000kxB' );


Then here's my apex extension method: 
public PageReference redirect(){
        Id parentId = ApexPages.currentPage().getParameters().get('retURL').substring(1,16);
        system.debug('This is the parent Id Im recieving' + parentId);
        String param = '';
		List<job__c> job = [select id, division__c from Job__c where id =: ParentId limit 10];
        for(job__c j: job){
            if(j.Division__c == 'Contents'){
                param = getParameters()+'&RecordType=012Q00000000kxB';
                System.debug('This is the job division' + j.Division__c);
            else if(j.Division__c == 'Structure'){
                param = getParameters()+'&RecordType=012Q00000000l42';
                System.debug('This is the job division' + j.Division__c);
                param = getParameters()+'&RecordType=012Q00000000kxG';
        system.debug('RecordType' + param);
        String prefix = Work_Order__c.SObjectType.getDescribe().getKeyPrefix();
        Pagereference page = new PageReference('/'+prefix+'/e?nooverride=1&'+param); 
        return page;

Hi ,

Where are you setting record type value in your code.
private String getParameters(){
        string param = '';
        Map<String, String> strMap = ApexPages.currentPage().getParameters();
        String[] keys = new String[]{'RecordType','retURL', 'cancelURL'};
        for(String s : keys){
        if(strMap.containsKey(S)) param += s + '=' + strMap.get(s) + '&';
        if(param.length() > 0) param = param.substring(0, param.length()-1);
        return param;

I'm setting this inside the redirect method but this is where I'm getting my param.