Delimiter //
/**
 * Test of LOADER_BALANCECONTROL_NORMALIZE_CHECK_ACCOUNT_EXISTS
 * @test
 */
Drop Procedure If Exists TEST_LOADER_BALANCECONTROL_NORMALIZE_CHECK_APPLICATION_BALANCE//
Create Procedure TEST_LOADER_BALANCECONTROL_NORMALIZE_CHECK_APPLICATION_BALANCE()
Begin

    -- Context
    call LOADER_TEST_MOCK_BALANCECONTROL_CLEAN();
    call LOADER_TEST_MOCK_BALANCECONTROL_PUSH(1, 'ID_ACCOUNTS = 1, BALANCE = 100', 1, Null);
    call LOADER_TEST_MOCK_BALANCECONTROL_PUSH(2, 'ID_ACCOUNTS = 2, BALANCE = 200', 2, Null);

    -- Business tables
    Call LOADER_TEST_MOCK_BUSINESS_PUSH('FI_ANA', 'ACCOUNTS_ID_ACCOUNTS = 1, FI_ANA_OUTSTANDING = 100');
    Call LOADER_TEST_MOCK_BUSINESS_PUSH('FI_ANA', 'ACCOUNTS_ID_ACCOUNTS = 2, FI_ANA_OUTSTANDING = 400');

    -- Tested procedure
    Call LOADER_BALANCECONTROL_NORMALIZE_CHECK_APPLICATION_BALANCE();
    
    Call utAssert_eq('During a balance control, when application and file balances are different an error was added'
        , 1
        , (Select LOADER_BALANCECONTROL_ACCOUNTS_STATUS_ERRCOUNT From LOADER_BALANCECONTROL_ACCOUNTS_STATUS Where ACCOUNTS_ID_ACCOUNTS IS NULL)
    );


    -- Clean
    Call LOADER_TEST_MOCK_BUSINESS_CLEAN('FI_ANA');
    Call LOADER_TEST_MOCK_INFO_CLEAN();
    Call LOADER_TEST_MOCK_BALANCECONTROL_CLEAN();

End//
Delimiter ;