{"action":"created","comment":{"url":"https://api.github.com/repos/mulesoft/mule/pulls/comments/52772707","id":52772707,"diff_hunk":"@@ -0,0 +1,194 @@\n+/*\n+ * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com\n+ * The software in this package is published under the terms of the CPAL v1.0\n+ * license, a copy of which has been included with this distribution in the\n+ * LICENSE.txt file.\n+ */\n+package org.mule.functional.junit4;\n+\n+import org.mule.api.MuleContext;\n+import org.mule.api.MuleEvent;\n+import org.mule.api.MuleMessage;\n+import org.mule.api.construct.FlowConstruct;\n+\n+import java.util.Map;\n+\n+import org.mockito.Mockito;\n+\n+/**\n+ * Provides a fluent API for running events through batch FlowConstructs.\n+ * \n+ * @param <R> the runner class for a {@link FlowConstruct} implementation.\n+ */\n+public abstract class FlowConstructRunner<R extends FlowConstructRunner>\n+{\n+\n+    protected MuleContext muleContext;\n+    protected TestEventBuilder eventBuilder = new TestEventBuilder();\n+    private MuleEvent requestEvent;\n+\n+    /**\n+     * Prepares the given data to be sent as the payload of the {@link MuleEvent} to the configured flow.\n+     * \n+     * @param payload the payload to use in the message\n+     * @return this {@link FlowRunner}\n+     */\n+    public R withPayload(Object payload)\n+    {\n+        eventBuilder.withPayload(payload);\n+    \n+        return (R) this;\n+    }\n+\n+    /**\n+     * Prepares a property with the given key and value to be sent as an inbound property of the {@link MuleMessage} to\n+     * the configured flow.\n+     * \n+     * @param key the key of the inbound property to add\n+     * @param value the value of the inbound property to add\n+     * @return this {@link FlowRunner}\n+     */\n+    public R withInboundProperty(String key, Object value)\n+    {\n+        eventBuilder.withInboundProperty(key, value);\n+    \n+        return (R) this;\n+    }\n+\n+    /**\n+     * Prepares the given properties map to be sent as inbound properties of the {@link MuleMessage} to the configured\n+     * flow.\n+     * \n+     * @param properties the inbound properties to add\n+     * @return this {@link FlowRunner}\n+     */\n+    public R withInboundProperties(Map<String, Object> properties)\n+    {\n+        eventBuilder.withInboundProperties(properties);\n+    \n+        return (R) this;\n+    }\n+\n+    /**\n+     * Prepares a property with the given key and value to be sent as an outbound property of the {@link MuleMessage} to\n+     * the configured flow.\n+     * \n+     * @param key the key of the outbound property to add\n+     * @param value the value of the outbound property to add\n+     * @return this {@link FlowRunner}\n+     */\n+    public R withOutboundProperty(String key, Object value)\n+    {\n+        eventBuilder.withOutboundProperty(key, value);\n+    \n+        return (R) this;\n+    }\n+\n+    /**\n+     * Prepares a property with the given key and value to be sent as a session property of the {@link MuleMessage} to\n+     * the configured flow.\n+     * \n+     * @param key the key of the session property to add\n+     * @param value the value of the session property to add\n+     * @return this {@link FlowRunner}\n+     */\n+    public R withSessionProperty(String key, Object value)\n+    {\n+        eventBuilder.withSessionProperty(key, value);\n+    \n+        return (R) this;\n+    }\n+\n+    /**\n+     * Prepares a property with the given key and value to be sent as an invocation property of the {@link MuleMessage}\n+     * to the configured flow.\n+     * \n+     * @param key the key of the invocation property to add\n+     * @param value the value of the invocation property to add\n+     * @return this {@link FlowRunner}\n+     */\n+    public R withInvocationProperty(String key, Object value)\n+    {\n+        eventBuilder.withInvocationProperty(key, value);\n+    \n+        return (R) this;\n+    }\n+\n+    /**\n+     * Prepares a flow variable with the given key and value to be set in the {@link MuleMessage} to the configured\n+     * flow.\n+     * \n+     * @param key the key of the flow variable to put\n+     * @param value the value of the flow variable to put\n+     * @return this {@link FlowRunner}\n+     */\n+    public R withFlowVariable(String key, Object value)\n+    {\n+        eventBuilder.withFlowVariable(key, value);\n+    \n+        return (R) this;\n+    }\n+\n+    /**\n+     * Configures this runner to run this flow as one-way.\n+     * \n+     * @return this {@link FlowRunner}\n+     */\n+    public R asynchronously()\n+    {\n+        eventBuilder.asynchronously();\n+    \n+        return (R) this;\n+    }\n+\n+    /**\n+     * Will spy the built {@link MuleMessage} and {@link MuleEvent}. See {@link Mockito#spy(Object) spy}.\n+     * \n+     * @return this {@link FlowRunner}\n+     */\n+    public R spyObjects()\n+    {\n+        eventBuilder.spyObjects();\n+    \n+        return (R) this;\n+    }\n+\n+    public FlowConstructRunner(MuleContext muleContext)\n+    {\n+        this.muleContext = muleContext;\n+    }\n+\n+    /**\n+     * Builds a new event based on this runner's config. If one has already been built, it will return that one.","path":"tests/functional/src/main/java/org/mule/functional/junit4/FlowConstructRunner.java","position":162,"original_position":162,"commit_id":"71721d23a17fc8560aa36539f38e6377f76b26c2","original_commit_id":"71721d23a17fc8560aa36539f38e6377f76b26c2","user":{"login":"pablokraan","id":561399,"avatar_url":"https://avatars.githubusercontent.com/u/561399?v=3","gravatar_id":"","url":"https://api.github.com/users/pablokraan","html_url":"https://github.com/pablokraan","followers_url":"https://api.github.com/users/pablokraan/followers","following_url":"https://api.github.com/users/pablokraan/following{/other_user}","gists_url":"https://api.github.com/users/pablokraan/gists{/gist_id}","starred_url":"https://api.github.com/users/pablokraan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pablokraan/subscriptions","organizations_url":"https://api.github.com/users/pablokraan/orgs","repos_url":"https://api.github.com/users/pablokraan/repos","events_url":"https://api.github.com/users/pablokraan/events{/privacy}","received_events_url":"https://api.github.com/users/pablokraan/received_events","type":"User","site_admin":false},"body":"I don't know what are the usages for this method, but seems a bit counterintuitive that it only creates an event the first time that is invoked.","created_at":"2016-02-12T17:39:14Z","updated_at":"2016-02-12T17:39:14Z","html_url":"https://github.com/mulesoft/mule/pull/2408#discussion_r52772707","pull_request_url":"https://api.github.com/repos/mulesoft/mule/pulls/2408","_links":{"self":{"href":"https://api.github.com/repos/mulesoft/mule/pulls/comments/52772707"},"html":{"href":"https://github.com/mulesoft/mule/pull/2408#discussion_r52772707"},"pull_request":{"href":"https://api.github.com/repos/mulesoft/mule/pulls/2408"}}},"pull_request":{"url":"https://api.github.com/repos/mulesoft/mule/pulls/2408","id":59176934,"html_url":"https://github.com/mulesoft/mule/pull/2408","diff_url":"https://github.com/mulesoft/mule/pull/2408.diff","patch_url":"https://github.com/mulesoft/mule/pull/2408.patch","issue_url":"https://api.github.com/repos/mulesoft/mule/issues/2408","number":2408,"state":"open","locked":false,"title":"MULE-9378: Expand FlowRunner to support different FlowConstruct types","user":{"login":"elrodro83","id":8010105,"avatar_url":"https://avatars.githubusercontent.com/u/8010105?v=3","gravatar_id":"","url":"https://api.github.com/users/elrodro83","html_url":"https://github.com/elrodro83","followers_url":"https://api.github.com/users/elrodro83/followers","following_url":"https://api.github.com/users/elrodro83/following{/other_user}","gists_url":"https://api.github.com/users/elrodro83/gists{/gist_id}","starred_url":"https://api.github.com/users/elrodro83/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elrodro83/subscriptions","organizations_url":"https://api.github.com/users/elrodro83/orgs","repos_url":"https://api.github.com/users/elrodro83/repos","events_url":"https://api.github.com/users/elrodro83/events{/privacy}","received_events_url":"https://api.github.com/users/elrodro83/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-02-12T14:05:44Z","updated_at":"2016-02-12T17:39:14Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d08ad266a717f1a7aedd273a9beceb171f0a4344","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mulesoft/mule/pulls/2408/commits","review_comments_url":"https://api.github.com/repos/mulesoft/mule/pulls/2408/comments","review_comment_url":"https://api.github.com/repos/mulesoft/mule/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mulesoft/mule/issues/2408/comments","statuses_url":"https://api.github.com/repos/mulesoft/mule/statuses/71721d23a17fc8560aa36539f38e6377f76b26c2","head":{"label":"mulesoft:MULE-9378","ref":"MULE-9378","sha":"71721d23a17fc8560aa36539f38e6377f76b26c2","user":{"login":"mulesoft","id":185740,"avatar_url":"https://avatars.githubusercontent.com/u/185740?v=3","gravatar_id":"","url":"https://api.github.com/users/mulesoft","html_url":"https://github.com/mulesoft","followers_url":"https://api.github.com/users/mulesoft/followers","following_url":"https://api.github.com/users/mulesoft/following{/other_user}","gists_url":"https://api.github.com/users/mulesoft/gists{/gist_id}","starred_url":"https://api.github.com/users/mulesoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mulesoft/subscriptions","organizations_url":"https://api.github.com/users/mulesoft/orgs","repos_url":"https://api.github.com/users/mulesoft/repos","events_url":"https://api.github.com/users/mulesoft/events{/privacy}","received_events_url":"https://api.github.com/users/mulesoft/received_events","type":"Organization","site_admin":false},"repo":{"id":7058562,"name":"mule","full_name":"mulesoft/mule","owner":{"login":"mulesoft","id":185740,"avatar_url":"https://avatars.githubusercontent.com/u/185740?v=3","gravatar_id":"","url":"https://api.github.com/users/mulesoft","html_url":"https://github.com/mulesoft","followers_url":"https://api.github.com/users/mulesoft/followers","following_url":"https://api.github.com/users/mulesoft/following{/other_user}","gists_url":"https://api.github.com/users/mulesoft/gists{/gist_id}","starred_url":"https://api.github.com/users/mulesoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mulesoft/subscriptions","organizations_url":"https://api.github.com/users/mulesoft/orgs","repos_url":"https://api.github.com/users/mulesoft/repos","events_url":"https://api.github.com/users/mulesoft/events{/privacy}","received_events_url":"https://api.github.com/users/mulesoft/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mulesoft/mule","description":"Mule Community Edition","fork":false,"url":"https://api.github.com/repos/mulesoft/mule","forks_url":"https://api.github.com/repos/mulesoft/mule/forks","keys_url":"https://api.github.com/repos/mulesoft/mule/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mulesoft/mule/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mulesoft/mule/teams","hooks_url":"https://api.github.com/repos/mulesoft/mule/hooks","issue_events_url":"https://api.github.com/repos/mulesoft/mule/issues/events{/number}","events_url":"https://api.github.com/repos/mulesoft/mule/events","assignees_url":"https://api.github.com/repos/mulesoft/mule/assignees{/user}","branches_url":"https://api.github.com/repos/mulesoft/mule/branches{/branch}","tags_url":"https://api.github.com/repos/mulesoft/mule/tags","blobs_url":"https://api.github.com/repos/mulesoft/mule/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mulesoft/mule/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mulesoft/mule/git/refs{/sha}","trees_url":"https://api.github.com/repos/mulesoft/mule/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mulesoft/mule/statuses/{sha}","languages_url":"https://api.github.com/repos/mulesoft/mule/languages","stargazers_url":"https://api.github.com/repos/mulesoft/mule/stargazers","contributors_url":"https://api.github.com/repos/mulesoft/mule/contributors","subscribers_url":"https://api.github.com/repos/mulesoft/mule/subscribers","subscription_url":"https://api.github.com/repos/mulesoft/mule/subscription","commits_url":"https://api.github.com/repos/mulesoft/mule/commits{/sha}","git_commits_url":"https://api.github.com/repos/mulesoft/mule/git/commits{/sha}","comments_url":"https://api.github.com/repos/mulesoft/mule/comments{/number}","issue_comment_url":"https://api.github.com/repos/mulesoft/mule/issues/comments{/number}","contents_url":"https://api.github.com/repos/mulesoft/mule/contents/{+path}","compare_url":"https://api.github.com/repos/mulesoft/mule/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mulesoft/mule/merges","archive_url":"https://api.github.com/repos/mulesoft/mule/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mulesoft/mule/downloads","issues_url":"https://api.github.com/repos/mulesoft/mule/issues{/number}","pulls_url":"https://api.github.com/repos/mulesoft/mule/pulls{/number}","milestones_url":"https://api.github.com/repos/mulesoft/mule/milestones{/number}","notifications_url":"https://api.github.com/repos/mulesoft/mule/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mulesoft/mule/labels{/name}","releases_url":"https://api.github.com/repos/mulesoft/mule/releases{/id}","deployments_url":"https://api.github.com/repos/mulesoft/mule/deployments","created_at":"2012-12-07T19:23:06Z","updated_at":"2016-02-09T07:31:19Z","pushed_at":"2016-02-12T16:52:29Z","git_url":"git://github.com/mulesoft/mule.git","ssh_url":"git@github.com:mulesoft/mule.git","clone_url":"https://github.com/mulesoft/mule.git","svn_url":"https://github.com/mulesoft/mule","homepage":null,"size":220099,"stargazers_count":276,"watchers_count":276,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":318,"mirror_url":null,"open_issues_count":19,"forks":318,"open_issues":19,"watchers":276,"default_branch":"mule-3.x"}},"base":{"label":"mulesoft:mule-4.x","ref":"mule-4.x","sha":"1b81ddffc7e8a3f6614c617b93bac693ee41a5c9","user":{"login":"mulesoft","id":185740,"avatar_url":"https://avatars.githubusercontent.com/u/185740?v=3","gravatar_id":"","url":"https://api.github.com/users/mulesoft","html_url":"https://github.com/mulesoft","followers_url":"https://api.github.com/users/mulesoft/followers","following_url":"https://api.github.com/users/mulesoft/following{/other_user}","gists_url":"https://api.github.com/users/mulesoft/gists{/gist_id}","starred_url":"https://api.github.com/users/mulesoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mulesoft/subscriptions","organizations_url":"https://api.github.com/users/mulesoft/orgs","repos_url":"https://api.github.com/users/mulesoft/repos","events_url":"https://api.github.com/users/mulesoft/events{/privacy}","received_events_url":"https://api.github.com/users/mulesoft/received_events","type":"Organization","site_admin":false},"repo":{"id":7058562,"name":"mule","full_name":"mulesoft/mule","owner":{"login":"mulesoft","id":185740,"avatar_url":"https://avatars.githubusercontent.com/u/185740?v=3","gravatar_id":"","url":"https://api.github.com/users/mulesoft","html_url":"https://github.com/mulesoft","followers_url":"https://api.github.com/users/mulesoft/followers","following_url":"https://api.github.com/users/mulesoft/following{/other_user}","gists_url":"https://api.github.com/users/mulesoft/gists{/gist_id}","starred_url":"https://api.github.com/users/mulesoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mulesoft/subscriptions","organizations_url":"https://api.github.com/users/mulesoft/orgs","repos_url":"https://api.github.com/users/mulesoft/repos","events_url":"https://api.github.com/users/mulesoft/events{/privacy}","received_events_url":"https://api.github.com/users/mulesoft/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mulesoft/mule","description":"Mule Community Edition","fork":false,"url":"https://api.github.com/repos/mulesoft/mule","forks_url":"https://api.github.com/repos/mulesoft/mule/forks","keys_url":"https://api.github.com/repos/mulesoft/mule/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mulesoft/mule/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mulesoft/mule/teams","hooks_url":"https://api.github.com/repos/mulesoft/mule/hooks","issue_events_url":"https://api.github.com/repos/mulesoft/mule/issues/events{/number}","events_url":"https://api.github.com/repos/mulesoft/mule/events","assignees_url":"https://api.github.com/repos/mulesoft/mule/assignees{/user}","branches_url":"https://api.github.com/repos/mulesoft/mule/branches{/branch}","tags_url":"https://api.github.com/repos/mulesoft/mule/tags","blobs_url":"https://api.github.com/repos/mulesoft/mule/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mulesoft/mule/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mulesoft/mule/git/refs{/sha}","trees_url":"https://api.github.com/repos/mulesoft/mule/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mulesoft/mule/statuses/{sha}","languages_url":"https://api.github.com/repos/mulesoft/mule/languages","stargazers_url":"https://api.github.com/repos/mulesoft/mule/stargazers","contributors_url":"https://api.github.com/repos/mulesoft/mule/contributors","subscribers_url":"https://api.github.com/repos/mulesoft/mule/subscribers","subscription_url":"https://api.github.com/repos/mulesoft/mule/subscription","commits_url":"https://api.github.com/repos/mulesoft/mule/commits{/sha}","git_commits_url":"https://api.github.com/repos/mulesoft/mule/git/commits{/sha}","comments_url":"https://api.github.com/repos/mulesoft/mule/comments{/number}","issue_comment_url":"https://api.github.com/repos/mulesoft/mule/issues/comments{/number}","contents_url":"https://api.github.com/repos/mulesoft/mule/contents/{+path}","compare_url":"https://api.github.com/repos/mulesoft/mule/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mulesoft/mule/merges","archive_url":"https://api.github.com/repos/mulesoft/mule/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mulesoft/mule/downloads","issues_url":"https://api.github.com/repos/mulesoft/mule/issues{/number}","pulls_url":"https://api.github.com/repos/mulesoft/mule/pulls{/number}","milestones_url":"https://api.github.com/repos/mulesoft/mule/milestones{/number}","notifications_url":"https://api.github.com/repos/mulesoft/mule/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mulesoft/mule/labels{/name}","releases_url":"https://api.github.com/repos/mulesoft/mule/releases{/id}","deployments_url":"https://api.github.com/repos/mulesoft/mule/deployments","created_at":"2012-12-07T19:23:06Z","updated_at":"2016-02-09T07:31:19Z","pushed_at":"2016-02-12T16:52:29Z","git_url":"git://github.com/mulesoft/mule.git","ssh_url":"git@github.com:mulesoft/mule.git","clone_url":"https://github.com/mulesoft/mule.git","svn_url":"https://github.com/mulesoft/mule","homepage":null,"size":220099,"stargazers_count":276,"watchers_count":276,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":318,"mirror_url":null,"open_issues_count":19,"forks":318,"open_issues":19,"watchers":276,"default_branch":"mule-3.x"}},"_links":{"self":{"href":"https://api.github.com/repos/mulesoft/mule/pulls/2408"},"html":{"href":"https://github.com/mulesoft/mule/pull/2408"},"issue":{"href":"https://api.github.com/repos/mulesoft/mule/issues/2408"},"comments":{"href":"https://api.github.com/repos/mulesoft/mule/issues/2408/comments"},"review_comments":{"href":"https://api.github.com/repos/mulesoft/mule/pulls/2408/comments"},"review_comment":{"href":"https://api.github.com/repos/mulesoft/mule/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mulesoft/mule/pulls/2408/commits"},"statuses":{"href":"https://api.github.com/repos/mulesoft/mule/statuses/71721d23a17fc8560aa36539f38e6377f76b26c2"}}}}