• Samuel Wolfe
  • NEWBIE
  • 5 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 3
    Replies
I have a test class with 70+ tests in it. Every single tests needs to create an Account, a Contact, and several custom objects. All of these Accounts, Contacts, etc... are the exact same.

Since all of these records need to be inserted again in every test case, this test class takes a very long time to run. Is it possible to create the account/contacts/etc... only 1 time, and have it be accessible in every test class so I don't have to re-insert them 77 times each?
So I am confused. I need to be able to insert a new User with a specific profile/permission sets and a new account before starting my Test.startTest block.

If I create the User first, then creating the account causes
MIXED_DML_OPERATION, DML operation on setup object is not permitted after you have updated a non-setup object (or vice versa)
The documentation recommends using @future methods, but this won't work because I need the guarantee that both the account and user exist before running my test.

How do you accomplish this?
 
We are trying to store a value in a session cache partition. When I add values to the session cache, appears to be stored successfully for the duration of 1 debug log.

However when I list all the data from the session cache, it appears to be cleared every time a new debug log is started. We never explcitily clear the session cache.

Any idea why this could be happening?

Here is the code where I store the value in the partition:
Cache.SessionPartition apicache  = Cache.Session.getPartition('local.APICache.'+hash);
            apicache.put(hash, json);
Here is how we retrieve data from the partition
Cache.SessionPartition apicache = Cache.Session.getPartition('local.APICache.'+hash);

This successfully stores and retrieves the data through the duration of 1 debug log. But when I initiate the code again (aka by clicking a link to an object), it is no longer there.

5MB has been allocated to the session cache partition.
 
They have one for the Salesforce IoT REST API here:
https://developer.salesforce.com/docs/atlas.en-us.api_iot.meta/api_iot/intro_swagger_file.htm

Anyone know if they have one hidden away for Lightning Platform REST API?
Trying to find one. They have one for the Salesforce IoT REST API here:
https://developer.salesforce.com/docs/atlas.en-us.api_iot.meta/api_iot/intro_swagger_file.htm

Anyone know if they have one hidden away for Lightning Platform REST API?
So I am confused. I need to be able to insert a new User with a specific profile/permission sets and a new account before starting my Test.startTest block.

If I create the User first, then creating the account causes
MIXED_DML_OPERATION, DML operation on setup object is not permitted after you have updated a non-setup object (or vice versa)
The documentation recommends using @future methods, but this won't work because I need the guarantee that both the account and user exist before running my test.

How do you accomplish this?
 
We are trying to store a value in a session cache partition. When I add values to the session cache, appears to be stored successfully for the duration of 1 debug log.

However when I list all the data from the session cache, it appears to be cleared every time a new debug log is started. We never explcitily clear the session cache.

Any idea why this could be happening?

Here is the code where I store the value in the partition:
Cache.SessionPartition apicache  = Cache.Session.getPartition('local.APICache.'+hash);
            apicache.put(hash, json);
Here is how we retrieve data from the partition
Cache.SessionPartition apicache = Cache.Session.getPartition('local.APICache.'+hash);

This successfully stores and retrieves the data through the duration of 1 debug log. But when I initiate the code again (aka by clicking a link to an object), it is no longer there.

5MB has been allocated to the session cache partition.
 
They have one for the Salesforce IoT REST API here:
https://developer.salesforce.com/docs/atlas.en-us.api_iot.meta/api_iot/intro_swagger_file.htm

Anyone know if they have one hidden away for Lightning Platform REST API?