• Randi Warner
  • NEWBIE
  • 0 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 3
    Replies
I have a script that is hitting a System.LimitException: Regex too complicated Error and so to combat this I've come up with a solution to chunk up the string and then do the regex to the chunks so that it wont hit that limit. 
Here is the problem, finding a clean way to cut up the document so that it still works. 
Originally I was cutting the string up by every new line String.split('\r\n|\r|\n') so it could then digest it line by line (but if the document was too long it hit the above limit) so now im targeting some text and then want to get the next new line that comes after so it will be a clean cut. Then once I get a chunk, i'll apply the new line regex and add it to a list then keep doing that for each chunk so I can achive the same result and work around the limit.

so for example:

If myString = '22:45:07.0 (1307331)|HEAP_ALLOCATE|[139]|Bytes:6
22:45:07.0 (1328106)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:27
22:45:07.0 (1358441)|METHOD_ENTRY|[2]|01p4x000006c0jb|AttachmentTriggerLogic_Test.AttachmentTriggerLogic_Test()
22:45:07.0 (1374280)|STATEMENT_EXECUTE|[2]
22:45:07.0 (1383574)|STATEMENT_EXECUTE|[2]
22:45:07.0 (1386012)|STATEMENT_EXECUTE|[4]'

and I target the index of ')|METHOD_ENTRY|', how then would i be able to take that index and find the next index of a match? 

Integer firstMatch = myString.indexOf(')|METHOD_ENTRY|');
String newLineRegex = '\r\n|\r|\n';
Integer secondMatch = *new line after first match*?

Let me know if anyone has any ideas?
I have a script that is hitting a System.LimitException: Regex too complicated Error and so to combat this I've come up with a solution to chunk up the string and then do the regex to the chunks so that it wont hit that limit. 
Here is the problem, finding a clean way to cut up the document so that it still works. 
Originally I was cutting the string up by every new line String.split('\r\n|\r|\n') so it could then digest it line by line (but if the document was too long it hit the above limit) so now im targeting some text and then want to get the next new line that comes after so it will be a clean cut. Then once I get a chunk, i'll apply the new line regex and add it to a list then keep doing that for each chunk so I can achive the same result and work around the limit.

so for example:

If myString = '22:45:07.0 (1307331)|HEAP_ALLOCATE|[139]|Bytes:6
22:45:07.0 (1328106)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:27
22:45:07.0 (1358441)|METHOD_ENTRY|[2]|01p4x000006c0jb|AttachmentTriggerLogic_Test.AttachmentTriggerLogic_Test()
22:45:07.0 (1374280)|STATEMENT_EXECUTE|[2]
22:45:07.0 (1383574)|STATEMENT_EXECUTE|[2]
22:45:07.0 (1386012)|STATEMENT_EXECUTE|[4]'

and I target the index of ')|METHOD_ENTRY|', how then would i be able to take that index and find the next index of a match? 

Integer firstMatch = myString.indexOf(')|METHOD_ENTRY|');
String newLineRegex = '\r\n|\r|\n';
Integer secondMatch = *new line after first match*?

Let me know if anyone has any ideas?
Hi all,
I am trying to discover why while compiling a test class method, this is telling me 'Variable doesn't exist' in the row:
System.assertEquals(testEntitlement.Id



I would appreciate if someone could tell me what I am doing wrong?:
 
@isTest
    private static void EntitlementUpdate() {
    //ARRANGE
        User serviceUser = [
        SELECT
            Id
        FROM
            User
        WHERE
            Email =: 'test.serviceuser@google.com'
    ];
	
	 Account testAccount = [
        SELECT 
            Id 
        FROM 
            Account];
			
       Product2 testProduct = [
        SELECT 
            Id 
        FROM 
            Product2];
		

	CaseAsset__c testCaseAsset = new CaseAsset__c(Name='Test Case Asset', Account__c=testAccount.Id, SerialNumber__c='123', Product__c = testProduct.Id, StartDate__c = System.today(), EndDate__c = System.today() + );
    testCaseAsset.OwnerId = serviceUser.ID;
    
    insert testCaseAsset;

    //ACT
    test.startTest();
    System.runAs(serviceUser){
        Entitlement testEntitlement = new Entitlement();
		testEntitlement.AccountID = testCaseAsset.Account__c;
		testEntitlement.Name = testCaseAsset.Name;
        testEntitlement.CasesPerEntitlement = integer.valueOf(testCaseAsset.NoOfCasesPerYear__c);
        testEntitlement.EndDate = testCaseAsset.EndDate__c;
        testEntitlement.StartDate = testCaseAsset.StartDate__c;
        testEntitlement.IsPerIncident = true;
        testEntitlement.CaseAsset__c = testCaseAsset.Id;
        testEntitlement.RemainingCases = integer.valueOf(testCaseAsset.NoOfCasesPerYear__c);
		insert testEntitlement;
    }   
    test.stopTest();
    //ASSERT
    Entitlement testEntitlementAfterProcess = [
        SELECT 
            Id,
            Name
        FROM 
            Entitlement
        ];
        System.assertEquals(testEntitlement.Id,
                        testEntitlementAfterProcess.Name,
                        'Entitlement not created');
   
    }