{"action":"created","comment":{"url":"https://api.github.com/repos/midasplatform/Midas/pulls/comments/54802328","id":54802328,"diff_hunk":"@@ -0,0 +1,212 @@\n+<?php\n+/*=========================================================================\n+ Midas Server\n+ Copyright Kitware SAS, 26 rue Louis Guérin, 69100 Villeurbanne, France.\n+ All rights reserved.\n+ For more information visit http://www.kitware.com/.\n+\n+ Licensed under the Apache License, Version 2.0 (the \"License\");\n+ you may not use this file except in compliance with the License.\n+ You may obtain a copy of the License at\n+\n+         http://www.apache.org/licenses/LICENSE-2.0.txt\n+\n+ Unless required by applicable law or agreed to in writing, software\n+ distributed under the License is distributed on an \"AS IS\" BASIS,\n+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+ See the License for the specific language governing permissions and\n+ limitations under the License.\n+=========================================================================*/\n+\n+require_once BASE_PATH.'/core/tests/controllers/api/RestCallMethodsTestCase.php';\n+\n+/** API test for tracker module ApiaggregatemetricspecComponent. */\n+class Tracker_ApiAggregatemetricspecComponentTest extends RestCallMethodsTestCase\n+{\n+    public $moduleName = 'tracker';\n+\n+    /** Setup. */\n+    public function setUp()\n+    {\n+        $this->enabledModules = array('api', 'scheduler', $this->moduleName);\n+        $this->_models = array('Assetstore', 'Community', 'Setting', 'User');\n+        $this->setupDatabase(array('default'));\n+        $this->setupDatabase(array('aggregateMetric'), 'tracker');\n+        $db = Zend_Registry::get('dbAdapter');\n+        $configDatabase = Zend_Registry::get('configDatabase');\n+        if ($configDatabase->database->adapter == 'PDO_PGSQL') {\n+            $db->query(\"SELECT setval('tracker_aggregate_metric_spec_aggregate_metric_spec_id_seq', (SELECT MAX(aggregate_metric_spec_id) FROM tracker_aggregate_metric_spec)+1);\");\n+            $db->query(\"SELECT setval('tracker_scalar_scalar_id_seq', (SELECT MAX(scalar_id) FROM tracker_scalar)+1);\");\n+        }\n+        ControllerTestCase::setUp();\n+    }\n+\n+    /**\n+     * Test getting an existing existing aggregate metric spec with a set of params, via GET.\n+     *\n+     * @throws Zend_Exception\n+     */\n+    public function testGET()\n+    {\n+        $usersFile = $this->loadData('User', 'default');\n+        /** @var UserDao $userDao */\n+        $userDao = $this->User->load($usersFile[0]->getKey());\n+        $token = $this->_loginAsAdministrator();\n+\n+        $restParams = array(\n+            'token' => $token,\n+        );\n+        $this->resetAll();\n+        $this->params = $restParams;\n+        $resp = $this->_callRestApi('GET', '/tracker/aggregatemetricspec/1');\n+\n+        /** @var Tracker_AggregateMetricSpecModel $aggregateMetricSpecModel */\n+        $aggregateMetricSpecModel = midasloader::loadmodel('AggregateMetricSpec', 'tracker');\n+        /** @var Tracker_AggregateMetricSpecDao $specDao */\n+        $specDao = $aggregateMetricSpecModel->initdao('AggregateMetricSpec', json_decode(json_encode($resp['body']), true), $this->moduleName);\n+\n+        $this->assertEquals($specDao->getProducerId(), '100');\n+        $this->assertEquals($specDao->getComparison(), '!=');\n+        $this->assertEquals($specDao->getValue(), '1.0');\n+        $this->assertEquals($specDao->getBranch(), 'master');\n+        $this->assertEquals($specDao->getName(), '95th Percentile Greedy error');\n+        $this->assertEquals($specDao->getDescription(), '95th Percentile Greedy error');\n+        $this->assertEquals($specDao->getSpec(), \"percentile('Greedy error', 95)\");\n+    }\n+\n+    /**\n+     * Test createing an existing aggregate metric spec with a set of params, via POST.\n+     *\n+     * @throws Zend_Exception\n+     */\n+    public function testPOST()\n+    {\n+        $usersFile = $this->loadData('User', 'default');\n+        /** @var UserDao $userDao */\n+        $userDao = $this->User->load($usersFile[0]->getKey());\n+        $token = $this->_loginAsAdministrator();\n+\n+        $restParams = array(\n+            'token' => $token,\n+            'producer_id' => 100,\n+            'branch' => 'newbranch',\n+            'name' => 'POST 23 percentile',\n+            'description' => 'opaque',\n+            'value' => '23',\n+            'comparison' => '==',\n+            'spec' => \"percentile('POST', 23)\",\n+        );\n+\n+        $this->resetAll();\n+        $this->params = $restParams;\n+        $resp = $this->_callRestApi('POST', '/tracker/aggregatemetricspec/');\n+\n+        /** @var Tracker_AggregateMetricSpecModel $aggregateMetricSpecModel */\n+        $aggregateMetricSpecModel = midasloader::loadmodel('AggregateMetricSpec', 'tracker');\n+        /** @var Tracker_AggregateMetricSpecDao $specDao */\n+        $specDao = $aggregateMetricSpecModel->initdao('AggregateMetricSpec', json_decode(json_encode($resp['body']), true), $this->moduleName);","path":"modules/tracker/tests/controllers/ApiAggregatemetricspecComponentTest.php","position":107,"original_position":107,"commit_id":"d0d60a5d6a2884ca78076c37ae2c92b78077a43e","original_commit_id":"d0d60a5d6a2884ca78076c37ae2c92b78077a43e","user":{"login":"cpatrick","id":115384,"avatar_url":"https://avatars.githubusercontent.com/u/115384?v=3","gravatar_id":"","url":"https://api.github.com/users/cpatrick","html_url":"https://github.com/cpatrick","followers_url":"https://api.github.com/users/cpatrick/followers","following_url":"https://api.github.com/users/cpatrick/following{/other_user}","gists_url":"https://api.github.com/users/cpatrick/gists{/gist_id}","starred_url":"https://api.github.com/users/cpatrick/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cpatrick/subscriptions","organizations_url":"https://api.github.com/users/cpatrick/orgs","repos_url":"https://api.github.com/users/cpatrick/repos","events_url":"https://api.github.com/users/cpatrick/events{/privacy}","received_events_url":"https://api.github.com/users/cpatrick/received_events","type":"User","site_admin":false},"body":"case of `initDao`.","created_at":"2016-03-02T22:21:22Z","updated_at":"2016-03-02T22:21:22Z","html_url":"https://github.com/midasplatform/Midas/pull/191#discussion_r54802328","pull_request_url":"https://api.github.com/repos/midasplatform/Midas/pulls/191","_links":{"self":{"href":"https://api.github.com/repos/midasplatform/Midas/pulls/comments/54802328"},"html":{"href":"https://github.com/midasplatform/Midas/pull/191#discussion_r54802328"},"pull_request":{"href":"https://api.github.com/repos/midasplatform/Midas/pulls/191"}}},"pull_request":{"url":"https://api.github.com/repos/midasplatform/Midas/pulls/191","id":61322021,"html_url":"https://github.com/midasplatform/Midas/pull/191","diff_url":"https://github.com/midasplatform/Midas/pull/191.diff","patch_url":"https://github.com/midasplatform/Midas/pull/191.patch","issue_url":"https://api.github.com/repos/midasplatform/Midas/issues/191","number":191,"state":"open","locked":false,"title":"Aggregate metric spec rest","user":{"login":"mgrauer","id":595023,"avatar_url":"https://avatars.githubusercontent.com/u/595023?v=3","gravatar_id":"","url":"https://api.github.com/users/mgrauer","html_url":"https://github.com/mgrauer","followers_url":"https://api.github.com/users/mgrauer/followers","following_url":"https://api.github.com/users/mgrauer/following{/other_user}","gists_url":"https://api.github.com/users/mgrauer/gists{/gist_id}","starred_url":"https://api.github.com/users/mgrauer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mgrauer/subscriptions","organizations_url":"https://api.github.com/users/mgrauer/orgs","repos_url":"https://api.github.com/users/mgrauer/repos","events_url":"https://api.github.com/users/mgrauer/events{/privacy}","received_events_url":"https://api.github.com/users/mgrauer/received_events","type":"User","site_admin":false},"body":"A smaller changeset.","created_at":"2016-03-01T22:46:28Z","updated_at":"2016-03-02T22:21:22Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2e77313240c944dce6d1835c189f9511cf47c04f","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/midasplatform/Midas/pulls/191/commits","review_comments_url":"https://api.github.com/repos/midasplatform/Midas/pulls/191/comments","review_comment_url":"https://api.github.com/repos/midasplatform/Midas/pulls/comments{/number}","comments_url":"https://api.github.com/repos/midasplatform/Midas/issues/191/comments","statuses_url":"https://api.github.com/repos/midasplatform/Midas/statuses/d0d60a5d6a2884ca78076c37ae2c92b78077a43e","head":{"label":"midasplatform:aggregate_metric_spec_REST","ref":"aggregate_metric_spec_REST","sha":"d0d60a5d6a2884ca78076c37ae2c92b78077a43e","user":{"login":"midasplatform","id":1188892,"avatar_url":"https://avatars.githubusercontent.com/u/1188892?v=3","gravatar_id":"","url":"https://api.github.com/users/midasplatform","html_url":"https://github.com/midasplatform","followers_url":"https://api.github.com/users/midasplatform/followers","following_url":"https://api.github.com/users/midasplatform/following{/other_user}","gists_url":"https://api.github.com/users/midasplatform/gists{/gist_id}","starred_url":"https://api.github.com/users/midasplatform/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/midasplatform/subscriptions","organizations_url":"https://api.github.com/users/midasplatform/orgs","repos_url":"https://api.github.com/users/midasplatform/repos","events_url":"https://api.github.com/users/midasplatform/events{/privacy}","received_events_url":"https://api.github.com/users/midasplatform/received_events","type":"Organization","site_admin":false},"repo":{"id":18849230,"name":"Midas","full_name":"midasplatform/Midas","owner":{"login":"midasplatform","id":1188892,"avatar_url":"https://avatars.githubusercontent.com/u/1188892?v=3","gravatar_id":"","url":"https://api.github.com/users/midasplatform","html_url":"https://github.com/midasplatform","followers_url":"https://api.github.com/users/midasplatform/followers","following_url":"https://api.github.com/users/midasplatform/following{/other_user}","gists_url":"https://api.github.com/users/midasplatform/gists{/gist_id}","starred_url":"https://api.github.com/users/midasplatform/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/midasplatform/subscriptions","organizations_url":"https://api.github.com/users/midasplatform/orgs","repos_url":"https://api.github.com/users/midasplatform/repos","events_url":"https://api.github.com/users/midasplatform/events{/privacy}","received_events_url":"https://api.github.com/users/midasplatform/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/midasplatform/Midas","description":"An open-source application that enables the rapid creation of tailored, web-enabled data storage","fork":false,"url":"https://api.github.com/repos/midasplatform/Midas","forks_url":"https://api.github.com/repos/midasplatform/Midas/forks","keys_url":"https://api.github.com/repos/midasplatform/Midas/keys{/key_id}","collaborators_url":"https://api.github.com/repos/midasplatform/Midas/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/midasplatform/Midas/teams","hooks_url":"https://api.github.com/repos/midasplatform/Midas/hooks","issue_events_url":"https://api.github.com/repos/midasplatform/Midas/issues/events{/number}","events_url":"https://api.github.com/repos/midasplatform/Midas/events","assignees_url":"https://api.github.com/repos/midasplatform/Midas/assignees{/user}","branches_url":"https://api.github.com/repos/midasplatform/Midas/branches{/branch}","tags_url":"https://api.github.com/repos/midasplatform/Midas/tags","blobs_url":"https://api.github.com/repos/midasplatform/Midas/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/midasplatform/Midas/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/midasplatform/Midas/git/refs{/sha}","trees_url":"https://api.github.com/repos/midasplatform/Midas/git/trees{/sha}","statuses_url":"https://api.github.com/repos/midasplatform/Midas/statuses/{sha}","languages_url":"https://api.github.com/repos/midasplatform/Midas/languages","stargazers_url":"https://api.github.com/repos/midasplatform/Midas/stargazers","contributors_url":"https://api.github.com/repos/midasplatform/Midas/contributors","subscribers_url":"https://api.github.com/repos/midasplatform/Midas/subscribers","subscription_url":"https://api.github.com/repos/midasplatform/Midas/subscription","commits_url":"https://api.github.com/repos/midasplatform/Midas/commits{/sha}","git_commits_url":"https://api.github.com/repos/midasplatform/Midas/git/commits{/sha}","comments_url":"https://api.github.com/repos/midasplatform/Midas/comments{/number}","issue_comment_url":"https://api.github.com/repos/midasplatform/Midas/issues/comments{/number}","contents_url":"https://api.github.com/repos/midasplatform/Midas/contents/{+path}","compare_url":"https://api.github.com/repos/midasplatform/Midas/compare/{base}...{head}","merges_url":"https://api.github.com/repos/midasplatform/Midas/merges","archive_url":"https://api.github.com/repos/midasplatform/Midas/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/midasplatform/Midas/downloads","issues_url":"https://api.github.com/repos/midasplatform/Midas/issues{/number}","pulls_url":"https://api.github.com/repos/midasplatform/Midas/pulls{/number}","milestones_url":"https://api.github.com/repos/midasplatform/Midas/milestones{/number}","notifications_url":"https://api.github.com/repos/midasplatform/Midas/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/midasplatform/Midas/labels{/name}","releases_url":"https://api.github.com/repos/midasplatform/Midas/releases{/id}","deployments_url":"https://api.github.com/repos/midasplatform/Midas/deployments","created_at":"2014-04-16T17:36:18Z","updated_at":"2016-02-12T17:55:58Z","pushed_at":"2016-03-02T22:05:51Z","git_url":"git://github.com/midasplatform/Midas.git","ssh_url":"git@github.com:midasplatform/Midas.git","clone_url":"https://github.com/midasplatform/Midas.git","svn_url":"https://github.com/midasplatform/Midas","homepage":"http://www.midasplatform.org/","size":71404,"stargazers_count":8,"watchers_count":8,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":7,"mirror_url":null,"open_issues_count":37,"forks":7,"open_issues":37,"watchers":8,"default_branch":"master"}},"base":{"label":"midasplatform:master","ref":"master","sha":"766a7c08f8f6a21d254a84e6040820906b626348","user":{"login":"midasplatform","id":1188892,"avatar_url":"https://avatars.githubusercontent.com/u/1188892?v=3","gravatar_id":"","url":"https://api.github.com/users/midasplatform","html_url":"https://github.com/midasplatform","followers_url":"https://api.github.com/users/midasplatform/followers","following_url":"https://api.github.com/users/midasplatform/following{/other_user}","gists_url":"https://api.github.com/users/midasplatform/gists{/gist_id}","starred_url":"https://api.github.com/users/midasplatform/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/midasplatform/subscriptions","organizations_url":"https://api.github.com/users/midasplatform/orgs","repos_url":"https://api.github.com/users/midasplatform/repos","events_url":"https://api.github.com/users/midasplatform/events{/privacy}","received_events_url":"https://api.github.com/users/midasplatform/received_events","type":"Organization","site_admin":false},"repo":{"id":18849230,"name":"Midas","full_name":"midasplatform/Midas","owner":{"login":"midasplatform","id":1188892,"avatar_url":"https://avatars.githubusercontent.com/u/1188892?v=3","gravatar_id":"","url":"https://api.github.com/users/midasplatform","html_url":"https://github.com/midasplatform","followers_url":"https://api.github.com/users/midasplatform/followers","following_url":"https://api.github.com/users/midasplatform/following{/other_user}","gists_url":"https://api.github.com/users/midasplatform/gists{/gist_id}","starred_url":"https://api.github.com/users/midasplatform/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/midasplatform/subscriptions","organizations_url":"https://api.github.com/users/midasplatform/orgs","repos_url":"https://api.github.com/users/midasplatform/repos","events_url":"https://api.github.com/users/midasplatform/events{/privacy}","received_events_url":"https://api.github.com/users/midasplatform/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/midasplatform/Midas","description":"An open-source application that enables the rapid creation of tailored, web-enabled data storage","fork":false,"url":"https://api.github.com/repos/midasplatform/Midas","forks_url":"https://api.github.com/repos/midasplatform/Midas/forks","keys_url":"https://api.github.com/repos/midasplatform/Midas/keys{/key_id}","collaborators_url":"https://api.github.com/repos/midasplatform/Midas/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/midasplatform/Midas/teams","hooks_url":"https://api.github.com/repos/midasplatform/Midas/hooks","issue_events_url":"https://api.github.com/repos/midasplatform/Midas/issues/events{/number}","events_url":"https://api.github.com/repos/midasplatform/Midas/events","assignees_url":"https://api.github.com/repos/midasplatform/Midas/assignees{/user}","branches_url":"https://api.github.com/repos/midasplatform/Midas/branches{/branch}","tags_url":"https://api.github.com/repos/midasplatform/Midas/tags","blobs_url":"https://api.github.com/repos/midasplatform/Midas/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/midasplatform/Midas/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/midasplatform/Midas/git/refs{/sha}","trees_url":"https://api.github.com/repos/midasplatform/Midas/git/trees{/sha}","statuses_url":"https://api.github.com/repos/midasplatform/Midas/statuses/{sha}","languages_url":"https://api.github.com/repos/midasplatform/Midas/languages","stargazers_url":"https://api.github.com/repos/midasplatform/Midas/stargazers","contributors_url":"https://api.github.com/repos/midasplatform/Midas/contributors","subscribers_url":"https://api.github.com/repos/midasplatform/Midas/subscribers","subscription_url":"https://api.github.com/repos/midasplatform/Midas/subscription","commits_url":"https://api.github.com/repos/midasplatform/Midas/commits{/sha}","git_commits_url":"https://api.github.com/repos/midasplatform/Midas/git/commits{/sha}","comments_url":"https://api.github.com/repos/midasplatform/Midas/comments{/number}","issue_comment_url":"https://api.github.com/repos/midasplatform/Midas/issues/comments{/number}","contents_url":"https://api.github.com/repos/midasplatform/Midas/contents/{+path}","compare_url":"https://api.github.com/repos/midasplatform/Midas/compare/{base}...{head}","merges_url":"https://api.github.com/repos/midasplatform/Midas/merges","archive_url":"https://api.github.com/repos/midasplatform/Midas/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/midasplatform/Midas/downloads","issues_url":"https://api.github.com/repos/midasplatform/Midas/issues{/number}","pulls_url":"https://api.github.com/repos/midasplatform/Midas/pulls{/number}","milestones_url":"https://api.github.com/repos/midasplatform/Midas/milestones{/number}","notifications_url":"https://api.github.com/repos/midasplatform/Midas/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/midasplatform/Midas/labels{/name}","releases_url":"https://api.github.com/repos/midasplatform/Midas/releases{/id}","deployments_url":"https://api.github.com/repos/midasplatform/Midas/deployments","created_at":"2014-04-16T17:36:18Z","updated_at":"2016-02-12T17:55:58Z","pushed_at":"2016-03-02T22:05:51Z","git_url":"git://github.com/midasplatform/Midas.git","ssh_url":"git@github.com:midasplatform/Midas.git","clone_url":"https://github.com/midasplatform/Midas.git","svn_url":"https://github.com/midasplatform/Midas","homepage":"http://www.midasplatform.org/","size":71404,"stargazers_count":8,"watchers_count":8,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":7,"mirror_url":null,"open_issues_count":37,"forks":7,"open_issues":37,"watchers":8,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/midasplatform/Midas/pulls/191"},"html":{"href":"https://github.com/midasplatform/Midas/pull/191"},"issue":{"href":"https://api.github.com/repos/midasplatform/Midas/issues/191"},"comments":{"href":"https://api.github.com/repos/midasplatform/Midas/issues/191/comments"},"review_comments":{"href":"https://api.github.com/repos/midasplatform/Midas/pulls/191/comments"},"review_comment":{"href":"https://api.github.com/repos/midasplatform/Midas/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/midasplatform/Midas/pulls/191/commits"},"statuses":{"href":"https://api.github.com/repos/midasplatform/Midas/statuses/d0d60a5d6a2884ca78076c37ae2c92b78077a43e"}}}}