{"action":"created","comment":{"url":"https://api.github.com/repos/testmycode/tmc-langs/pulls/comments/25997272","id":25997272,"diff_hunk":"@@ -0,0 +1,118 @@\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 fi.helsinki.cs.tmc.langs;\n+\n+import fi.helsinki.cs.tmc.langs.ExerciseBuilder;\n+import com.google.common.io.Files;\n+import java.io.File;\n+import java.io.IOException;\n+import java.util.HashMap;\n+import java.util.List;\n+import java.util.Map;\n+import org.apache.commons.io.FileUtils;\n+import org.junit.Test;\n+import static org.junit.Assert.*;\n+\n+/**\n+ *\n+ * @author villheik\n+ */\n+public class ExerciseBuilderTest {\n+\n+    public ExerciseBuilderTest() {\n+    }\n+\n+    private File createTemporaryCopyOf(File file) throws IOException {\n+        File tempFolder = Files.createTempDir();\n+        FileUtils.copyDirectory(file, tempFolder);\n+        return tempFolder;\n+    }\n+\n+    /**\n+     * Test of prepareStub method, of class ExerciseUtils.\n+     * @throws java.io.IOException\n+     */\n+    @Test\n+    public void testPrepareStub() throws IOException {\n+        System.out.println(\"prepareStub\");\n+        File originProject = new File(\"src/test/resources/arith_funcs/\");\n+\n+        File targetFolder = createTemporaryCopyOf(originProject);\n+        ExerciseBuilder instance = new ExerciseBuilder();\n+\n+        instance.prepareStub(targetFolder.toPath());\n+       \n+        File expectedFolder = new File(\"src/test/resources/arith_funcs_stub/src\");\n+        File outputFolder = new File(targetFolder.getAbsolutePath() + \"/src\");\n+        \n+        Map<String, File> expectedFiles = getFileMap(expectedFolder);\n+        Map<String, File> actualFiles = getFileMap(outputFolder);\n+        \n+        for(String fileName : expectedFiles.keySet()) {\n+            File expected = expectedFiles.get(fileName);\n+            File actual = actualFiles.get(fileName);\n+            List<String> expectedLines = FileUtils.readLines(expected);\n+            List<String> actualLines = FileUtils.readLines(actual);\n+            for (int i = 0 ; i < expectedLines.size() ; ++i) {\n+                String expectedLine = expectedLines.get(i);\n+                String actualLine = actualLines.get(i);\n+                assertEquals(\"Line in file \" + fileName + \" did not match \", expectedLine, actualLine);\n+            }\n+            \n+        }\n+        \n+    }\n+\n+    private Map<String, File> getFileMap(File folder) throws IOException {\n+        if (!folder.isDirectory()) {\n+            throw new IOException(\"Supplied path was not a directory\");\n+        }\n+        Map<String, File> result = new HashMap<>();\n+        for (File file : folder.listFiles()) {\n+            if (file.isDirectory()) {\n+                result.putAll(getFileMap(file));\n+                continue;\n+            }\n+            result.put(file.getName(), file);","path":"tmc-langs-framework/src/test/java/fi/helsinki/cs/tmc/langs/ExerciseBuilderTest.java","position":79,"original_position":79,"commit_id":"0435837b3b88ea69e9b0a16f9f0751038c9d9849","original_commit_id":"0435837b3b88ea69e9b0a16f9f0751038c9d9849","user":{"login":"mpartel","id":328952,"avatar_url":"https://avatars.githubusercontent.com/u/328952?v=3","gravatar_id":"","url":"https://api.github.com/users/mpartel","html_url":"https://github.com/mpartel","followers_url":"https://api.github.com/users/mpartel/followers","following_url":"https://api.github.com/users/mpartel/following{/other_user}","gists_url":"https://api.github.com/users/mpartel/gists{/gist_id}","starred_url":"https://api.github.com/users/mpartel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mpartel/subscriptions","organizations_url":"https://api.github.com/users/mpartel/orgs","repos_url":"https://api.github.com/users/mpartel/repos","events_url":"https://api.github.com/users/mpartel/events{/privacy}","received_events_url":"https://api.github.com/users/mpartel/received_events","type":"User","site_admin":false},"body":"So this assumes there's only one file with a given name in a tree?\r\n\r\nMaybe make these keys be relative paths instead?","created_at":"2015-03-07T16:33:49Z","updated_at":"2015-03-07T16:33:49Z","html_url":"https://github.com/testmycode/tmc-langs/pull/3#discussion_r25997272","pull_request_url":"https://api.github.com/repos/testmycode/tmc-langs/pulls/3","_links":{"self":{"href":"https://api.github.com/repos/testmycode/tmc-langs/pulls/comments/25997272"},"html":{"href":"https://github.com/testmycode/tmc-langs/pull/3#discussion_r25997272"},"pull_request":{"href":"https://api.github.com/repos/testmycode/tmc-langs/pulls/3"}}},"pull_request":{"url":"https://api.github.com/repos/testmycode/tmc-langs/pulls/3","id":30565047,"html_url":"https://github.com/testmycode/tmc-langs/pull/3","diff_url":"https://github.com/testmycode/tmc-langs/pull/3.diff","patch_url":"https://github.com/testmycode/tmc-langs/pull/3.patch","issue_url":"https://api.github.com/repos/testmycode/tmc-langs/issues/3","number":3,"state":"open","locked":false,"title":"ANT-language support","user":{"login":"PunyW","id":4546681,"avatar_url":"https://avatars.githubusercontent.com/u/4546681?v=3","gravatar_id":"","url":"https://api.github.com/users/PunyW","html_url":"https://github.com/PunyW","followers_url":"https://api.github.com/users/PunyW/followers","following_url":"https://api.github.com/users/PunyW/following{/other_user}","gists_url":"https://api.github.com/users/PunyW/gists{/gist_id}","starred_url":"https://api.github.com/users/PunyW/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PunyW/subscriptions","organizations_url":"https://api.github.com/users/PunyW/orgs","repos_url":"https://api.github.com/users/PunyW/repos","events_url":"https://api.github.com/users/PunyW/events{/privacy}","received_events_url":"https://api.github.com/users/PunyW/received_events","type":"User","site_admin":false},"body":"Language support for ant mostly done, still working on returning runResult with correct information if compiling fails. ","created_at":"2015-03-05T15:18:53Z","updated_at":"2015-03-07T16:33:49Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d89fdebeeaa38ef58338c24922442855cc1f6590","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/testmycode/tmc-langs/pulls/3/commits","review_comments_url":"https://api.github.com/repos/testmycode/tmc-langs/pulls/3/comments","review_comment_url":"https://api.github.com/repos/testmycode/tmc-langs/pulls/comments{/number}","comments_url":"https://api.github.com/repos/testmycode/tmc-langs/issues/3/comments","statuses_url":"https://api.github.com/repos/testmycode/tmc-langs/statuses/0435837b3b88ea69e9b0a16f9f0751038c9d9849","head":{"label":"tmc-langs:master","ref":"master","sha":"0435837b3b88ea69e9b0a16f9f0751038c9d9849","user":{"login":"tmc-langs","id":10543868,"avatar_url":"https://avatars.githubusercontent.com/u/10543868?v=3","gravatar_id":"","url":"https://api.github.com/users/tmc-langs","html_url":"https://github.com/tmc-langs","followers_url":"https://api.github.com/users/tmc-langs/followers","following_url":"https://api.github.com/users/tmc-langs/following{/other_user}","gists_url":"https://api.github.com/users/tmc-langs/gists{/gist_id}","starred_url":"https://api.github.com/users/tmc-langs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tmc-langs/subscriptions","organizations_url":"https://api.github.com/users/tmc-langs/orgs","repos_url":"https://api.github.com/users/tmc-langs/repos","events_url":"https://api.github.com/users/tmc-langs/events{/privacy}","received_events_url":"https://api.github.com/users/tmc-langs/received_events","type":"Organization","site_admin":false},"repo":{"id":29287055,"name":"tmc-langs","full_name":"tmc-langs/tmc-langs","owner":{"login":"tmc-langs","id":10543868,"avatar_url":"https://avatars.githubusercontent.com/u/10543868?v=3","gravatar_id":"","url":"https://api.github.com/users/tmc-langs","html_url":"https://github.com/tmc-langs","followers_url":"https://api.github.com/users/tmc-langs/followers","following_url":"https://api.github.com/users/tmc-langs/following{/other_user}","gists_url":"https://api.github.com/users/tmc-langs/gists{/gist_id}","starred_url":"https://api.github.com/users/tmc-langs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tmc-langs/subscriptions","organizations_url":"https://api.github.com/users/tmc-langs/orgs","repos_url":"https://api.github.com/users/tmc-langs/repos","events_url":"https://api.github.com/users/tmc-langs/events{/privacy}","received_events_url":"https://api.github.com/users/tmc-langs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/tmc-langs/tmc-langs","description":"TMC language support framework","fork":true,"url":"https://api.github.com/repos/tmc-langs/tmc-langs","forks_url":"https://api.github.com/repos/tmc-langs/tmc-langs/forks","keys_url":"https://api.github.com/repos/tmc-langs/tmc-langs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tmc-langs/tmc-langs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tmc-langs/tmc-langs/teams","hooks_url":"https://api.github.com/repos/tmc-langs/tmc-langs/hooks","issue_events_url":"https://api.github.com/repos/tmc-langs/tmc-langs/issues/events{/number}","events_url":"https://api.github.com/repos/tmc-langs/tmc-langs/events","assignees_url":"https://api.github.com/repos/tmc-langs/tmc-langs/assignees{/user}","branches_url":"https://api.github.com/repos/tmc-langs/tmc-langs/branches{/branch}","tags_url":"https://api.github.com/repos/tmc-langs/tmc-langs/tags","blobs_url":"https://api.github.com/repos/tmc-langs/tmc-langs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tmc-langs/tmc-langs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tmc-langs/tmc-langs/git/refs{/sha}","trees_url":"https://api.github.com/repos/tmc-langs/tmc-langs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tmc-langs/tmc-langs/statuses/{sha}","languages_url":"https://api.github.com/repos/tmc-langs/tmc-langs/languages","stargazers_url":"https://api.github.com/repos/tmc-langs/tmc-langs/stargazers","contributors_url":"https://api.github.com/repos/tmc-langs/tmc-langs/contributors","subscribers_url":"https://api.github.com/repos/tmc-langs/tmc-langs/subscribers","subscription_url":"https://api.github.com/repos/tmc-langs/tmc-langs/subscription","commits_url":"https://api.github.com/repos/tmc-langs/tmc-langs/commits{/sha}","git_commits_url":"https://api.github.com/repos/tmc-langs/tmc-langs/git/commits{/sha}","comments_url":"https://api.github.com/repos/tmc-langs/tmc-langs/comments{/number}","issue_comment_url":"https://api.github.com/repos/tmc-langs/tmc-langs/issues/comments{/number}","contents_url":"https://api.github.com/repos/tmc-langs/tmc-langs/contents/{+path}","compare_url":"https://api.github.com/repos/tmc-langs/tmc-langs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tmc-langs/tmc-langs/merges","archive_url":"https://api.github.com/repos/tmc-langs/tmc-langs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tmc-langs/tmc-langs/downloads","issues_url":"https://api.github.com/repos/tmc-langs/tmc-langs/issues{/number}","pulls_url":"https://api.github.com/repos/tmc-langs/tmc-langs/pulls{/number}","milestones_url":"https://api.github.com/repos/tmc-langs/tmc-langs/milestones{/number}","notifications_url":"https://api.github.com/repos/tmc-langs/tmc-langs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tmc-langs/tmc-langs/labels{/name}","releases_url":"https://api.github.com/repos/tmc-langs/tmc-langs/releases{/id}","created_at":"2015-01-15T08:04:12Z","updated_at":"2015-03-05T15:16:05Z","pushed_at":"2015-03-06T11:47:40Z","git_url":"git://github.com/tmc-langs/tmc-langs.git","ssh_url":"git@github.com:tmc-langs/tmc-langs.git","clone_url":"https://github.com/tmc-langs/tmc-langs.git","svn_url":"https://github.com/tmc-langs/tmc-langs","homepage":null,"size":1186,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":0,"forks":1,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"testmycode:master","ref":"master","sha":"bb5224b7cfe06b36522c64f4ef598f0beb3c1361","user":{"login":"testmycode","id":893468,"avatar_url":"https://avatars.githubusercontent.com/u/893468?v=3","gravatar_id":"","url":"https://api.github.com/users/testmycode","html_url":"https://github.com/testmycode","followers_url":"https://api.github.com/users/testmycode/followers","following_url":"https://api.github.com/users/testmycode/following{/other_user}","gists_url":"https://api.github.com/users/testmycode/gists{/gist_id}","starred_url":"https://api.github.com/users/testmycode/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/testmycode/subscriptions","organizations_url":"https://api.github.com/users/testmycode/orgs","repos_url":"https://api.github.com/users/testmycode/repos","events_url":"https://api.github.com/users/testmycode/events{/privacy}","received_events_url":"https://api.github.com/users/testmycode/received_events","type":"Organization","site_admin":false},"repo":{"id":23525445,"name":"tmc-langs","full_name":"testmycode/tmc-langs","owner":{"login":"testmycode","id":893468,"avatar_url":"https://avatars.githubusercontent.com/u/893468?v=3","gravatar_id":"","url":"https://api.github.com/users/testmycode","html_url":"https://github.com/testmycode","followers_url":"https://api.github.com/users/testmycode/followers","following_url":"https://api.github.com/users/testmycode/following{/other_user}","gists_url":"https://api.github.com/users/testmycode/gists{/gist_id}","starred_url":"https://api.github.com/users/testmycode/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/testmycode/subscriptions","organizations_url":"https://api.github.com/users/testmycode/orgs","repos_url":"https://api.github.com/users/testmycode/repos","events_url":"https://api.github.com/users/testmycode/events{/privacy}","received_events_url":"https://api.github.com/users/testmycode/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/testmycode/tmc-langs","description":"TMC language support framework","fork":false,"url":"https://api.github.com/repos/testmycode/tmc-langs","forks_url":"https://api.github.com/repos/testmycode/tmc-langs/forks","keys_url":"https://api.github.com/repos/testmycode/tmc-langs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/testmycode/tmc-langs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/testmycode/tmc-langs/teams","hooks_url":"https://api.github.com/repos/testmycode/tmc-langs/hooks","issue_events_url":"https://api.github.com/repos/testmycode/tmc-langs/issues/events{/number}","events_url":"https://api.github.com/repos/testmycode/tmc-langs/events","assignees_url":"https://api.github.com/repos/testmycode/tmc-langs/assignees{/user}","branches_url":"https://api.github.com/repos/testmycode/tmc-langs/branches{/branch}","tags_url":"https://api.github.com/repos/testmycode/tmc-langs/tags","blobs_url":"https://api.github.com/repos/testmycode/tmc-langs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/testmycode/tmc-langs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/testmycode/tmc-langs/git/refs{/sha}","trees_url":"https://api.github.com/repos/testmycode/tmc-langs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/testmycode/tmc-langs/statuses/{sha}","languages_url":"https://api.github.com/repos/testmycode/tmc-langs/languages","stargazers_url":"https://api.github.com/repos/testmycode/tmc-langs/stargazers","contributors_url":"https://api.github.com/repos/testmycode/tmc-langs/contributors","subscribers_url":"https://api.github.com/repos/testmycode/tmc-langs/subscribers","subscription_url":"https://api.github.com/repos/testmycode/tmc-langs/subscription","commits_url":"https://api.github.com/repos/testmycode/tmc-langs/commits{/sha}","git_commits_url":"https://api.github.com/repos/testmycode/tmc-langs/git/commits{/sha}","comments_url":"https://api.github.com/repos/testmycode/tmc-langs/comments{/number}","issue_comment_url":"https://api.github.com/repos/testmycode/tmc-langs/issues/comments{/number}","contents_url":"https://api.github.com/repos/testmycode/tmc-langs/contents/{+path}","compare_url":"https://api.github.com/repos/testmycode/tmc-langs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/testmycode/tmc-langs/merges","archive_url":"https://api.github.com/repos/testmycode/tmc-langs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/testmycode/tmc-langs/downloads","issues_url":"https://api.github.com/repos/testmycode/tmc-langs/issues{/number}","pulls_url":"https://api.github.com/repos/testmycode/tmc-langs/pulls{/number}","milestones_url":"https://api.github.com/repos/testmycode/tmc-langs/milestones{/number}","notifications_url":"https://api.github.com/repos/testmycode/tmc-langs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/testmycode/tmc-langs/labels{/name}","releases_url":"https://api.github.com/repos/testmycode/tmc-langs/releases{/id}","created_at":"2014-08-31T23:37:38Z","updated_at":"2015-02-19T07:59:58Z","pushed_at":"2015-02-19T07:59:57Z","git_url":"git://github.com/testmycode/tmc-langs.git","ssh_url":"git@github.com:testmycode/tmc-langs.git","clone_url":"https://github.com/testmycode/tmc-langs.git","svn_url":"https://github.com/testmycode/tmc-langs","homepage":null,"size":196,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":2,"forks":2,"open_issues":2,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/testmycode/tmc-langs/pulls/3"},"html":{"href":"https://github.com/testmycode/tmc-langs/pull/3"},"issue":{"href":"https://api.github.com/repos/testmycode/tmc-langs/issues/3"},"comments":{"href":"https://api.github.com/repos/testmycode/tmc-langs/issues/3/comments"},"review_comments":{"href":"https://api.github.com/repos/testmycode/tmc-langs/pulls/3/comments"},"review_comment":{"href":"https://api.github.com/repos/testmycode/tmc-langs/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/testmycode/tmc-langs/pulls/3/commits"},"statuses":{"href":"https://api.github.com/repos/testmycode/tmc-langs/statuses/0435837b3b88ea69e9b0a16f9f0751038c9d9849"}}}}