{"action":"created","comment":{"url":"https://api.github.com/repos/tebanhdez/refiere.co/pulls/comments/64686843","id":64686843,"diff_hunk":"@@ -2,59 +2,78 @@\n \n import static org.junit.Assert.assertEquals;\n \n+import javax.json.Json;\n+import javax.json.JsonObject;\n+import javax.json.JsonReader;\n import javax.ws.rs.client.Entity;\n import javax.ws.rs.core.Application;\n import javax.ws.rs.core.Response;\n \n+import co.refiere.dao.PersonDao;\n+import co.refiere.dao.ReferencesCodesDao;\n+import co.refiere.models.Person;\n import org.glassfish.jersey.server.ResourceConfig;\n import org.glassfish.jersey.test.JerseyTest;\n import org.junit.Assert;\n import org.junit.Before;\n import org.junit.Test;\n \n-import co.refiere.dao.CampaingDao;\n+import co.refiere.dao.CampaignDao;\n import co.refiere.dao.CompanyDatabaseDao;\n import co.refiere.models.Campaign;\n import co.refiere.models.CompanyDatabase;\n import co.refiere.resources.base.NewUserRequest;\n \n+import java.io.StringReader;\n+\n public class RedeemCodeResourceTest extends JerseyTest {\n-     \n-    private int databaseId;\n-    \n-    @Override\n-      protected Application configure() {\n-        return new ResourceConfig(RedeemCodeResource.class);\n-      }\n-    \n-     @Before\n-     public void createTestData(){\n-         CompanyDatabase companyData = new CompanyDatabase();\n-         companyData.setName(\"testCompany\");\n-         CompanyDatabaseDao companyDataBase = new CompanyDatabaseDao();\n-         companyDataBase.save(companyData);\n-         databaseId = companyData.getId();\n-         Assert.assertNotNull(databaseId);\n-         \n-         Campaign campaign = new Campaign();\n-         campaign.setName(\"test campaig name\");\n-         campaign.setCompanyDatabase(companyData);\n-         CampaingDao campaingDao = new CampaingDao();\n-         campaingDao.save(campaign);\n-     }\n-    \n-     \n-      @Test\n-      public void testGetIt() {\n-        NewUserRequest newUserRequest = new NewUserRequest();\n-        newUserRequest.setCampaignId(databaseId); \n-        newUserRequest.setReferalPersonId(2);\n-        newUserRequest.setIdentificationCardNumber(\"1274563495\");\n-        newUserRequest.setName(\"User Test Name\");\n-        newUserRequest.setLastName(\"Last-name\");\n-        newUserRequest.setEmail(\"email@test.com\");\n-        newUserRequest.setPhoneNumber(\"89898989\");\n-        Response response = target().path(\"v1/redeemCode/registerUser\").request().post(Entity.json(newUserRequest));\n-        assertEquals(200, response.getStatus());\n-      }\n-}\n+\n+\tprivate int databaseId;\n+\tPerson referalPerson = new Person();\n+\tCampaignDao campaignDao = new CampaignDao();\n+\tCampaign testCampaign;\n+\tReferencesCodesDao referencesCodesDao = new ReferencesCodesDao();\n+\n+\n+\t@Override\n+\tprotected Application configure() {\n+\t\treturn new ResourceConfig(RedeemCodeResource.class);\n+\t}\n+\n+\t@Before\n+\tpublic void createTestData(){\n+\t\tCompanyDatabase companyData = new CompanyDatabase();\n+\t\tcompanyData.setName(\"testCompany\");\n+\t\tCompanyDatabaseDao companyDataBase = new CompanyDatabaseDao();\n+\t\tcompanyDataBase.save(companyData);\n+\t\tdatabaseId = companyData.getId();\n+\t\tAssert.assertNotNull(databaseId);\n+\n+\t\ttestCampaign = new Campaign();\n+\t\ttestCampaign.setName(\"test campaig name\");\n+\t\ttestCampaign.setCompanyDatabase(companyData);\n+\t\tcampaignDao.save(testCampaign);\n+\n+\t\treferalPerson.setIdentificationCardNumber(\"00000\");\n+\t\treferalPerson.setName(\"ReferalName\");\n+\t\treferalPerson.setLastName(\"ReferalLastName\");\n+\t\treferalPerson.setPhoneNumber(\"0000000\");\n+\t\treferalPerson.setEmail(\"referalEmail@test.com\");\n+\t\tPersonDao personDao = new PersonDao();\n+\t\tpersonDao.save(referalPerson);\n+\t}\n+\n+\t@Test\n+\tpublic void createNewUserTest() {\n+\t\tNewUserRequest newUserRequest = new NewUserRequest();\n+\t\tnewUserRequest.setCampaignId(testCampaign.getId()); \n+\t\tnewUserRequest.setReferalPersonId(referalPerson.getId());\n+\t\tnewUserRequest.setIdentificationCardNumber(\"1111111\");\n+\t\tnewUserRequest.setName(\"newUserName\");\n+\t\tnewUserRequest.setLastName(\"newUserLastName\");\n+\t\tnewUserRequest.setEmail(\"newUserEmail@test.com\");\n+\t\tnewUserRequest.setPhoneNumber(\"00000000\");\n+\t\tResponse response = target().path(\"v1/redeemCode/registerUser\").request().post(Entity.json(newUserRequest));\n+\t\tassertEquals(200, response.getStatus());","path":"src/test/java/co/refiere/resources/RedeemCodeResourceTest.java","position":116,"original_position":116,"commit_id":"36abdad37f424085f577b7079b1102b51670b06a","original_commit_id":"36abdad37f424085f577b7079b1102b51670b06a","user":{"login":"tebanhdez","id":1818178,"avatar_url":"https://avatars.githubusercontent.com/u/1818178?v=3","gravatar_id":"","url":"https://api.github.com/users/tebanhdez","html_url":"https://github.com/tebanhdez","followers_url":"https://api.github.com/users/tebanhdez/followers","following_url":"https://api.github.com/users/tebanhdez/following{/other_user}","gists_url":"https://api.github.com/users/tebanhdez/gists{/gist_id}","starred_url":"https://api.github.com/users/tebanhdez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tebanhdez/subscriptions","organizations_url":"https://api.github.com/users/tebanhdez/orgs","repos_url":"https://api.github.com/users/tebanhdez/repos","events_url":"https://api.github.com/users/tebanhdez/events{/privacy}","received_events_url":"https://api.github.com/users/tebanhdez/received_events","type":"User","site_admin":false},"body":"Check status 200 does not guarantee the user was created or not, cause even though the service creates or not a new user, the end-point is going to return a OK response. Please be more strict in the assert.","created_at":"2016-05-26T03:16:06Z","updated_at":"2016-05-26T03:16:06Z","html_url":"https://github.com/tebanhdez/refiere.co/pull/14#discussion_r64686843","pull_request_url":"https://api.github.com/repos/tebanhdez/refiere.co/pulls/14","_links":{"self":{"href":"https://api.github.com/repos/tebanhdez/refiere.co/pulls/comments/64686843"},"html":{"href":"https://github.com/tebanhdez/refiere.co/pull/14#discussion_r64686843"},"pull_request":{"href":"https://api.github.com/repos/tebanhdez/refiere.co/pulls/14"}}},"pull_request":{"url":"https://api.github.com/repos/tebanhdez/refiere.co/pulls/14","id":71408420,"html_url":"https://github.com/tebanhdez/refiere.co/pull/14","diff_url":"https://github.com/tebanhdez/refiere.co/pull/14.diff","patch_url":"https://github.com/tebanhdez/refiere.co/pull/14.patch","issue_url":"https://api.github.com/repos/tebanhdez/refiere.co/issues/14","number":14,"state":"open","locked":false,"title":"ReferalCodeResource, bug fixes","user":{"login":"pfernandez01","id":16561762,"avatar_url":"https://avatars.githubusercontent.com/u/16561762?v=3","gravatar_id":"","url":"https://api.github.com/users/pfernandez01","html_url":"https://github.com/pfernandez01","followers_url":"https://api.github.com/users/pfernandez01/followers","following_url":"https://api.github.com/users/pfernandez01/following{/other_user}","gists_url":"https://api.github.com/users/pfernandez01/gists{/gist_id}","starred_url":"https://api.github.com/users/pfernandez01/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pfernandez01/subscriptions","organizations_url":"https://api.github.com/users/pfernandez01/orgs","repos_url":"https://api.github.com/users/pfernandez01/repos","events_url":"https://api.github.com/users/pfernandez01/events{/privacy}","received_events_url":"https://api.github.com/users/pfernandez01/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-05-25T15:07:27Z","updated_at":"2016-05-26T03:16:06Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b2b2784e20e8a28ce73ea2490e43c642d6761859","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/tebanhdez/refiere.co/pulls/14/commits","review_comments_url":"https://api.github.com/repos/tebanhdez/refiere.co/pulls/14/comments","review_comment_url":"https://api.github.com/repos/tebanhdez/refiere.co/pulls/comments{/number}","comments_url":"https://api.github.com/repos/tebanhdez/refiere.co/issues/14/comments","statuses_url":"https://api.github.com/repos/tebanhdez/refiere.co/statuses/36abdad37f424085f577b7079b1102b51670b06a","head":{"label":"tebanhdez:fix_referral_code","ref":"fix_referral_code","sha":"36abdad37f424085f577b7079b1102b51670b06a","user":{"login":"tebanhdez","id":1818178,"avatar_url":"https://avatars.githubusercontent.com/u/1818178?v=3","gravatar_id":"","url":"https://api.github.com/users/tebanhdez","html_url":"https://github.com/tebanhdez","followers_url":"https://api.github.com/users/tebanhdez/followers","following_url":"https://api.github.com/users/tebanhdez/following{/other_user}","gists_url":"https://api.github.com/users/tebanhdez/gists{/gist_id}","starred_url":"https://api.github.com/users/tebanhdez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tebanhdez/subscriptions","organizations_url":"https://api.github.com/users/tebanhdez/orgs","repos_url":"https://api.github.com/users/tebanhdez/repos","events_url":"https://api.github.com/users/tebanhdez/events{/privacy}","received_events_url":"https://api.github.com/users/tebanhdez/received_events","type":"User","site_admin":false},"repo":{"id":56186747,"name":"refiere.co","full_name":"tebanhdez/refiere.co","owner":{"login":"tebanhdez","id":1818178,"avatar_url":"https://avatars.githubusercontent.com/u/1818178?v=3","gravatar_id":"","url":"https://api.github.com/users/tebanhdez","html_url":"https://github.com/tebanhdez","followers_url":"https://api.github.com/users/tebanhdez/followers","following_url":"https://api.github.com/users/tebanhdez/following{/other_user}","gists_url":"https://api.github.com/users/tebanhdez/gists{/gist_id}","starred_url":"https://api.github.com/users/tebanhdez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tebanhdez/subscriptions","organizations_url":"https://api.github.com/users/tebanhdez/orgs","repos_url":"https://api.github.com/users/tebanhdez/repos","events_url":"https://api.github.com/users/tebanhdez/events{/privacy}","received_events_url":"https://api.github.com/users/tebanhdez/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tebanhdez/refiere.co","description":"Refiere.co","fork":false,"url":"https://api.github.com/repos/tebanhdez/refiere.co","forks_url":"https://api.github.com/repos/tebanhdez/refiere.co/forks","keys_url":"https://api.github.com/repos/tebanhdez/refiere.co/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tebanhdez/refiere.co/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tebanhdez/refiere.co/teams","hooks_url":"https://api.github.com/repos/tebanhdez/refiere.co/hooks","issue_events_url":"https://api.github.com/repos/tebanhdez/refiere.co/issues/events{/number}","events_url":"https://api.github.com/repos/tebanhdez/refiere.co/events","assignees_url":"https://api.github.com/repos/tebanhdez/refiere.co/assignees{/user}","branches_url":"https://api.github.com/repos/tebanhdez/refiere.co/branches{/branch}","tags_url":"https://api.github.com/repos/tebanhdez/refiere.co/tags","blobs_url":"https://api.github.com/repos/tebanhdez/refiere.co/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tebanhdez/refiere.co/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tebanhdez/refiere.co/git/refs{/sha}","trees_url":"https://api.github.com/repos/tebanhdez/refiere.co/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tebanhdez/refiere.co/statuses/{sha}","languages_url":"https://api.github.com/repos/tebanhdez/refiere.co/languages","stargazers_url":"https://api.github.com/repos/tebanhdez/refiere.co/stargazers","contributors_url":"https://api.github.com/repos/tebanhdez/refiere.co/contributors","subscribers_url":"https://api.github.com/repos/tebanhdez/refiere.co/subscribers","subscription_url":"https://api.github.com/repos/tebanhdez/refiere.co/subscription","commits_url":"https://api.github.com/repos/tebanhdez/refiere.co/commits{/sha}","git_commits_url":"https://api.github.com/repos/tebanhdez/refiere.co/git/commits{/sha}","comments_url":"https://api.github.com/repos/tebanhdez/refiere.co/comments{/number}","issue_comment_url":"https://api.github.com/repos/tebanhdez/refiere.co/issues/comments{/number}","contents_url":"https://api.github.com/repos/tebanhdez/refiere.co/contents/{+path}","compare_url":"https://api.github.com/repos/tebanhdez/refiere.co/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tebanhdez/refiere.co/merges","archive_url":"https://api.github.com/repos/tebanhdez/refiere.co/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tebanhdez/refiere.co/downloads","issues_url":"https://api.github.com/repos/tebanhdez/refiere.co/issues{/number}","pulls_url":"https://api.github.com/repos/tebanhdez/refiere.co/pulls{/number}","milestones_url":"https://api.github.com/repos/tebanhdez/refiere.co/milestones{/number}","notifications_url":"https://api.github.com/repos/tebanhdez/refiere.co/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tebanhdez/refiere.co/labels{/name}","releases_url":"https://api.github.com/repos/tebanhdez/refiere.co/releases{/id}","deployments_url":"https://api.github.com/repos/tebanhdez/refiere.co/deployments","created_at":"2016-04-13T21:17:05Z","updated_at":"2016-04-27T20:02:09Z","pushed_at":"2016-05-25T19:59:33Z","git_url":"git://github.com/tebanhdez/refiere.co.git","ssh_url":"git@github.com:tebanhdez/refiere.co.git","clone_url":"https://github.com/tebanhdez/refiere.co.git","svn_url":"https://github.com/tebanhdez/refiere.co","homepage":null,"size":2927,"stargazers_count":0,"watchers_count":0,"language":"HTML","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":2,"forks":1,"open_issues":2,"watchers":0,"default_branch":"dev"}},"base":{"label":"tebanhdez:dev","ref":"dev","sha":"c14b543b483a9b4561fbc6aafd522d665d72e3df","user":{"login":"tebanhdez","id":1818178,"avatar_url":"https://avatars.githubusercontent.com/u/1818178?v=3","gravatar_id":"","url":"https://api.github.com/users/tebanhdez","html_url":"https://github.com/tebanhdez","followers_url":"https://api.github.com/users/tebanhdez/followers","following_url":"https://api.github.com/users/tebanhdez/following{/other_user}","gists_url":"https://api.github.com/users/tebanhdez/gists{/gist_id}","starred_url":"https://api.github.com/users/tebanhdez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tebanhdez/subscriptions","organizations_url":"https://api.github.com/users/tebanhdez/orgs","repos_url":"https://api.github.com/users/tebanhdez/repos","events_url":"https://api.github.com/users/tebanhdez/events{/privacy}","received_events_url":"https://api.github.com/users/tebanhdez/received_events","type":"User","site_admin":false},"repo":{"id":56186747,"name":"refiere.co","full_name":"tebanhdez/refiere.co","owner":{"login":"tebanhdez","id":1818178,"avatar_url":"https://avatars.githubusercontent.com/u/1818178?v=3","gravatar_id":"","url":"https://api.github.com/users/tebanhdez","html_url":"https://github.com/tebanhdez","followers_url":"https://api.github.com/users/tebanhdez/followers","following_url":"https://api.github.com/users/tebanhdez/following{/other_user}","gists_url":"https://api.github.com/users/tebanhdez/gists{/gist_id}","starred_url":"https://api.github.com/users/tebanhdez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tebanhdez/subscriptions","organizations_url":"https://api.github.com/users/tebanhdez/orgs","repos_url":"https://api.github.com/users/tebanhdez/repos","events_url":"https://api.github.com/users/tebanhdez/events{/privacy}","received_events_url":"https://api.github.com/users/tebanhdez/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tebanhdez/refiere.co","description":"Refiere.co","fork":false,"url":"https://api.github.com/repos/tebanhdez/refiere.co","forks_url":"https://api.github.com/repos/tebanhdez/refiere.co/forks","keys_url":"https://api.github.com/repos/tebanhdez/refiere.co/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tebanhdez/refiere.co/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tebanhdez/refiere.co/teams","hooks_url":"https://api.github.com/repos/tebanhdez/refiere.co/hooks","issue_events_url":"https://api.github.com/repos/tebanhdez/refiere.co/issues/events{/number}","events_url":"https://api.github.com/repos/tebanhdez/refiere.co/events","assignees_url":"https://api.github.com/repos/tebanhdez/refiere.co/assignees{/user}","branches_url":"https://api.github.com/repos/tebanhdez/refiere.co/branches{/branch}","tags_url":"https://api.github.com/repos/tebanhdez/refiere.co/tags","blobs_url":"https://api.github.com/repos/tebanhdez/refiere.co/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tebanhdez/refiere.co/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tebanhdez/refiere.co/git/refs{/sha}","trees_url":"https://api.github.com/repos/tebanhdez/refiere.co/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tebanhdez/refiere.co/statuses/{sha}","languages_url":"https://api.github.com/repos/tebanhdez/refiere.co/languages","stargazers_url":"https://api.github.com/repos/tebanhdez/refiere.co/stargazers","contributors_url":"https://api.github.com/repos/tebanhdez/refiere.co/contributors","subscribers_url":"https://api.github.com/repos/tebanhdez/refiere.co/subscribers","subscription_url":"https://api.github.com/repos/tebanhdez/refiere.co/subscription","commits_url":"https://api.github.com/repos/tebanhdez/refiere.co/commits{/sha}","git_commits_url":"https://api.github.com/repos/tebanhdez/refiere.co/git/commits{/sha}","comments_url":"https://api.github.com/repos/tebanhdez/refiere.co/comments{/number}","issue_comment_url":"https://api.github.com/repos/tebanhdez/refiere.co/issues/comments{/number}","contents_url":"https://api.github.com/repos/tebanhdez/refiere.co/contents/{+path}","compare_url":"https://api.github.com/repos/tebanhdez/refiere.co/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tebanhdez/refiere.co/merges","archive_url":"https://api.github.com/repos/tebanhdez/refiere.co/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tebanhdez/refiere.co/downloads","issues_url":"https://api.github.com/repos/tebanhdez/refiere.co/issues{/number}","pulls_url":"https://api.github.com/repos/tebanhdez/refiere.co/pulls{/number}","milestones_url":"https://api.github.com/repos/tebanhdez/refiere.co/milestones{/number}","notifications_url":"https://api.github.com/repos/tebanhdez/refiere.co/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tebanhdez/refiere.co/labels{/name}","releases_url":"https://api.github.com/repos/tebanhdez/refiere.co/releases{/id}","deployments_url":"https://api.github.com/repos/tebanhdez/refiere.co/deployments","created_at":"2016-04-13T21:17:05Z","updated_at":"2016-04-27T20:02:09Z","pushed_at":"2016-05-25T19:59:33Z","git_url":"git://github.com/tebanhdez/refiere.co.git","ssh_url":"git@github.com:tebanhdez/refiere.co.git","clone_url":"https://github.com/tebanhdez/refiere.co.git","svn_url":"https://github.com/tebanhdez/refiere.co","homepage":null,"size":2927,"stargazers_count":0,"watchers_count":0,"language":"HTML","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":2,"forks":1,"open_issues":2,"watchers":0,"default_branch":"dev"}},"_links":{"self":{"href":"https://api.github.com/repos/tebanhdez/refiere.co/pulls/14"},"html":{"href":"https://github.com/tebanhdez/refiere.co/pull/14"},"issue":{"href":"https://api.github.com/repos/tebanhdez/refiere.co/issues/14"},"comments":{"href":"https://api.github.com/repos/tebanhdez/refiere.co/issues/14/comments"},"review_comments":{"href":"https://api.github.com/repos/tebanhdez/refiere.co/pulls/14/comments"},"review_comment":{"href":"https://api.github.com/repos/tebanhdez/refiere.co/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/tebanhdez/refiere.co/pulls/14/commits"},"statuses":{"href":"https://api.github.com/repos/tebanhdez/refiere.co/statuses/36abdad37f424085f577b7079b1102b51670b06a"}}}}
{"actor":{"display_login":"tebanhdez"}}