[CONPRO-1430] BlockWiseTransfer Error
[platform/upstream/iotivity.git] / service / notification / unittest / NSConsumerTest.cpp
index 8f38d43..4a57bde 100644 (file)
@@ -45,6 +45,15 @@ namespace
     std::condition_variable responseCon;
     std::mutex mutexForCondition;
 
+    enum class NSSelector
+    {
+        NS_SELECTION_CONSUMER = 0,
+        NS_SELECTION_PROVIDER = 1
+    };
+
+    NSConsumerConfig cfg;
+
+    NSProviderSimulator::NS_TopicStateList g_topicStateList;
 }
 
 class TestWithMock: public testing::Test
@@ -53,9 +62,13 @@ public:
     MockRepository mocks;
 
 protected:
-    virtual ~TestWithMock() noexcept(noexcept(std::declval<Test>().~Test())) {}
+    virtual ~TestWithMock() noexcept(noexcept(std::declval<Test>().~Test()))
+    {
+
+    }
 
-    virtual void TearDown() {
+    virtual void TearDown()
+    {
         try
         {
             mocks.VerifyAll();
@@ -74,16 +87,25 @@ public:
     NotificationConsumerTest() = default;
     ~NotificationConsumerTest() = default;
 
-    static void NSProviderDiscoveredCallbackEmpty(NSProvider *)
+    static void NSNotificationReceivedCallbackEmpty(NSMessage *)
     {
         std::cout << __func__ << std::endl;
     }
 
-    static void NSNotificationReceivedCallbackEmpty(NSProvider *, NSMessage *) { }
+    static void NSSyncCallbackEmpty(NSSyncInfo *)
+    {
+        std::cout << __func__ << std::endl;
+    }
 
-    static void NSSyncCallbackEmpty(NSProvider *, NSSync *) { }
+    static void NSFoundResourceEmpty(std::shared_ptr< OC::OCResource >)
+    {
+        std::cout << __func__ << std::endl;
+    }
 
-    static void foundResourceEmpty(std::shared_ptr< OC::OCResource >) { }
+    static void NSProviderChangedCallback(NSProvider *,  NSProviderState)
+    {
+        std::cout << __func__ << std::endl;
+    }
 
 protected:
 
@@ -93,7 +115,7 @@ protected:
 
         if (g_isStartedStack == false)
         {
-            OC::PlatformConfig cfg
+            OC::PlatformConfig occfg
             {
                 OC::ServiceType::InProc,
                 OC::ModeType::Both,
@@ -101,7 +123,7 @@ protected:
                 0,
                 OC::QualityOfService::LowQos
             };
-            OC::OCPlatform::Configure(cfg);
+            OC::OCPlatform::Configure(occfg);
 
             try
             {
@@ -113,6 +135,10 @@ protected:
             }
 
             g_isStartedStack = true;
+
+            cfg.changedCb = NSProviderChangedCallback;
+            cfg.messageCb = NSNotificationReceivedCallbackEmpty;
+            cfg.syncInfoCb = NSSyncCallbackEmpty;
         }
 
     }
@@ -124,13 +150,48 @@ protected:
 
 };
 
+TEST_F(NotificationConsumerTest, StartConsumerNegativeNonSetChangedCB)
+{
+    cfg.changedCb = NULL;
+    cfg.messageCb = NSNotificationReceivedCallbackEmpty;
+    cfg.syncInfoCb = NSSyncCallbackEmpty;
+
+    EXPECT_EQ(NS_ERROR, NSStartConsumer(cfg));
+    std::unique_lock< std::mutex > lock{ mutexForCondition };
+    responseCon.wait_for(lock, g_waitForResponse);
+}
+
+TEST_F(NotificationConsumerTest, StartConsumerNegativeNonSetNotiReceiveCB)
+{
+    cfg.changedCb = NSProviderChangedCallback;
+    cfg.messageCb = NULL;
+    cfg.syncInfoCb = NSSyncCallbackEmpty;
+
+    EXPECT_EQ(NS_ERROR, NSStartConsumer(cfg));
+    std::unique_lock< std::mutex > lock{ mutexForCondition };
+    responseCon.wait_for(lock, g_waitForResponse);
+}
+
+TEST_F(NotificationConsumerTest, StartConsumerNegativeNonSetSyncCB)
+{
+    cfg.changedCb = NSProviderChangedCallback;
+    cfg.messageCb = NSNotificationReceivedCallbackEmpty;
+    cfg.syncInfoCb = NULL;
+
+    EXPECT_EQ(NS_ERROR, NSStartConsumer(cfg));
+    std::unique_lock< std::mutex > lock{ mutexForCondition };
+    responseCon.wait_for(lock, g_waitForResponse);
+}
+
 TEST_F(NotificationConsumerTest, StartConsumerPositive)
 {
-    EXPECT_EQ(NS_OK,
-              NSStartConsumer(
-                    NSProviderDiscoveredCallbackEmpty,
-                    NSNotificationReceivedCallbackEmpty,
-                    NSSyncCallbackEmpty));
+    cfg.changedCb = NSProviderChangedCallback;
+    cfg.messageCb = NSNotificationReceivedCallbackEmpty;
+    cfg.syncInfoCb = NSSyncCallbackEmpty;
+
+    EXPECT_EQ(NS_OK, NSStartConsumer(cfg));
+    std::unique_lock< std::mutex > lock{ mutexForCondition };
+    responseCon.wait_for(lock, g_waitForResponse);
 }
 
 TEST_F(NotificationConsumerTest, StopConsumerPositive)
@@ -138,21 +199,25 @@ TEST_F(NotificationConsumerTest, StopConsumerPositive)
     EXPECT_EQ(NSStopConsumer(), NS_OK);
 }
 
