I am trying to test Apex code that was developed to provide a @RestResource for Kimble Event information. In order to test it I either need to insert the event through Apex or us SeeAllData=true. I would rather do the former. However, when I try to insert all of the elements to create a Kimble Event I get an error from a Trigger within Kimble. Since it is a managed application I am not sure how to see what I need to do to insert the correct information.
Here is the error message:
System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, KimbleOne.ResourcedActivity_A_I: execution of AfterInsert caused by: KimbleOne.HandledException: ERR:Invalid or missing ResourcedActivityType Other (KimbleOne): []
Here is the code in my test class that tries to insert the Kimble Event:
KimbleOne__ResourcedActivityType__c kimAT= new KimbleOne__ResourcedActivityType__c(name='test');
insert kimAT;
KimbleOne__ResourcedActivity__c kimRACT=new KimbleOne__ResourcedActivity__c(name='testkrc',KimbleOne__ResourcedActivityType__c=kimAT.id);
insert kimRACT;
KimbleOne__ActivityAssignment__c actAssign= new KimbleOne__ActivityAssignment__c(name='test',KimbleOne__ResourcedActivity__c=kimRACT.Id);
insert actAssign;
The error message fails on the line that tries to insert kimRACT. kimAT inserts just fine. And without the Resourced Activity the Activity Assignment fails.
Here is the code within the class the checks for the Activity Assignment:
@RestResource(urlMapping='/DataEvent/*')
global class KimbleEventManager {
@HttpGet
global static KimbleOne__ActivityAssignment__c getEventById() {
RestRequest request = RestContext.request;
// grab the EventId from the end of the URL
String eventId = request.requestURI.substring(
request.requestURI.lastIndexOf('/')+1);
KimbleOne__ActivityAssignment__c result = [select ID, Account_Id__c,Resource_Name__c,KimbleOne__ResourceUser__c,KimbleOne__StartDate__c,Number_of_Attendees__c,Workshop_Name__r.Name,Service_Type__c,Account_Name__c,KimbleOne__Location__r.name,(select ID,Capability_Type_Name__c,Name from KimbleOne__RequiredCapabilities__r where KimbleOne__IsMandatory__c=TRUE) from KimbleOne__ActivityAssignment__c where event_id__c =:eventid];
return result;
}
}
Any idea from the error message what I need to do? Is there another way to test this class?
KimbleOne__ResourcedActivityType__c
construction to passName='Other'
?