{"action":"created","comment":{"url":"https://api.github.com/repos/OpenLightingProject/ja-rule/pulls/comments/35488606","id":35488606,"diff_hunk":"@@ -0,0 +1,485 @@\n+/*\n+ * This program is free software; you can redistribute it and/or modify\n+ * it under the terms of the GNU General Public License as published by\n+ * the Free Software Foundation; either version 2 of the License, or\n+ * (at your option) any later version.\n+ *\n+ * This program is distributed in the hope that it will be useful,\n+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\n+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n+ * GNU Library General Public License for more details.\n+ *\n+ * You should have received a copy of the GNU General Public License\n+ * along with this program; if not, write to the Free Software\n+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n+ *\n+ * NetworkModelTest.cpp\n+ * Tests for the Network Model RDM responder.\n+ * Copyright (C) 2015 Simon Newton\n+ */\n+\n+#include <gtest/gtest.h>\n+\n+#include <ola/rdm/UID.h>\n+#include <ola/rdm/RDMCommand.h>\n+#include <ola/rdm/RDMEnums.h>\n+#include <ola/rdm/RDMCommandSerializer.h>\n+#include <ola/network/NetworkUtils.h>\n+#include <string.h>\n+#include <memory>\n+\n+#include \"network_model.h\"\n+#include \"rdm.h\"\n+#include \"rdm_buffer.h\"\n+#include \"rdm_responder.h\"\n+#include \"Array.h\"\n+#include \"Matchers.h\"\n+#include \"ModelTest.h\"\n+#include \"TestHelpers.h\"\n+\n+using ola::network::HostToNetwork;\n+using ola::rdm::UID;\n+using ola::rdm::GetResponseFromData;\n+using ola::rdm::NackWithReason;\n+using ola::rdm::RDMGetRequest;\n+using ola::rdm::RDMRequest;\n+using ola::rdm::RDMResponse;\n+using ola::rdm::RDMSetRequest;\n+using ola::rdm::RDMStatusCode;\n+using std::unique_ptr;\n+using ::testing::NotNull;\n+\n+const uint8_t ModelTest::TEST_UID[] = {\n+  0x7a, 0x70, 0x12, 0x34, 0x56, 0x78\n+};\n+\n+class NetworkModelTest : public ModelTest {\n+ public:\n+  NetworkModelTest() : ModelTest(&NETWORK_MODEL_ENTRY) {}\n+\n+  void SetUp() {\n+    RDMResponder_Initialize(TEST_UID);\n+    NetworkModel_Initialize();\n+    NETWORK_MODEL_ENTRY.activate_fn();\n+  }\n+};\n+\n+TEST_F(NetworkModelTest, testLifecycle) {\n+  EXPECT_EQ(NETWORK_MODEL_ID, NETWORK_MODEL_ENTRY.model_id);\n+  NETWORK_MODEL_ENTRY.tasks_fn();\n+  NETWORK_MODEL_ENTRY.deactivate_fn();\n+}\n+\n+TEST_F(NetworkModelTest, listInterfaces) {\n+  // Get the list of interfaces\n+  unique_ptr<RDMRequest> request = BuildGetRequest(PID_LIST_INTERFACES);\n+\n+  const uint8_t expected_response[] = {\n+    0x00, 0x00, 0x00, 0x01, 0x00, 0x01,\n+    0x00, 0x00, 0x00, 0x03, 0x00, 0x1f,\n+    0x00, 0x00, 0x00, 0x04, 0x00, 0x01,\n+  };\n+\n+  unique_ptr<RDMResponse> response(GetResponseFromData(\n+        request.get(), expected_response, arraysize(expected_response)));\n+\n+  int size = InvokeRDMHandler(request.get());\n+  EXPECT_THAT(ArrayTuple(g_rdm_buffer, size), ResponseIs(response.get()));\n+}\n+\n+TEST_F(NetworkModelTest, getInterfaceLabel) {\n+  // Get the label for the first interface.\n+  uint32_t interface_id = HostToNetwork(1);\n+  unique_ptr<RDMRequest> request = BuildGetRequest(PID_INTERFACE_LABEL,\n+      reinterpret_cast<uint8_t*>(&interface_id), sizeof(interface_id));\n+\n+  const uint8_t expected_response[] = {\n+    0x00, 0x00, 0x00, 0x01,\n+    'e', 't', 'h', '0'\n+  };\n+\n+  unique_ptr<RDMResponse> response(GetResponseFromData(\n+        request.get(), expected_response, arraysize(expected_response)));\n+\n+  int size = InvokeRDMHandler(request.get());\n+  EXPECT_THAT(ArrayTuple(g_rdm_buffer, size), ResponseIs(response.get()));\n+\n+  // test the NR_DATA_OUT_OF_RANGE\n+  interface_id = HostToNetwork(2);\n+  request = BuildGetRequest(PID_INTERFACE_LABEL,\n+      reinterpret_cast<uint8_t*>(&interface_id), sizeof(interface_id));\n+\n+  response.reset(NackWithReason(request.get(), ola::rdm::NR_DATA_OUT_OF_RANGE));\n+  size = InvokeRDMHandler(request.get());\n+  EXPECT_THAT(ArrayTuple(g_rdm_buffer, size), ResponseIs(response.get()));\n+}\n+\n+TEST_F(NetworkModelTest, getHardwareAddress) {\n+  // Get the hardware address for the first interface.\n+  uint32_t interface_id = HostToNetwork(1);\n+  unique_ptr<RDMRequest> request = BuildGetRequest(\n+      PID_INTERFACE_HARDWARE_ADDRESS_TYPE1,\n+      reinterpret_cast<uint8_t*>(&interface_id), sizeof(interface_id));\n+\n+  const uint8_t expected_response[] = {\n+    0x00, 0x00, 0x00, 0x01,\n+    0x52, 0x12, 0x34, 0x56, 0x78, 0x9a\n+  };\n+\n+  unique_ptr<RDMResponse> response(GetResponseFromData(\n+        request.get(), expected_response, arraysize(expected_response)));\n+\n+  int size = InvokeRDMHandler(request.get());\n+  EXPECT_THAT(ArrayTuple(g_rdm_buffer, size), ResponseIs(response.get()));\n+\n+  // test the NR_DATA_OUT_OF_RANGE","path":"tests/tests/NetworkModelTest.cpp","position":135,"original_position":135,"commit_id":"0c2a3ff4c8ecc301745c77a8076c2eed3dca826c","original_commit_id":"0c2a3ff4c8ecc301745c77a8076c2eed3dca826c","user":{"login":"nomis52","id":4355332,"avatar_url":"https://avatars.githubusercontent.com/u/4355332?v=3","gravatar_id":"","url":"https://api.github.com/users/nomis52","html_url":"https://github.com/nomis52","followers_url":"https://api.github.com/users/nomis52/followers","following_url":"https://api.github.com/users/nomis52/following{/other_user}","gists_url":"https://api.github.com/users/nomis52/gists{/gist_id}","starred_url":"https://api.github.com/users/nomis52/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nomis52/subscriptions","organizations_url":"https://api.github.com/users/nomis52/orgs","repos_url":"https://api.github.com/users/nomis52/repos","events_url":"https://api.github.com/users/nomis52/events{/privacy}","received_events_url":"https://api.github.com/users/nomis52/received_events","type":"User","site_admin":false},"body":"Done","created_at":"2015-07-26T02:19:30Z","updated_at":"2015-07-26T02:19:30Z","html_url":"https://github.com/OpenLightingProject/ja-rule/pull/95#discussion_r35488606","pull_request_url":"https://api.github.com/repos/OpenLightingProject/ja-rule/pulls/95","_links":{"self":{"href":"https://api.github.com/repos/OpenLightingProject/ja-rule/pulls/comments/35488606"},"html":{"href":"https://github.com/OpenLightingProject/ja-rule/pull/95#discussion_r35488606"},"pull_request":{"href":"https://api.github.com/repos/OpenLightingProject/ja-rule/pulls/95"}}},"pull_request":{"url":"https://api.github.com/repos/OpenLightingProject/ja-rule/pulls/95","id":40822495,"html_url":"https://github.com/OpenLightingProject/ja-rule/pull/95","diff_url":"https://github.com/OpenLightingProject/ja-rule/pull/95.diff","patch_url":"https://github.com/OpenLightingProject/ja-rule/pull/95.patch","issue_url":"https://api.github.com/repos/OpenLightingProject/ja-rule/issues/95","number":95,"state":"open","locked":false,"title":"Add test coverage for the Network Model","user":{"login":"nomis52","id":4355332,"avatar_url":"https://avatars.githubusercontent.com/u/4355332?v=3","gravatar_id":"","url":"https://api.github.com/users/nomis52","html_url":"https://github.com/nomis52","followers_url":"https://api.github.com/users/nomis52/followers","following_url":"https://api.github.com/users/nomis52/following{/other_user}","gists_url":"https://api.github.com/users/nomis52/gists{/gist_id}","starred_url":"https://api.github.com/users/nomis52/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nomis52/subscriptions","organizations_url":"https://api.github.com/users/nomis52/orgs","repos_url":"https://api.github.com/users/nomis52/repos","events_url":"https://api.github.com/users/nomis52/events{/privacy}","received_events_url":"https://api.github.com/users/nomis52/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-07-24T22:41:11Z","updated_at":"2015-07-26T02:19:30Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1141074ad5bc8fcb01eb9b9501035ab6e5882b76","assignee":{"login":"peternewman","id":6216436,"avatar_url":"https://avatars.githubusercontent.com/u/6216436?v=3","gravatar_id":"","url":"https://api.github.com/users/peternewman","html_url":"https://github.com/peternewman","followers_url":"https://api.github.com/users/peternewman/followers","following_url":"https://api.github.com/users/peternewman/following{/other_user}","gists_url":"https://api.github.com/users/peternewman/gists{/gist_id}","starred_url":"https://api.github.com/users/peternewman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/peternewman/subscriptions","organizations_url":"https://api.github.com/users/peternewman/orgs","repos_url":"https://api.github.com/users/peternewman/repos","events_url":"https://api.github.com/users/peternewman/events{/privacy}","received_events_url":"https://api.github.com/users/peternewman/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/OpenLightingProject/ja-rule/pulls/95/commits","review_comments_url":"https://api.github.com/repos/OpenLightingProject/ja-rule/pulls/95/comments","review_comment_url":"https://api.github.com/repos/OpenLightingProject/ja-rule/pulls/comments{/number}","comments_url":"https://api.github.com/repos/OpenLightingProject/ja-rule/issues/95/comments","statuses_url":"https://api.github.com/repos/OpenLightingProject/ja-rule/statuses/0c2a3ff4c8ecc301745c77a8076c2eed3dca826c","head":{"label":"nomis52:network_testing","ref":"network_testing","sha":"0c2a3ff4c8ecc301745c77a8076c2eed3dca826c","user":{"login":"nomis52","id":4355332,"avatar_url":"https://avatars.githubusercontent.com/u/4355332?v=3","gravatar_id":"","url":"https://api.github.com/users/nomis52","html_url":"https://github.com/nomis52","followers_url":"https://api.github.com/users/nomis52/followers","following_url":"https://api.github.com/users/nomis52/following{/other_user}","gists_url":"https://api.github.com/users/nomis52/gists{/gist_id}","starred_url":"https://api.github.com/users/nomis52/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nomis52/subscriptions","organizations_url":"https://api.github.com/users/nomis52/orgs","repos_url":"https://api.github.com/users/nomis52/repos","events_url":"https://api.github.com/users/nomis52/events{/privacy}","received_events_url":"https://api.github.com/users/nomis52/received_events","type":"User","site_admin":false},"repo":{"id":29171822,"name":"ja-rule","full_name":"nomis52/ja-rule","owner":{"login":"nomis52","id":4355332,"avatar_url":"https://avatars.githubusercontent.com/u/4355332?v=3","gravatar_id":"","url":"https://api.github.com/users/nomis52","html_url":"https://github.com/nomis52","followers_url":"https://api.github.com/users/nomis52/followers","following_url":"https://api.github.com/users/nomis52/following{/other_user}","gists_url":"https://api.github.com/users/nomis52/gists{/gist_id}","starred_url":"https://api.github.com/users/nomis52/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nomis52/subscriptions","organizations_url":"https://api.github.com/users/nomis52/orgs","repos_url":"https://api.github.com/users/nomis52/repos","events_url":"https://api.github.com/users/nomis52/events{/privacy}","received_events_url":"https://api.github.com/users/nomis52/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/nomis52/ja-rule","description":"Ja Rule","fork":true,"url":"https://api.github.com/repos/nomis52/ja-rule","forks_url":"https://api.github.com/repos/nomis52/ja-rule/forks","keys_url":"https://api.github.com/repos/nomis52/ja-rule/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nomis52/ja-rule/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nomis52/ja-rule/teams","hooks_url":"https://api.github.com/repos/nomis52/ja-rule/hooks","issue_events_url":"https://api.github.com/repos/nomis52/ja-rule/issues/events{/number}","events_url":"https://api.github.com/repos/nomis52/ja-rule/events","assignees_url":"https://api.github.com/repos/nomis52/ja-rule/assignees{/user}","branches_url":"https://api.github.com/repos/nomis52/ja-rule/branches{/branch}","tags_url":"https://api.github.com/repos/nomis52/ja-rule/tags","blobs_url":"https://api.github.com/repos/nomis52/ja-rule/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nomis52/ja-rule/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nomis52/ja-rule/git/refs{/sha}","trees_url":"https://api.github.com/repos/nomis52/ja-rule/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nomis52/ja-rule/statuses/{sha}","languages_url":"https://api.github.com/repos/nomis52/ja-rule/languages","stargazers_url":"https://api.github.com/repos/nomis52/ja-rule/stargazers","contributors_url":"https://api.github.com/repos/nomis52/ja-rule/contributors","subscribers_url":"https://api.github.com/repos/nomis52/ja-rule/subscribers","subscription_url":"https://api.github.com/repos/nomis52/ja-rule/subscription","commits_url":"https://api.github.com/repos/nomis52/ja-rule/commits{/sha}","git_commits_url":"https://api.github.com/repos/nomis52/ja-rule/git/commits{/sha}","comments_url":"https://api.github.com/repos/nomis52/ja-rule/comments{/number}","issue_comment_url":"https://api.github.com/repos/nomis52/ja-rule/issues/comments{/number}","contents_url":"https://api.github.com/repos/nomis52/ja-rule/contents/{+path}","compare_url":"https://api.github.com/repos/nomis52/ja-rule/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nomis52/ja-rule/merges","archive_url":"https://api.github.com/repos/nomis52/ja-rule/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nomis52/ja-rule/downloads","issues_url":"https://api.github.com/repos/nomis52/ja-rule/issues{/number}","pulls_url":"https://api.github.com/repos/nomis52/ja-rule/pulls{/number}","milestones_url":"https://api.github.com/repos/nomis52/ja-rule/milestones{/number}","notifications_url":"https://api.github.com/repos/nomis52/ja-rule/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nomis52/ja-rule/labels{/name}","releases_url":"https://api.github.com/repos/nomis52/ja-rule/releases{/id}","created_at":"2015-01-13T03:58:08Z","updated_at":"2015-04-19T22:29:48Z","pushed_at":"2015-07-26T01:58:52Z","git_url":"git://github.com/nomis52/ja-rule.git","ssh_url":"git@github.com:nomis52/ja-rule.git","clone_url":"https://github.com/nomis52/ja-rule.git","svn_url":"https://github.com/nomis52/ja-rule","homepage":null,"size":1763,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"OpenLightingProject:master","ref":"master","sha":"e16ad6a7336774f253a27b788082cb560c072c2d","user":{"login":"OpenLightingProject","id":6199314,"avatar_url":"https://avatars.githubusercontent.com/u/6199314?v=3","gravatar_id":"","url":"https://api.github.com/users/OpenLightingProject","html_url":"https://github.com/OpenLightingProject","followers_url":"https://api.github.com/users/OpenLightingProject/followers","following_url":"https://api.github.com/users/OpenLightingProject/following{/other_user}","gists_url":"https://api.github.com/users/OpenLightingProject/gists{/gist_id}","starred_url":"https://api.github.com/users/OpenLightingProject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OpenLightingProject/subscriptions","organizations_url":"https://api.github.com/users/OpenLightingProject/orgs","repos_url":"https://api.github.com/users/OpenLightingProject/repos","events_url":"https://api.github.com/users/OpenLightingProject/events{/privacy}","received_events_url":"https://api.github.com/users/OpenLightingProject/received_events","type":"Organization","site_admin":false},"repo":{"id":27968183,"name":"ja-rule","full_name":"OpenLightingProject/ja-rule","owner":{"login":"OpenLightingProject","id":6199314,"avatar_url":"https://avatars.githubusercontent.com/u/6199314?v=3","gravatar_id":"","url":"https://api.github.com/users/OpenLightingProject","html_url":"https://github.com/OpenLightingProject","followers_url":"https://api.github.com/users/OpenLightingProject/followers","following_url":"https://api.github.com/users/OpenLightingProject/following{/other_user}","gists_url":"https://api.github.com/users/OpenLightingProject/gists{/gist_id}","starred_url":"https://api.github.com/users/OpenLightingProject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OpenLightingProject/subscriptions","organizations_url":"https://api.github.com/users/OpenLightingProject/orgs","repos_url":"https://api.github.com/users/OpenLightingProject/repos","events_url":"https://api.github.com/users/OpenLightingProject/events{/privacy}","received_events_url":"https://api.github.com/users/OpenLightingProject/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/OpenLightingProject/ja-rule","description":"Ja Rule","fork":false,"url":"https://api.github.com/repos/OpenLightingProject/ja-rule","forks_url":"https://api.github.com/repos/OpenLightingProject/ja-rule/forks","keys_url":"https://api.github.com/repos/OpenLightingProject/ja-rule/keys{/key_id}","collaborators_url":"https://api.github.com/repos/OpenLightingProject/ja-rule/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/OpenLightingProject/ja-rule/teams","hooks_url":"https://api.github.com/repos/OpenLightingProject/ja-rule/hooks","issue_events_url":"https://api.github.com/repos/OpenLightingProject/ja-rule/issues/events{/number}","events_url":"https://api.github.com/repos/OpenLightingProject/ja-rule/events","assignees_url":"https://api.github.com/repos/OpenLightingProject/ja-rule/assignees{/user}","branches_url":"https://api.github.com/repos/OpenLightingProject/ja-rule/branches{/branch}","tags_url":"https://api.github.com/repos/OpenLightingProject/ja-rule/tags","blobs_url":"https://api.github.com/repos/OpenLightingProject/ja-rule/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/OpenLightingProject/ja-rule/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/OpenLightingProject/ja-rule/git/refs{/sha}","trees_url":"https://api.github.com/repos/OpenLightingProject/ja-rule/git/trees{/sha}","statuses_url":"https://api.github.com/repos/OpenLightingProject/ja-rule/statuses/{sha}","languages_url":"https://api.github.com/repos/OpenLightingProject/ja-rule/languages","stargazers_url":"https://api.github.com/repos/OpenLightingProject/ja-rule/stargazers","contributors_url":"https://api.github.com/repos/OpenLightingProject/ja-rule/contributors","subscribers_url":"https://api.github.com/repos/OpenLightingProject/ja-rule/subscribers","subscription_url":"https://api.github.com/repos/OpenLightingProject/ja-rule/subscription","commits_url":"https://api.github.com/repos/OpenLightingProject/ja-rule/commits{/sha}","git_commits_url":"https://api.github.com/repos/OpenLightingProject/ja-rule/git/commits{/sha}","comments_url":"https://api.github.com/repos/OpenLightingProject/ja-rule/comments{/number}","issue_comment_url":"https://api.github.com/repos/OpenLightingProject/ja-rule/issues/comments{/number}","contents_url":"https://api.github.com/repos/OpenLightingProject/ja-rule/contents/{+path}","compare_url":"https://api.github.com/repos/OpenLightingProject/ja-rule/compare/{base}...{head}","merges_url":"https://api.github.com/repos/OpenLightingProject/ja-rule/merges","archive_url":"https://api.github.com/repos/OpenLightingProject/ja-rule/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/OpenLightingProject/ja-rule/downloads","issues_url":"https://api.github.com/repos/OpenLightingProject/ja-rule/issues{/number}","pulls_url":"https://api.github.com/repos/OpenLightingProject/ja-rule/pulls{/number}","milestones_url":"https://api.github.com/repos/OpenLightingProject/ja-rule/milestones{/number}","notifications_url":"https://api.github.com/repos/OpenLightingProject/ja-rule/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/OpenLightingProject/ja-rule/labels{/name}","releases_url":"https://api.github.com/repos/OpenLightingProject/ja-rule/releases{/id}","created_at":"2014-12-13T17:36:05Z","updated_at":"2015-04-19T22:43:43Z","pushed_at":"2015-07-26T01:58:52Z","git_url":"git://github.com/OpenLightingProject/ja-rule.git","ssh_url":"git@github.com:OpenLightingProject/ja-rule.git","clone_url":"https://github.com/OpenLightingProject/ja-rule.git","svn_url":"https://github.com/OpenLightingProject/ja-rule","homepage":null,"size":1977,"stargazers_count":1,"watchers_count":1,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":6,"forks":5,"open_issues":6,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/OpenLightingProject/ja-rule/pulls/95"},"html":{"href":"https://github.com/OpenLightingProject/ja-rule/pull/95"},"issue":{"href":"https://api.github.com/repos/OpenLightingProject/ja-rule/issues/95"},"comments":{"href":"https://api.github.com/repos/OpenLightingProject/ja-rule/issues/95/comments"},"review_comments":{"href":"https://api.github.com/repos/OpenLightingProject/ja-rule/pulls/95/comments"},"review_comment":{"href":"https://api.github.com/repos/OpenLightingProject/ja-rule/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/OpenLightingProject/ja-rule/pulls/95/commits"},"statuses":{"href":"https://api.github.com/repos/OpenLightingProject/ja-rule/statuses/0c2a3ff4c8ecc301745c77a8076c2eed3dca826c"}}}}