{"action":"created","comment":{"url":"https://api.github.com/repos/sangnvus/201605JS01/pulls/comments/75578209","id":75578209,"diff_hunk":"@@ -0,0 +1,209 @@\n+/*\n+ * To change this license header, choose License Headers in Project Properties.\n+ * To change this template file, choose Tools | Templates\n+ * and open the template in the editor.\n+ */\n+package vn.edu.fu.veazy.core.service;\n+\n+import java.util.List;\n+import org.junit.After;\n+import org.junit.Assert;\n+import org.junit.Before;\n+import org.junit.Test;\n+import org.junit.runner.RunWith;\n+import org.springframework.beans.factory.annotation.Autowired;\n+import org.springframework.test.context.ContextConfiguration;\n+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;\n+import vn.edu.fu.veazy.core.common.Const;\n+import vn.edu.fu.veazy.core.exception.PasswordIncorrectException;\n+import vn.edu.fu.veazy.core.form.RegisterForm;\n+import vn.edu.fu.veazy.core.form.UpdateUserForm;\n+import vn.edu.fu.veazy.core.model.UserModel;\n+/**\n+ *\n+ * @author Hoang Linh\n+ */\n+@RunWith(SpringJUnit4ClassRunner.class)\n+@ContextConfiguration( locations = { \"classpath:testContext.xml\" } )\n+public class UserServiceTest {\n+    \n+\tprivate UserModel user;\n+    @Autowired\n+    private UserService userService;\n+    private Integer userId;\n+    private String email;\n+    private String username;\n+    private String password;\n+    private Integer role;\n+    private UpdateUserForm form;\n+\n+    public UserModel setUpUser() throws Exception {\n+        RegisterForm form = new RegisterForm();\n+        form.setUsername(username);\n+        form.setEmail(email);\n+        form.setPassword(password);\n+        userService.saveUser(form);\n+        UserModel user = userService.findUserByUsername(username);\n+        return user;\n+    }\n+    @Before\n+    public void setUp() throws Exception {\n+        username = \"user1\";\n+        email = \"user1@email.com\";\n+        password = \"password\";\n+        user = setUpUser();\n+        userId = user.getId();\n+        form = new UpdateUserForm(\"first\", \"last\", (long) 1234, email, email, email, email, email);\n+        role = Const.ROLE_EDITOR;\n+    }\n+\n+    @After\n+    public void tearDown() {\n+        try {\n+            userService.delete(user);\n+        } catch (Exception e) {\n+            assert false;\n+        }\n+    }\n+\n+    @Test\n+    public void testSaveUser() throws Exception {\n+        userService.saveUser(user);\n+\t\tUserModel user = userService.findUserByUsername(username);\n+        Assert.assertNotNull(user);\n+    }\n+\n+    @Test\n+    public void testSaveUser2() throws Exception {\n+        RegisterForm form = new RegisterForm();\n+        form.setUsername(\"user2\");\n+        form.setEmail(\"user2@email.com\");\n+        form.setPassword(\"user2\");\n+        userService.saveUser(form);\n+\t\t\n+\t\tUserModel user = userService.findUserByUsername(\"user2\");\n+        Assert.assertNotNull(user);\n+    }\n+\n+    @Test\n+    public void testFindUserById() throws Exception {\n+        UserModel user = userService.findUserById(userId);\n+        Assert.assertNotNull(user);\n+    }\n+\n+    @Test\n+    public void testFindUserById2() throws Exception {\n+        UserModel user = userService.findUserById(-1);\n+        Assert.assertNull(user);\n+    }\n+\n+    @Test\n+    public void testFindUserById3() throws Exception {\n+        UserModel user = userService.findUserById(null);\n+        Assert.assertNull(user);\n+    }\n+\n+    @Test\n+    public void testFindUserByEmail() throws Exception {\n+        UserModel user = userService.findUserByEmail(email);\n+        Assert.assertNotNull(user);\n+    }\n+\n+    @Test\n+    public void testFindUserByEmail2() throws Exception {\n+        UserModel user = userService.findUserByEmail(null);\n+        Assert.assertNull(user);\n+    }\n+\n+    @Test\n+    public void testFindUserByEmail3() throws Exception {\n+        UserModel user = userService.findUserByEmail(\"\");\n+        Assert.assertNull(user);\n+    }\n+\n+    @Test\n+    public void testFindUserByEmail4() throws Exception {\n+        UserModel user = userService.findUserByEmail(\"notexistemail.com\");\n+        Assert.assertNull(user);\n+    }\n+\n+    @Test\n+    public void testFindUserByUserName() throws Exception {\n+        UserModel user = userService.findUserByUsername(username);\n+        Assert.assertNotNull(user);\n+    }\n+\n+    @Test\n+    public void testFindUserByUserName2() throws Exception {\n+        UserModel user = userService.findUserByUsername(null);\n+        Assert.assertNull(user);\n+    }\n+\n+    @Test\n+    public void testFindUserByUserName3() throws Exception {\n+        UserModel user = userService.findUserByUsername(\"\");\n+        Assert.assertNull(user);\n+    }\n+\n+    @Test\n+    public void testFindUserByUserName4() throws Exception {\n+        UserModel user = userService.findUserByUsername(\"notExistUserName\");\n+        Assert.assertNull(user);\n+    }\n+\n+    @Test\n+    public void testFindAllUser() throws Exception {\n+        List<UserModel> findAllUser = userService.findAllUser();\n+        Assert.assertNotNull(findAllUser);\n+        Assert.assertNotEquals(0, findAllUser.size());\n+    }\n+\n+    @Test\n+    public void testUpdateUser() throws Exception {\n+        userService.update(user, form);\n+\t\tUserModel user = userService.findUserById(userId);\n+\t\tAssert.assertEquals(\"first\", user.getFirstName());","path":"WIP/Source/Veazy/src/test/java/vn/edu/fu/veazy/core/service/UserServiceTest.java","position":165,"original_position":165,"commit_id":"442cb029a2ed3ce65a0c4e6062ce71d64bbc74d1","original_commit_id":"442cb029a2ed3ce65a0c4e6062ce71d64bbc74d1","user":{"login":"LinhNguyen3","id":19389539,"avatar_url":"https://avatars.githubusercontent.com/u/19389539?v=3","gravatar_id":"","url":"https://api.github.com/users/LinhNguyen3","html_url":"https://github.com/LinhNguyen3","followers_url":"https://api.github.com/users/LinhNguyen3/followers","following_url":"https://api.github.com/users/LinhNguyen3/following{/other_user}","gists_url":"https://api.github.com/users/LinhNguyen3/gists{/gist_id}","starred_url":"https://api.github.com/users/LinhNguyen3/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LinhNguyen3/subscriptions","organizations_url":"https://api.github.com/users/LinhNguyen3/orgs","repos_url":"https://api.github.com/users/LinhNguyen3/repos","events_url":"https://api.github.com/users/LinhNguyen3/events{/privacy}","received_events_url":"https://api.github.com/users/LinhNguyen3/received_events","type":"User","site_admin":false},"body":"test 2 method khác nhau\n\n\nOn Fri, Aug 19, 2016 at 6:48 PM, Nguyễn Ngọc Minh <notifications@github.com>\nwrote:\n\n> In WIP/Source/Veazy/src/test/java/vn/edu/fu/veazy/core/\n> service/UserServiceTest.java\n> <https://github.com/sangnvus/201605JS01/pull/25#discussion_r75468482>:\n>\n> > +        UserModel user = userService.findUserByUsername(\"notExistUserName\");\n> > +        Assert.assertNull(user);\n> > +    }\n> > +\n> > +    @Test\n> > +    public void testFindAllUser() throws Exception {\n> > +        List<UserModel> findAllUser = userService.findAllUser();\n> > +        Assert.assertNotNull(findAllUser);\n> > +        Assert.assertNotEquals(0, findAllUser.size());\n> > +    }\n> > +\n> > +    @Test\n> > +    public void testUpdateUser() throws Exception {\n> > +        userService.update(user, form);\n> > +\t\tUserModel user = userService.findUserById(userId);\n> > +\t\tAssert.assertEquals(\"first\", user.getFirstName());\n>\n> sao gioongs case dưới thế\n>\n> —\n> You are receiving this because you authored the thread.\n> Reply to this email directly, view it on GitHub\n> <https://github.com/sangnvus/201605JS01/pull/25/files/442cb029a2ed3ce65a0c4e6062ce71d64bbc74d1#r75468482>,\n> or mute the thread\n> <https://github.com/notifications/unsubscribe-auth/ASfcY6XwXi--Z4y3TuzZpJmzu0Lwyedgks5qhZgLgaJpZM4JnxSY>\n> .\n>\n","created_at":"2016-08-20T12:57:53Z","updated_at":"2016-08-20T12:57:53Z","html_url":"https://github.com/sangnvus/201605JS01/pull/25#discussion_r75578209","pull_request_url":"https://api.github.com/repos/sangnvus/201605JS01/pulls/25","_links":{"self":{"href":"https://api.github.com/repos/sangnvus/201605JS01/pulls/comments/75578209"},"html":{"href":"https://github.com/sangnvus/201605JS01/pull/25#discussion_r75578209"},"pull_request":{"href":"https://api.github.com/repos/sangnvus/201605JS01/pulls/25"}}},"pull_request":{"url":"https://api.github.com/repos/sangnvus/201605JS01/pulls/25","id":81863160,"html_url":"https://github.com/sangnvus/201605JS01/pull/25","diff_url":"https://github.com/sangnvus/201605JS01/pull/25.diff","patch_url":"https://github.com/sangnvus/201605JS01/pull/25.patch","issue_url":"https://api.github.com/repos/sangnvus/201605JS01/issues/25","number":25,"state":"open","locked":false,"title":"Unit test2","user":{"login":"LinhNguyen3","id":19389539,"avatar_url":"https://avatars.githubusercontent.com/u/19389539?v=3","gravatar_id":"","url":"https://api.github.com/users/LinhNguyen3","html_url":"https://github.com/LinhNguyen3","followers_url":"https://api.github.com/users/LinhNguyen3/followers","following_url":"https://api.github.com/users/LinhNguyen3/following{/other_user}","gists_url":"https://api.github.com/users/LinhNguyen3/gists{/gist_id}","starred_url":"https://api.github.com/users/LinhNguyen3/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LinhNguyen3/subscriptions","organizations_url":"https://api.github.com/users/LinhNguyen3/orgs","repos_url":"https://api.github.com/users/LinhNguyen3/repos","events_url":"https://api.github.com/users/LinhNguyen3/events{/privacy}","received_events_url":"https://api.github.com/users/LinhNguyen3/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-08-18T18:19:26Z","updated_at":"2016-08-20T12:57:53Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a639ccdf95544b9467c5bb51065bc129861da0c0","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/sangnvus/201605JS01/pulls/25/commits","review_comments_url":"https://api.github.com/repos/sangnvus/201605JS01/pulls/25/comments","review_comment_url":"https://api.github.com/repos/sangnvus/201605JS01/pulls/comments{/number}","comments_url":"https://api.github.com/repos/sangnvus/201605JS01/issues/25/comments","statuses_url":"https://api.github.com/repos/sangnvus/201605JS01/statuses/442cb029a2ed3ce65a0c4e6062ce71d64bbc74d1","head":{"label":"sangnvus:UnitTest2","ref":"UnitTest2","sha":"442cb029a2ed3ce65a0c4e6062ce71d64bbc74d1","user":{"login":"sangnvus","id":11451130,"avatar_url":"https://avatars.githubusercontent.com/u/11451130?v=3","gravatar_id":"","url":"https://api.github.com/users/sangnvus","html_url":"https://github.com/sangnvus","followers_url":"https://api.github.com/users/sangnvus/followers","following_url":"https://api.github.com/users/sangnvus/following{/other_user}","gists_url":"https://api.github.com/users/sangnvus/gists{/gist_id}","starred_url":"https://api.github.com/users/sangnvus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sangnvus/subscriptions","organizations_url":"https://api.github.com/users/sangnvus/orgs","repos_url":"https://api.github.com/users/sangnvus/repos","events_url":"https://api.github.com/users/sangnvus/events{/privacy}","received_events_url":"https://api.github.com/users/sangnvus/received_events","type":"User","site_admin":false},"repo":{"id":58912867,"name":"201605JS01","full_name":"sangnvus/201605JS01","owner":{"login":"sangnvus","id":11451130,"avatar_url":"https://avatars.githubusercontent.com/u/11451130?v=3","gravatar_id":"","url":"https://api.github.com/users/sangnvus","html_url":"https://github.com/sangnvus","followers_url":"https://api.github.com/users/sangnvus/followers","following_url":"https://api.github.com/users/sangnvus/following{/other_user}","gists_url":"https://api.github.com/users/sangnvus/gists{/gist_id}","starred_url":"https://api.github.com/users/sangnvus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sangnvus/subscriptions","organizations_url":"https://api.github.com/users/sangnvus/orgs","repos_url":"https://api.github.com/users/sangnvus/repos","events_url":"https://api.github.com/users/sangnvus/events{/privacy}","received_events_url":"https://api.github.com/users/sangnvus/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sangnvus/201605JS01","description":"","fork":false,"url":"https://api.github.com/repos/sangnvus/201605JS01","forks_url":"https://api.github.com/repos/sangnvus/201605JS01/forks","keys_url":"https://api.github.com/repos/sangnvus/201605JS01/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sangnvus/201605JS01/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sangnvus/201605JS01/teams","hooks_url":"https://api.github.com/repos/sangnvus/201605JS01/hooks","issue_events_url":"https://api.github.com/repos/sangnvus/201605JS01/issues/events{/number}","events_url":"https://api.github.com/repos/sangnvus/201605JS01/events","assignees_url":"https://api.github.com/repos/sangnvus/201605JS01/assignees{/user}","branches_url":"https://api.github.com/repos/sangnvus/201605JS01/branches{/branch}","tags_url":"https://api.github.com/repos/sangnvus/201605JS01/tags","blobs_url":"https://api.github.com/repos/sangnvus/201605JS01/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sangnvus/201605JS01/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sangnvus/201605JS01/git/refs{/sha}","trees_url":"https://api.github.com/repos/sangnvus/201605JS01/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sangnvus/201605JS01/statuses/{sha}","languages_url":"https://api.github.com/repos/sangnvus/201605JS01/languages","stargazers_url":"https://api.github.com/repos/sangnvus/201605JS01/stargazers","contributors_url":"https://api.github.com/repos/sangnvus/201605JS01/contributors","subscribers_url":"https://api.github.com/repos/sangnvus/201605JS01/subscribers","subscription_url":"https://api.github.com/repos/sangnvus/201605JS01/subscription","commits_url":"https://api.github.com/repos/sangnvus/201605JS01/commits{/sha}","git_commits_url":"https://api.github.com/repos/sangnvus/201605JS01/git/commits{/sha}","comments_url":"https://api.github.com/repos/sangnvus/201605JS01/comments{/number}","issue_comment_url":"https://api.github.com/repos/sangnvus/201605JS01/issues/comments{/number}","contents_url":"https://api.github.com/repos/sangnvus/201605JS01/contents/{+path}","compare_url":"https://api.github.com/repos/sangnvus/201605JS01/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sangnvus/201605JS01/merges","archive_url":"https://api.github.com/repos/sangnvus/201605JS01/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sangnvus/201605JS01/downloads","issues_url":"https://api.github.com/repos/sangnvus/201605JS01/issues{/number}","pulls_url":"https://api.github.com/repos/sangnvus/201605JS01/pulls{/number}","milestones_url":"https://api.github.com/repos/sangnvus/201605JS01/milestones{/number}","notifications_url":"https://api.github.com/repos/sangnvus/201605JS01/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sangnvus/201605JS01/labels{/name}","releases_url":"https://api.github.com/repos/sangnvus/201605JS01/releases{/id}","deployments_url":"https://api.github.com/repos/sangnvus/201605JS01/deployments","created_at":"2016-05-16T07:36:09Z","updated_at":"2016-06-13T08:01:30Z","pushed_at":"2016-08-20T12:45:30Z","git_url":"git://github.com/sangnvus/201605JS01.git","ssh_url":"git@github.com:sangnvus/201605JS01.git","clone_url":"https://github.com/sangnvus/201605JS01.git","svn_url":"https://github.com/sangnvus/201605JS01","homepage":null,"size":159601,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":4,"forks":1,"open_issues":4,"watchers":0,"default_branch":"master"}},"base":{"label":"sangnvus:master","ref":"master","sha":"77a911a89907d42f93832e0f124f71108651133c","user":{"login":"sangnvus","id":11451130,"avatar_url":"https://avatars.githubusercontent.com/u/11451130?v=3","gravatar_id":"","url":"https://api.github.com/users/sangnvus","html_url":"https://github.com/sangnvus","followers_url":"https://api.github.com/users/sangnvus/followers","following_url":"https://api.github.com/users/sangnvus/following{/other_user}","gists_url":"https://api.github.com/users/sangnvus/gists{/gist_id}","starred_url":"https://api.github.com/users/sangnvus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sangnvus/subscriptions","organizations_url":"https://api.github.com/users/sangnvus/orgs","repos_url":"https://api.github.com/users/sangnvus/repos","events_url":"https://api.github.com/users/sangnvus/events{/privacy}","received_events_url":"https://api.github.com/users/sangnvus/received_events","type":"User","site_admin":false},"repo":{"id":58912867,"name":"201605JS01","full_name":"sangnvus/201605JS01","owner":{"login":"sangnvus","id":11451130,"avatar_url":"https://avatars.githubusercontent.com/u/11451130?v=3","gravatar_id":"","url":"https://api.github.com/users/sangnvus","html_url":"https://github.com/sangnvus","followers_url":"https://api.github.com/users/sangnvus/followers","following_url":"https://api.github.com/users/sangnvus/following{/other_user}","gists_url":"https://api.github.com/users/sangnvus/gists{/gist_id}","starred_url":"https://api.github.com/users/sangnvus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sangnvus/subscriptions","organizations_url":"https://api.github.com/users/sangnvus/orgs","repos_url":"https://api.github.com/users/sangnvus/repos","events_url":"https://api.github.com/users/sangnvus/events{/privacy}","received_events_url":"https://api.github.com/users/sangnvus/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sangnvus/201605JS01","description":"","fork":false,"url":"https://api.github.com/repos/sangnvus/201605JS01","forks_url":"https://api.github.com/repos/sangnvus/201605JS01/forks","keys_url":"https://api.github.com/repos/sangnvus/201605JS01/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sangnvus/201605JS01/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sangnvus/201605JS01/teams","hooks_url":"https://api.github.com/repos/sangnvus/201605JS01/hooks","issue_events_url":"https://api.github.com/repos/sangnvus/201605JS01/issues/events{/number}","events_url":"https://api.github.com/repos/sangnvus/201605JS01/events","assignees_url":"https://api.github.com/repos/sangnvus/201605JS01/assignees{/user}","branches_url":"https://api.github.com/repos/sangnvus/201605JS01/branches{/branch}","tags_url":"https://api.github.com/repos/sangnvus/201605JS01/tags","blobs_url":"https://api.github.com/repos/sangnvus/201605JS01/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sangnvus/201605JS01/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sangnvus/201605JS01/git/refs{/sha}","trees_url":"https://api.github.com/repos/sangnvus/201605JS01/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sangnvus/201605JS01/statuses/{sha}","languages_url":"https://api.github.com/repos/sangnvus/201605JS01/languages","stargazers_url":"https://api.github.com/repos/sangnvus/201605JS01/stargazers","contributors_url":"https://api.github.com/repos/sangnvus/201605JS01/contributors","subscribers_url":"https://api.github.com/repos/sangnvus/201605JS01/subscribers","subscription_url":"https://api.github.com/repos/sangnvus/201605JS01/subscription","commits_url":"https://api.github.com/repos/sangnvus/201605JS01/commits{/sha}","git_commits_url":"https://api.github.com/repos/sangnvus/201605JS01/git/commits{/sha}","comments_url":"https://api.github.com/repos/sangnvus/201605JS01/comments{/number}","issue_comment_url":"https://api.github.com/repos/sangnvus/201605JS01/issues/comments{/number}","contents_url":"https://api.github.com/repos/sangnvus/201605JS01/contents/{+path}","compare_url":"https://api.github.com/repos/sangnvus/201605JS01/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sangnvus/201605JS01/merges","archive_url":"https://api.github.com/repos/sangnvus/201605JS01/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sangnvus/201605JS01/downloads","issues_url":"https://api.github.com/repos/sangnvus/201605JS01/issues{/number}","pulls_url":"https://api.github.com/repos/sangnvus/201605JS01/pulls{/number}","milestones_url":"https://api.github.com/repos/sangnvus/201605JS01/milestones{/number}","notifications_url":"https://api.github.com/repos/sangnvus/201605JS01/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sangnvus/201605JS01/labels{/name}","releases_url":"https://api.github.com/repos/sangnvus/201605JS01/releases{/id}","deployments_url":"https://api.github.com/repos/sangnvus/201605JS01/deployments","created_at":"2016-05-16T07:36:09Z","updated_at":"2016-06-13T08:01:30Z","pushed_at":"2016-08-20T12:45:30Z","git_url":"git://github.com/sangnvus/201605JS01.git","ssh_url":"git@github.com:sangnvus/201605JS01.git","clone_url":"https://github.com/sangnvus/201605JS01.git","svn_url":"https://github.com/sangnvus/201605JS01","homepage":null,"size":159601,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":4,"forks":1,"open_issues":4,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/sangnvus/201605JS01/pulls/25"},"html":{"href":"https://github.com/sangnvus/201605JS01/pull/25"},"issue":{"href":"https://api.github.com/repos/sangnvus/201605JS01/issues/25"},"comments":{"href":"https://api.github.com/repos/sangnvus/201605JS01/issues/25/comments"},"review_comments":{"href":"https://api.github.com/repos/sangnvus/201605JS01/pulls/25/comments"},"review_comment":{"href":"https://api.github.com/repos/sangnvus/201605JS01/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/sangnvus/201605JS01/pulls/25/commits"},"statuses":{"href":"https://api.github.com/repos/sangnvus/201605JS01/statuses/442cb029a2ed3ce65a0c4e6062ce71d64bbc74d1"}}}}
{"actor":{"display_login":"LinhNguyen3"}}