Delimiter //
/**
 * 
 * MUST BE AFTER LOADER_ENTRIES_NORMALIZE_MAP_DATE_NOTPROVIDED()
 * 
 * test of LOADER_ENTRIES_NORMALIZE_MAP_DUEDATE_NOTPROVIDED()
 * @test
 */
Drop Procedure If Exists TEST_LOADER_ENTRIES_MAP_DUEDATE_NOTPROVIDED//

Create Procedure TEST_LOADER_ENTRIES_MAP_DUEDATE_NOTPROVIDED()
Begin

    Set @default_code_type = 'CLIENT';
    Set @batchnum = 1;
    Set @id_admin_params = GET_LOADER_INFO('ID_ADMIN_PARAMS', @batchnum);
    Set @id_loader_status = 1;


    Call LOADER_TEST_MOCK_ENTRIES_CLEAN();
    call LOADER_TEST_MOCK_ENTRIES_PUSH(1,'ID_ENTRIES_NEW = 1, ENTRIES_DUE_DATE = Null , ENTRIES_DATE = ''2012-05-20''', @id_loader_status , Null); 
    call LOADER_TEST_MOCK_ENTRIES_PUSH(2,'ID_ENTRIES_NEW = 2, ENTRIES_DUE_DATE = ''2012-05-25'', ENTRIES_DATE = ''2012-05-20''', @id_loader_status , Null); 
    
    -- Tested procedure
    call LOADER_ENTRIES_NORMALIZE_MAP_DUEDATE_NOTPROVIDED(@batchnum);
    
    CALL utAssert_eq('When no dueDate is provided for an entry, row receive the entry''s date'
        , '2012-05-20'
        , (SELECT ENTRIES_DUE_DATE FROM LOADER_ENTRIES WHERE ID_LOADER_ENTRIES = 1)
    );
    CALL utAssert_eq('When dueDate is provided for an entry, this dueDate is preserved'
        , '2012-05-25'
        , (SELECT ENTRIES_DUE_DATE FROM LOADER_ENTRIES WHERE ID_LOADER_ENTRIES = 2)
    );
    Call LOADER_TEST_MOCK_ENTRIES_CLEAN();

End//
Delimiter ;