You need to sign in to do that
Don't have an account?
newbiewithapex
Account Number and Division Number coverage
I have these main class and test class that I am working with. I have it at 76% and only missing 4 lines of coverage. Can someone please take a look and let me know what am I missing here to cover those 4 lines?
//MAIN CLASS public class ARStatementValidate { @AuraEnabled public static String getTandemDivisionNo(String accId) { String tandemNo; String divisionNo; String resp; System.debug(tandemNo); System.debug(divisionNo); System.debug(resp); if(isProfileNotToBeAllowed()){ return 'profileCheckFailed'; } else{ for(Account a : [SELECT Id, Tandem_Account_Number__c, Division_Number__c FROM Account WHERE Id = :accId]){ tandemNo = a.Tandem_Account_Number__c; divisionNo = a.Division_Number__c; } if(tandemNo != null && tandemNo != '' && divisionNo != null && divisionNo != ''){ resp = 'SUCCESSSS'; system.debug('-----------' + resp + '------------'); return resp; }else{ return null; } } } public static boolean isProfileNotToBeAllowed(){ SalesforceIds__c profileIds = SalesforceIds__c.getOrgDefaults(); System.debug(profileIds); return (UserInfo.getProfileId().contains(profileIds.Profile_USF_ChefStoreRep__c)); } } //TEST CLASS @isTest public class ARStatementValidateTest { private static User thisUser = [select Id, Profile.Name, Name from User where Id = : UserInfo.getUserId() limit 1]; private static User testUser = new User(); @testSetup static void createTestData() { SalesforceIds__c settings = new SalesforceIds__c(); settings.Name = 'SF Environment Settings'; settings.Profile_USF_ChefStoreRep__c = UserInfo.getProfileId(); insert settings; } Static testMethod void verifyURL(){ Account acc = UTIL_TestDataCreation.createSingleAccount('TestAccountName1', thisUser.Id); acc.Tandem_Account_Number__c='123'; acc.Division_Number__c='123'; Database.insert(acc); String finalURL = ARStatementValidate.getTandemDivisionNo(acc.id); Boolean check ; if(finalURL != null) check = true; else check = false; } Static testMethod void verifyNullURL(){ Account acc = UTIL_TestDataCreation.createSingleAccount('TestAccountName1', thisUser.Id); Database.insert(acc); String finalURL = USFoodOnlineSetupFormCntrl.getTandemAccNo(acc.id); Boolean check ; if(finalURL == null){ check = true; }else{ check = false; } } static testMethod void testElse() { Account acc = UTIL_TestDataCreation.createSingleAccount('TestAccountName1', thisUser.Id); acc.Tandem_Account_Number__c='12345'; acc.Division_Number__c='1010'; Database.insert(acc, true); Account acc1 = UTIL_TestDataCreation.createSingleAccount('TestAccountName1', thisUser.Id); acc1.Tandem_Account_Number__c='45674'; acc1.Division_Number__c=''; Database.insert(acc1, true); Test.StartTest(); Profile profileId = [SELECT Id FROM Profile WHERE Name = 'USF_TerritoryManager' LIMIT 1]; List<Account> accounts = [SELECT Id, Tandem_Account_Number__c, Division_Number__c FROM Account]; accounts.add(acc); accounts.add(acc1); User testUser = UTIL_TestDataCreation.createUser('tmtst', profileId.Id); Database.insert(testUser,true); System.runAs(testUser) { ARStatementValidate.isProfileNotToBeAllowed(); String results= ARStatementValidate.getTandemDivisionNo(String.valueOf(accounts[0].Id)); } Test.StopTest(); } }