You need to sign in to do that
Don't have an account?
MikeCamp
How do I Assert in a CanvasLifecycleHandler test class
I have a CanvasLifecycleHandler thst rewrites the url with a timeStamp. Is it possible to assert in the test class that the url has been changed? If so, how?
CanvasLifecycleHandler
CanvasLifecycleHandler
public class CANV_LIFECYCLE_Registration implements Canvas.CanvasLifecycleHandler { public Set<Canvas.ContextTypeEnum> excludeContextTypes(){ Set<Canvas.ContextTypeEnum> excluded = new Set<Canvas.ContextTypeEnum>(); return excluded; } public void onRender(Canvas.RenderContext renderContext) { Canvas.ApplicationContext app = renderContext.getApplicationContext(); // get urlpath from canvas app string newURL = getURLPath(app.getCanvasUrl()); //add random string to prevent caching newURL += '?R='+ DateTime.now().gettime(); //update the url app.setCanvasUrlPath(newURL); } private string getURLPath(string canvasURL){ String[] URLList = canvasUrl.split('/'); string URLPath = ''; for(Integer a = 3; a < URLList.size(); a++){ URLPath += '/' + URLList[a]; } return URLPath; } }What I have so far for Test Class (strait from docs here (https://developer.salesforce.com/docs/atlas.en-us.platform_connect.meta/platform_connect/canvas_testing_your_canvaslifecyclehandler.htm))
@isTest private class CANV_LIFECYCLE_Registration_TEST { static testMethod void testDefaultMockValues(){ // Test handler using the default mock RenderContext Canvas.Test creates CANV_LIFECYCLE_Registration handler = new CANV_LIFECYCLE_Registration(); Canvas.Test.testCanvasLifecycle(handler,null); } }
I'm basing that information off this method being available in the documentation: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_canvas_ApplicationContext_getCanvasUrl.htm
All Answers
I'm basing that information off this method being available in the documentation: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_canvas_ApplicationContext_getCanvasUrl.htm