@isTest public with sharing class Updatelocation_Test { @isTest public static void UpdatelocationTesting() { CustomSettingRecordInsert.InsertingConfiguration(); CustomSettingRecordInsert.InsertingWebhook(); HIC_ShopifySync__Location__c loc = new HIC_ShopifySync__Location__c(); loc.name = 'noida'; loc.HIC_ShopifySync__Shopify_Id__c = '36702486587'; insert loc; Restrequest authenticationReq = new Restrequest(); authenticationReq.requestBody = Blob.valueOf('{ "id": 36702486587, "name": "america", "address1": "america addddddddd", "address2": "america", "city": "America", "zip": "130024", "province": "AN", "country": "IN", "phone": "+917894561267", "created_at": "2020-01-10T13:13:49+05:30", "updated_at": "2020-01-15T18:41:27+05:30", "country_code": "IN", "country_name": "India", "province_code": "AN", "legacy": false, "active": true, "admin_graphql_api_id": "gid" }'); Restresponse authenticationRes = new Restresponse(); authenticationReq.requestURI = 'https://hicsfshopify-developer-edition.ap4.force.com/services/apexrest/HIC_ShopifySync/UpdateLocationFromShopify'; authenticationReq.httpMethod = 'POST'; RestContext.request = authenticationReq; RestContext.response= authenticationRes ; authenticationRes.statusCode = 200; UpdateLocationFromShopify.updatelocation(); System.assertequals(200, authenticationRes.statuscode); } @isTest public static void Deletelocation(){ HIC_ShopifySync__Location__c loc = new HIC_ShopifySync__Location__c(); loc.name = 'noida'; loc.HIC_ShopifySync__Shopify_Id__c = '367024865875'; insert loc; Restrequest authenticationReq = new Restrequest(); authenticationReq.requestBody = Blob.valueOf('{ "id": 367024865875 }'); Restresponse authenticationRes = new Restresponse(); authenticationReq.requestURI = 'https://hicsfshopify-developer-edition.ap4.force.com/services/apexrest/HIC_ShopifySync/DeleteLocationFromShopify'; authenticationReq.httpMethod = 'POST'; RestContext.request = authenticationReq; RestContext.response= authenticationRes ; authenticationRes.statusCode = 200; DeleteLocationFromShopify.DeleteLocation(); System.assertequals(200, authenticationRes.statuscode); } @isTest public static void Batchfordeletelogs(){ HIC_ShopifySync__Shopify_Log__c slog = new HIC_ShopifySync__Shopify_Log__c(); slog.Name = 'logs'; slog.HIC_ShopifySync__Error_id__c = '132313131account'; insert slog; Datetime yesterday = Datetime.now().addDays(-40); Test.setCreatedDate(slog.Id, yesterday); database.executeBatch(new BatchtodeletelogsNew(),1); System.assertequals('logs', slog.Name); } @isTest public static void BatchFordeletlogs_ScheduleClass_Test(){ Test.startTest(); BatchFordeletlogs_ScheduleClass bs = new BatchFordeletlogs_ScheduleClass(); String sch = '0 0 23 * * ?'; system.schedule('Test BatchFordeletlogs_ScheduleClass', sch, bs); System.assert(true,true); Test.stopTest(); } @isTest static void test_getFieldValue() { // Create a test Account Account acc = new Account(Name = 'Test Account'); insert acc; // Re-query to ensure field values are available acc = [SELECT Id, Name FROM Account WHERE Id = :acc.Id]; // 1️⃣ Simple field access Object val1 = EmailErrorCSV.getFieldValue(acc, 'Name'); System.assertEquals('Test Account', val1, 'Should return direct field value'); // 4️⃣ Null object handling Account emptyAcc = new Account(); Object val4 =EmailErrorCSV.getFieldValue(emptyAcc, 'Name'); System.assertEquals(null, val4, 'Should return null for null field'); } }