<commit_before>create or replace package body test_output_buffer is

  procedure test_receive is
    l_actual_text        clob;
    l_actual_item_type   varchar2(1000);
    l_remaining          integer;
    l_expected_text      clob;
    l_expected_item_type varchar2(1000);
    l_buffer             ut3.ut_output_buffer_base;
  begin
    --Arrange
    l_buffer        := ut3.ut_output_clob_table_buffer();
    l_expected_text := to_clob(lpad('a text', 31000, ',a text'))
      || chr(10) || to_clob(lpad('a text', 31000, ',a text'))
      || chr(13) || to_clob(lpad('a text', 31000, ',a text'))
      || chr(13) || chr(10) || to_clob(lpad('a text', 31000, ',a text')) || to_clob(lpad('a text', 31000, ',a text'));
    l_expected_item_type := lpad('some item type',1000,'-');
    --Act
    l_buffer.send_clob(l_expected_text, l_expected_item_type);
    l_buffer.close();

    select text, item_type
      into l_actual_text, l_actual_item_type
      from table(l_buffer.get_lines(0,0));

    --Assert
    ut.expect(l_actual_text).to_equal(l_expected_text);
    ut.expect(l_actual_item_type).to_equal(l_expected_item_type);

    select count(1) into l_remaining from table(ut3_tester_helper.run_helper.ut_output_buffer_tmp) 
      where output_id = l_buffer.output_id;

    ut.expect(l_remaining).to_equal(0);
  end;
  
  procedure test_doesnt_send_on_null_text is
    l_cur    sys_refcursor;
    l_result integer;
    l_buffer ut3.ut_output_buffer_base := ut3.ut_output_table_buffer();
  begin
    ut3_tester_helper.run_helper.delete_buffer();
    --Act
    l_buffer.send_line(null);

    open l_cur for select * from table(ut3_tester_helper.run_helper.ut_output_buffer_tmp);
    ut.expect(l_cur).to_be_empty;
  end;
  
  
  procedure test_doesnt_send_on_null_elem is
    l_cur    sys_refcursor;
    l_result integer;
    l_buffer ut3.ut_output_buffer_base := ut3.ut_output_table_buffer();
    l_message_id varchar2(255);
    l_text varchar2(4000);
  begin
    ut3_tester_helper.run_helper.delete_buffer();
    --Act
    l_buffer.send_lines(ut_varchar2_rows(null));
    l_buffer.send_lines(ut_varchar2_rows('test'));

    select message_id, text into l_message_id, l_text from table(ut3_tester_helper.run_helper.ut_output_buffer_tmp);
    ut.expect(l_message_id).to_equal('1');
    ut.expect(l_text).to_equal('test');
  end;  
  <commit_msg>fix type<commit_after>create or replace package body test_output_buffer is

  procedure test_receive is
    l_actual_text        clob;
    l_actual_item_type   varchar2(1000);
    l_remaining          integer;
    l_expected_text      clob;
    l_expected_item_type varchar2(1000);
    l_buffer             ut3.ut_output_buffer_base;
  begin
    --Arrange
    l_buffer        := ut3.ut_output_clob_table_buffer();
    l_expected_text := to_clob(lpad('a text', 31000, ',a text'))
      || chr(10) || to_clob(lpad('a text', 31000, ',a text'))
      || chr(13) || to_clob(lpad('a text', 31000, ',a text'))
      || chr(13) || chr(10) || to_clob(lpad('a text', 31000, ',a text')) || to_clob(lpad('a text', 31000, ',a text'));
    l_expected_item_type := lpad('some item type',1000,'-');
    --Act
    l_buffer.send_clob(l_expected_text, l_expected_item_type);
    l_buffer.close();

    select text, item_type
      into l_actual_text, l_actual_item_type
      from table(l_buffer.get_lines(0,0));

    --Assert
    ut.expect(l_actual_text).to_equal(l_expected_text);
    ut.expect(l_actual_item_type).to_equal(l_expected_item_type);

    select count(1) into l_remaining from table(ut3_tester_helper.run_helper.ut_output_buffer_tmp) 
      where output_id = l_buffer.output_id;

    ut.expect(l_remaining).to_equal(0);
  end;
  
  procedure test_doesnt_send_on_null_text is
    l_cur    sys_refcursor;
    l_result integer;
    l_buffer ut3.ut_output_buffer_base := ut3.ut_output_table_buffer();
  begin
    ut3_tester_helper.run_helper.delete_buffer();
    --Act
    l_buffer.send_line(null);

    open l_cur for select * from table(ut3_tester_helper.run_helper.ut_output_buffer_tmp);
    ut.expect(l_cur).to_be_empty;
  end;
  
  
  procedure test_doesnt_send_on_null_elem is
    l_cur    sys_refcursor;
    l_result integer;
    l_buffer ut3.ut_output_buffer_base := ut3.ut_output_table_buffer();
    l_message_id varchar2(255);
    l_text varchar2(4000);
  begin
    ut3_tester_helper.run_helper.delete_buffer();
    --Act
    l_buffer.send_lines(ut3.ut_varchar2_rows(null));
    l_buffer.send_lines(ut3.ut_varchar2_rows('test'));

    select message_id, text into l_message_id, l_text from table(ut3_tester_helper.run_helper.ut_output_buffer_tmp);
    ut.expect(l_message_id).to_equal('1');
    ut.expect(l_text).to_equal('test');
  end;  
  
{'fraction_non_alphanumeric': 0.11270010672358591, 'fraction_numerical': 0.032017075773746, 'mean_word_length': 3.88125, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '242546', 'n_tokens_mistral': 1846, 'n_tokens_neox': 1751, 'n_words': 277}