{"action":"created","comment":{"url":"https://api.github.com/repos/opensecuritycontroller/osc-core/pulls/comments/142242957","pull_request_review_id":66577129,"id":142242957,"diff_hunk":"@@ -16,17 +16,170 @@\n  *******************************************************************************/\n package org.osc.core.broker.service.tasks.conformance.openstack.sfc;\n \n-import static org.junit.Assert.fail;\n+import static org.junit.Assert.assertEquals;\n+import static org.junit.Assert.assertNull;\n+import static org.mockito.Matchers.any;\n+import static org.mockito.Matchers.argThat;\n+import static org.mockito.Mockito.mock;\n \n-import org.junit.Ignore;\n+import java.util.ArrayList;\n+import java.util.List;\n+\n+import javax.persistence.EntityManager;\n+import javax.persistence.EntityTransaction;\n+\n+import org.junit.Before;\n+import org.junit.Rule;\n import org.junit.Test;\n+import org.junit.rules.ExpectedException;\n+import org.junit.runner.RunWith;\n+import org.mockito.Answers;\n+import org.mockito.ArgumentCaptor;\n+import org.mockito.Captor;\n+import org.mockito.InjectMocks;\n+import org.mockito.Mock;\n+import org.mockito.Mockito;\n+import org.mockito.MockitoAnnotations;\n+import org.mockito.runners.MockitoJUnitRunner;\n+import org.osc.core.broker.model.entities.virtualization.SecurityGroup;\n+import org.osc.core.broker.model.entities.virtualization.ServiceFunctionChain;\n+import org.osc.core.broker.model.entities.virtualization.VirtualizationConnector;\n+import org.osc.core.broker.model.plugin.ApiFactoryService;\n+import org.osc.core.broker.model.sdn.NetworkElementImpl;\n+import org.osc.core.broker.util.TransactionalBroadcastUtil;\n+import org.osc.core.broker.util.db.DBConnectionManager;\n+import org.osc.core.test.util.TestTransactionControl;\n+import org.osc.core.test.util.mockito.matchers.NetworkElementIdMatcher;\n+import org.osc.sdk.controller.api.SdnRedirectionApi;\n+import org.osc.sdk.controller.element.NetworkElement;\n \n-@Ignore\n+@RunWith(MockitoJUnitRunner.class)\n public class UpdateServiceFunctionChainTaskTest {\n \n+    @Rule\n+    public ExpectedException exception = ExpectedException.none();\n+\n+    @Mock\n+    private EntityManager em;\n+\n+    @Mock\n+    private EntityTransaction tx;\n+\n+    @Mock(answer = Answers.CALLS_REAL_METHODS)\n+    private TestTransactionControl txControl;\n+\n+    @Mock\n+    private DBConnectionManager dbMgr;\n+\n+    @Mock\n+    private TransactionalBroadcastUtil txBroadcastUtil;\n+\n+    @Mock\n+    private ApiFactoryService apiFactoryServiceMock;\n+\n+    @Mock\n+    private SdnRedirectionApi sdnApi;\n+\n+    @Captor\n+    private ArgumentCaptor<List<NetworkElement>> neListCaptor;\n+\n+    @InjectMocks\n+    private UpdateServiceFunctionChainTask task;\n+\n+    private SecurityGroup sg;\n+    private ServiceFunctionChain sfc;\n+    private List<NetworkElement> networkElementList;\n+\n+    @Before\n+    public void testInitialize() throws Exception {\n+        MockitoAnnotations.initMocks(this);\n+\n+        Mockito.when(this.em.getTransaction()).thenReturn(this.tx);\n+\n+        this.txControl.setEntityManager(this.em);\n+\n+        Mockito.when(this.dbMgr.getTransactionalEntityManager()).thenReturn(this.em);\n+        Mockito.when(this.dbMgr.getTransactionControl()).thenReturn(this.txControl);\n+\n+        VirtualizationConnector mockVc = mock(VirtualizationConnector.class);\n+        this.sg = new SecurityGroup(mockVc, \"PROJECT_ID\", \"PROJECT_NAME\");\n+        this.sg.setId(2L);\n+        this.sg.setName(\"A_SECURITY_GROUP\");\n+\n+        Mockito.when(this.em.find(SecurityGroup.class, this.sg.getId())).thenReturn(this.sg);\n+\n+        this.sfc = new ServiceFunctionChain();\n+        this.sfc.setId(3L);\n+        this.sfc.setName(\"A_SFC_NAME\");\n+\n+        Mockito.when(this.em.find(ServiceFunctionChain.class, this.sfc.getId())).thenReturn(this.sfc);\n+\n+        Mockito.when(this.apiFactoryServiceMock.createNetworkRedirectionApi(mockVc)).thenReturn(this.sdnApi);\n+\n+    }\n+\n     @Test\n-    public void test() {\n-        fail(\"Not yet implemented\");\n+    public void testExecuteTransaction_WithSecurityGroupSFCIdSetToNull_ExpectUpdate() throws Exception {\n+        // Arrange\n+        UpdateServiceFunctionChainTask updateTask = this.task.create(this.sfc, this.sg, this.networkElementList);\n+        Mockito.when(this.sdnApi\n+                .updateNetworkElement(argThat(new NetworkElementIdMatcher(this.sg.getNetworkElementId())), any()))\n+                .thenReturn(new NetworkElementImpl(\"UPDATED_SFC_ID\"));\n+\n+        assertNull(this.sg.getNetworkElementId());","path":"osc-server/src/test/java/org/osc/core/broker/service/tasks/conformance/openstack/sfc/UpdateServiceFunctionChainTaskTest.java","position":119,"original_position":119,"commit_id":"b2899faa860b059fcd41735e0ed34b3ee8e8afd4","original_commit_id":"b2899faa860b059fcd41735e0ed34b3ee8e8afd4","user":{"login":"arvindn05","id":7297623,"avatar_url":"https://avatars2.githubusercontent.com/u/7297623?v=4","gravatar_id":"","url":"https://api.github.com/users/arvindn05","html_url":"https://github.com/arvindn05","followers_url":"https://api.github.com/users/arvindn05/followers","following_url":"https://api.github.com/users/arvindn05/following{/other_user}","gists_url":"https://api.github.com/users/arvindn05/gists{/gist_id}","starred_url":"https://api.github.com/users/arvindn05/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arvindn05/subscriptions","organizations_url":"https://api.github.com/users/arvindn05/orgs","repos_url":"https://api.github.com/users/arvindn05/repos","events_url":"https://api.github.com/users/arvindn05/events{/privacy}","received_events_url":"https://api.github.com/users/arvindn05/received_events","type":"User","site_admin":false},"body":"making sure that the task execution actually updates a null field...if something does change in the testInitialize we are making sure the update still happens correctly","created_at":"2017-10-02T20:15:42Z","updated_at":"2017-10-02T20:15:42Z","html_url":"https://github.com/opensecuritycontroller/osc-core/pull/506#discussion_r142242957","pull_request_url":"https://api.github.com/repos/opensecuritycontroller/osc-core/pulls/506","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/opensecuritycontroller/osc-core/pulls/comments/142242957"},"html":{"href":"https://github.com/opensecuritycontroller/osc-core/pull/506#discussion_r142242957"},"pull_request":{"href":"https://api.github.com/repos/opensecuritycontroller/osc-core/pulls/506"}},"in_reply_to_id":142034987},"pull_request":{"url":"https://api.github.com/repos/opensecuritycontroller/osc-core/pulls/506","id":144000047,"html_url":"https://github.com/opensecuritycontroller/osc-core/pull/506","diff_url":"https://github.com/opensecuritycontroller/osc-core/pull/506.diff","patch_url":"https://github.com/opensecuritycontroller/osc-core/pull/506.patch","issue_url":"https://api.github.com/repos/opensecuritycontroller/osc-core/issues/506","number":506,"state":"open","locked":false,"title":"Update sfc task and unit test","user":{"login":"arvindn05","id":7297623,"avatar_url":"https://avatars2.githubusercontent.com/u/7297623?v=4","gravatar_id":"","url":"https://api.github.com/users/arvindn05","html_url":"https://github.com/arvindn05","followers_url":"https://api.github.com/users/arvindn05/followers","following_url":"https://api.github.com/users/arvindn05/following{/other_user}","gists_url":"https://api.github.com/users/arvindn05/gists{/gist_id}","starred_url":"https://api.github.com/users/arvindn05/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arvindn05/subscriptions","organizations_url":"https://api.github.com/users/arvindn05/orgs","repos_url":"https://api.github.com/users/arvindn05/repos","events_url":"https://api.github.com/users/arvindn05/events{/privacy}","received_events_url":"https://api.github.com/users/arvindn05/received_events","type":"User","site_admin":false},"body":"","created_at":"2017-09-29T23:36:14Z","updated_at":"2017-10-02T20:15:42Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2d2f59df30fb7761455701f336c34521269c1b18","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/opensecuritycontroller/osc-core/pulls/506/commits","review_comments_url":"https://api.github.com/repos/opensecuritycontroller/osc-core/pulls/506/comments","review_comment_url":"https://api.github.com/repos/opensecuritycontroller/osc-core/pulls/comments{/number}","comments_url":"https://api.github.com/repos/opensecuritycontroller/osc-core/issues/506/comments","statuses_url":"https://api.github.com/repos/opensecuritycontroller/osc-core/statuses/b2899faa860b059fcd41735e0ed34b3ee8e8afd4","head":{"label":"arvindn05:update-sfc","ref":"update-sfc","sha":"b2899faa860b059fcd41735e0ed34b3ee8e8afd4","user":{"login":"arvindn05","id":7297623,"avatar_url":"https://avatars2.githubusercontent.com/u/7297623?v=4","gravatar_id":"","url":"https://api.github.com/users/arvindn05","html_url":"https://github.com/arvindn05","followers_url":"https://api.github.com/users/arvindn05/followers","following_url":"https://api.github.com/users/arvindn05/following{/other_user}","gists_url":"https://api.github.com/users/arvindn05/gists{/gist_id}","starred_url":"https://api.github.com/users/arvindn05/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arvindn05/subscriptions","organizations_url":"https://api.github.com/users/arvindn05/orgs","repos_url":"https://api.github.com/users/arvindn05/repos","events_url":"https://api.github.com/users/arvindn05/events{/privacy}","received_events_url":"https://api.github.com/users/arvindn05/received_events","type":"User","site_admin":false},"repo":{"id":95853862,"name":"osc-core","full_name":"arvindn05/osc-core","owner":{"login":"arvindn05","id":7297623,"avatar_url":"https://avatars2.githubusercontent.com/u/7297623?v=4","gravatar_id":"","url":"https://api.github.com/users/arvindn05","html_url":"https://github.com/arvindn05","followers_url":"https://api.github.com/users/arvindn05/followers","following_url":"https://api.github.com/users/arvindn05/following{/other_user}","gists_url":"https://api.github.com/users/arvindn05/gists{/gist_id}","starred_url":"https://api.github.com/users/arvindn05/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arvindn05/subscriptions","organizations_url":"https://api.github.com/users/arvindn05/orgs","repos_url":"https://api.github.com/users/arvindn05/repos","events_url":"https://api.github.com/users/arvindn05/events{/privacy}","received_events_url":"https://api.github.com/users/arvindn05/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/arvindn05/osc-core","description":null,"fork":true,"url":"https://api.github.com/repos/arvindn05/osc-core","forks_url":"https://api.github.com/repos/arvindn05/osc-core/forks","keys_url":"https://api.github.com/repos/arvindn05/osc-core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/arvindn05/osc-core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/arvindn05/osc-core/teams","hooks_url":"https://api.github.com/repos/arvindn05/osc-core/hooks","issue_events_url":"https://api.github.com/repos/arvindn05/osc-core/issues/events{/number}","events_url":"https://api.github.com/repos/arvindn05/osc-core/events","assignees_url":"https://api.github.com/repos/arvindn05/osc-core/assignees{/user}","branches_url":"https://api.github.com/repos/arvindn05/osc-core/branches{/branch}","tags_url":"https://api.github.com/repos/arvindn05/osc-core/tags","blobs_url":"https://api.github.com/repos/arvindn05/osc-core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/arvindn05/osc-core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/arvindn05/osc-core/git/refs{/sha}","trees_url":"https://api.github.com/repos/arvindn05/osc-core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/arvindn05/osc-core/statuses/{sha}","languages_url":"https://api.github.com/repos/arvindn05/osc-core/languages","stargazers_url":"https://api.github.com/repos/arvindn05/osc-core/stargazers","contributors_url":"https://api.github.com/repos/arvindn05/osc-core/contributors","subscribers_url":"https://api.github.com/repos/arvindn05/osc-core/subscribers","subscription_url":"https://api.github.com/repos/arvindn05/osc-core/subscription","commits_url":"https://api.github.com/repos/arvindn05/osc-core/commits{/sha}","git_commits_url":"https://api.github.com/repos/arvindn05/osc-core/git/commits{/sha}","comments_url":"https://api.github.com/repos/arvindn05/osc-core/comments{/number}","issue_comment_url":"https://api.github.com/repos/arvindn05/osc-core/issues/comments{/number}","contents_url":"https://api.github.com/repos/arvindn05/osc-core/contents/{+path}","compare_url":"https://api.github.com/repos/arvindn05/osc-core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/arvindn05/osc-core/merges","archive_url":"https://api.github.com/repos/arvindn05/osc-core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/arvindn05/osc-core/downloads","issues_url":"https://api.github.com/repos/arvindn05/osc-core/issues{/number}","pulls_url":"https://api.github.com/repos/arvindn05/osc-core/pulls{/number}","milestones_url":"https://api.github.com/repos/arvindn05/osc-core/milestones{/number}","notifications_url":"https://api.github.com/repos/arvindn05/osc-core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/arvindn05/osc-core/labels{/name}","releases_url":"https://api.github.com/repos/arvindn05/osc-core/releases{/id}","deployments_url":"https://api.github.com/repos/arvindn05/osc-core/deployments","created_at":"2017-06-30T05:56:20Z","updated_at":"2017-06-30T05:56:25Z","pushed_at":"2017-09-29T23:35:11Z","git_url":"git://github.com/arvindn05/osc-core.git","ssh_url":"git@github.com:arvindn05/osc-core.git","clone_url":"https://github.com/arvindn05/osc-core.git","svn_url":"https://github.com/arvindn05/osc-core","homepage":null,"size":10195,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"opensecuritycontroller:master","ref":"master","sha":"e292f17c1670a8ae7c8d9b4170562ddde7ba4afe","user":{"login":"opensecuritycontroller","id":24922846,"avatar_url":"https://avatars1.githubusercontent.com/u/24922846?v=4","gravatar_id":"","url":"https://api.github.com/users/opensecuritycontroller","html_url":"https://github.com/opensecuritycontroller","followers_url":"https://api.github.com/users/opensecuritycontroller/followers","following_url":"https://api.github.com/users/opensecuritycontroller/following{/other_user}","gists_url":"https://api.github.com/users/opensecuritycontroller/gists{/gist_id}","starred_url":"https://api.github.com/users/opensecuritycontroller/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/opensecuritycontroller/subscriptions","organizations_url":"https://api.github.com/users/opensecuritycontroller/orgs","repos_url":"https://api.github.com/users/opensecuritycontroller/repos","events_url":"https://api.github.com/users/opensecuritycontroller/events{/privacy}","received_events_url":"https://api.github.com/users/opensecuritycontroller/received_events","type":"Organization","site_admin":false},"repo":{"id":80228150,"name":"osc-core","full_name":"opensecuritycontroller/osc-core","owner":{"login":"opensecuritycontroller","id":24922846,"avatar_url":"https://avatars1.githubusercontent.com/u/24922846?v=4","gravatar_id":"","url":"https://api.github.com/users/opensecuritycontroller","html_url":"https://github.com/opensecuritycontroller","followers_url":"https://api.github.com/users/opensecuritycontroller/followers","following_url":"https://api.github.com/users/opensecuritycontroller/following{/other_user}","gists_url":"https://api.github.com/users/opensecuritycontroller/gists{/gist_id}","starred_url":"https://api.github.com/users/opensecuritycontroller/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/opensecuritycontroller/subscriptions","organizations_url":"https://api.github.com/users/opensecuritycontroller/orgs","repos_url":"https://api.github.com/users/opensecuritycontroller/repos","events_url":"https://api.github.com/users/opensecuritycontroller/events{/privacy}","received_events_url":"https://api.github.com/users/opensecuritycontroller/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/opensecuritycontroller/osc-core","description":"A software-defined security orchestration solution","fork":false,"url":"https://api.github.com/repos/opensecuritycontroller/osc-core","forks_url":"https://api.github.com/repos/opensecuritycontroller/osc-core/forks","keys_url":"https://api.github.com/repos/opensecuritycontroller/osc-core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/opensecuritycontroller/osc-core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/opensecuritycontroller/osc-core/teams","hooks_url":"https://api.github.com/repos/opensecuritycontroller/osc-core/hooks","issue_events_url":"https://api.github.com/repos/opensecuritycontroller/osc-core/issues/events{/number}","events_url":"https://api.github.com/repos/opensecuritycontroller/osc-core/events","assignees_url":"https://api.github.com/repos/opensecuritycontroller/osc-core/assignees{/user}","branches_url":"https://api.github.com/repos/opensecuritycontroller/osc-core/branches{/branch}","tags_url":"https://api.github.com/repos/opensecuritycontroller/osc-core/tags","blobs_url":"https://api.github.com/repos/opensecuritycontroller/osc-core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/opensecuritycontroller/osc-core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/opensecuritycontroller/osc-core/git/refs{/sha}","trees_url":"https://api.github.com/repos/opensecuritycontroller/osc-core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/opensecuritycontroller/osc-core/statuses/{sha}","languages_url":"https://api.github.com/repos/opensecuritycontroller/osc-core/languages","stargazers_url":"https://api.github.com/repos/opensecuritycontroller/osc-core/stargazers","contributors_url":"https://api.github.com/repos/opensecuritycontroller/osc-core/contributors","subscribers_url":"https://api.github.com/repos/opensecuritycontroller/osc-core/subscribers","subscription_url":"https://api.github.com/repos/opensecuritycontroller/osc-core/subscription","commits_url":"https://api.github.com/repos/opensecuritycontroller/osc-core/commits{/sha}","git_commits_url":"https://api.github.com/repos/opensecuritycontroller/osc-core/git/commits{/sha}","comments_url":"https://api.github.com/repos/opensecuritycontroller/osc-core/comments{/number}","issue_comment_url":"https://api.github.com/repos/opensecuritycontroller/osc-core/issues/comments{/number}","contents_url":"https://api.github.com/repos/opensecuritycontroller/osc-core/contents/{+path}","compare_url":"https://api.github.com/repos/opensecuritycontroller/osc-core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/opensecuritycontroller/osc-core/merges","archive_url":"https://api.github.com/repos/opensecuritycontroller/osc-core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/opensecuritycontroller/osc-core/downloads","issues_url":"https://api.github.com/repos/opensecuritycontroller/osc-core/issues{/number}","pulls_url":"https://api.github.com/repos/opensecuritycontroller/osc-core/pulls{/number}","milestones_url":"https://api.github.com/repos/opensecuritycontroller/osc-core/milestones{/number}","notifications_url":"https://api.github.com/repos/opensecuritycontroller/osc-core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/opensecuritycontroller/osc-core/labels{/name}","releases_url":"https://api.github.com/repos/opensecuritycontroller/osc-core/releases{/id}","deployments_url":"https://api.github.com/repos/opensecuritycontroller/osc-core/deployments","created_at":"2017-01-27T17:14:45Z","updated_at":"2017-09-29T21:38:31Z","pushed_at":"2017-10-02T19:56:28Z","git_url":"git://github.com/opensecuritycontroller/osc-core.git","ssh_url":"git@github.com:opensecuritycontroller/osc-core.git","clone_url":"https://github.com/opensecuritycontroller/osc-core.git","svn_url":"https://github.com/opensecuritycontroller/osc-core","homepage":"https://www.opensecuritycontroller.org/","size":201419,"stargazers_count":17,"watchers_count":17,"language":"Java","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":17,"mirror_url":null,"open_issues_count":51,"forks":17,"open_issues":51,"watchers":17,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/opensecuritycontroller/osc-core/pulls/506"},"html":{"href":"https://github.com/opensecuritycontroller/osc-core/pull/506"},"issue":{"href":"https://api.github.com/repos/opensecuritycontroller/osc-core/issues/506"},"comments":{"href":"https://api.github.com/repos/opensecuritycontroller/osc-core/issues/506/comments"},"review_comments":{"href":"https://api.github.com/repos/opensecuritycontroller/osc-core/pulls/506/comments"},"review_comment":{"href":"https://api.github.com/repos/opensecuritycontroller/osc-core/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/opensecuritycontroller/osc-core/pulls/506/commits"},"statuses":{"href":"https://api.github.com/repos/opensecuritycontroller/osc-core/statuses/b2899faa860b059fcd41735e0ed34b3ee8e8afd4"}},"author_association":"OWNER"}}
{"actor":{"display_login":"arvindn05"}}