SyncMadeEasy/force-app/main/default/classes/HICWebhookUtility_Test.cls

101 lines
4.5 KiB
OpenEdge ABL

@isTest
public with sharing class HICWebhookUtility_Test {
@isTest
static void TestHICWebhookUtility(){
List<HIC_ShopifySync__HIC_Configuration__c> recordList = New List<HIC_ShopifySync__HIC_Configuration__c>();
HIC_ShopifySync__HIC_Configuration__c con = new HIC_ShopifySync__HIC_Configuration__c ();
con.name = 'Default';
con.HIC_ShopifySync__Opportunity__c = true;
con.HIC_ShopifySync__Order__c = false;
con.HIC_ShopifySync__Opportunity_Line_Item__c = true;
con.HIC_ShopifySync__Order_Line_Item__c = true;
con.HIC_ShopifySync__Salesforce_Site_URL__c = 'Salesforce.com';
con.HIC_ShopifySync__API_Key__c ='d9932b009966b97329fa9e6435141b21';
con.HIC_ShopifySync__Private_Key_Password__c= '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';
con.HIC_ShopifySync__Shopify_URL__c='https://madeeasy78.myshopify.com';
con.HIC_ShopifySync__Store__c = '123';
recordList.add(con);
insert con;
HIC_ShopifySync__HIC_Webhook__c wh = new HIC_ShopifySync__HIC_Webhook__c();
wh.Name = 'Order-Update';
wh.HIC_ShopifySync__SF_URL_Mapping__c = 'UpdateOrderFromShopifyAuthentication';
wh.HIC_ShopifySync__Topic__c = 'orders/updated';
wh.HIC_ShopifySync__Webhook_Id__c = '513611792477';
wh.HIC_ShopifySync__Shopify_Object__c = 'Order';
wh.HIC_ShopifySync__DML_Type__c = 'Update';
insert wh;
CustomSettingRecordInsert postinstall = new CustomSettingRecordInsert();
Test.testInstall(postinstall, null);
Test.testInstall(postinstall, new Version(1,0), true);
//HICWebhookUtility.createWebhook('Order', 'Update');
HICWebhookUtility.deleteWebhook('Order', 'Update','123');
system.assert(con.HIC_ShopifySync__Opportunity__c);
system.assert(wh.HIC_ShopifySync__SF_URL_Mapping__c.contains('Update'));
}
@isTest
static void TestHICWebhookUtilityWithoutid(){
List<HIC_ShopifySync__HIC_Configuration__c> configList = new List<HIC_ShopifySync__HIC_Configuration__c>();
HIC_ShopifySync__HIC_Configuration__c con = new HIC_ShopifySync__HIC_Configuration__c ();
con.name = 'Default';
con.HIC_ShopifySync__Opportunity__c = true;
con.HIC_ShopifySync__Order__c = false;
con.HIC_ShopifySync__Opportunity_Line_Item__c = true;
con.HIC_ShopifySync__Order_Line_Item__c = true;
con.HIC_ShopifySync__Salesforce_Site_URL__c = 'Salesforce.com';
con.HIC_ShopifySync__API_Key__c ='afsasaf';
con.HIC_ShopifySync__Private_Key_Password__c= 'fasafa';
con.HIC_ShopifySync__Shopify_URL__c='https://hicshopifymadeeasy-dev-ed.my.salesforce.com';
con.HIC_ShopifySync__Store__c = '123';
configList.add(con);
insert configList;
List<HIC_ShopifySync__HIC_Webhook__c> webhookList = new List<HIC_ShopifySync__HIC_Webhook__c>();
HIC_ShopifySync__HIC_Webhook__c wh = new HIC_ShopifySync__HIC_Webhook__c();
wh.Name = 'Order-Update';
wh.HIC_ShopifySync__SF_URL_Mapping__c = 'UpdateOrderFromShopifyAuthentication';
wh.HIC_ShopifySync__Topic__c = 'orders/updated';
wh.HIC_ShopifySync__Webhook_Id__c = '12345';
wh.HIC_ShopifySync__Shopify_Object__c = 'Order';
wh.HIC_ShopifySync__DML_Type__c = 'Update';
wh.HIC_ShopifySync__Store__c = '123';
webhookList.add(wh);
insert webhookList;
CustomSettingRecordInsert postinstall = new CustomSettingRecordInsert();
Test.testInstall(postinstall, null);
Test.testInstall(postinstall, new Version(1,0), true);
//HICWebhookUtility.createWebhook('Order', 'Update');
HICWebhookUtility.deleteWebhook('Order', 'Update','123');
HICWebhookUtility hc = new HICWebhookUtility(configList);
system.assert(con.HIC_ShopifySync__Opportunity__c);
system.assert(wh.HIC_ShopifySync__SF_URL_Mapping__c.contains('Update'));
test.startTest();
HICWebhookUtility.CheckingWebhookExist('topic', 'SiteUrl', 'returnClassUrl', configList,webhookList, 'store');
HICWebhookUtility.deleteWebhook('Order', 'Update', '123',JSON.serialize(configList) );
HICWebhookUtility.deleteWebhook('objectName', 'forDML');
HICWebhookUtility.processRequest('test', 'method', 'body', 'store',configList);
test.stopTest();
}
}