+TEST_F(NotificationConsumerTest, StopConsumerNegative)
+{
+    EXPECT_EQ(NSStopConsumer(), NS_ERROR);
+}
+
 TEST_F(NotificationConsumerTest, DiscoverProviderWithNonAccepterWhenStartedConsumerFirst)
 {
-    mocks.ExpectCallFunc(NSProviderDiscoveredCallbackEmpty).Do(
-            [this, & responseCon](NSProvider *)
+    NSProviderState revState = NS_STOPPED;
+    mocks.OnCallFunc(NSProviderChangedCallback).Do(
+            [this, & revState](NSProvider *, NSProviderState state)
             {
                 std::cout << "Call Discovered" << std::endl;
+                revState = state;
                 responseCon.notify_all();
             });
 
-    NSStartConsumer(
-            NSProviderDiscoveredCallbackEmpty,
-            NSNotificationReceivedCallbackEmpty,
-            NSSyncCallbackEmpty);
+    NSStartConsumer(cfg);
 
-    g_providerSimul.setAccepter(1);
+    g_providerSimul.setAccepter((int)NSSelector::NS_SELECTION_CONSUMER);
     g_providerSimul.createNotificationResource();
 
     std::unique_lock< std::mutex > lock{ mutexForCondition };
@@ -160,42 +225,51 @@ TEST_F(NotificationConsumerTest, DiscoverProviderWithNonAccepterWhenStartedConsu
 
     NSStopConsumer();
     g_providerSimul.deleteNotificationResource();
+
+    EXPECT_EQ(NS_DISCOVERED, revState);
 }
 
 TEST_F(NotificationConsumerTest, DiscoverProviderWithNonAccepterWhenStartedConsumerAfter)
 {
-    g_providerSimul.setAccepter(1);
+    g_providerSimul.setAccepter((int)NSSelector::NS_SELECTION_CONSUMER);
     g_providerSimul.createNotificationResource();
     {
         std::unique_lock< std::mutex > lock{ mutexForCondition };
         responseCon.wait_for(lock, g_waitForResponse);
     }
 
-    mocks.ExpectCallFunc(NSProviderDiscoveredCallbackEmpty).Do(
-            [this, & responseCon](NSProvider *)
+    NSProviderState revState = NS_STOPPED;
+    mocks.OnCallFunc(NSProviderChangedCallback).Do(
+            [this, & revState](NSProvider * provider, NSProviderState state)
             {
                 std::cout << "Call Discovered" << std::endl;
+
+                g_provider = provider;
+                revState = state;
                 responseCon.notify_all();
             });
 
-    NSStartConsumer(
-            NSProviderDiscoveredCallbackEmpty,
-            NSNotificationReceivedCallbackEmpty,
-            NSSyncCallbackEmpty);
+    NSStartConsumer(cfg);
 
     std::unique_lock< std::mutex > lock{ mutexForCondition };
     responseCon.wait_for(lock, g_waitForResponse);
 
+    EXPECT_EQ(NS_DISCOVERED, revState);
+
+    ASSERT_NE(nullptr, g_provider) << "error: discovery failure";
 }
 
 TEST_F(NotificationConsumerTest, DiscoverProviderWithNonAccepterWhenRescan)
 {
-    mocks.ExpectCallFunc(NSProviderDiscoveredCallbackEmpty)
-            .Do(
-            [this, & responseCon](NSProvider * provider)
+    g_providerSimul.setAccepter((int)NSSelector::NS_SELECTION_CONSUMER);
+    NSProviderState revState = NS_STOPPED;
+    mocks.OnCallFunc(NSProviderChangedCallback).Do(
+            [this, &revState](NSProvider * provider, NSProviderState state)
             {
                 std::cout << "Call Discovered" << std::endl;
+                revState = state;
                 g_provider = provider;
+                std::cout << g_provider->providerId << std::endl;
                 responseCon.notify_all();
             });
 
@@ -204,29 +278,44 @@ TEST_F(NotificationConsumerTest, DiscoverProviderWithNonAccepterWhenRescan)
     std::unique_lock< std::mutex > lock{ mutexForCondition };
     responseCon.wait_for(lock, g_waitForResponse);
 
-//    NSStopConsumer();
+    EXPECT_EQ(NS_DISCOVERED, revState);
 }
 
 TEST_F(NotificationConsumerTest, ExpectSubscribeSuccess)
 {
-    NSResult ret = NSSubscribe(g_provider);
+    NSProviderState revState = NS_DENY;
+
+    ASSERT_NE(nullptr, g_provider) << "error: discovery failure";
+
+    mocks.OnCallFunc(NSProviderChangedCallback).Do(
+            [this, & revState](NSProvider * , NSProviderState state)
+            {
+                std::cout << "Income Changed Callback : " << state << std::endl;
+                revState = state;
+                responseCon.notify_all();
+            });
+
+    NSResult ret = NSSubscribe(g_provider->providerId);
     std::unique_lock< std::mutex > lock{ mutexForCondition };
     responseCon.wait_for(lock, g_waitForResponse);
 
+    EXPECT_EQ(NS_ALLOW, revState);
     EXPECT_EQ(NS_OK, ret);
 }
 
 TEST_F(NotificationConsumerTest, ExpectReceiveNotification)
 {
-    std::string id = "id";
+    uint64_t id = 10;
     std::string title = "title";
     std::string msg = "msg";
+    uint64_t revId = 0;
 
-    mocks.ExpectCallFunc(NSNotificationReceivedCallbackEmpty).Do(
-            [](NSProvider *, NSMessage * message)
+    mocks.OnCallFunc(NSNotificationReceivedCallbackEmpty).Do(
+            [this, & revId](NSMessage * message)
             {
-                std::cout << "Income Notification : " << message->mId << std::endl;
-                NSDropNSObject(message);
+                std::cout << "Income Notification : " << message->messageId << std::endl;
+                revId = message->messageId;
+                responseCon.notify_all();
             });
 
     g_providerSimul.notifyMessage(id, title, msg);
@@ -234,36 +323,57 @@ TEST_F(NotificationConsumerTest, ExpectReceiveNotification)
     std::unique_lock< std::mutex > lock{ mutexForCondition };
     responseCon.wait_for(lock, g_waitForResponse);
 
+    EXPECT_EQ(id, revId);
+    NSStopConsumer();
+    g_providerSimul.deleteNotificationResource();
 }
 
-TEST_F(NotificationConsumerTest, ExpectUnsubscribeSuccess)
+TEST_F(NotificationConsumerTest, ExpectReceiveSubAllowWithAccepterisProvider)
 {
-    NSResult ret = NSUnsubscribe(g_provider);
+    g_providerSimul.setAccepter((int)NSSelector::NS_SELECTION_PROVIDER);
+    NSProviderState revState = NS_DENY;
+    g_providerSimul.createNotificationResource();
+    {
+        std::unique_lock< std::mutex > lock{ mutexForCondition };
+        responseCon.wait_for(lock, g_waitForResponse);
+    }
+
+    mocks.OnCallFunc(NSProviderChangedCallback).Do(
+            [this, & revState](NSProvider * provider, NSProviderState state)
+            {
+                std::cout << "Income Changed Callback : " << state << std::endl;
+                revState = state;
+                g_provider = provider;
+                responseCon.notify_all();
+            });
+    mocks.OnCallFunc(NSProviderChangedCallback).Do(
+            [this, & revState](NSProvider *, NSProviderState state)
+            {
+                std::cout << "Income Changed Callback : " << state << std::endl;
+                revState = state;
+                responseCon.notify_all();
+            });
+
+    NSStartConsumer(cfg);
     std::unique_lock< std::mutex > lock{ mutexForCondition };
     responseCon.wait_for(lock, g_waitForResponse);
 
-    EXPECT_EQ(NS_OK, ret);
+    EXPECT_EQ(NS_ALLOW, revState);
 }
 
 TEST_F(NotificationConsumerTest, ExpectReceiveNotificationWithAccepterisProvider)
 {
-    std::string id = "ExpectReceiveNotificationWithAccepterisProvider";
+    uint64_t id = 11;
     std::string title = "title";
     std::string msg = "msg";
+    uint64_t revId = 1;
 
-    g_providerSimul.setAccepter(0);
-
-    NSRescanProvider();
-    {
-        std::unique_lock< std::mutex > lock{ mutexForCondition };
-        responseCon.wait_for(lock, g_waitForResponse);
-    }
-
-    mocks.ExpectCallFunc(NSNotificationReceivedCallbackEmpty).Do(
-            [](NSProvider *, NSMessage * message)
+    mocks.OnCallFunc(NSNotificationReceivedCallbackEmpty).Do(
+            [this, & id, & revId](NSMessage * message)
             {
-                std::cout << "Income Notification : " << message->mId << std::endl;
-                NSDropNSObject(message);
+                std::cout << "Income Notification : " << message->messageId << std::endl;
+                revId = message->messageId;
+                responseCon.notify_all();
             });
 
     g_providerSimul.notifyMessage(id, title, msg);
@@ -271,32 +381,30 @@ TEST_F(NotificationConsumerTest, ExpectReceiveNotificationWithAccepterisProvider
     std::unique_lock< std::mutex > lock{ mutexForCondition };
     responseCon.wait_for(lock, g_waitForResponse);
 
-//    g_providerSimul.deleteNotificationResource();
-//    NSStopConsumer();
+    EXPECT_EQ(id, revId);
 }
 
 TEST_F(NotificationConsumerTest, ExpectCallbackReadCheckWhenProviderNotifySync)
 {
-    std::string id = "ExpectCallbackReadCheckWhenProviderNotifySync";
+    uint64_t id = 12;
     std::string title = "title";
     std::string msg = "msg";
-
-    NSSyncTypes type = Notification_Dismiss;
+    NSSyncType type = NS_SYNC_DELETED;
 
     mocks.OnCallFunc(NSNotificationReceivedCallbackEmpty).Do(
-            [](NSProvider *, NSMessage * message)
+            [this](NSMessage * message)
             {
-                std::cout << "Income Notification : " << message->mId << std::endl;
-                NSDropNSObject(message);
+                std::cout << "Income Notification : " << message->messageId << std::endl;
+                responseCon.notify_all();
             });
 
-    mocks.ExpectCallFunc(NSSyncCallbackEmpty).Do(
-            [& type](NSProvider *, NSSync * sync)
+    mocks.OnCallFunc(NSSyncCallbackEmpty).Do(
+            [& type, this](NSSyncInfo * sync)
             {
-                std::cout << "Income Notification : " << sync->mMessageId
-                        << ", State : " << sync->mState << std::endl;
-                type = sync->mState;
-
+                std::cout << "Income SyncInfo : " << sync->messageId
+                        << ", State : " << sync->state << std::endl;
+                type = sync->state;
+                responseCon.notify_all();
             });
 
     g_providerSimul.notifyMessage(id, title, msg);
@@ -311,34 +419,30 @@ TEST_F(NotificationConsumerTest, ExpectCallbackReadCheckWhenProviderNotifySync)
         responseCon.wait_for(lock, g_waitForResponse);
     }
 
-//    g_providerSimul.deleteNotificationResource();
-//    NSStopConsumer();
-
-    EXPECT_EQ(Notification_Read, type);
+    EXPECT_EQ(NS_SYNC_READ, type);
 }
 
 TEST_F(NotificationConsumerTest, ExpectCallbackDismissCheckWhenProviderNotifySync)
 {
-    std::string id = "ExpectCallbackDismissCheckWhenProviderNotifySync";
+    uint64_t id = 13;
     std::string title = "title";
     std::string msg = "msg";
-
-    NSSyncTypes type = Notification_Read;
+    NSSyncType type = NS_SYNC_READ;
 
     mocks.OnCallFunc(NSNotificationReceivedCallbackEmpty).Do(
-            [](NSProvider *, NSMessage * message)
+            [this](NSMessage * message)
             {
-                std::cout << "Income Notification : " << message->mId << std::endl;
-                NSDropNSObject(message);
+                std::cout << "Income Notification : " << message->messageId << std::endl;
+                responseCon.notify_all();
             });
 
-    mocks.ExpectCallFunc(NSSyncCallbackEmpty).Do(
-            [& type](NSProvider *, NSSync * sync)
+    mocks.OnCallFunc(NSSyncCallbackEmpty).Do(
+            [& type, this](NSSyncInfo * sync)
             {
-                std::cout << "Income Notification : " << sync->mMessageId
-                        << ", State : " << sync->mState << std::endl;
-                type = sync->mState;
-
+                std::cout << "Income Notification : " << sync->messageId
+                        << ", State : " << sync->state << std::endl;
+                type = sync->state;
+                responseCon.notify_all();
             });
 
     g_providerSimul.notifyMessage(id, title, msg);
@@ -353,36 +457,32 @@ TEST_F(NotificationConsumerTest, ExpectCallbackDismissCheckWhenProviderNotifySyn
         responseCon.wait_for(lock, g_waitForResponse);
     }
 
-//    g_providerSimul.deleteNotificationResource();
-//    NSStopConsumer();
-
-    EXPECT_EQ(Notification_Dismiss, type);
+    EXPECT_EQ(NS_SYNC_DELETED, type);
 }
 
 TEST_F(NotificationConsumerTest, ExpectCallbackReadCheckWhenConsumerPostSync)
 {
-    std::string id = "ExpectCallbackReadCheckWhenConsumerPostSync";
+    uint64_t id = 14;
     std::string title = "title";
     std::string msg = "msg";
-
-    NSSyncTypes type = Notification_Dismiss;
+    NSSyncType type = NS_SYNC_DELETED;
 
     mocks.OnCallFunc(NSNotificationReceivedCallbackEmpty).Do(
-            [](NSProvider *, NSMessage * message)
+            [this](NSMessage * message)
             {
-                std::cout << "Income Notification : " << message->mId << std::endl;
-                NSConsumerReadCheck(message);
+                std::cout << "Income Notification : " << message->messageId << std::endl;
+                NSConsumerSendSyncInfo(message->providerId, message->messageId, NS_SYNC_READ);
                 std::unique_lock< std::mutex > lock{ mutexForCondition };
                 responseCon.wait_for(lock, g_waitForResponse);
             });
 
-    mocks.ExpectCallFunc(NSSyncCallbackEmpty).Do(
-            [& type](NSProvider *, NSSync * sync)
+    mocks.OnCallFunc(NSSyncCallbackEmpty).Do(
+            [& type, this](NSSyncInfo * sync)
             {
-                std::cout << "Income Notification : " << sync->mMessageId
-                        << ", State : " << sync->mState << std::endl;
-                type = sync->mState;
-
+                std::cout << "Income Notification : " << sync->messageId
+                        << ", State : " << sync->state << std::endl;
+                type = sync->state;
+                responseCon.notify_all();
             });
 
     g_providerSimul.notifyMessage(id, title, msg);
@@ -391,36 +491,32 @@ TEST_F(NotificationConsumerTest, ExpectCallbackReadCheckWhenConsumerPostSync)
         responseCon.wait_for(lock, g_waitForResponse);
     }
 
-//    g_providerSimul.deleteNotificationResource();
-//    NSStopConsumer();
-
-    EXPECT_EQ(Notification_Read, type);
+    EXPECT_EQ(NS_SYNC_READ, type);
 }
 
 TEST_F(NotificationConsumerTest, ExpectCallbackDismissCheckWhenConsumerPostSync)
 {
-    std::string id = "ExpectCallbackDismissCheckWhenConsumerPostSync";
+    uint64_t id = 15;
     std::string title = "title";
     std::string msg = "msg";
-
-    NSSyncTypes type = Notification_Read;
+    NSSyncType state = NS_SYNC_READ;
 
     mocks.OnCallFunc(NSNotificationReceivedCallbackEmpty).Do(
-            [](NSProvider *, NSMessage * message)
+            [this](NSMessage * message)
             {
-                std::cout << "Income Notification : " << message->mId << std::endl;
-                NSConsumerDismissCheck(message);
+                std::cout << "Income Notification : " << message->messageId << std::endl;
+                NSConsumerSendSyncInfo(message->providerId, message->messageId, NS_SYNC_DELETED);
                 std::unique_lock< std::mutex > lock{ mutexForCondition };
                 responseCon.wait_for(lock, g_waitForResponse);
             });
 
-    mocks.ExpectCallFunc(NSSyncCallbackEmpty).Do(
-            [& type](NSProvider *, NSSync * sync)
+    mocks.OnCallFunc(NSSyncCallbackEmpty).Do(
+            [& state, this](NSSyncInfo * sync)
             {
-                std::cout << "Income Notification : " << sync->mMessageId
-                        << ", State : " << sync->mState << std::endl;
-                type = sync->mState;
-
+                std::cout << "Income Notification : " << sync->messageId
+                        << ", State : " << sync->state << std::endl;
+                state = sync->state;
+                responseCon.notify_all();
             });
 
     g_providerSimul.notifyMessage(id, title, msg);
@@ -429,8 +525,115 @@ TEST_F(NotificationConsumerTest, ExpectCallbackDismissCheckWhenConsumerPostSync)
         responseCon.wait_for(lock, g_waitForResponse);
     }
 
+    EXPECT_EQ(NS_SYNC_DELETED, state);
+}
+
+TEST_F(NotificationConsumerTest, ExpectGetProviderSuccessWithValidProviderId)
+{
+    ASSERT_NE(nullptr, g_provider) << "error: discovery failure";
+
+    NSProvider * provider = NSConsumerGetProvider(g_provider->providerId);
+    int ret = strcmp(provider->providerId, g_provider->providerId);
+    EXPECT_EQ(0, ret);
+    free(provider);
+}
+
+TEST_F(NotificationConsumerTest, ExpectGetProviderSuccessWithInvalidProviderId)
+{
+    NSProvider * provider = NSConsumerGetProvider("123456789012345678901234567890123457");
+    EXPECT_EQ(provider, (void*)NULL);
+}
+
+TEST_F(NotificationConsumerTest, ExpectGetProviderSuccessWithNULL)
+{
+    NSProvider * provider = NSConsumerGetProvider(NULL);
+    EXPECT_EQ(provider, (void*)NULL);
+}
+
+TEST_F(NotificationConsumerTest, ExpectGetTopicListIsNULL)
+{
+    ASSERT_NE(nullptr, g_provider) << "error: discovery failure";
+
+    NSTopicLL * currentTopics = NSConsumerGetTopicList(g_provider->providerId);
+    EXPECT_EQ(NULL, currentTopics);
+}
+
+TEST_F(NotificationConsumerTest, ExpectCallbackTopicUpdated)
+{
+    NSProviderState revState = NS_STOPPED;
+    mocks.OnCallFunc(NSProviderChangedCallback).Do(
+        [this, & revState](NSProvider * , NSProviderState state)
+        {
+            std::cout << "Income Changed Callback : " << state << std::endl;
+            revState = state;
+            responseCon.notify_all();
+        });
+
+    NSProviderSimulator::NS_TopicList topics;
+    topics.push_back("1");
+    topics.push_back("2");
+    topics.push_back("3");
+
+    g_providerSimul.setTopics(topics);
+
+    std::unique_lock< std::mutex > lock{ mutexForCondition };
+    responseCon.wait_for(lock, g_waitForResponse);
+
+    EXPECT_EQ(NS_TOPIC, revState);
+}
+
+TEST_F(NotificationConsumerTest, ExpectEQTopicList)
+{
+    bool isSame = false;
+
+    NSProviderSimulator::NS_TopicList topics;
+    topics.push_back("1");
+    topics.push_back("2");
+    topics.push_back("3");
+
+    ASSERT_NE(nullptr, g_provider) << "error: discovery failure";
+
+    NSTopicLL * retTopic = NSConsumerGetTopicList(g_provider->providerId);
+    std::for_each (topics.begin(), topics.end(),
+            [this, & retTopic, & isSame](const std::string & str)
+            {
+                isSame = (str == std::string(retTopic->topicName));
+                retTopic = retTopic->next;
+            });
+
+    EXPECT_EQ(true, isSame);
+}
+
+TEST_F(NotificationConsumerTest, ExpectFailUpdateTopicOnConsumer)
+{
+    ASSERT_NE(nullptr, g_provider) << "error: discovery failure";
+
+    NSTopicLL * retTopic = NSConsumerGetTopicList(g_provider->providerId);
+    for (; retTopic; retTopic = retTopic->next)
+    {
+        retTopic->state = NS_TOPIC_SUBSCRIBED;
+    }
+    NSResult ret = NSConsumerUpdateTopicList(g_provider->providerId, retTopic);
+
+    EXPECT_EQ(NS_ERROR, ret);
+}
+
+TEST_F(NotificationConsumerTest, ExpectCallbackDeletedProvider)
+{
+    NSProviderState type = NS_ALLOW;
+    mocks.OnCallFunc(NSProviderChangedCallback).Do(
+            [& type, this](NSProvider * , NSProviderState state)
+            {
+                std::cout << "Income Changed Callback : " << state << std::endl;
+                type = state;
+                responseCon.notify_all();
+            });
+
     g_providerSimul.deleteNotificationResource();
-    NSStopConsumer();
 
-    EXPECT_EQ(Notification_Dismiss, type);
+    std::unique_lock< std::mutex > lock{ mutexForCondition };
+    responseCon.wait_for(lock, std::chrono::milliseconds(2000));
+
+    EXPECT_EQ(type, NS_STOPPED);
+    NSStopConsumer();
 }