You need to sign in to do that
Don't have an account?
APEX CLASS - Failure Stack Trace
I AM RECEIVING THIS ERROR MESSAGE:
Failure Message: "System.DmlException: Insert failed. First exception on row 0; first error: INACTIVE_OWNER_OR_USER, operation performed with inactive user: []", Failure Stack Trace: "Class.TestEventDivisionUpdate.testEventDivisionUpdate: line 13, column 1"
WHEN I DEPLOY AN UPDATE TO AN EXISTING TRIGGER USING THIS CLASS:
CAN SOMEONE PLEASE HELP ME UNDERSTAND WHY I WOULD GET A "FAILURE STACK TRACE"? THANK YOU!
@isTest
private class TestEventDivisionUpdate {
//This test will also test the Account and Contact Trigger
static testMethod void testEventDivisionUpdate() {
// Create a User, an Account and a Contact for testing purposes
User u = [SELECT Id, Division, Department from User
WHERE Division <> null AND Department <> null LIMIT 1];
Account a = new Account(Name = 'Test Account', OwnerId=u.Id);
insert a;
Contact c = new Contact(LastName='Test', AccountId=a.Id, OwnerId=u.Id);
insert c;
datetime StartDate = datetime.newInstance (2011, 5, 27);
datetime EndDate = StartDate.addDays(2);
Event e = new Event(Subject = 'TestSubject', OwnerId=u.Id, WhoId = c.Id, StartDateTime = StartDate, EndDateTime=EndDate);
insert e;
Event updatedE = [SELECT Id, Department__c
FROM Event WHERE Id = :e.Id LIMIT 1];
Account UpdatedA = [SELECT Id, Department__c
FROM Account WHERE Id = :a.Id LIMIT 1];
Contact UpdatedC = [SELECT Id, ePrize_Department__c
FROM Contact WHERE Id = :c.Id LIMIT 1];
// Now do the assertions
// System.assertEquals(updatedE.Department__c, u.Department);
// System.assertEquals(updatedA.Department__c, u.Department);
// System.assertEquals(updatedC.ePrize_Department__c, u.Department);
Normally you should create the objects you are using in your testMethod.
Create the user using the following code. Insert a profile name in the query.
All Answers
put a debug statement after this line and get the user id. Appears like the user this statement is fetching is no more active in the system.
User u = [SELECT Id, Division, Department from User
WHERE Division <> null AND Department <> null LIMIT 1];
Normally you should create the objects you are using in your testMethod.
Create the user using the following code. Insert a profile name in the query.
Thank you for the help; I will try to add that code to my CLASS.