{"action":"created","comment":{"url":"https://api.github.com/repos/abiquo/api-java-client/pulls/comments/22581791","id":22581791,"diff_hunk":"@@ -287,4 +292,204 @@ public void testRefreshLibrary() throws Exception\n         assertAccept(second, TaskDto.SHORT_MEDIA_TYPE_JSON, SingleResourceTransportDto.API_VERSION);\n     }\n \n+    public void testCreatePersistent() throws Exception\n+    {\n+\n+        AcceptedRequestDto<String> acceptDto = new AcceptedRequestDto<String>();\n+        RESTLink link =\n+            new RESTLink(\"status\",\n+                \"/admin/enterprises/1/datacenterrepositories/1/virtualmachinetemplates/1/tasks/1\");\n+        link.setType(TaskDto.SHORT_MEDIA_TYPE_JSON);\n+        acceptDto.addLink(link);\n+\n+        server.enqueue(new MockResponse().addHeader(\"Content-type\",\n+            AcceptedRequestDto.SHORT_MEDIA_TYPE_JSON).setBody(json.write(acceptDto)));\n+\n+        TaskDto inProgress = new TaskDto();\n+        inProgress.setState(TaskState.PENDING);\n+        TaskDto completed = new TaskDto();\n+        completed.setState(TaskState.FINISHED_SUCCESSFULLY);\n+        link =\n+            new RESTLink(\"result\",\n+                \"/admin/enterprises/1/datacenterrepositories/1/virtualmachinetemplates/1\");\n+        link.setType(VirtualMachineTemplateDto.SHORT_MEDIA_TYPE_JSON);\n+        completed.addLink(link);\n+\n+        server.enqueue(new MockResponse().addHeader(\"Content-type\", TaskDto.SHORT_MEDIA_TYPE_JSON)\n+            .setBody(json.write(inProgress)));\n+        server.enqueue(new MockResponse().addHeader(\"Content-type\", TaskDto.SHORT_MEDIA_TYPE_JSON)\n+            .setBody(json.write(completed)));\n+\n+        MockResponse response =\n+            new MockResponse().setHeader(\"Content-Type\",\n+                VirtualMachineTemplateDto.SHORT_MEDIA_TYPE_JSON).setBody(\n+                payloadFromResource(\"persistentTemplate.json\"));\n+\n+        server.enqueue(response);\n+        server.play();\n+\n+        TierDto tier = new TierDto();\n+        link = new RESTLink(\"self\", \"/cloud/virtualdatacenters/1/tiers/1\");\n+        link.setType(TierDto.SHORT_MEDIA_TYPE_JSON);\n+        tier.addLink(link);\n+\n+        VirtualDatacenterDto vdc = new VirtualDatacenterDto();\n+        link = new RESTLink(\"edit\", \"/cloud/virtualdatacenters/1\");\n+        link.setType(VirtualDatacenterDto.SHORT_MEDIA_TYPE_JSON);\n+        vdc.addLink(link);\n+\n+        VirtualMachineTemplateDto vmt = new VirtualMachineTemplateDto();\n+        link =\n+            new RESTLink(\"edit\",\n+                \"/admin/enterprises/1/datacenterrepositories/1/virtualmachinetemplates/1\");\n+        link.setType(VirtualMachineTemplateDto.SHORT_MEDIA_TYPE_JSON);\n+        vmt.addLink(link);\n+        link = new RESTLink(\"repository\", \"/admin/enterprises/1/datacenterrepositories/1\");\n+        link.setType(DatacenterRepositoriesDto.SHORT_MEDIA_TYPE_JSON);\n+        vmt.addLink(link);\n+\n+        newApiClient().getTemplatesApi().createPersistent(vdc, vmt, \"persistentName\", tier, 10,\n+            300, TimeUnit.SECONDS);\n+\n+        // Make sure the polling has retried once\n+        assertEquals(server.getRequestCount(), 4);\n+\n+        // Verify the first request\n+        RecordedRequest request = server.takeRequest();\n+        assertRequest(request, \"POST\",\n+            \"/admin/enterprises/1/datacenterrepositories/1/virtualmachinetemplates\");\n+        assertAccept(request, AcceptedRequestDto.SHORT_MEDIA_TYPE_JSON,\n+            SingleResourceTransportDto.API_VERSION);\n+        assertContentType(request, VirtualMachineTemplatePersistentDto.SHORT_MEDIA_TYPE_JSON,\n+            SingleResourceTransportDto.API_VERSION);\n+\n+        VirtualMachineTemplatePersistentDto requestBody =\n+            readBody(request, VirtualMachineTemplatePersistentDto.class);\n+        assertEquals(requestBody.getPersistentTemplateName(), \"persistentName\");\n+        assertEquals(requestBody.getPersistentVolumeName(), \"persistentName\");\n+        assertLinkExist(requestBody, requestBody.searchLink(\"tier\").getHref(), \"tier\",\n+            TierDto.SHORT_MEDIA_TYPE_JSON);\n+        assertLinkExist(requestBody, requestBody.searchLink(\"virtualdatacenter\").getHref(),\n+            \"virtualdatacenter\", VirtualDatacenterDto.SHORT_MEDIA_TYPE_JSON);\n+        assertLinkExist(requestBody, requestBody.searchLink(\"virtualmachinetemplate\").getHref(),\n+            \"virtualmachinetemplate\", VirtualMachineTemplateDto.SHORT_MEDIA_TYPE_JSON);\n+\n+        // Verify the second request\n+        RecordedRequest second = server.takeRequest();\n+        assertRequest(second, \"GET\",\n+            \"/admin/enterprises/1/datacenterrepositories/1/virtualmachinetemplates/1/tasks/1\");\n+        assertAccept(second, TaskDto.SHORT_MEDIA_TYPE_JSON, SingleResourceTransportDto.API_VERSION);\n+\n+        // Verify the third request\n+        RecordedRequest third = server.takeRequest();\n+        assertRequest(third, \"GET\",\n+            \"/admin/enterprises/1/datacenterrepositories/1/virtualmachinetemplates/1/tasks/1\");\n+        assertAccept(third, TaskDto.SHORT_MEDIA_TYPE_JSON, SingleResourceTransportDto.API_VERSION);\n+\n+        // Verify the forth request\n+        RecordedRequest forth = server.takeRequest();\n+        assertRequest(forth, \"GET\",\n+            \"/admin/enterprises/1/datacenterrepositories/1/virtualmachinetemplates/1\");\n+        assertAccept(forth, VirtualMachineTemplateDto.SHORT_MEDIA_TYPE_JSON,\n+            SingleResourceTransportDto.API_VERSION);\n+\n+    }\n+\n+    public void testCreatePersistentFails() throws Exception\n+    {\n+\n+        AcceptedRequestDto<String> acceptDto = new AcceptedRequestDto<String>();\n+        RESTLink link =\n+            new RESTLink(\"status\",\n+                \"/api/admin/enterprises/1/datacenterrepositories/1/virtualmachinetemplates/1/tasks/1\");\n+        link.setType(TaskDto.SHORT_MEDIA_TYPE_JSON);\n+        acceptDto.addLink(link);\n+\n+        server.enqueue(new MockResponse().addHeader(\"Content-type\",\n+            AcceptedRequestDto.SHORT_MEDIA_TYPE_JSON).setBody(json.write(acceptDto)));\n+\n+        TaskDto unsuccesful = new TaskDto();\n+        unsuccesful.setState(TaskState.FINISHED_UNSUCCESSFULLY);\n+        link =\n+            new RESTLink(\"result\",\n+                \"/admin/enterprises/1/datacenterrepositories/1/virtualmachinetemplates/1\");\n+        link.setType(VirtualMachineTemplateDto.SHORT_MEDIA_TYPE_JSON);\n+        unsuccesful.addLink(link);\n+\n+        server.enqueue(new MockResponse().addHeader(\"Content-type\", TaskDto.SHORT_MEDIA_TYPE_JSON)\n+            .setBody(json.write(unsuccesful)));\n+\n+        MockResponse response =\n+            new MockResponse().setHeader(\"Content-Type\", AcceptedRequestDto.SHORT_MEDIA_TYPE_JSON)\n+                .setBody(payloadFromResource(\"acceptedRequest.json\"));","path":"src/test/java/com/abiquo/apiclient/templates/TemplatesApiTest.java","position":159,"original_position":159,"commit_id":"8d03d9d007a7c3dddb191f99c90ae1aa3908d2bd","original_commit_id":"8d03d9d007a7c3dddb191f99c90ae1aa3908d2bd","user":{"login":"nacx","id":446705,"avatar_url":"https://avatars.githubusercontent.com/u/446705?v=3","gravatar_id":"","url":"https://api.github.com/users/nacx","html_url":"https://github.com/nacx","followers_url":"https://api.github.com/users/nacx/followers","following_url":"https://api.github.com/users/nacx/following{/other_user}","gists_url":"https://api.github.com/users/nacx/gists{/gist_id}","starred_url":"https://api.github.com/users/nacx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nacx/subscriptions","organizations_url":"https://api.github.com/users/nacx/orgs","repos_url":"https://api.github.com/users/nacx/repos","events_url":"https://api.github.com/users/nacx/events{/privacy}","received_events_url":"https://api.github.com/users/nacx/received_events","type":"User","site_admin":false},"body":"Is this response being used? Don't enqueue it if it is not.","created_at":"2015-01-07T11:30:30Z","updated_at":"2015-01-07T11:30:30Z","html_url":"https://github.com/abiquo/api-java-client/pull/10#discussion_r22581791","pull_request_url":"https://api.github.com/repos/abiquo/api-java-client/pulls/10","_links":{"self":{"href":"https://api.github.com/repos/abiquo/api-java-client/pulls/comments/22581791"},"html":{"href":"https://github.com/abiquo/api-java-client/pull/10#discussion_r22581791"},"pull_request":{"href":"https://api.github.com/repos/abiquo/api-java-client/pulls/10"}}},"pull_request":{"url":"https://api.github.com/repos/abiquo/api-java-client/pulls/10","id":26758236,"html_url":"https://github.com/abiquo/api-java-client/pull/10","diff_url":"https://github.com/abiquo/api-java-client/pull/10.diff","patch_url":"https://github.com/abiquo/api-java-client/pull/10.patch","issue_url":"https://api.github.com/repos/abiquo/api-java-client/issues/10","number":10,"state":"open","locked":false,"title":"added Create Persistent","user":{"login":"sacedo","id":624901,"avatar_url":"https://avatars.githubusercontent.com/u/624901?v=3","gravatar_id":"","url":"https://api.github.com/users/sacedo","html_url":"https://github.com/sacedo","followers_url":"https://api.github.com/users/sacedo/followers","following_url":"https://api.github.com/users/sacedo/following{/other_user}","gists_url":"https://api.github.com/users/sacedo/gists{/gist_id}","starred_url":"https://api.github.com/users/sacedo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sacedo/subscriptions","organizations_url":"https://api.github.com/users/sacedo/orgs","repos_url":"https://api.github.com/users/sacedo/repos","events_url":"https://api.github.com/users/sacedo/events{/privacy}","received_events_url":"https://api.github.com/users/sacedo/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-01-02T14:17:44Z","updated_at":"2015-01-07T11:30:30Z","closed_at":null,"merged_at":null,"merge_commit_sha":"da7e1612e5c98eeaae58e5fc0da5f058a2f1c2bb","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/abiquo/api-java-client/pulls/10/commits","review_comments_url":"https://api.github.com/repos/abiquo/api-java-client/pulls/10/comments","review_comment_url":"https://api.github.com/repos/abiquo/api-java-client/pulls/comments/{number}","comments_url":"https://api.github.com/repos/abiquo/api-java-client/issues/10/comments","statuses_url":"https://api.github.com/repos/abiquo/api-java-client/statuses/8d03d9d007a7c3dddb191f99c90ae1aa3908d2bd","head":{"label":"abiquo:createPersistent","ref":"createPersistent","sha":"8d03d9d007a7c3dddb191f99c90ae1aa3908d2bd","user":{"login":"abiquo","id":53275,"avatar_url":"https://avatars.githubusercontent.com/u/53275?v=3","gravatar_id":"","url":"https://api.github.com/users/abiquo","html_url":"https://github.com/abiquo","followers_url":"https://api.github.com/users/abiquo/followers","following_url":"https://api.github.com/users/abiquo/following{/other_user}","gists_url":"https://api.github.com/users/abiquo/gists{/gist_id}","starred_url":"https://api.github.com/users/abiquo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abiquo/subscriptions","organizations_url":"https://api.github.com/users/abiquo/orgs","repos_url":"https://api.github.com/users/abiquo/repos","events_url":"https://api.github.com/users/abiquo/events{/privacy}","received_events_url":"https://api.github.com/users/abiquo/received_events","type":"Organization","site_admin":false},"repo":{"id":26806820,"name":"api-java-client","full_name":"abiquo/api-java-client","owner":{"login":"abiquo","id":53275,"avatar_url":"https://avatars.githubusercontent.com/u/53275?v=3","gravatar_id":"","url":"https://api.github.com/users/abiquo","html_url":"https://github.com/abiquo","followers_url":"https://api.github.com/users/abiquo/followers","following_url":"https://api.github.com/users/abiquo/following{/other_user}","gists_url":"https://api.github.com/users/abiquo/gists{/gist_id}","starred_url":"https://api.github.com/users/abiquo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abiquo/subscriptions","organizations_url":"https://api.github.com/users/abiquo/orgs","repos_url":"https://api.github.com/users/abiquo/repos","events_url":"https://api.github.com/users/abiquo/events{/privacy}","received_events_url":"https://api.github.com/users/abiquo/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/abiquo/api-java-client","description":"A small Java client for the Abiquo API","fork":false,"url":"https://api.github.com/repos/abiquo/api-java-client","forks_url":"https://api.github.com/repos/abiquo/api-java-client/forks","keys_url":"https://api.github.com/repos/abiquo/api-java-client/keys{/key_id}","collaborators_url":"https://api.github.com/repos/abiquo/api-java-client/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/abiquo/api-java-client/teams","hooks_url":"https://api.github.com/repos/abiquo/api-java-client/hooks","issue_events_url":"https://api.github.com/repos/abiquo/api-java-client/issues/events{/number}","events_url":"https://api.github.com/repos/abiquo/api-java-client/events","assignees_url":"https://api.github.com/repos/abiquo/api-java-client/assignees{/user}","branches_url":"https://api.github.com/repos/abiquo/api-java-client/branches{/branch}","tags_url":"https://api.github.com/repos/abiquo/api-java-client/tags","blobs_url":"https://api.github.com/repos/abiquo/api-java-client/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/abiquo/api-java-client/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/abiquo/api-java-client/git/refs{/sha}","trees_url":"https://api.github.com/repos/abiquo/api-java-client/git/trees{/sha}","statuses_url":"https://api.github.com/repos/abiquo/api-java-client/statuses/{sha}","languages_url":"https://api.github.com/repos/abiquo/api-java-client/languages","stargazers_url":"https://api.github.com/repos/abiquo/api-java-client/stargazers","contributors_url":"https://api.github.com/repos/abiquo/api-java-client/contributors","subscribers_url":"https://api.github.com/repos/abiquo/api-java-client/subscribers","subscription_url":"https://api.github.com/repos/abiquo/api-java-client/subscription","commits_url":"https://api.github.com/repos/abiquo/api-java-client/commits{/sha}","git_commits_url":"https://api.github.com/repos/abiquo/api-java-client/git/commits{/sha}","comments_url":"https://api.github.com/repos/abiquo/api-java-client/comments{/number}","issue_comment_url":"https://api.github.com/repos/abiquo/api-java-client/issues/comments/{number}","contents_url":"https://api.github.com/repos/abiquo/api-java-client/contents/{+path}","compare_url":"https://api.github.com/repos/abiquo/api-java-client/compare/{base}...{head}","merges_url":"https://api.github.com/repos/abiquo/api-java-client/merges","archive_url":"https://api.github.com/repos/abiquo/api-java-client/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/abiquo/api-java-client/downloads","issues_url":"https://api.github.com/repos/abiquo/api-java-client/issues{/number}","pulls_url":"https://api.github.com/repos/abiquo/api-java-client/pulls{/number}","milestones_url":"https://api.github.com/repos/abiquo/api-java-client/milestones{/number}","notifications_url":"https://api.github.com/repos/abiquo/api-java-client/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/abiquo/api-java-client/labels{/name}","releases_url":"https://api.github.com/repos/abiquo/api-java-client/releases{/id}","created_at":"2014-11-18T11:46:37Z","updated_at":"2015-01-07T10:19:03Z","pushed_at":"2015-01-07T11:17:29Z","git_url":"git://github.com/abiquo/api-java-client.git","ssh_url":"git@github.com:abiquo/api-java-client.git","clone_url":"https://github.com/abiquo/api-java-client.git","svn_url":"https://github.com/abiquo/api-java-client","homepage":"http://www.abiquo.com","size":639,"stargazers_count":3,"watchers_count":3,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":3,"default_branch":"master"}},"base":{"label":"abiquo:master","ref":"master","sha":"dfcbfe4d568c4ca692500ce008cffcce7ba910fc","user":{"login":"abiquo","id":53275,"avatar_url":"https://avatars.githubusercontent.com/u/53275?v=3","gravatar_id":"","url":"https://api.github.com/users/abiquo","html_url":"https://github.com/abiquo","followers_url":"https://api.github.com/users/abiquo/followers","following_url":"https://api.github.com/users/abiquo/following{/other_user}","gists_url":"https://api.github.com/users/abiquo/gists{/gist_id}","starred_url":"https://api.github.com/users/abiquo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abiquo/subscriptions","organizations_url":"https://api.github.com/users/abiquo/orgs","repos_url":"https://api.github.com/users/abiquo/repos","events_url":"https://api.github.com/users/abiquo/events{/privacy}","received_events_url":"https://api.github.com/users/abiquo/received_events","type":"Organization","site_admin":false},"repo":{"id":26806820,"name":"api-java-client","full_name":"abiquo/api-java-client","owner":{"login":"abiquo","id":53275,"avatar_url":"https://avatars.githubusercontent.com/u/53275?v=3","gravatar_id":"","url":"https://api.github.com/users/abiquo","html_url":"https://github.com/abiquo","followers_url":"https://api.github.com/users/abiquo/followers","following_url":"https://api.github.com/users/abiquo/following{/other_user}","gists_url":"https://api.github.com/users/abiquo/gists{/gist_id}","starred_url":"https://api.github.com/users/abiquo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abiquo/subscriptions","organizations_url":"https://api.github.com/users/abiquo/orgs","repos_url":"https://api.github.com/users/abiquo/repos","events_url":"https://api.github.com/users/abiquo/events{/privacy}","received_events_url":"https://api.github.com/users/abiquo/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/abiquo/api-java-client","description":"A small Java client for the Abiquo API","fork":false,"url":"https://api.github.com/repos/abiquo/api-java-client","forks_url":"https://api.github.com/repos/abiquo/api-java-client/forks","keys_url":"https://api.github.com/repos/abiquo/api-java-client/keys{/key_id}","collaborators_url":"https://api.github.com/repos/abiquo/api-java-client/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/abiquo/api-java-client/teams","hooks_url":"https://api.github.com/repos/abiquo/api-java-client/hooks","issue_events_url":"https://api.github.com/repos/abiquo/api-java-client/issues/events{/number}","events_url":"https://api.github.com/repos/abiquo/api-java-client/events","assignees_url":"https://api.github.com/repos/abiquo/api-java-client/assignees{/user}","branches_url":"https://api.github.com/repos/abiquo/api-java-client/branches{/branch}","tags_url":"https://api.github.com/repos/abiquo/api-java-client/tags","blobs_url":"https://api.github.com/repos/abiquo/api-java-client/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/abiquo/api-java-client/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/abiquo/api-java-client/git/refs{/sha}","trees_url":"https://api.github.com/repos/abiquo/api-java-client/git/trees{/sha}","statuses_url":"https://api.github.com/repos/abiquo/api-java-client/statuses/{sha}","languages_url":"https://api.github.com/repos/abiquo/api-java-client/languages","stargazers_url":"https://api.github.com/repos/abiquo/api-java-client/stargazers","contributors_url":"https://api.github.com/repos/abiquo/api-java-client/contributors","subscribers_url":"https://api.github.com/repos/abiquo/api-java-client/subscribers","subscription_url":"https://api.github.com/repos/abiquo/api-java-client/subscription","commits_url":"https://api.github.com/repos/abiquo/api-java-client/commits{/sha}","git_commits_url":"https://api.github.com/repos/abiquo/api-java-client/git/commits{/sha}","comments_url":"https://api.github.com/repos/abiquo/api-java-client/comments{/number}","issue_comment_url":"https://api.github.com/repos/abiquo/api-java-client/issues/comments/{number}","contents_url":"https://api.github.com/repos/abiquo/api-java-client/contents/{+path}","compare_url":"https://api.github.com/repos/abiquo/api-java-client/compare/{base}...{head}","merges_url":"https://api.github.com/repos/abiquo/api-java-client/merges","archive_url":"https://api.github.com/repos/abiquo/api-java-client/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/abiquo/api-java-client/downloads","issues_url":"https://api.github.com/repos/abiquo/api-java-client/issues{/number}","pulls_url":"https://api.github.com/repos/abiquo/api-java-client/pulls{/number}","milestones_url":"https://api.github.com/repos/abiquo/api-java-client/milestones{/number}","notifications_url":"https://api.github.com/repos/abiquo/api-java-client/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/abiquo/api-java-client/labels{/name}","releases_url":"https://api.github.com/repos/abiquo/api-java-client/releases{/id}","created_at":"2014-11-18T11:46:37Z","updated_at":"2015-01-07T10:19:03Z","pushed_at":"2015-01-07T11:17:29Z","git_url":"git://github.com/abiquo/api-java-client.git","ssh_url":"git@github.com:abiquo/api-java-client.git","clone_url":"https://github.com/abiquo/api-java-client.git","svn_url":"https://github.com/abiquo/api-java-client","homepage":"http://www.abiquo.com","size":639,"stargazers_count":3,"watchers_count":3,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/abiquo/api-java-client/pulls/10"},"html":{"href":"https://github.com/abiquo/api-java-client/pull/10"},"issue":{"href":"https://api.github.com/repos/abiquo/api-java-client/issues/10"},"comments":{"href":"https://api.github.com/repos/abiquo/api-java-client/issues/10/comments"},"review_comments":{"href":"https://api.github.com/repos/abiquo/api-java-client/pulls/10/comments"},"review_comment":{"href":"https://api.github.com/repos/abiquo/api-java-client/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/abiquo/api-java-client/pulls/10/commits"},"statuses":{"href":"https://api.github.com/repos/abiquo/api-java-client/statuses/8d03d9d007a7c3dddb191f99c90ae1aa3908d2bd"}}}}