@isTest
private class MilestoneTimeCalculatorTest {
static testMethod void testMilestoneTimeCalculator() {
// Select an existing milestone type to test with
MilestoneType[] mtLst = [SELECT Id, Name FROM MilestoneType LIMIT 1];
if(mtLst.size() == 0) { return; }
MilestoneType mt = mtLst[0];
// Create case data.
// Typically, the milestone type is related to the case,
// but for simplicity, the case is created separately for this test.
Case c = new Case(priority = 'High');
insert c;
myMilestoneTimeCalculator calculator = new myMilestoneTimeCalculator();
Integer actualTriggerTime = calculator.calculateMilestoneTriggerTime(c.Id, mt.Id);
if(mt.name != null && mt.Name.equals('m1')) {
System.assertEquals(actualTriggerTime, 7);
}
else {
System.assertEquals(actualTriggerTime, 5);
}
c.priority = 'Low';
update c;
actualTriggerTime = calculator.calculateMilestoneTriggerTime(c.Id, mt.Id);
System.assertEquals(actualTriggerTime, 18);
}
}
list<case> caselist=[select c.Id,(select id,TargetResponseInHrs,TargetDate from case.casemilestones where MilestoneTypeId in :milestonemap.keyset() and IsCompleted=false limit 1), c.account.name, c.subject,c.Owner.Name, c.status,c.CreatedDate,c.LastModifiedDate ,c.Case_Severity__c,c.casenumber,c.Priority, c.Status_Number__c,c.Status_priority__c,c.Case_Age__c,c.IsEscalated from Case c where c.Owner.Id != : userinfo.getUserID() and c.owner.name=:curUser.Primary_Group__c and c.IsClosed != true order by c.Case_Severity__c,c.Status_priority__c,c.lastmodifieddate desc,c.createddate Limit 100]; please give a sample code.
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_interface_support_milestonetriggertimecalculator.htm
https://salesforce.stackexchange.com/questions/150226/milestone-completion-test-class-not-getting-100-code-coverage
list<case> caselist=[select c.Id,(select id,TargetResponseInHrs,TargetDate from case.casemilestones where MilestoneTypeId in :milestonemap.keyset() and IsCompleted=false limit 1), c.account.name, c.subject,c.Owner.Name, c.status,c.CreatedDate,c.LastModifiedDate ,c.Case_Severity__c,c.casenumber,c.Priority, c.Status_Number__c,c.Status_priority__c,c.Case_Age__c,c.IsEscalated from Case c where c.Owner.Id != : userinfo.getUserID() and c.owner.name=:curUser.Primary_Group__c and c.IsClosed != true order by c.Case_Severity__c,c.Status_priority__c,c.lastmodifieddate desc,c.createddate Limit 100];
please give a sample code.