2

I've implemented platform cache, I'm running a test and i received the following error:

caused by: cache.Org.OrgCacheException: Failed Cache.Org.contains() for key 'timeZones': Org cache is only supported in Data Silo tests

This is the test class, im not using SeeAllData=true.

public static testmethod void testReassign(){
    SlaProcess sla = [SELECT Id FROM SlaProcess LIMIT 1];
    Account_Default_Entitlement_Process__c ent = new Account_Default_Entitlement_Process__c();
    ent.Name='Standard1';
    ent.Process_id__c=sla.Id;
    insert ent;

    Account testAccount = new Account(
        Name              = 'test',
        BillingCountry = 'United States',
        BillingState = 'Alabama',
        Customer_Type__c = 'Customer',
        Industry = 'Automotive',
        Billing_Account_ID__c = '123456'
    );
    insert testAccount;

    User userTDR = TestUtil.getTDRUser('TDRUser');
    User userSE = TestUtil.getSalesEngenerUser('SEUser'); 
    insert New List<User>{userTDR,userSE};

    Opportunity testOpty = new Opportunity();
    testOpty.StageName = 'Discover';
    testOpty.CloseDate = System.today()+1;
    testOpty.AccountId=testAccount.Id;
    testOpty.Name='testOpty';
    testOpty.Type = 'testType';
    testOpty.Sales_Engineer__C = userSE.Id;
    testOpty.TDR__c = userTDR.Id;
    insert testOpty;

    MassReassignOpportunitiesController controller = new MassReassignOpportunitiesController();
    controller.refreshOptyList();
    controller.filterId = controller.listviewoptions[1].getValue();
    controller.refreshOptyList();
    controller.searchRecord.stageName = 'Discover';
    controller.helperRecord.ClosedDate_From__c=System.today();
    controller.helperRecord.ClosedDate_To__c=System.today()+2;
    controller.helperRecord.From__c=System.today();
    controller.helperRecord.To__c=System.today()+1;
    controller.searchRecord.Type = 'testType';
    controller.refreshOptyListBySearch();

    System.assert(controller.optyList.size()>0);

    controller.optyList[0].selected = true;
    controller.helperRecord.Assign_to__c = UserInfo.getUserId();
    controller.Assign();
}

what are data silo tests? how can i solve this? i saw this thread but it didnt help: Apex unit testing - Session cache is only supported in Data Silo tests

  • What API Version is your test class? – Adrian Larson Oct 11 '18 at 14:07
  • @AdrianLarson Didnt even think about looking at that. it's an old test class. i re-wrote it to version 38 and it worked. Thanks! – Dana Griff Oct 11 '18 at 14:13
2

Your tests see all data by default for any API Version below 24. Set your version to a more recent value and your test will run with data silo.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.