Delimiter //
/**
 * test for LOADER_ENTRIES_NORMALIZE_STATUS_PROVIDED()
 * 
 * @author Armen
 */
Drop Procedure If Exists TEST_LOADER_ENTRIES_NORMALIZE_MAP_STATUS_PROVIDED//
Create Procedure TEST_LOADER_ENTRIES_NORMALIZE_MAP_STATUS_PROVIDED()
Begin
--     Set @id_tpl_loader = 1;
    Set @id_admin_param = 1;
    Call LOADER_TEST_MOCK_INFO_CLEAN();
--     Call LOADER_TEST_MOCK_INFO_PUSH('ID_TEMPLATE_LOADER', @id_tpl_loader);
    Call LOADER_TEST_MOCK_INFO_PUSH('ID_ADMIN_PARAMS', @id_admin_param);

    -- table
    Call LOADER_TEST_MOCK_ENTRIES_CLEAN();
    Call LOADER_TEST_MOCK_ENTRIES_PUSH(1, Concat('ENTRIES_STATUS_CODE = ''FOUND'' ') , 1, Null);
    Call LOADER_TEST_MOCK_ENTRIES_PUSH(2, Concat('ENTRIES_STATUS_CODE = ''XXX'' ') , 2, Null);

    -- business tables
    Call LOADER_TEST_MOCK_BUSINESS_CLEAN('DF_ENTRIES_STATUT');
    Call LOADER_TEST_MOCK_BUSINESS_CLEAN('DF_ICONS');
    
    Call LOADER_TEST_MOCK_BUSINESS_PUSH('DF_ICONS'
                                        , 'ID_DF_ICONS = 1, ADMIN_PARAMS_ID_ADMIN_PARAMS = 1 '
                                    )
                                  ;
    Call LOADER_TEST_MOCK_BUSINESS_PUSH('DF_ENTRIES_STATUT'
                                    , Concat('ID_DF_ENTRIES_STATUT = 1'
                                            , ', DF_ENTRIES_STATUT_CODE = ''FOUND'' '
                                            , ', ADMIN_PARAMS_ID_ADMIN_PARAMS = 1 '
                                            , ', DF_ICONS_ID_DF_ICONS = 1'
                                            , ', DF_ENTRIES_STATUT_INDICATOR = 0'
                                            , ', DF_ENTRIES_STATUT_TRASH = 0'
                                            , ', DF_ENTRIES_STATUT_AUTH_DEFAULT = 0'
                                        )
                                    )
                                  ;
    -- tested procedure
    Call LOADER_ENTRIES_NORMALIZE_MAP_STATUS_PROVIDED(1);

    -- assertions
    Call utAssert_eq('When status is provided, and this given status exists, row receives this status'
        , 1
        , (Select DF_ENTR_STT_ID_DF_ENTR_STT From LOADER_ENTRIES Where ID_LOADER_ENTRIES = 1)
    );
    Call utAssert_eq('When status is provided, and this given status exists, row does not receive any error'
        , 0
        , (Select LOADER_STATUS_ERRCOUNT From LOADER_STATUS Where ID_LOADER_STATUS = 1)
    );

-- 	call LOADER_ENTRIES_NORMALIZE_MAP_STATUS_NOTPROVIDED(1);
--     Call utAssert_eq('When status is provided, and this given status not exists, row receives warning'
--         , 1
--         , (Select LOADER_STATUS_WARNCOUNT From LOADER_STATUS Where ID_LOADER_STATUS = 2)
--     );
--     

    -- cleans
    Call LOADER_TEST_MOCK_ENTRIES_CLEAN();
    Call LOADER_TEST_MOCK_BUSINESS_CLEAN('DF_ENTRIES_STATUT');
    Call LOADER_TEST_MOCK_BUSINESS_CLEAN('DF_ICONS');
    Call LOADER_TEST_MOCK_INFO_CLEAN();
End//
Delimiter ;