{"action":"created","comment":{"url":"https://api.github.com/repos/codenvy/che-core/pulls/comments/39853414","id":39853414,"diff_hunk":"@@ -0,0 +1,142 @@\n+/*******************************************************************************\n+ * Copyright (c) 2012-2015 Codenvy, S.A.\n+ * All rights reserved. This program and the accompanying materials\n+ * are made available under the terms of the Eclipse Public License v1.0\n+ * which accompanies this distribution, and is available at\n+ * http://www.eclipse.org/legal/epl-v10.html\n+ *\n+ * Contributors:\n+ *   Codenvy, S.A. - initial API and implementation\n+ *******************************************************************************/\n+package org.eclipse.che.api.machine.server;\n+\n+\n+import org.eclipse.che.api.core.notification.EventService;\n+import org.eclipse.che.api.core.util.LineConsumer;\n+import org.eclipse.che.api.machine.server.dao.SnapshotDao;\n+import org.eclipse.che.api.machine.server.exception.MachineException;\n+import org.eclipse.che.api.machine.server.impl.MachineImpl;\n+import org.eclipse.che.api.machine.server.spi.Instance;\n+import org.eclipse.che.api.machine.server.spi.InstanceProvider;\n+import org.eclipse.che.api.machine.shared.MachineStatus;\n+import org.eclipse.che.api.machine.shared.Recipe;\n+import org.eclipse.che.api.machine.shared.dto.RecipeMachineCreationMetadata;\n+import org.eclipse.che.api.machine.shared.dto.recipe.MachineRecipe;\n+import org.eclipse.che.commons.env.EnvironmentContext;\n+import org.eclipse.che.commons.user.UserImpl;\n+import org.mockito.Mock;\n+import org.mockito.testng.MockitoTestNGListener;\n+import org.testng.annotations.AfterMethod;\n+import org.testng.annotations.BeforeMethod;\n+import org.testng.annotations.Listeners;\n+import org.testng.annotations.Test;\n+\n+import java.util.Collections;\n+import java.util.HashSet;\n+import java.util.List;\n+import java.util.Set;\n+\n+import static org.mockito.Matchers.anyBoolean;\n+import static org.mockito.Matchers.anyInt;\n+import static org.mockito.Matchers.anyString;\n+import static org.mockito.Mockito.any;\n+import static org.mockito.Mockito.doNothing;\n+import static org.mockito.Mockito.mock;\n+import static org.mockito.Mockito.spy;\n+import static org.mockito.Mockito.when;\n+import static org.testng.Assert.assertEquals;\n+\n+/**\n+ * @author Anton Korneta\n+ */\n+@Listeners(MockitoTestNGListener.class)\n+public class MachineManagerTest {\n+    private static final String MACHINE_LOGS_DIR               = \"target/logs-dir\";\n+    private static final int    DEFAULT_MACHINE_MEMORY_SIZE_MB = 1000;\n+\n+    private MachineManager manager;\n+\n+    @Mock\n+    private MachineInstanceProviders machineInstanceProviders;\n+    @Mock\n+    private MachineRegistry          machineRegistry;\n+\n+    @BeforeMethod\n+    public void setUp() {\n+        final SnapshotDao snapshotDao = mock(SnapshotDao.class);\n+        final EventService eventService = mock(EventService.class);\n+\n+        manager = spy(new MachineManager(snapshotDao,\n+                                         machineRegistry,\n+                                         machineInstanceProviders,\n+                                         MACHINE_LOGS_DIR,\n+                                         eventService,\n+                                         DEFAULT_MACHINE_MEMORY_SIZE_MB));\n+\n+        EnvironmentContext envCont = new EnvironmentContext();\n+        envCont.setUser(new UserImpl(\"user\", null, null, null, false));\n+        EnvironmentContext.setCurrent(envCont);\n+    }\n+\n+    @AfterMethod\n+    public void tearDown() throws Exception {\n+        EnvironmentContext.reset();\n+    }\n+\n+    @Test(expectedExceptions = MachineException.class)\n+    public void shouldBeAnExceptionWhileValidatingDockerDisplayName() throws Exception {\n+        final RecipeMachineCreationMetadata machineCreationMetadata = mock(RecipeMachineCreationMetadata.class);\n+        final MachineRecipe machineRecipe = mock(MachineRecipe.class);\n+        final InstanceProvider instanceProvider = mock(InstanceProvider.class);\n+        final String type = \"type\";\n+        final Set<String> recipeTypes = new HashSet<String>() {{","path":"platform-api/che-core-api-machine/src/test/java/org/eclipse/che/api/machine/server/MachineManagerTest.java","position":92,"original_position":92,"commit_id":"40d479024e7a7d36b9cc35faf98cc9803e267dd5","original_commit_id":"40d479024e7a7d36b9cc35faf98cc9803e267dd5","user":{"login":"evoevodin","id":4053805,"avatar_url":"https://avatars.githubusercontent.com/u/4053805?v=3","gravatar_id":"","url":"https://api.github.com/users/evoevodin","html_url":"https://github.com/evoevodin","followers_url":"https://api.github.com/users/evoevodin/followers","following_url":"https://api.github.com/users/evoevodin/following{/other_user}","gists_url":"https://api.github.com/users/evoevodin/gists{/gist_id}","starred_url":"https://api.github.com/users/evoevodin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/evoevodin/subscriptions","organizations_url":"https://api.github.com/users/evoevodin/orgs","repos_url":"https://api.github.com/users/evoevodin/repos","events_url":"https://api.github.com/users/evoevodin/events{/privacy}","received_events_url":"https://api.github.com/users/evoevodin/received_events","type":"User","site_admin":false},"body":"Hmm, actually here you create an instance of anonymous class which is not good, you can simplify it:\r\n<code>new HashSet<>(Collections.singleton(type));","created_at":"2015-09-18T13:20:57Z","updated_at":"2015-09-18T13:20:57Z","html_url":"https://github.com/codenvy/che-core/pull/268#discussion_r39853414","pull_request_url":"https://api.github.com/repos/codenvy/che-core/pulls/268","_links":{"self":{"href":"https://api.github.com/repos/codenvy/che-core/pulls/comments/39853414"},"html":{"href":"https://github.com/codenvy/che-core/pull/268#discussion_r39853414"},"pull_request":{"href":"https://api.github.com/repos/codenvy/che-core/pulls/268"}}},"pull_request":{"url":"https://api.github.com/repos/codenvy/che-core/pulls/268","id":45398601,"html_url":"https://github.com/codenvy/che-core/pull/268","diff_url":"https://github.com/codenvy/che-core/pull/268.diff","patch_url":"https://github.com/codenvy/che-core/pull/268.patch","issue_url":"https://api.github.com/repos/codenvy/che-core/issues/268","number":268,"state":"open","locked":false,"title":"Idex 2848","user":{"login":"akorneta","id":12269156,"avatar_url":"https://avatars.githubusercontent.com/u/12269156?v=3","gravatar_id":"","url":"https://api.github.com/users/akorneta","html_url":"https://github.com/akorneta","followers_url":"https://api.github.com/users/akorneta/followers","following_url":"https://api.github.com/users/akorneta/following{/other_user}","gists_url":"https://api.github.com/users/akorneta/gists{/gist_id}","starred_url":"https://api.github.com/users/akorneta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akorneta/subscriptions","organizations_url":"https://api.github.com/users/akorneta/orgs","repos_url":"https://api.github.com/users/akorneta/repos","events_url":"https://api.github.com/users/akorneta/events{/privacy}","received_events_url":"https://api.github.com/users/akorneta/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-09-18T12:02:21Z","updated_at":"2015-09-18T13:20:57Z","closed_at":null,"merged_at":null,"merge_commit_sha":"78cdbd09004274679f77993bc80647e99aacfe43","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/codenvy/che-core/pulls/268/commits","review_comments_url":"https://api.github.com/repos/codenvy/che-core/pulls/268/comments","review_comment_url":"https://api.github.com/repos/codenvy/che-core/pulls/comments{/number}","comments_url":"https://api.github.com/repos/codenvy/che-core/issues/268/comments","statuses_url":"https://api.github.com/repos/codenvy/che-core/statuses/40d479024e7a7d36b9cc35faf98cc9803e267dd5","head":{"label":"codenvy:IDEX-2848","ref":"IDEX-2848","sha":"40d479024e7a7d36b9cc35faf98cc9803e267dd5","user":{"login":"codenvy","id":2736247,"avatar_url":"https://avatars.githubusercontent.com/u/2736247?v=3","gravatar_id":"","url":"https://api.github.com/users/codenvy","html_url":"https://github.com/codenvy","followers_url":"https://api.github.com/users/codenvy/followers","following_url":"https://api.github.com/users/codenvy/following{/other_user}","gists_url":"https://api.github.com/users/codenvy/gists{/gist_id}","starred_url":"https://api.github.com/users/codenvy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codenvy/subscriptions","organizations_url":"https://api.github.com/users/codenvy/orgs","repos_url":"https://api.github.com/users/codenvy/repos","events_url":"https://api.github.com/users/codenvy/events{/privacy}","received_events_url":"https://api.github.com/users/codenvy/received_events","type":"Organization","site_admin":false},"repo":{"id":32935706,"name":"che-core","full_name":"codenvy/che-core","owner":{"login":"codenvy","id":2736247,"avatar_url":"https://avatars.githubusercontent.com/u/2736247?v=3","gravatar_id":"","url":"https://api.github.com/users/codenvy","html_url":"https://github.com/codenvy","followers_url":"https://api.github.com/users/codenvy/followers","following_url":"https://api.github.com/users/codenvy/following{/other_user}","gists_url":"https://api.github.com/users/codenvy/gists{/gist_id}","starred_url":"https://api.github.com/users/codenvy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codenvy/subscriptions","organizations_url":"https://api.github.com/users/codenvy/orgs","repos_url":"https://api.github.com/users/codenvy/repos","events_url":"https://api.github.com/users/codenvy/events{/privacy}","received_events_url":"https://api.github.com/users/codenvy/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/codenvy/che-core","description":"Core for che","fork":false,"url":"https://api.github.com/repos/codenvy/che-core","forks_url":"https://api.github.com/repos/codenvy/che-core/forks","keys_url":"https://api.github.com/repos/codenvy/che-core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/codenvy/che-core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/codenvy/che-core/teams","hooks_url":"https://api.github.com/repos/codenvy/che-core/hooks","issue_events_url":"https://api.github.com/repos/codenvy/che-core/issues/events{/number}","events_url":"https://api.github.com/repos/codenvy/che-core/events","assignees_url":"https://api.github.com/repos/codenvy/che-core/assignees{/user}","branches_url":"https://api.github.com/repos/codenvy/che-core/branches{/branch}","tags_url":"https://api.github.com/repos/codenvy/che-core/tags","blobs_url":"https://api.github.com/repos/codenvy/che-core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/codenvy/che-core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/codenvy/che-core/git/refs{/sha}","trees_url":"https://api.github.com/repos/codenvy/che-core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/codenvy/che-core/statuses/{sha}","languages_url":"https://api.github.com/repos/codenvy/che-core/languages","stargazers_url":"https://api.github.com/repos/codenvy/che-core/stargazers","contributors_url":"https://api.github.com/repos/codenvy/che-core/contributors","subscribers_url":"https://api.github.com/repos/codenvy/che-core/subscribers","subscription_url":"https://api.github.com/repos/codenvy/che-core/subscription","commits_url":"https://api.github.com/repos/codenvy/che-core/commits{/sha}","git_commits_url":"https://api.github.com/repos/codenvy/che-core/git/commits{/sha}","comments_url":"https://api.github.com/repos/codenvy/che-core/comments{/number}","issue_comment_url":"https://api.github.com/repos/codenvy/che-core/issues/comments{/number}","contents_url":"https://api.github.com/repos/codenvy/che-core/contents/{+path}","compare_url":"https://api.github.com/repos/codenvy/che-core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/codenvy/che-core/merges","archive_url":"https://api.github.com/repos/codenvy/che-core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/codenvy/che-core/downloads","issues_url":"https://api.github.com/repos/codenvy/che-core/issues{/number}","pulls_url":"https://api.github.com/repos/codenvy/che-core/pulls{/number}","milestones_url":"https://api.github.com/repos/codenvy/che-core/milestones{/number}","notifications_url":"https://api.github.com/repos/codenvy/che-core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/codenvy/che-core/labels{/name}","releases_url":"https://api.github.com/repos/codenvy/che-core/releases{/id}","created_at":"2015-03-26T15:30:10Z","updated_at":"2015-09-09T08:53:01Z","pushed_at":"2015-09-18T13:19:34Z","git_url":"git://github.com/codenvy/che-core.git","ssh_url":"git@github.com:codenvy/che-core.git","clone_url":"https://github.com/codenvy/che-core.git","svn_url":"https://github.com/codenvy/che-core","homepage":null,"size":11432,"stargazers_count":12,"watchers_count":12,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":19,"mirror_url":null,"open_issues_count":7,"forks":19,"open_issues":7,"watchers":12,"default_branch":"master"}},"base":{"label":"codenvy:4.0","ref":"4.0","sha":"8682ca8cdd90cf34d59af9a24b01179d0706608b","user":{"login":"codenvy","id":2736247,"avatar_url":"https://avatars.githubusercontent.com/u/2736247?v=3","gravatar_id":"","url":"https://api.github.com/users/codenvy","html_url":"https://github.com/codenvy","followers_url":"https://api.github.com/users/codenvy/followers","following_url":"https://api.github.com/users/codenvy/following{/other_user}","gists_url":"https://api.github.com/users/codenvy/gists{/gist_id}","starred_url":"https://api.github.com/users/codenvy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codenvy/subscriptions","organizations_url":"https://api.github.com/users/codenvy/orgs","repos_url":"https://api.github.com/users/codenvy/repos","events_url":"https://api.github.com/users/codenvy/events{/privacy}","received_events_url":"https://api.github.com/users/codenvy/received_events","type":"Organization","site_admin":false},"repo":{"id":32935706,"name":"che-core","full_name":"codenvy/che-core","owner":{"login":"codenvy","id":2736247,"avatar_url":"https://avatars.githubusercontent.com/u/2736247?v=3","gravatar_id":"","url":"https://api.github.com/users/codenvy","html_url":"https://github.com/codenvy","followers_url":"https://api.github.com/users/codenvy/followers","following_url":"https://api.github.com/users/codenvy/following{/other_user}","gists_url":"https://api.github.com/users/codenvy/gists{/gist_id}","starred_url":"https://api.github.com/users/codenvy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codenvy/subscriptions","organizations_url":"https://api.github.com/users/codenvy/orgs","repos_url":"https://api.github.com/users/codenvy/repos","events_url":"https://api.github.com/users/codenvy/events{/privacy}","received_events_url":"https://api.github.com/users/codenvy/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/codenvy/che-core","description":"Core for che","fork":false,"url":"https://api.github.com/repos/codenvy/che-core","forks_url":"https://api.github.com/repos/codenvy/che-core/forks","keys_url":"https://api.github.com/repos/codenvy/che-core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/codenvy/che-core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/codenvy/che-core/teams","hooks_url":"https://api.github.com/repos/codenvy/che-core/hooks","issue_events_url":"https://api.github.com/repos/codenvy/che-core/issues/events{/number}","events_url":"https://api.github.com/repos/codenvy/che-core/events","assignees_url":"https://api.github.com/repos/codenvy/che-core/assignees{/user}","branches_url":"https://api.github.com/repos/codenvy/che-core/branches{/branch}","tags_url":"https://api.github.com/repos/codenvy/che-core/tags","blobs_url":"https://api.github.com/repos/codenvy/che-core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/codenvy/che-core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/codenvy/che-core/git/refs{/sha}","trees_url":"https://api.github.com/repos/codenvy/che-core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/codenvy/che-core/statuses/{sha}","languages_url":"https://api.github.com/repos/codenvy/che-core/languages","stargazers_url":"https://api.github.com/repos/codenvy/che-core/stargazers","contributors_url":"https://api.github.com/repos/codenvy/che-core/contributors","subscribers_url":"https://api.github.com/repos/codenvy/che-core/subscribers","subscription_url":"https://api.github.com/repos/codenvy/che-core/subscription","commits_url":"https://api.github.com/repos/codenvy/che-core/commits{/sha}","git_commits_url":"https://api.github.com/repos/codenvy/che-core/git/commits{/sha}","comments_url":"https://api.github.com/repos/codenvy/che-core/comments{/number}","issue_comment_url":"https://api.github.com/repos/codenvy/che-core/issues/comments{/number}","contents_url":"https://api.github.com/repos/codenvy/che-core/contents/{+path}","compare_url":"https://api.github.com/repos/codenvy/che-core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/codenvy/che-core/merges","archive_url":"https://api.github.com/repos/codenvy/che-core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/codenvy/che-core/downloads","issues_url":"https://api.github.com/repos/codenvy/che-core/issues{/number}","pulls_url":"https://api.github.com/repos/codenvy/che-core/pulls{/number}","milestones_url":"https://api.github.com/repos/codenvy/che-core/milestones{/number}","notifications_url":"https://api.github.com/repos/codenvy/che-core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/codenvy/che-core/labels{/name}","releases_url":"https://api.github.com/repos/codenvy/che-core/releases{/id}","created_at":"2015-03-26T15:30:10Z","updated_at":"2015-09-09T08:53:01Z","pushed_at":"2015-09-18T13:19:34Z","git_url":"git://github.com/codenvy/che-core.git","ssh_url":"git@github.com:codenvy/che-core.git","clone_url":"https://github.com/codenvy/che-core.git","svn_url":"https://github.com/codenvy/che-core","homepage":null,"size":11432,"stargazers_count":12,"watchers_count":12,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":19,"mirror_url":null,"open_issues_count":7,"forks":19,"open_issues":7,"watchers":12,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/codenvy/che-core/pulls/268"},"html":{"href":"https://github.com/codenvy/che-core/pull/268"},"issue":{"href":"https://api.github.com/repos/codenvy/che-core/issues/268"},"comments":{"href":"https://api.github.com/repos/codenvy/che-core/issues/268/comments"},"review_comments":{"href":"https://api.github.com/repos/codenvy/che-core/pulls/268/comments"},"review_comment":{"href":"https://api.github.com/repos/codenvy/che-core/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/codenvy/che-core/pulls/268/commits"},"statuses":{"href":"https://api.github.com/repos/codenvy/che-core/statuses/40d479024e7a7d36b9cc35faf98cc9803e267dd5"}}}}