You need to sign in to do that
Don't have an account?
VancouverDev
Unexpected Token Account
Hi everyone,
I'm trying to build a test class for a trigger, and I'm running into an issue I don't fully understand. Here's the code:
I'm having issues when I save where it says "Error: Compile Error: Unexpected token '{'. at line 2 column 33"
I'm guessing I did something wrong in the formatting for creating my test data, but I'm not sure what. Any help is appreciated!
I'm trying to build a test class for a trigger, and I'm running into an issue I don't fully understand. Here's the code:
@isTest class TestValidateCorrectSIC{ public static void CreateTestData{ Account acct = new Account(Name='Test Account'); acct.Sic='1111'; acct.NumberOfEmployees=101; acct.AnnualRevenue=1000000; insert acct; MultiplierMetadata__mdt multCheck = new MultiplierMetadata__mdt(); multCheck.SIC__c = '1111'; multCheck.Employee_Lower_Bound__c = 100; multCheck.Employee_Upper_Bound__c = 102; multCheck.Industry__c = 'Test'; multCheck.Industry_Code__c = 'I'; multCheck.Addressable_Spend_Multiplier__c = 3.0; insert multCheck; } @isTest static void testInitialValues(){ acct.Sic=''; system.assertequals(updatedSpendDetails, 0); system.assertequals(isPublic, false); system.assertequals(accToMult.Sic, NULL); system.assertequals(sicCode.size(), 0); system.assertequals(multiMap.addressMult, NULL); system.assertequals(acct.SC_Addressable_Spend__c, ''); system.assertequals(acct.Account_Segmentation__c, ''); system.assertequals(acct.Industry, ''); system.assertequals(acct.Industry_Code__c, ''); } @isTest static void testInvalidSIC(){ acct.Sic='1110'; try{ update acct; throw new Exception('This should have failed, but instead succeeded.') } catch (Exception e){ Boolean expectedExceptionThrown = e.getMessage().contains('SIC not found')) ? true : false; System.AssertEquals(expectedExceptionThrown, true); system.assertequals(updatedSpendDetails, 0); system.assertequals(isPublic, false); system.assertequals(accToMult.Sic, NULL); system.assertequals(sicCode.size(), 0); system.assertequals(multiMap.addressMult, NULL); system.assertequals(acct.Addressable_Spend__c, ''); system.assertequals(acct.Account_Segmentation__c, ''); system.assertequals(acct.Industry, ''); system.assertequals(acct.Industry_Code__c, ''); } } @isTest static void testSicAdd(){ acct.Sic = '1111'; update acct; system.assert(multiMap.addressMult.size()>0, 'Error: sicCode not properly adding Account SIC to set'); system.assert(addressMult.size()>0, 'Error: query of MultiplierMetadata__mdt table did not return and store records'); } @isTest static void testIndustryCode(){ acct.Sic='1111'; update acct; system.assertequals(acct.Industry_Code__c, 'I'); } @isTest static void testIndustryName(){ acct.Sic='1111'; update acct; system.assertequals(acct.Industry, 'Test'); } @isTest static void testOneFieldBlank(){ acct.NumberOfEmployees=''; update acct; system.assertequals(acct.SIC__c, '1111'); system.assertequals(acct.AnnualRevenue, 1000000); system.assertequals(updatedSpendDetails, 0); system.assertequals(acct.Addressable_Spend__c, ''); system.assertequals(acct.Segment, ''); } @isTest static void testNegativeEmployees(){ acct.NumberOfEmployees = -1; system.assert(acct.SC_Addressable_Spend__c=0); system.assert(acct.Account_Segmentation__c='Emerging'); } @isTest static void testPositiveEmployees(){ acct.NumberOfEmployees = 101; update acct; system.assert(acct.); } @isTest static void testPutInRevenue(){ update acct; system.assert(acct.Addressable_Spend__c=3000000); } @isTest static void testOverrideSegment(){ acct.Account_Segmentation__c='C'; acct.Override_Account_Segment__c=true; update acct; system.assertequals(acct.Account_Segmentation__c, 'Commercial'); system.assertequals(acct.Segment_Calculated__c, 'SMB'); } @isTest static void testNonOverridenSegment(){ acct.Account_Segmentation__c='C'; acct.Override_Account_Segment__c=false; update acct; system.assertequals(acct.Account_Segmentation__c, 'SMB'); system.assertequals(acct.Segment_Calculated__c, 'SMB'); } @isTest static void testPublicSectorSegment(){ acct.NumberOfEmployees=''; acct.AnnualRevenue=0; acct.Account_Segmentation__c='Commercial'; acct.Sic='9621'; update acct; system.assertequals(acct.Account_Segmentation__c, 'P'); system.assertequals(acct.Segment_Calculated__c, 'P'); } }
I'm having issues when I save where it says "Error: Compile Error: Unexpected token '{'. at line 2 column 33"
I'm guessing I did something wrong in the formatting for creating my test data, but I'm not sure what. Any help is appreciated!
Check below line, I guess there is one extra closing bracket.
Best Regards,
Sandhya
Thanks!