Change ChatroomInfo to contain more information

Change-Id: Ie91ced5dd9be51c8d59a0c5d881967658a58fd15
diff --git a/test/test-chatroom-info.cpp b/test/test-chatroom-info.cpp
index a1b444e..39a5006 100644
--- a/test/test-chatroom-info.cpp
+++ b/test/test-chatroom-info.cpp
@@ -11,10 +11,19 @@
 BOOST_AUTO_TEST_SUITE(TestChatroomInfo)
 
 const uint8_t chatroomInfo[] = {
-  0x81, 0x2d, // ChatroomInfo
+  0x80, 0x5d, // ChatroomInfo
+    0x81, 0x06, // ChatroomName
+      0x08, 0x04,
+        0x06e, 0x64, 0x6e, 0x64,
     0x82, 0x01, // TrustModel
       0x01,
-    0x80, 0x14,// Participant1
+    0x83, 0x12, // ChatroomPrefix
+      0x07, 0x10,
+        0x08, 0x03,
+          0x6e, 0x64, 0x6e,
+        0x08, 0x09,
+          0x62, 0x72, 0x6f, 0x61, 0x64, 0x63, 0x61, 0x73, 0x74,
+    0x84, 0x14, // ManagerPrefix
       0x07, 0x12,
         0x08, 0x03,
           0x6e, 0x64, 0x6e,
@@ -22,7 +31,14 @@
           0x75, 0x63, 0x6c, 0x61,
         0x08, 0x05,
           0x61, 0x6c, 0x69, 0x63, 0x65,
-    0x80, 0x12, // Participant2
+    0x85, 0x26,// Participants
+      0x07, 0x12,
+        0x08, 0x03,
+          0x6e, 0x64, 0x6e,
+        0x08, 0x04,
+          0x75, 0x63, 0x6c, 0x61,
+        0x08, 0x05,
+          0x61, 0x6c, 0x69, 0x63, 0x65,
       0x07, 0x10,
         0x08, 0x03,
           0x6e, 0x64, 0x6e,
@@ -34,17 +50,41 @@
 
 BOOST_AUTO_TEST_CASE(EncodeChatroom)
 {
-  //Chatroom := CHATROOM-TYPE TLV-LENGTH
-  //              TrustModel
-  //              Participant+
+
+  // ChatroomInfo := CHATROOM-INFO-TYPE TLV-LENGTH
+  //                   ChatroomName
+  //                   TrustModel
+  //                   ChatroomPrefix
+  //                   ManagerPrefix
+  //                   Participants
+  //
+  // ChatroomName := CHATROOM-NAME-TYPE TLV-LENGTH
+  //                   NameComponent
+  //
+  // TrustModel := TRUST-MODEL-TYPE TLV-LENGTH
+  //                 nonNegativeInteger
+  //
+  // ChatroomPrefix := CHATROOM-PREFIX-TYPE TLV-LENGTH
+  //                     Name
+  //
+  // ManagerPrefix := MANAGER-PREFIX-TYPE TLV-LENGTH
+  //                    Name
+  //
+  // Participants := PARTICIPANTS-TYPE TLV-LENGTH
+  //                   Name+
 
   ChatroomInfo chatroom;
-  chatroom.setName(ndn::Name::Component("lunch-talk"));
+  chatroom.setName(ndn::Name::Component("ndnd"));
+  chatroom.setManager("/ndn/ucla/alice");
+  chatroom.setSyncPrefix("/ndn/broadcast");
   chatroom.addParticipant(Name("/ndn/ucla/alice"));
   chatroom.addParticipant(Name("/ndn/ucla/ymj"));
+  chatroom.addParticipant(Name("/ndn/ucla"));
+  chatroom.removeParticipant(Name("/ndn/ucla"));
   chatroom.setTrustModel(ChatroomInfo::TRUST_MODEL_WEBOFTRUST);
 
   const Block& encoded = chatroom.wireEncode();
+
   Block chatroomInfoBlock(chatroomInfo, sizeof(chatroomInfo));
 
   BOOST_CHECK_EQUAL_COLLECTIONS(chatroomInfoBlock.wire(),
@@ -56,7 +96,9 @@
 BOOST_AUTO_TEST_CASE(DecodeChatroomCorrect)
 {
   ChatroomInfo chatroom;
-  chatroom.setName(ndn::Name::Component("lunch-talk"));
+  chatroom.setName(ndn::Name::Component("ndnd"));
+  chatroom.setManager("/ndn/ucla/alice");
+  chatroom.setSyncPrefix("/ndn/broadcast");
   chatroom.addParticipant(Name("/ndn/ucla/alice"));
   chatroom.addParticipant(Name("/ndn/ucla/ymj"));
   chatroom.setTrustModel(ChatroomInfo::TRUST_MODEL_WEBOFTRUST);
@@ -64,22 +106,33 @@
   Block chatroomInfoBlock(chatroomInfo, sizeof(chatroomInfo));
   ChatroomInfo dechatroom;
   dechatroom.wireDecode(chatroomInfoBlock);
-  dechatroom.setName(ndn::Name::Component("lunch-talk"));
 
   BOOST_CHECK_EQUAL(chatroom.getName(), dechatroom.getName());
+  BOOST_CHECK_EQUAL(chatroom.getSyncPrefix().toUri(), dechatroom.getSyncPrefix().toUri());
+  BOOST_CHECK_EQUAL(chatroom.getManagerPrefix().toUri(), dechatroom.getManagerPrefix().toUri());
   BOOST_CHECK_EQUAL(chatroom.getParticipants().size(), dechatroom.getParticipants().size());
-  BOOST_CHECK_EQUAL(chatroom.getParticipants()[0].toUri(), dechatroom.getParticipants()[0].toUri());
-  BOOST_CHECK_EQUAL(chatroom.getParticipants()[1].toUri(), dechatroom.getParticipants()[1].toUri());
-  BOOST_CHECK_EQUAL(chatroom.getTrustModel(), dechatroom.getTrustModel());
+  BOOST_CHECK_EQUAL(chatroom.getParticipants().begin()->toUri(),
+                    dechatroom.getParticipants().begin()->toUri());
+  BOOST_CHECK_EQUAL(chatroom.getParticipants().begin()->toUri(),
+                    dechatroom.getParticipants().begin()->toUri());
 }
 
 BOOST_AUTO_TEST_CASE(DecodeChatroomError)
 {
   const uint8_t error1[] = {
-    0x80, 0x2d, // Wrong ChatroomInfo Type (0x81, 0x2d)
+    0x81, 0x5d, // ChatroomInfo Type Error
+      0x81, 0x06, // ChatroomName
+        0x08, 0x04,
+          0x06e, 0x64, 0x6e, 0x64,
       0x82, 0x01, // TrustModel
         0x01,
-      0x80, 0x14,// Participant1
+      0x83, 0x12, // ChatroomPrefix
+        0x07, 0x10,
+          0x08, 0x03,
+            0x6e, 0x64, 0x6e,
+          0x08, 0x09,
+            0x62, 0x72, 0x6f, 0x61, 0x64, 0x63, 0x61, 0x73, 0x74,
+      0x84, 0x14, // ManagerPrefix
         0x07, 0x12,
           0x08, 0x03,
             0x6e, 0x64, 0x6e,
@@ -87,7 +140,14 @@
             0x75, 0x63, 0x6c, 0x61,
           0x08, 0x05,
             0x61, 0x6c, 0x69, 0x63, 0x65,
-      0x80, 0x12, // Participant2
+      0x85, 0x26,// Participants
+        0x07, 0x12,
+          0x08, 0x03,
+            0x6e, 0x64, 0x6e,
+          0x08, 0x04,
+            0x75, 0x63, 0x6c, 0x61,
+          0x08, 0x05,
+            0x61, 0x6c, 0x69, 0x63, 0x65,
         0x07, 0x10,
           0x08, 0x03,
             0x6e, 0x64, 0x6e,
@@ -101,10 +161,19 @@
   BOOST_CHECK_THROW(ChatroomInfo chatroom(errorBlock1), ChatroomInfo::Error);
 
   const uint8_t error2[] = {
-    0x81, 0x2d, // ChatroomInfo
-      0x81, 0x01, // Wrong TrustModel Type (0x82, 0x01)
+    0x80, 0x5d, // ChatroomInfo
+      0x81, 0x06, // ChatroomName
+        0x08, 0x04,
+          0x06e, 0x64, 0x6e, 0x64,
+      0x83, 0x01, // TrustModel Type Error
         0x01,
-      0x80, 0x14,// Participant1
+      0x83, 0x12, // ChatroomPrefix
+        0x07, 0x10,
+          0x08, 0x03,
+            0x6e, 0x64, 0x6e,
+          0x08, 0x09,
+            0x62, 0x72, 0x6f, 0x61, 0x64, 0x63, 0x61, 0x73, 0x74,
+      0x84, 0x14, // ManagerPrefix
         0x07, 0x12,
           0x08, 0x03,
             0x6e, 0x64, 0x6e,
@@ -112,7 +181,14 @@
             0x75, 0x63, 0x6c, 0x61,
           0x08, 0x05,
             0x61, 0x6c, 0x69, 0x63, 0x65,
-      0x80, 0x12, // Participant2
+      0x85, 0x26,// Participants
+        0x07, 0x12,
+          0x08, 0x03,
+            0x6e, 0x64, 0x6e,
+          0x08, 0x04,
+            0x75, 0x63, 0x6c, 0x61,
+          0x08, 0x05,
+            0x61, 0x6c, 0x69, 0x63, 0x65,
         0x07, 0x10,
           0x08, 0x03,
             0x6e, 0x64, 0x6e,
@@ -126,10 +202,19 @@
   BOOST_CHECK_THROW(ChatroomInfo chatroom(errorBlock2), ChatroomInfo::Error);
 
   const uint8_t error3[] = {
-    0x81, 0x2d, // ChatroomInfo
+    0x80, 0x5d, // ChatroomInfo
+      0x81, 0x06, // ChatroomName
+        0x08, 0x04,
+          0x06e, 0x64, 0x6e, 0x64,
       0x82, 0x01, // TrustModel
         0x01,
-      0x80, 0x14,// Participant1
+      0x80, 0x12, // ChatroomPrefix Type Error
+        0x07, 0x10,
+          0x08, 0x03,
+            0x6e, 0x64, 0x6e,
+          0x08, 0x09,
+            0x62, 0x72, 0x6f, 0x61, 0x64, 0x63, 0x61, 0x73, 0x74,
+      0x84, 0x14, // ManagerPrefix
         0x07, 0x12,
           0x08, 0x03,
             0x6e, 0x64, 0x6e,
@@ -137,7 +222,14 @@
             0x75, 0x63, 0x6c, 0x61,
           0x08, 0x05,
             0x61, 0x6c, 0x69, 0x63, 0x65,
-      0x81, 0x12, // Wrong Participant Type (0x80, 0x12)
+      0x85, 0x26,// Participants
+        0x07, 0x12,
+          0x08, 0x03,
+            0x6e, 0x64, 0x6e,
+          0x08, 0x04,
+            0x75, 0x63, 0x6c, 0x61,
+          0x08, 0x05,
+            0x61, 0x6c, 0x69, 0x63, 0x65,
         0x07, 0x10,
           0x08, 0x03,
             0x6e, 0x64, 0x6e,
@@ -151,25 +243,116 @@
   BOOST_CHECK_THROW(ChatroomInfo chatroom(errorBlock3), ChatroomInfo::Error);
 
   const uint8_t error4[] = {
-    0x81, 0x00 // Empty ChatroomInfo
+    0x80, 0x5d, // ChatroomInfo
+      0x81, 0x06, // ChatroomName
+        0x08, 0x04,
+          0x06e, 0x64, 0x6e, 0x64,
+      0x82, 0x01, // TrustModel
+        0x01,
+      0x83, 0x12, // ChatroomPrefix
+        0x07, 0x10,
+          0x08, 0x03,
+            0x6e, 0x64, 0x6e,
+          0x08, 0x09,
+            0x62, 0x72, 0x6f, 0x61, 0x64, 0x63, 0x61, 0x73, 0x74,
+      0x80, 0x14, // ManagerPrefix Error Type
+        0x07, 0x12,
+          0x08, 0x03,
+            0x6e, 0x64, 0x6e,
+          0x08, 0x04,
+            0x75, 0x63, 0x6c, 0x61,
+          0x08, 0x05,
+            0x61, 0x6c, 0x69, 0x63, 0x65,
+      0x85, 0x26,// Participants
+        0x07, 0x12,
+          0x08, 0x03,
+            0x6e, 0x64, 0x6e,
+          0x08, 0x04,
+            0x75, 0x63, 0x6c, 0x61,
+          0x08, 0x05,
+            0x61, 0x6c, 0x69, 0x63, 0x65,
+        0x07, 0x10,
+          0x08, 0x03,
+            0x6e, 0x64, 0x6e,
+          0x08, 0x04,
+            0x75, 0x63, 0x6c, 0x61,
+          0x08, 0x03,
+            0x79, 0x6d, 0x6a
   };
 
   Block errorBlock4(error4, sizeof(error4));
   BOOST_CHECK_THROW(ChatroomInfo chatroom(errorBlock4), ChatroomInfo::Error);
 
   const uint8_t error5[] = {
-    0x81, 0x03, // ChatroomInfo
+    0x80, 0x5d, // ChatroomInfo
+      0x81, 0x06, // ChatroomName
+        0x08, 0x04,
+          0x06e, 0x64, 0x6e, 0x64,
       0x82, 0x01, // TrustModel
-        0x01
-    //zero Participant
+        0x01,
+      0x83, 0x12, // ChatroomPrefix
+        0x07, 0x10,
+          0x08, 0x03,
+            0x6e, 0x64, 0x6e,
+          0x08, 0x09,
+            0x62, 0x72, 0x6f, 0x61, 0x64, 0x63, 0x61, 0x73, 0x74,
+      0x84, 0x14, // ManagerPrefix
+        0x07, 0x12,
+          0x08, 0x03,
+            0x6e, 0x64, 0x6e,
+          0x08, 0x04,
+            0x75, 0x63, 0x6c, 0x61,
+          0x08, 0x05,
+            0x61, 0x6c, 0x69, 0x63, 0x65,
+      0x80, 0x26,// Participants Error Type
+        0x07, 0x12,
+          0x08, 0x03,
+            0x6e, 0x64, 0x6e,
+          0x08, 0x04,
+            0x75, 0x63, 0x6c, 0x61,
+          0x08, 0x05,
+            0x61, 0x6c, 0x69, 0x63, 0x65,
+        0x07, 0x10,
+          0x08, 0x03,
+            0x6e, 0x64, 0x6e,
+          0x08, 0x04,
+            0x75, 0x63, 0x6c, 0x61,
+          0x08, 0x03,
+            0x79, 0x6d, 0x6a
   };
 
   Block errorBlock5(error5, sizeof(error5));
   BOOST_CHECK_THROW(ChatroomInfo chatroom(errorBlock5), ChatroomInfo::Error);
+
+  const uint8_t error6[] = {
+    0x80, 0x00 // Empty ChatroomInfo
+  };
+
+  Block errorBlock6(error6, sizeof(error6));
+  BOOST_CHECK_THROW(ChatroomInfo chatroom(errorBlock6), ChatroomInfo::Error);
+
+  const uint8_t error7[] = {
+    0x80, 0x1f, // ChatroomInfo
+      0x81, 0x06, // ChatroomName
+        0x08, 0x04,
+          0x06e, 0x64, 0x6e, 0x64,
+      0x82, 0x01, // TrustModel
+        0x01,
+      0x83, 0x12, // ChatroomPrefix
+        0x07, 0x10,
+          0x08, 0x03,
+            0x6e, 0x64, 0x6e,
+          0x08, 0x09,
+            0x62, 0x72, 0x6f, 0x61, 0x64, 0x63, 0x61, 0x73, 0x74,
+    // no Participant
+  };
+
+  Block errorBlock7(error7, sizeof(error7));
+  BOOST_CHECK_THROW(ChatroomInfo chatroom(errorBlock7), ChatroomInfo::Error);
 }
 
 BOOST_AUTO_TEST_SUITE_END()
 
-} //namespace test
+} // namespace test
 
-} //namespace chronos
+} // namespace chronos