You need to sign in to do that
Don't have an account?

how to call Below trigger in text class:
for(vlocity_cmt__OrchestrationItem__c items:Trigger.New)
{
if(items.Name=='Generate Bill Manual Task')
{
allItemsGenBilling.add(items);
}
}
if(allItemsGenBilling.size()>0)
{
Tet_GenerateBillManualTaskForGenBill.UpdateOrderStatus(allItemsGenBilling);
}
{
if(items.Name=='Generate Bill Manual Task')
{
allItemsGenBilling.add(items);
}
}
if(allItemsGenBilling.size()>0)
{
Tet_GenerateBillManualTaskForGenBill.UpdateOrderStatus(allItemsGenBilling);
}
To cover your trigger. You need to first insert data on the object your trigger is on. See this Trailhead Module to learn more
Insert vlocity_cmt__OrchestrationItem__c record in your test class and ensure 'Name' is populated with value Generate Bill Manual Task. You don't need to explicitly call Tet_GenerateBillManualTaskForGenBill.UpdateOrderStatus(allItemsGenBilling); Test class will automatically cover this code
If you find this information helpful, please mark this answer as Best. It may help others in the community. Thank You!
Anudeep
I have tried that,added item into item as belwo but trigger showing 0% coverage:
@isTest
public class Tet_GenerateBillManualTaskForGenBillTest {
public static testMethod void testUpdateOrderStatus(){
try{
Account account_Obj = new Account(Name ='Test');
insert account_Obj;
Product2 product = new product2(name='Acer',family='Telecom',productcode='12345',Tet_Product_Type__c='SplitPayment',Tet_Prefix__c='DLMS');
insert product;
Order order_Obj = new Order(AccountId = account_Obj.id, Pricebook2Id = Test.getStandardPricebookId(), EffectiveDate = Date.today(),
Status = 'Draft', Tet_Internal_Movement_Required__c = true,Tet_Order_SubStatus__c='Open');
Insert order_Obj;
Id stdpbId = Test.getStandardPricebookId();
PricebookEntry pbe = new PricebookEntry(pricebook2id=stdpbId, product2id=product.id,unitprice=1.0, isActive=true,UseStandardPrice=false);
insert pbe;
OrderItem orderItem = new OrderItem(OrderId = order_Obj.Id, PricebookEntryId = pbe.Id, UnitPrice = 10.0, vlocity_cmt__RootItemId__c='RootTest',
Quantity = 2, Tet_Reserved_At_Id__c = '4',product2id=product.id,Tet_Internal_Movement_Required__c = true);
vlocity_cmt__ItemImplementation__c itemImpl = new vlocity_cmt__ItemImplementation__c(Name = 'Generate Bill Manual Task test',
vlocity_cmt__Implementation__c = 'GenerateBillManualTasktest');
vlocity_cmt__OrchestrationPlanDefinition__c planDef = new vlocity_cmt__OrchestrationPlanDefinition__c(Name ='Billing Test');
insert planDef;
vlocity_cmt__OrchestrationItemDefinition__c itemDef = new vlocity_cmt__OrchestrationItemDefinition__c(
vlocity_cmt__OrchestrationPlanDefinitionId__c =planDef.Id,
Name = 'Generate Bill Manual Task',vlocity_cmt__itemImplementationId__c = itemImpl.Id,
vlocity_cmt__GlobalKey__c = 'ac70f77d-0446-eec4-4f8a-b375ae61e3a');
insert itemDef;
vlocity_cmt__OrchestrationPlan__c planId = new vlocity_cmt__OrchestrationPlan__c(vlocity_cmt__State__c = 'In progress',
vlocity_cmt__OrderId__c = order_Obj.Id);
insert planId;
vlocity_cmt__FulfilmentRequest__c FRId = new vlocity_cmt__FulfilmentRequest__c(vlocity_cmt__Status__c = 'New',
vlocity_cmt__OrchestrationPlanId__c = planId.Id,
vlocity_cmt__OrderId__c=order_Obj.Id);
insert FRId;
vlocity_cmt__FulfilmentRequestLine__c FRLine = new vlocity_cmt__FulfilmentRequestLine__c(vlocity_cmt__Action__c = 'Add',
vlocity_cmt__FulfilmentRequestID__c = FRId.Id);
insert FRLine;
vlocity_cmt__FulfilmentRequestLineDecompRelationship__c FRLineDecom = new vlocity_cmt__FulfilmentRequestLineDecompRelationship__c(
vlocity_cmt__DestinationFulfilmentRequestLineId__c = FRLine.Id,
vlocity_cmt__SourceOrderItemId__c = orderItem.Id);
insert FRLineDecom;
vlocity_cmt__OrchestrationItem__c item1 = new vlocity_cmt__OrchestrationItem__c(Name = 'Generate Bill Manual Task',
vlocity_cmt__OrchestrationPlanId__c = planId.Id,
vlocity_cmt__State__c='Completed',
vlocity_cmt__FulfilmentRequestLineId__c = FRLine.Id,
vlocity_cmt__OrderItemId__c = orderItem.Id);
insert item1;
System.debug('Item Name : ' +item1.Name);
vlocity_cmt__OrchestrationItem__c item2 = new vlocity_cmt__OrchestrationItem__c(Name = 'Manual task2',
vlocity_cmt__OrchestrationPlanId__c = planId.Id,
vlocity_cmt__State__c='Completed',
vlocity_cmt__FulfilmentRequestLineId__c = FRLine.Id,
vlocity_cmt__OrderItemId__c = orderItem.Id);
insert item2;
List<vlocity_cmt__OrchestrationItem__c> allItemsGenBilling = new List<vlocity_cmt__OrchestrationItem__c>();
allItemsGenBilling.add(item1);
allItemsGenBilling.add(item2);
system.debug('List is :' +allItemsGenBilling );
test.startTest();
Tet_GenerateBillManualTaskForGenBill.UpdateOrderStatus(allItemsGenBilling);
test.stopTest();
}catch(Exception c)
{
System.debug(c);
}
}
}