Delimiter //
/**
 * @test
 * Test For LOADER_CONTACTS_NORMALIZE_CONTACTS_REF_LENGTH()
 */
DROP Procedure IF EXISTS TEST_LOADER_CONTACTS_NORMALIZE_CONTACTS_REF_LENGTH//

Create Procedure TEST_LOADER_CONTACTS_NORMALIZE_CONTACTS_REF_LENGTH()
Begin

    -- initial dataset
    CALL LOADER_TEST_MOCK_CONTACTS_CLEAN();

    CALL LOADER_TEST_MOCK_CONTACTS_PUSH(1, 'CONTACTS_REF = LPAD('''', 30, ''*'')', 1, NULL);
    CALL LOADER_TEST_MOCK_CONTACTS_PUSH(2, 'CONTACTS_REF = LPAD('''', 20, ''*'')', 2, NULL);
    CALL LOADER_TEST_MOCK_CONTACTS_PUSH(3, 'CONTACTS_REF = LPAD('''', 10, ''*'')', 3, NULL);

    -- Procedure
    CALL LOADER_CONTACTS_NORMALIZE_CONTACTS_REF_LENGTH(1);

    -- Assertions
-- Test inutile car données de test automatiquement tronquées
-- 
--     CALL utAssert_eq('Contacts with too long ref are flagged'
--         , 1
--         , (SELECT LOADER_STATUS_ERRCOUNT FROM LOADER_STATUS WHERE ID_LOADER_STATUS = 1)
--     );
    CALL utAssert_eq('Contacts with the exact ref lenght are not flagged' 
        , 0
        , (SELECT LOADER_STATUS_ERRCOUNT FROM LOADER_STATUS WHERE ID_LOADER_STATUS = 2) 
    );
    CALL utAssert_eq('Contacts with a valid ref lenght are not flagged' 
        , 0
        , (SELECT LOADER_STATUS_ERRCOUNT FROM LOADER_STATUS WHERE ID_LOADER_STATUS = 3) 
    );
    
    -- clean
    CALL LOADER_TEST_MOCK_CONTACTS_CLEAN();

End //
Delimiter ;
