[VOL-2043] : OLT Enable Test Case

- Added more test cases for OLT Enable. Now covers all scenarios.
- Fixed typos in unit test README.md

Change-Id: Ib931d89cedee78fe40ca67761a028365a047ebc3
diff --git a/agent/test/src/bal_mocker.cc b/agent/test/src/bal_mocker.cc
index 5c89b03..b38906f 100644
--- a/agent/test/src/bal_mocker.cc
+++ b/agent/test/src/bal_mocker.cc
@@ -18,7 +18,8 @@
 
 
 #include "bal_mocker.h"
-
+extern "C" {
 CMOCK_MOCK_FUNCTION1(BalMocker, bcmolt_host_init, bcmos_errno(bcmolt_host_init_parms*));
 CMOCK_MOCK_FUNCTION2(BalMocker, bcmolt_cfg_get, bcmos_errno(bcmolt_oltid, bcmolt_cfg*));
 CMOCK_MOCK_FUNCTION2(BalMocker, bcmolt_oper_submit, bcmos_errno(bcmolt_oltid, bcmolt_oper*));
+}
diff --git a/agent/test/src/bal_stub.cc b/agent/test/src/bal_stub.cc
index 3119827..5ab1b79 100644
--- a/agent/test/src/bal_stub.cc
+++ b/agent/test/src/bal_stub.cc
@@ -144,11 +144,6 @@
     return BCM_ERR_OK;
 }
 
-bcmos_errno bcmolt_host_init(const bcmolt_host_init_parms *init_parms)
-{
-    return BCM_ERR_OK;
-}
-
 /* Map error code to error string */
 const char *bcmos_strerror(bcmos_errno err)
 {
diff --git a/agent/test/src/test_enable_olt.cc b/agent/test/src/test_enable_olt.cc
index db63606..0cdb965 100644
--- a/agent/test/src/test_enable_olt.cc
+++ b/agent/test/src/test_enable_olt.cc
@@ -56,3 +56,107 @@
     ASSERT_TRUE( olt_enable_res.error_message() == Status::OK.error_message() );
 }
 
