Delimiter //
/**
 * @test
 * Test For LOADER_CONTACTS_NORMALIZE_MAP_COUNTRY_NOT_PROVIDED()
 */
Drop Procedure IF EXISTS TEST_LOADER_CONTACTS_MAP_COUNTRY_NOT_PROVIDED//

Create Procedure TEST_LOADER_CONTACTS_MAP_COUNTRY_NOT_PROVIDED()
Begin

        -- initial dataset
        Call LOADER_TEST_MOCK_CONTACTS_CLEAN();
        Call LOADER_TEST_MOCK_INFO_CLEAN();
        Call LOADER_TEST_MOCK_BUSINESS_CLEAN('ADMIN_PARAMS');

        Call LOADER_TEST_MOCK_CONTACTS_PUSH(1, 'ID_CONTACTS_NEW = 1, DF_COUNTRY_LABEL = '''' ', 1, Null);
        Call LOADER_TEST_MOCK_CONTACTS_PUSH(2, 'ID_CONTACTS_NEW = 2, DF_COUNTRY_LABEL = ''FILLED'' ', 2, Null);

        Call LOADER_TEST_MOCK_INFO_PUSH('ID_ADMIN_PARAMS', 1);

        Call LOADER_TEST_MOCK_BUSINESS_PUSH('ADMIN_PARAMS', 'ID_ADMIN_PARAMS = 1, DF_COUNTRY_ID_DF_COUNTRY = 1');

        -- Procedure
        Call LOADER_CONTACTS_NORMALIZE_MAP_COUNTRY_NOT_PROVIDED(1);

        -- Assertions
        Call utAssert_eq('Contacts without provided country receive by default the country of the admin param'
            , 1
            , (SELECT DF_COUNTRY_ID_DF_COUNTRY  FROM LOADER_CONTACTS WHERE ID_LOADER_CONTACTS = 1)
        );
        Call utAssert_eq('Contacts with provided country are not modified' 
            , Null
            , (SELECT DF_COUNTRY_ID_DF_COUNTRY FROM LOADER_CONTACTS WHERE ID_LOADER_CONTACTS = 2) 
        );

        -- clean
        Call LOADER_TEST_MOCK_BUSINESS_CLEAN('ADMIN_PARAMS');
        Call LOADER_TEST_MOCK_INFO_CLEAN();
        Call LOADER_TEST_MOCK_CONTACTS_CLEAN();

End //
Delimiter ;
