204 lines
12 KiB
OpenEdge ABL
204 lines
12 KiB
OpenEdge ABL
@istest
|
|
public class AuthenticateAllapexclass_Test {
|
|
@isTest
|
|
static void TestAuthenticateAllclass(){
|
|
HIC_ShopifySync__Configuration__c col = new HIC_ShopifySync__Configuration__c();
|
|
col.Name = 'Default';
|
|
insert col;
|
|
|
|
Test.startTest();
|
|
Restrequest authenticationReq0 = new Restrequest();
|
|
authenticationReq0.requestBody = Blob.valueOf('{ "HIC_ShopifySync__Refresh_Token__c" : "hgfghjhkfdsgfhgjkhdfssgffh" }');
|
|
Restresponse authenticationRes0 = new Restresponse();
|
|
authenticationReq0.requestURI = 'https://hic-sf-shopify-developer-edition.ap15.force.com/services/apexrest/HIC_ShopifySync/AuthenticateAllApexClass';
|
|
authenticationReq0.httpMethod = 'POST';
|
|
authenticationReq0.addParameter('objectname', 'UpdateRefreshToken');
|
|
authenticationReq0.addParameter('DMLType', 'Update');
|
|
|
|
RestContext.request = authenticationReq0;
|
|
RestContext.response= authenticationRes0 ;
|
|
authenticationRes0.statusCode = 200;
|
|
AuthenticateAllapexClass.AuthenticateClass();
|
|
|
|
Restrequest authenticationReq = new Restrequest();
|
|
authenticationReq.requestBody = Blob.valueOf('{ "HIC_ShopifySync__Refresh_Token__c" : "hgfghjhkfdsgfhgjkhdfssgffh" }');
|
|
Restresponse authenticationRes = new Restresponse();
|
|
authenticationReq.requestURI = 'https://hic-sf-shopify-developer-edition.ap15.force.com/services/apexrest/HIC_ShopifySync/AuthenticateAllApexClass';
|
|
authenticationReq.httpMethod = 'POST';
|
|
authenticationReq.addParameter('objectname', 'Customer');
|
|
authenticationReq.addParameter('DMLType', 'Update');
|
|
|
|
RestContext.request = authenticationReq;
|
|
RestContext.response= authenticationRes ;
|
|
authenticationRes.statusCode = 200;
|
|
|
|
AuthenticateAllapexClass.AuthenticateClass();
|
|
system.assertEquals(200, authenticationRes.statusCode);
|
|
|
|
Restrequest authenticationReq1 = new Restrequest();
|
|
authenticationReq1.requestBody = Blob.valueOf('{ "HIC_ShopifySync__Refresh_Token__c" : "hgfghjhkfdsgfhgjkhdfssgffh" }');
|
|
Restresponse authenticationRes1 = new Restresponse();
|
|
authenticationReq1.requestURI = 'https://hic-sf-shopify-developer-edition.ap15.force.com/services/apexrest/HIC_ShopifySync/AuthenticateAllApexClass';
|
|
authenticationReq1.httpMethod = 'POST';
|
|
authenticationReq1.addParameter('objectname', 'Customer');
|
|
authenticationReq1.addParameter('DMLType', 'Delete');
|
|
|
|
RestContext.request = authenticationReq1;
|
|
RestContext.response= authenticationRes ;
|
|
authenticationRes.statusCode = 200;
|
|
|
|
AuthenticateAllapexClass.AuthenticateClass();
|
|
system.assertEquals(200, authenticationRes.statusCode);
|
|
|
|
Restrequest authenticationReq2 = new Restrequest();
|
|
authenticationReq2.requestBody = Blob.valueOf('{ "HIC_ShopifySync__Refresh_Token__c" : "hgfghjhkfdsgfhgjkhdfssgffh" }');
|
|
Restresponse authenticationRes2 = new Restresponse();
|
|
authenticationReq2.requestURI = 'https://hic-sf-shopify-developer-edition.ap15.force.com/services/apexrest/HIC_ShopifySync/AuthenticateAllApexClass';
|
|
authenticationReq2.httpMethod = 'POST';
|
|
authenticationReq2.addParameter('objectname', 'Product2');
|
|
authenticationReq2.addParameter('DMLType', 'Delete');
|
|
|
|
RestContext.request = authenticationReq2;
|
|
RestContext.response= authenticationRes ;
|
|
authenticationRes.statusCode = 200;
|
|
|
|
AuthenticateAllapexClass.AuthenticateClass();
|
|
|
|
Restrequest authenticationReq3 = new Restrequest();
|
|
authenticationReq3.requestBody = Blob.valueOf('{ "HIC_ShopifySync__Refresh_Token__c" : "hgfghjhkfdsgfhgjkhdfssgffh" }');
|
|
Restresponse authenticationRes3 = new Restresponse();
|
|
authenticationReq3.requestURI = 'https://hic-sf-shopify-developer-edition.ap15.force.com/services/apexrest/HIC_ShopifySync/AuthenticateAllApexClass';
|
|
authenticationReq3.httpMethod = 'POST';
|
|
authenticationReq3.addParameter('objectname', 'Product2');
|
|
authenticationReq3.addParameter('DMLType', 'Update');
|
|
|
|
RestContext.request = authenticationReq3;
|
|
RestContext.response= authenticationRes ;
|
|
authenticationRes.statusCode = 200;
|
|
|
|
AuthenticateAllapexClass.AuthenticateClass();
|
|
|
|
Restrequest authenticationReq4 = new Restrequest();
|
|
authenticationReq4.requestBody = Blob.valueOf('{ "HIC_ShopifySync__Refresh_Token__c" : "hgfghjhkfdsgfhgjkhdfssgffh" }');
|
|
Restresponse authenticationRes4 = new Restresponse();
|
|
authenticationReq4.requestURI = 'https://hic-sf-shopify-developer-edition.ap15.force.com/services/apexrest/HIC_ShopifySync/AuthenticateAllApexClass';
|
|
authenticationReq4.httpMethod = 'POST';
|
|
authenticationReq4.addParameter('objectname', 'Order');
|
|
authenticationReq4.addParameter('DMLType', 'Create');
|
|
|
|
RestContext.request = authenticationReq4;
|
|
RestContext.response= authenticationRes4 ;
|
|
authenticationRes.statusCode = 200;
|
|
AuthenticateAllapexClass.AuthenticateClass();
|
|
|
|
Restrequest authenticationReq5 = new Restrequest();
|
|
authenticationReq5.requestBody = Blob.valueOf('{ "HIC_ShopifySync__Refresh_Token__c" : "hgfghjhkfdsgfhgjkhdfssgffh" }');
|
|
Restresponse authenticationRes5 = new Restresponse();
|
|
authenticationReq5.requestURI = 'https://hic-sf-shopify-developer-edition.ap15.force.com/services/apexrest/HIC_ShopifySync/AuthenticateAllApexClass';
|
|
authenticationReq5.httpMethod = 'POST';
|
|
authenticationReq5.addParameter('objectname', 'Order');
|
|
authenticationReq5.addParameter('DMLType', 'Delete');
|
|
|
|
RestContext.request = authenticationReq5;
|
|
RestContext.response= authenticationRes5 ;
|
|
authenticationRes.statusCode = 200;
|
|
AuthenticateAllapexClass.AuthenticateClass();
|
|
|
|
|
|
Restrequest authenticationReq6 = new Restrequest();
|
|
authenticationReq6.requestBody = Blob.valueOf('{ "HIC_ShopifySync__Refresh_Token__c" : "hgfghjhkfdsgfhgjkhdfssgffh" }');
|
|
Restresponse authenticationRes6 = new Restresponse();
|
|
authenticationReq6.requestURI = 'https://hic-sf-shopify-developer-edition.ap15.force.com/services/apexrest/HIC_ShopifySync/AuthenticateAllApexClass';
|
|
authenticationReq6.httpMethod = 'POST';
|
|
authenticationReq6.addParameter('objectname', 'HIC_ShopifySync__Collection__c');
|
|
authenticationReq6.addParameter('DMLType', 'Delete');
|
|
|
|
RestContext.request = authenticationReq6;
|
|
RestContext.response= authenticationRes ;
|
|
authenticationRes.statusCode = 200;
|
|
AuthenticateAllapexClass.AuthenticateClass();
|
|
|
|
|
|
Restrequest authenticationReq7 = new Restrequest();
|
|
authenticationReq7.requestBody = Blob.valueOf('{ "HIC_ShopifySync__Refresh_Token__c" : "hgfghjhkfdsgfhgjkhdfssgffh" }');
|
|
Restresponse authenticationRes7 = new Restresponse();
|
|
authenticationReq7.requestURI = 'https://hic-sf-shopify-developer-edition.ap15.force.com/services/apexrest/HIC_ShopifySync/AuthenticateAllApexClass';
|
|
authenticationReq7.httpMethod = 'POST';
|
|
authenticationReq7.addParameter('objectname', 'HIC_ShopifySync__Collection__c');
|
|
authenticationReq7.addParameter('DMLType', 'Update');
|
|
|
|
RestContext.request = authenticationReq7;
|
|
RestContext.response= authenticationRes ;
|
|
authenticationRes.statusCode = 200;
|
|
AuthenticateAllapexClass.AuthenticateClass();
|
|
|
|
|
|
Restrequest authenticationReq8 = new Restrequest();
|
|
authenticationReq8.requestBody = Blob.valueOf('{ "HIC_ShopifySync__Refresh_Token__c" : "hgfghjhkfdsgfhgjkhdfssgffh" }');
|
|
Restresponse authenticationRes8 = new Restresponse();
|
|
authenticationReq8.requestURI = 'https://hic-sf-shopify-developer-edition.ap15.force.com/services/apexrest/HIC_ShopifySync/AuthenticateAllApexClass';
|
|
authenticationReq8.httpMethod = 'POST';
|
|
authenticationReq8.addParameter('objectname', 'HIC_ShopifySync__Inventory_Level__c');
|
|
authenticationReq8.addParameter('DMLType', 'Update');
|
|
|
|
RestContext.request = authenticationReq8;
|
|
RestContext.response= authenticationRes8 ;
|
|
authenticationRes8.statusCode = 200;
|
|
AuthenticateAllapexClass.AuthenticateClass();
|
|
|
|
|
|
Restrequest authenticationReq9 = new Restrequest();
|
|
authenticationReq9.requestBody = Blob.valueOf('{ "HIC_ShopifySync__Refresh_Token__c" : "hgfghjhkfdsgfhgjkhdfssgffh" }');
|
|
Restresponse authenticationRes9 = new Restresponse();
|
|
authenticationReq9.requestURI = 'https://hic-sf-shopify-developer-edition.ap15.force.com/services/apexrest/HIC_ShopifySync/AuthenticateAllApexClass';
|
|
authenticationReq9.httpMethod = 'POST';
|
|
authenticationReq9.addParameter('objectname', 'HIC_ShopifySync__Inventory_Level__c');
|
|
authenticationReq9.addParameter('DMLType', 'Delete');
|
|
|
|
RestContext.request = authenticationReq9;
|
|
RestContext.response= authenticationRes9 ;
|
|
authenticationRes9.statusCode = 200;
|
|
AuthenticateAllapexClass.AuthenticateClass();
|
|
|
|
Restrequest authenticationReq10 = new Restrequest();
|
|
authenticationReq10.requestBody = Blob.valueOf('{ "HIC_ShopifySync__Refresh_Token__c" : "hgfghjhkfdsgfhgjkhdfssgffh" }');
|
|
Restresponse authenticationRes10 = new Restresponse();
|
|
authenticationReq10.requestURI = 'https://hic-sf-shopify-developer-edition.ap15.force.com/services/apexrest/HIC_ShopifySync/AuthenticateAllApexClass';
|
|
authenticationReq10.httpMethod = 'POST';
|
|
authenticationReq10.addParameter('objectname', 'DraftOrder');
|
|
authenticationReq10.addParameter('DMLType', 'Delete');
|
|
|
|
RestContext.request = authenticationReq10;
|
|
RestContext.response= authenticationRes10 ;
|
|
authenticationRes10.statusCode = 200;
|
|
AuthenticateAllapexClass.AuthenticateClass();
|
|
|
|
|
|
Restrequest authenticationReq11 = new Restrequest();
|
|
authenticationReq11.requestBody = Blob.valueOf('{ "HIC_ShopifySync__Refresh_Token__c" : "hgfghjhkfdsgfhgjkhdfssgffh" }');
|
|
Restresponse authenticationRes11 = new Restresponse();
|
|
authenticationReq11.requestURI = 'https://hic-sf-shopify-developer-edition.ap15.force.com/services/apexrest/HIC_ShopifySync/AuthenticateAllApexClass';
|
|
authenticationReq11.httpMethod = 'POST';
|
|
authenticationReq11.addParameter('objectname', 'DraftOrder');
|
|
authenticationReq11.addParameter('DMLType', 'Update');
|
|
|
|
RestContext.request = authenticationReq11;
|
|
RestContext.response= authenticationRes11 ;
|
|
authenticationRes11.statusCode = 200;
|
|
|
|
AuthenticateAllapexClass.AuthenticateClass();
|
|
|
|
|
|
String JSONResponse = '{"access_token":"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","store_url":"https://hicshopifymadeeasy-dev-ed.my.salesforce-sites.com"}';
|
|
|
|
AuthenticateAllapexClass.updateAccesstoken(JSONResponse);
|
|
|
|
/*RestRequest request = RestContext.request;
|
|
RestResponse response = RestContext.response;
|
|
String JSONResponse;
|
|
JSONResponse = request.requestBody.toString().trim();
|
|
AuthenticateAllapexClass.updateAccesstoken(JSONResponse);*/
|
|
system.assertEquals(200, authenticationRes11.statusCode);
|
|
Test.stopTest();
|
|
}
|
|
} |