+// Test 2: OltEnableFail_host_init_fail
+TEST_F(TestOltEnable, OltEnableFail_host_init_fail) {
+    // NiceMock is used to suppress 'WillByDefault' return errors on using 'NiceMock'.
+    // This is described in https://github.com/arangodb-helper/gtest/blob/master/googlemock/docs/CookBook.md
+    ::testing::NiceMock<BalMocker> balMock;
+    bcmos_errno host_init_res = BCM_ERR_INTERNAL;
+    bcmos_errno bal_cfg_get_res = BCM_ERR_NOT_CONNECTED;
+    bcmos_errno olt_oper_res = BCM_ERR_OK;
+
+    Status olt_enable_res;
+
+    // The 'EXPECT_CALL' will do strict validation of input parameters. This may not be relevant for
+    // the current test case. Use 'ON_CALL' instead.
+    // The ON_CALL results in WARNINGs when running tests. Use NickMock instead of directly using BalMocker.
+    // https://github.com/google/googletest/blob/master/googlemock/docs/cook_book.md#the-nice-the-strict-and-the-naggy-nicestrictnaggy
+    // In below tests '::testing::_' does no validation on argument.
+    ON_CALL(balMock, bcmolt_host_init(::testing::_)).WillByDefault(::testing::Return(host_init_res));
+    ON_CALL(balMock, bcmolt_cfg_get(::testing::_,::testing::_)).WillByDefault(::testing::Return(bal_cfg_get_res));
+    ON_CALL(balMock, bcmolt_oper_submit(::testing::_, ::testing::_)).WillByDefault(::testing::Return(olt_oper_res));
+
+    olt_enable_res = Enable_(1, NULL);
+    ASSERT_TRUE( olt_enable_res.error_message() != Status::OK.error_message() );
+}
+
+// Test 3: OltEnableSuccess_PON_Device_Connected
+TEST_F(TestOltEnable, OltEnableSuccess_PON_Device_Connected) {
+    // NiceMock is used to suppress 'WillByDefault' return errors on using 'NiceMock'.
+    // This is described in https://github.com/arangodb-helper/gtest/blob/master/googlemock/docs/CookBook.md
+    ::testing::NiceMock<BalMocker> balMock;
+    bcmos_errno host_init_res = BCM_ERR_OK;
+    bcmos_errno bal_cfg_get_res = BCM_ERR_OK;
+
+    Status olt_enable_res;
+
+    // The 'EXPECT_CALL' will do strict validation of input parameters. This may not be relevant for
+    // the current test case. Use 'ON_CALL' instead.
+    // The ON_CALL results in WARNINGs when running tests. Use NickMock instead of directly using BalMocker.
+    // https://github.com/google/googletest/blob/master/googlemock/docs/cook_book.md#the-nice-the-strict-and-the-naggy-nicestrictnaggy
+    // In below tests '::testing::_' does no validation on argument.
+    ON_CALL(balMock, bcmolt_host_init(::testing::_)).WillByDefault(::testing::Return(host_init_res));
+    ON_CALL(balMock, bcmolt_cfg_get(::testing::_,::testing::_)).WillByDefault(::testing::Return(bal_cfg_get_res));
+
+    olt_enable_res = Enable_(1, NULL);
+    ASSERT_TRUE( olt_enable_res.error_message() == Status::OK.error_message() );
+}
+
+// Test 4: OltEnableFail_All_PON_Enable_Fail
+TEST_F(TestOltEnable, OltEnableFail_All_PON_Enable_Fail) {
+    // NiceMock is used to suppress 'WillByDefault' return errors on using 'NiceMock'.
+    // This is described in https://github.com/arangodb-helper/gtest/blob/master/googlemock/docs/CookBook.md
+    ::testing::NiceMock<BalMocker> balMock;
+    bcmos_errno host_init_res = BCM_ERR_OK;
+    bcmos_errno bal_cfg_get_res = BCM_ERR_NOT_CONNECTED;
+    bcmos_errno olt_oper_res = BCM_ERR_INTERNAL;
+
+    Status olt_enable_res;
+
+    // Ensure that the state of the OLT is in deactivated to start with..
+    state.deactivate();
+
+    // The 'EXPECT_CALL' will do strict validation of input parameters. This may not be relevant for
+    // the current test case. Use 'ON_CALL' instead.
+    // The ON_CALL results in WARNINGs when running tests. Use NickMock instead of directly using BalMocker.
+    // https://github.com/google/googletest/blob/master/googlemock/docs/cook_book.md#the-nice-the-strict-and-the-naggy-nicestrictnaggy
+    // In below tests '::testing::_' does no validation on argument.
+    ON_CALL(balMock, bcmolt_host_init(::testing::_)).WillByDefault(::testing::Return(host_init_res));
+    ON_CALL(balMock, bcmolt_cfg_get(::testing::_,::testing::_)).WillByDefault(::testing::Return(bal_cfg_get_res));
+    ON_CALL(balMock, bcmolt_oper_submit(::testing::_, ::testing::_)).WillByDefault(::testing::Return(olt_oper_res));
+
+    olt_enable_res = Enable_(1, NULL);
+    ASSERT_TRUE( olt_enable_res.error_message() != Status::OK.error_message() );
+}
+
+// Test 5 OltEnableSuccess_One_PON_Enable_Fail : One PON device enable fails, but all others succeed.
+TEST_F(TestOltEnable, OltEnableSuccess_One_PON_Enable_Fail) {
+    // NiceMock is used to suppress 'WillByDefault' return errors on using 'NiceMock'.
+    // This is described in https://github.com/arangodb-helper/gtest/blob/master/googlemock/docs/CookBook.md
+    ::testing::NiceMock<BalMocker> balMock;
+    bcmos_errno host_init_res = BCM_ERR_OK;
+    bcmos_errno bal_cfg_get_res = BCM_ERR_NOT_CONNECTED;
+    bcmos_errno olt_oper_res_fail = BCM_ERR_INTERNAL;
+    bcmos_errno olt_oper_res_success = BCM_ERR_OK;
+
+    Status olt_enable_res;
+
+    // Ensure that the state of the OLT is in deactivated to start with..
+    state.deactivate();
+
+    // The 'EXPECT_CALL' will do strict validation of input parameters. This may not be relevant for
+    // the current test case. Use 'ON_CALL' instead.
+    // The ON_CALL results in WARNINGs when running tests. Use NickMock instead of directly using BalMocker.
+    // https://github.com/google/googletest/blob/master/googlemock/docs/cook_book.md#the-nice-the-strict-and-the-naggy-nicestrictnaggy
+    // In below tests '::testing::_' does no validation on argument.
+    ON_CALL(balMock, bcmolt_host_init(::testing::_)).WillByDefault(::testing::Return(host_init_res));
+    ON_CALL(balMock, bcmolt_cfg_get(::testing::_,::testing::_)).WillByDefault(::testing::Return(bal_cfg_get_res));
+    // For the the first PON mac device, the activation result will fail, and will succeed for all other PON mac devices.
+    EXPECT_CALL(balMock, bcmolt_oper_submit(::testing::_, ::testing::_))
+                         .WillOnce(::testing::Return(olt_oper_res_fail))
+                         .WillRepeatedly(::testing::Return(olt_oper_res_success));
+
+    olt_enable_res = Enable_(1, NULL);
+    // The OLT activation should succeed if at least one PON mac device activation succeeds.
+    ASSERT_TRUE( olt_enable_res.error_message() == Status::OK.error_message() );
+}