update: Refactor to use ndn-cxx dispatcher for prefix update/readvertise

refs: #3728

Change-Id: I3186433ed460850753f033a1d03fe27fd1fe889c
diff --git a/tests/update/test-nfd-rib-command-processor.cpp b/tests/update/test-nfd-rib-command-processor.cpp
index 81b66ce..bb4db42 100644
--- a/tests/update/test-nfd-rib-command-processor.cpp
+++ b/tests/update/test-nfd-rib-command-processor.cpp
@@ -138,47 +138,6 @@
   BOOST_CHECK(!wasValidated);
 }
 
-BOOST_AUTO_TEST_CASE(InsertPrefix)
-{
-  ndn::nfd::ControlParameters parameters;
-  ndn::Name prefixName("/test/prefixA");
-  parameters.setName(prefixName);
-
-  processor.insertPrefix(parameters);
-  this->advanceClocks(ndn::time::milliseconds(10));
-
-  BOOST_CHECK_EQUAL(namePrefixes.getNameList().size(), 1);
-  auto itr = std::find(namePrefixes.getNameList().begin(), namePrefixes.getNameList().end(),
-                       prefixName);
-  if (itr == namePrefixes.getNameList().end()) {
-    BOOST_FAIL("Prefix was not inserted!");
-  }
-  BOOST_CHECK_EQUAL((*itr), parameters.getName());
-  BOOST_CHECK(wasRoutingUpdatePublished());
-  BOOST_CHECK(nameLsaSeqNoBeforeInterest < nlsr.getLsdb().getSequencingManager().getNameLsaSeq());
-}
-
-BOOST_AUTO_TEST_CASE(RemovePrefix)
-{
-  ndn::Name prefixName("/test/prefixA");
-  namePrefixes.getNameList().push_back(prefixName);
-  ndn::nfd::ControlParameters parameters;
-  parameters.setName("/test/prefixA");
-
-  BOOST_CHECK_EQUAL(namePrefixes.getNameList().size(), 1);
-  processor.removePrefix(parameters);
-  this->advanceClocks(ndn::time::milliseconds(10));
-
-  BOOST_CHECK_EQUAL(namePrefixes.getNameList().size(), 0);
-  auto itr = std::find(namePrefixes.getNameList().begin(), namePrefixes.getNameList().end(),
-                       prefixName);
-  if (itr != namePrefixes.getNameList().end()) {
-    BOOST_FAIL("Prefix was not removed!");
-  }
-  BOOST_CHECK(wasRoutingUpdatePublished());
-  BOOST_CHECK(nameLsaSeqNoBeforeInterest < nlsr.getLsdb().getSequencingManager().getNameLsaSeq());
-}
-
 BOOST_AUTO_TEST_CASE(onReceiveInterestRegisterCommand)
 {
   ndn::Name name("/localhost/nlsr/rib/register");
diff --git a/tests/update/test-prefix-update-processor.cpp b/tests/update/test-prefix-update-processor.cpp
index efb24a0..19deaf6 100644
--- a/tests/update/test-prefix-update-processor.cpp
+++ b/tests/update/test-prefix-update-processor.cpp
@@ -48,7 +48,8 @@
     , opIdentity(ndn::Name(siteIdentity).append(ndn::Name("%C1.Operator")).appendVersion())
     , nlsr(g_ioService, g_scheduler, face, g_keyChain)
     , keyPrefix(("/ndn/broadcast"))
-    , updateProcessor(nlsr.getPrefixUpdateProcessor())
+    , namePrefixList(nlsr.getNamePrefixList())
+    , updatePrefixUpdateProcessor(nlsr.getPrefixUpdateProcessor())
     , SITE_CERT_PATH(boost::filesystem::current_path() / std::string("site.cert"))
   {
     createSiteCert();
@@ -102,7 +103,7 @@
     const boost::filesystem::path CONFIG_PATH =
       (boost::filesystem::current_path() / std::string("unit-test.conf"));
 
-    updateProcessor.getValidator().load(CONFIG, CONFIG_PATH.native());
+    updatePrefixUpdateProcessor.getValidator().load(CONFIG, CONFIG_PATH.native());
 
     // Insert certs after the validator is loaded since ValidatorConfig::load() clears
     // the certificate cache
@@ -119,6 +120,7 @@
     sessionTime.appendNumber(ndn::time::toUnixTimestamp(ndn::time::system_clock::now()).count());
 
     this->advanceClocks(ndn::time::milliseconds(10));
+
     face.sentInterests.clear();
   }
 
@@ -224,7 +226,8 @@
 
   Nlsr nlsr;
   ndn::Name keyPrefix;
-  PrefixUpdateProcessor& updateProcessor;
+  NamePrefixList& namePrefixList;
+  PrefixUpdateProcessor& updatePrefixUpdateProcessor;
 
   const boost::filesystem::path SITE_CERT_PATH;
   ndn::Name sessionTime;
@@ -235,12 +238,9 @@
 BOOST_AUTO_TEST_CASE(Basic)
 {
   uint64_t nameLsaSeqNoBeforeInterest = nlsr.getLsdb().getSequencingManager().getNameLsaSeq();
-  updateProcessor.enable();
-
   // Advertise
   ndn::nfd::ControlParameters parameters;
   parameters.setName("/prefix/to/advertise/");
-
   ndn::Name advertiseCommand("/localhost/nlsr/prefix-update/advertise");
   advertiseCommand.append(parameters.wireEncode());
 
@@ -277,38 +277,6 @@
   BOOST_CHECK(nameLsaSeqNoBeforeInterest < nlsr.getLsdb().getSequencingManager().getNameLsaSeq());
 }
 
-BOOST_AUTO_TEST_CASE(DisabledAndEnabled)
-{
-  ndn::nfd::ControlParameters parameters;
-  parameters.setName("/prefix/to/advertise/");
-
-  ndn::Name advertiseCommand("/localhost/nlsr/prefix-update/advertise");
-  advertiseCommand.append(parameters.wireEncode());
-
-  std::shared_ptr<Interest> advertiseInterest = std::make_shared<Interest>(advertiseCommand);
-  keyChain.signByIdentity(*advertiseInterest, opIdentity);
-
-  // Command should be rejected
-  face.receive(*advertiseInterest);
-  this->advanceClocks(ndn::time::milliseconds(10));
-
-  BOOST_REQUIRE(!face.sentData.empty());
-
-  const ndn::MetaInfo& metaInfo = face.sentData.front().getMetaInfo();
-  BOOST_CHECK_EQUAL(metaInfo.getType(), ndn::tlv::ContentType_Nack);
-
-  face.sentData.clear();
-
-  // Enable PrefixUpdateProcessor so commands will be processed
-  updateProcessor.enable();
-
-  // Command should be accepted
-  face.receive(*advertiseInterest);
-  this->advanceClocks(ndn::time::milliseconds(10));
-
-  checkResponseCode(advertiseCommand, 200);
-}
-
 BOOST_AUTO_TEST_SUITE_END()
 
 } // namespace test