Delimiter //
/**
 * @test
 * Test For LOADER_CONTACTS_NORMALIZE_MAP_LAST_NAME_PROVIDED()
 */
Drop Procedure IF EXISTS TEST_LOADER_CONTACTS_NORMALIZE_MAP_LAST_NAME_PROVIDED//

Create Procedure TEST_LOADER_CONTACTS_NORMALIZE_MAP_LAST_NAME_PROVIDED()
Begin

        -- initial dataset
        Call LOADER_TEST_MOCK_CONTACTS_CLEAN();
        Call LOADER_TEST_MOCK_INFO_CLEAN();

        Call LOADER_TEST_MOCK_CONTACTS_PUSH(1, 'ID_CONTACTS_NEW = 1, CONTACTS_INDIVIDUAL_LAST_NAME = ''min'' ', 1, Null);
        Call LOADER_TEST_MOCK_CONTACTS_PUSH(2, 'ID_CONTACTS_NEW = 2, CONTACTS_INDIVIDUAL_LAST_NAME = ''MAJ'' ', 2, Null);
        Call LOADER_TEST_MOCK_CONTACTS_PUSH(3, 'ID_CONTACTS_NEW = 3, CONTACTS_INDIVIDUAL_LAST_NAME = ''nOm MéLaNgÉ'' ', 3, Null);

        -- Procedure
        Call LOADER_CONTACTS_NORMALIZE_MAP_LAST_NAME_PROVIDED(1);

        -- Assertions
        Call utAssert_eq('Contacts with last name provided in lower case are tronformed in upper case'
            , 'MIN'
            , (SELECT CONTACTS_INDIVIDUAL_LAST_NAME  FROM LOADER_CONTACTS WHERE ID_LOADER_CONTACTS = 1)
        );
        Call utAssert_eq('Contacts with last name provided in upper case are not modified' 
            , 'MAJ'
            , (SELECT CONTACTS_INDIVIDUAL_LAST_NAME FROM LOADER_CONTACTS WHERE ID_LOADER_CONTACTS = 2) 
        );
        Call utAssert_eq('Contacts with last name provided in mixed case are tronformed in upper case' 
            , 'NOM MÉLANGÉ'
            , (SELECT CONTACTS_INDIVIDUAL_LAST_NAME FROM LOADER_CONTACTS WHERE ID_LOADER_CONTACTS = 3) 
        );

        -- clean
        Call LOADER_TEST_MOCK_INFO_CLEAN();
        Call LOADER_TEST_MOCK_CONTACTS_CLEAN();

End //
Delimiter ;
