/** * @description : * @author : ChangeMeIn@UserSettingsUnder.SFDoc * @group : * @last modified on : 06-05-2024 * @last modified by : Shubham.c@hicglobalsolutions.com **/ @istest public with sharing class TestDataFactory { public static List createConfigurationCustomSetting(Integer numberOfRecord) { List configurationList = New List(); for(Integer i=0; i createConfiguration(Integer numberOfRecords){ List listOfConfiguration = New List(); for(Integer i=0; i < numberOfRecords; i++) { HIC_ShopifySync__HIC_Configuration__c configuration = New HIC_ShopifySync__HIC_Configuration__c(); configuration.name = 'Test Store'; configuration.HIC_ShopifySync__Order_Line_Item__c=true; configuration.HIC_ShopifySync__Private_Key_Password__c = 'Shopify@878'; configuration.HIC_ShopifySync__ProductVariantBatchCompleted__c = true; configuration.HIC_ShopifySync__AccountContactBatchCompleted__c = true; configuration.HIC_ShopifySync__Enable_Draft_Order__c = true; configuration.HIC_ShopifySync__OrderBatchCompleted__c = true; configuration.HIC_ShopifySync__InventoryBatchCompleted__c = true; configuration.HIC_ShopifySync__DraftOrderBatchCompleted__c = true; configuration.HIC_ShopifySync__Order__c= true; configuration.HIC_ShopifySync__Opportunity__c= true; configuration.HIC_ShopifySync__Opportunity_Line_Item__c= true; configuration.HIC_ShopifySync__Order_Fulfillment__c= true; configuration.HIC_ShopifySync__Enable_Draft_Order__c=true; configuration.HIC_ShopifySync__Account_Contact__c=true; configuration.HIC_ShopifySync__Person_Account__c= true; configuration.HIC_ShopifySync__Inventory_Location__c= true; configuration.HIC_ShopifySync__Collection__c = true; configuration.HIC_ShopifySync__Collection_Sync__c = true; configuration.HIC_ShopifySync__Customer_Sync__c = true; configuration.HIC_ShopifySync__Inventory_Location_Sync__c = true; configuration.HIC_ShopifySync__Product_Sync__c = true; configuration.HIC_ShopifySync__Order_Sync__c = true; configuration.HIC_ShopifySync__Opportunity_Sync__c = true; configuration.HIC_ShopifySync__Draft_Order_Sync__c = true; configuration.HIC_ShopifySync__BatchisAborted__c = true; configuration.HIC_ShopifySync__Batch_Is_Processing__c=true; configuration.HIC_ShopifySync__Shopify_URL__c = 'https//www.shopify.com'; configuration.HIC_ShopifySync__Store__c = 'Test Store'; // configuration.CurrencyIsoCode='USD'; configuration.HIC_ShopifySync__Specify_Close_Date__c = true; configuration.HIC_ShopifySync__Default_Account__c = true; configuration.HIC_ShopifySync__Default_Field_Mapping__c = true; configuration.HIC_ShopifySync__IsCurrencyChanged__c = true; configuration.HIC_ShopifySync__Cryptokey__c = 'BitCoinkey123456'; configuration.HIC_ShopifySync__BatchRunOnce__c = true; configuration.HIC_ShopifySync__Refresh_Token__c = 'Validate type'; configuration.HIC_ShopifySync__API_Key__c = 'QUISTER'; configuration.HIC_ShopifySync__Salesforce_Site_URL__c = 'https//www.shopify.com'; configuration.HIC_ShopifySync__Salesforce_Pricebook__c = '1878'; configuration.HIC_ShopifySync__CollectionsBatchCompleted__c = true; listOfConfiguration.add(configuration); } // if(!listOfConfiguration.isEmpty()){ // insert listOfConfiguration; // } return listOfConfiguration; } public static List createFieldMapping(Integer numOfRecords){ List listOfFieldMapping = New List(); for(Integer i=0; i < numOfRecords ; i++) { HIC_ShopifySync__HIC_Field_Mapping__c fieldMapping = New HIC_ShopifySync__HIC_Field_Mapping__c(); fieldMapping.Name = 'Opportunity-StageName'; fieldMapping.HIC_ShopifySync__SF_Field__c = 'Accountid'; fieldMapping.HIC_ShopifySync__Shopify_Field_Type__c = 'string'; fieldMapping.HIC_ShopifySync__Object_Name__c = 'OrderItem'; fieldMapping.HIC_ShopifySync__External_ID__c = 'Opportunity-Accountid'; fieldMapping.HIC_ShopifySync__Store__c = 'default'; fieldMapping.HIC_ShopifySync__Shopify_Fields__c = 'Test Field'; fieldMapping.HIC_ShopifySync__Default_Value__c = true; fieldMapping.HIC_ShopifySync__Nested__c = 'rohitrohitrohit1'; fieldMapping.HIC_ShopifySync__Store_External_ID__c = 'fdagafhhhaghfr'; //fieldMapping.HIC_ShopifySync__Registrations_Date__c=System.today(); fieldMapping.HIC_ShopifySync__SF_Field_Type__c='test'; fieldMapping.HIC_ShopifySync__IsSFID__c=true; // fieldMapping.CurrencyIsoCode='USD'; listOfFieldMapping.add(fieldMapping); } // if(!listOfFieldMapping.isEmpty()){ // insert listOfFieldMapping; // } return listOfFieldMapping; } public static List createErrorCsv(Integer numOfRecords){ List EmailErrorCsvList = New List(); for(Integer i=0; i < numOfRecords; i++) { HIC_ShopifySync__Email_Addresses_to_send_error_CSV__c ecs = New HIC_ShopifySync__Email_Addresses_to_send_error_CSV__c(); ecs.Name = 'TestErrorMail'; EmailErrorCsvList.add(ecs); } return EmailErrorCsvList; } public static List createPriceBook2(Integer numOfRecords){ List listofPriceBook = New List(); for(Integer i=0; i < numOfRecords ; i++) { Pricebook2 testPricebook = new Pricebook2(); testPricebook.Name='Test Pricebook'; testPricebook.IsActive=true; listofPriceBook.add(testPricebook); } // if(!testPricebook.isEmpty()){ // insert testPricebook; // } return listofPriceBook; } public static ListcreateAccount(Integer numOfRecords){ List listofAccount = New List(); for(Integer i=0; i < numOfRecords ; i++) { Account acc = new Account(); acc.Name='Test Account'; listofAccount.add(acc); } // if(!testPricebook.isEmpty()){ // insert testPricebook; // } return listofAccount; } public class oauthlogintest implements HttpCalloutMock { String clientIdProduction='3MVG9G9pzCUSkzZv4NsQV0kOphjUwrs4pHcnEP.g4ejkZCmpEmiSkw9X.M3tdeT.6lSfM1Z6uCn85AdMduQ.H'; String clientSecretproduction= '8B4246BE2D9D89EF4B53D64E1687D9040A8273323429EA9E5C930BE6EC06F4E6'; String refreshToken = 'EwA4A61DBAAUm4Az4MbwzN0ziTM/2hwxwNoGHboAAdhOerUo/69NOyhLCeT3ezAWVIqBl3d9GY2fZRgf5Mw1ZJCzcc6BqU13NOHc3Aoaw5Iv0oIPTRkPHiOrsI0CSd4DPopoFyL7DYbUQovZw34TXrtb8tLVl/sc/0tHYhkbNohcQV+AKxS+NcXJMLQoXhiifl5lmaap957Tpc3PO4528RyBzWP4T+lekjRl0370wEAhIw1m57wW2e6tCDUcdWaVlmxBtRSysMPYFAa5lHCk5ApmAWIbzkHX2gP7LS8JiIP310KiNGaD0EfSNI+2yBCijw0nU5up9Mpy1er+BCRPFZ8N9k9yx0I1i6OPWeOorO7kELc5jp1yn6YJ0ZO69rwDZgAACAdz/Dmx9JBxCALuUGFpNhs9D1Ub86sv8jTobxj0I4Gs5t/EiEfCFqTqXe/zpR0BotwLQ/02FkxMTn2YpnTcDPe6mLmg6e+Jhp4NJfklFxhOt5VVI9NXfjVqZfhSRW3zVklwGJF8UArQ1KUL/8aG8t4IUa5T3//DwArJ0Klac3mQ/+Wz8qQZl1hXnsFFlPegUFF+tab06eNecOlliL3kuhymmT5xJuG6+kRn5C0waNt/TnOjxlrWYqwJieL/uMqhUiJYqaSOQmWnR7s3jMkER45h049N0T3RjaR8NaFl9tARKEW72nIQO9MN2TFW1anvueKXRkItGfL3OYkGE6Phft5qlHoPhXAsARFAzVyMGEWfcdg3/eLhgjBCZrIT4MIB8pcHzzn/QEhienDhvN708w3em/dQzPRTmbk99wvFeszEcWYK2xVz2PG7jgTGnxWXqFVDGRjgElQ0KW6YsXBog0jBrGLcQBQ3SST+OiAeniwtVxj8/4rkgL7XdMkzb/V6Si6HA+M7TrTXPy8/1E21m9pX5J0bnc7B/Db4e77FjeRR8zD51UeJSlGmtqass4cboMSccjAoXm4YTPlgnXgtH5bvQ+QXHS4M5ZI+GKu2FHrNvDO5ikuUMaY5QOMdQcVCAnmV1/iaCOBzZi0NWYWsMKWN43gF5iyN25Yzo+RZQu+jbFU8F6urs2wKKyjZi5F75/6kRQI='; public HTTPResponse respond(HTTPRequest req) { HttpResponse res = new HttpResponse(); res.setHeader('X-Shopify-Access-Token', 'password@123'); res.setHeader('Content-Type', 'application/json'); req.setMethod('POST'); req.setBody( 'grant_type=refresh_token' + '&client_secret=' + clientSecretproduction + '&client_id=' + clientIdProduction + '&refresh_token=' + refreshToken); res.setStatusCode(200); return res; } } public class MockHttpResponseGeneratorTest implements HttpCalloutMock { public HTTPResponse respond(HTTPRequest req) { HttpResponse res = new HttpResponse(); res.setHeader('Content-Type', 'application/json'); res.setHeader('X-Shopify-Access-Token', 'Password123True'); res.setBody('{"access_scopes": [{"handle": "scope1"}, {"handle": "scope2"}]}'); res.setStatusCode(200); req.setTimeout(120000); req.setMethod('GET'); req.setEndpoint('Shopify' + '/admin/oauth/access_scopes.json'); // Remove or comment out the following line // req.setClientCertificateName('Shopify'); return res; } } }