diff --git a/assets/application.css b/assets/application.css index a443614..11b1029 100644 --- a/assets/application.css +++ b/assets/application.css @@ -748,6 +748,21 @@ td { text-align: center; border-radius: 6px; } + .source_table pre .blocks { + float: right; + margin-left: 10px; + padding: 2px 4px; + background-color: #444444; + background: -webkit-gradient(linear, 0 0, 0 bottom, from(#222222), to(#666666)); + background: -moz-linear-gradient(#222222, #666666); + background: linear-gradient(#222222, #666666); + color: white; + font-family: Helvetica, "Helvetica Neue", Arial, sans-serif; + font-size: 10px; + font-weight: bold; + text-align: center; + border-radius: 6px; } + #footer { color: #dddddd; font-size: 12px; diff --git a/index.html b/index.html index 097b23e..9bfc2e6 100644 --- a/index.html +++ b/index.html @@ -1,19363 +1,52982 @@ -
+
Codestin Search App +Generated 2019-08-25T14:25:33++All files (95.04% lines covered at 588 hits/line)
102 files in total.4741 relevant lines. 4506 lines covered (including 20 lines partially covered ) and 235 lines missed.+ ++UT3.UT
93.2 % lines covered
103 relevant lines. 96 lines covered and 7 lines missed+
- +
package body ut is
- +
- +
/*
- -
+utPLSQL - Version X.X.X.X
utPLSQL - Version 3
+- -
+Copyright 2016 - 2017 utPLSQL Project
Copyright 2016 - 2019 utPLSQL Project
+- +
- +
Licensed under the Apache License, Version 2.0 (the "License"):
- +
you may not use this file except in compliance with the License.
- +
You may obtain a copy of the License at
- +
- +
http://www.apache.org/licenses/LICENSE-2.0
- +
- +
Unless required by applicable law or agreed to in writing, software
- +
distributed under the License is distributed on an "AS IS" BASIS,
- +
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
See the License for the specific language governing permissions and
- +
limitations under the License.
- +
*/
- +
- -
g_nls_date_format varchar2(4000);
- -
+ +- + 1 +
+gc_fail_on_errors constant boolean := false;
- -
+function version return varchar2 is
+
- -
+begin
g_result_line_no binary_integer;
+- 1 -
+return ut_utils.gc_version;
g_result_lines ut_varchar2_list := ut_varchar2_list();
+- -
-end;
- + +
- +
+function version return varchar2 is
- -
-function expect(a_actual in anydata, a_message varchar2 := null) return ut_expectation_anydata is
- -
begin
- - 21 -
-return ut_expectation_anydata(ut_data_value_anydata.get_instance(a_actual), a_message);
- + +
- + 117 +
+ +return ut_runner.version();
- -
end;
- + +
- + +
- +
+function expect(a_actual in anydata, a_message varchar2 := null) return ut_expectation_compound is
- -
-function expect(a_actual in blob, a_message varchar2 := null) return ut_expectation_blob is
- -
begin
- - 21 -
-return ut_expectation_blob(ut_data_value_blob(a_actual), a_message);
- + +
- + 109 +
+ +return ut_expectation_compound(ut_data_value_anydata(a_actual), a_message);
- -
end;
- + +
- + +
- +
+function expect(a_actual in blob, a_message varchar2 := null) return ut_expectation is
- -
-function expect(a_actual in boolean, a_message varchar2 := null) return ut_expectation_boolean is
- -
begin
- - 76 -
-return ut_expectation_boolean(ut_data_value_boolean(a_actual), a_message);
- + +
- + 23 +
+ +return ut_expectation(ut_data_value_blob(a_actual), a_message);
- -
end;
- + +
- + +
- +
+function expect(a_actual in boolean, a_message varchar2 := null) return ut_expectation is
- -
-function expect(a_actual in clob, a_message varchar2 := null) return ut_expectation_clob is
- -
begin
- - 44 -
-return ut_expectation_clob(ut_data_value_clob(a_actual), a_message);
- + +
- + 29 +
+ +return ut_expectation(ut_data_value_boolean(a_actual), a_message);
- -
end;
- + +
- + +
- +
+function expect(a_actual in clob, a_message varchar2 := null) return ut_expectation is
- -
-function expect(a_actual in date, a_message varchar2 := null) return ut_expectation_date is
- -
begin
- - 45 -
-return ut_expectation_date(ut_data_value_date(a_actual), a_message);
- + +
- + 48 +
+ +return ut_expectation(ut_data_value_clob(a_actual), a_message);
- -
end;
- + +
- + +
- +
+function expect(a_actual in date, a_message varchar2 := null) return ut_expectation is
- -
-function expect(a_actual in number, a_message varchar2 := null) return ut_expectation_number is
- -
begin
- - 314 -
-return ut_expectation_number(ut_data_value_number(a_actual), a_message);
- + +
- + 42 +
+ +return ut_expectation(ut_data_value_date(a_actual), a_message);
- -
end;
- + +
- + +
- +
+function expect(a_actual in number, a_message varchar2 := null) return ut_expectation is
- -
-function expect(a_actual in timestamp_unconstrained, a_message varchar2 := null) return ut_expectation_timestamp is
- -
begin
- - 45 -
-return ut_expectation_timestamp(ut_data_value_timestamp(a_actual), a_message);
- + +
- + 122 +
+ +return ut_expectation(ut_data_value_number(a_actual), a_message);
- -
end;
- + +
- + +
- +
+function expect(a_actual in timestamp_unconstrained, a_message varchar2 := null) return ut_expectation is
- -
-function expect(a_actual in timestamp_ltz_unconstrained, a_message varchar2 := null) return ut_expectation_timestamp_ltz is
- -
begin
- - 47 -
-return ut_expectation_timestamp_ltz(ut_data_value_timestamp_ltz(a_actual), a_message);
- + +
- + 42 +
+ +return ut_expectation(ut_data_value_timestamp(a_actual), a_message);
- -
end;
- + +
- + +
- +
+function expect(a_actual in timestamp_ltz_unconstrained, a_message varchar2 := null) return ut_expectation is
- -
-function expect(a_actual in timestamp_tz_unconstrained, a_message varchar2 := null) return ut_expectation_timestamp_tz is
- -
begin
- - 43 -
-return ut_expectation_timestamp_tz(ut_data_value_timestamp_tz(a_actual), a_message);
- + +
- + 44 +
+ +return ut_expectation(ut_data_value_timestamp_ltz(a_actual), a_message);
- -
end;
- + +
- -
- -
-function expect(a_actual in varchar2, a_message varchar2 := null) return ut_expectation_varchar2 is
- + +
- +
+ +function expect(a_actual in timestamp_tz_unconstrained, a_message varchar2 := null) return ut_expectation is
- -
begin
- - 194 -
-return ut_expectation_varchar2(ut_data_value_varchar2(a_actual), a_message);
- + +
- + 40 +
+ +return ut_expectation(ut_data_value_timestamp_tz(a_actual), a_message);
- -
end;
- + +
- + +
- +
+function expect(a_actual in varchar2, a_message varchar2 := null) return ut_expectation is
- -
-function expect(a_actual in sys_refcursor, a_message varchar2 := null) return ut_expectation_refcursor is
- -
begin
- - 19 -
-return ut_expectation_refcursor(ut_data_value_refcursor(a_actual), a_message);
- + +
- + 57 +
+ +return ut_expectation(ut_data_value_varchar2(a_actual), a_message);
- -
end;
- + +
- + +
- +
+function expect(a_actual in sys_refcursor, a_message varchar2 := null) return ut_expectation_compound is
- -
-function expect(a_actual in yminterval_unconstrained, a_message varchar2 := null) return ut_expectation_yminterval is
- -
begin
- - 37 -
-return ut_expectation_yminterval(ut_data_value_yminterval(a_actual), a_message);
- + +
- + 153 +
+ +return ut_expectation_compound(ut_data_value_refcursor(a_actual), a_message);
- -
end;
- + +
- + +
- +
+function expect(a_actual in yminterval_unconstrained, a_message varchar2 := null) return ut_expectation is
- -
-function expect(a_actual in dsinterval_unconstrained, a_message varchar2 := null) return ut_expectation_dsinterval is
- -
begin
- - 37 -
-return ut_expectation_dsinterval(ut_data_value_dsinterval(a_actual), a_message);
- + +
- + 34 +
+ +return ut_expectation(ut_data_value_yminterval(a_actual), a_message);
- -
end;
- + +
- + +
- +
+function expect(a_actual in dsinterval_unconstrained, a_message varchar2 := null) return ut_expectation is
- -
-procedure fail(a_message in varchar2) is
- -
begin
- - 1 -
-ut_expectation_processor.report_failure(a_message);
- + +
- + 34 +
+ +return ut_expectation(ut_data_value_dsinterval(a_actual), a_message);
- -
end;
- + +
- + +
- +
+function expect(a_actual in json_element_t , a_message varchar2 := null) return ut_expectation_json is
- -
-procedure run_autonomous(
- -
+a_paths ut_varchar2_list, a_reporter ut_reporter_base, a_color_console integer,
begin
+ +- + 23 +
+return ut_expectation_json(ut_data_value_json(a_actual), a_message);
- -
+a_coverage_schemes ut_varchar2_list := null, a_source_file_mappings ut_file_mappings, a_test_file_mappings ut_file_mappings,
end;
+- -
+a_include_objects ut_varchar2_list, a_exclude_objects ut_varchar2_list
+
- -
+) is
procedure fail(a_message in varchar2) is
+- -
-pragma autonomous_transaction;
- -
begin
- - 26 -
+ +ut_runner.run(
- + 1 +
+ +ut_expectation_processor.report_failure(a_message);
- +
+end;
- -
+a_paths, a_reporter, ut_utils.int_to_boolean(a_color_console), a_coverage_schemes,
+
- -
+a_source_file_mappings, a_test_file_mappings, a_include_objects, a_exclude_objects
procedure raise_if_packages_invalidated is
+- -
-);
- - 25 -
+rollback;
e_package_invalidated exception;
+ +- +
+pragma exception_init (e_package_invalidated, -04068);
- -
-end;
- -
-- -
-procedure run_autonomous(
- -
+a_paths ut_varchar2_list, a_reporter ut_reporter_base, a_color_console integer,
begin
+ +- + 113 +
+ +if ut_expectation_processor.invalidation_exception_found() then
- + 1 +
+ +ut_expectation_processor.reset_invalidation_exception();
- + 1 +
+raise e_package_invalidated;
- -
+a_coverage_schemes ut_varchar2_list := null, a_source_files ut_varchar2_list, a_test_files ut_varchar2_list,
end if;
+- -
+a_include_objects ut_varchar2_list, a_exclude_objects ut_varchar2_list
end;
+- -
+) is
+
- -
+pragma autonomous_transaction;
+
- -
-begin
- - 3 -
+ut_runner.run(
procedure run_autonomous(
+ +- +
+a_paths ut_varchar2_list,
- -
+a_paths, a_reporter, ut_utils.int_to_boolean(a_color_console), a_coverage_schemes,
a_reporter in out nocopy ut_reporter_base,
+- -
+a_source_files, a_test_files, a_include_objects, a_exclude_objects
a_color_console integer,
+- -
-);
- - 3 -
+rollback;
a_coverage_schemes ut_varchar2_list,
+ +- +
+a_source_file_mappings ut_file_mappings,
- -
+end;
a_test_file_mappings ut_file_mappings,
+- -
+a_include_objects ut_varchar2_list,
+- -
+function run(
a_exclude_objects ut_varchar2_list,
+- -
+a_reporter ut_reporter_base := null, a_color_console integer := 0,
a_client_character_set varchar2,
+- -
+a_coverage_schemes ut_varchar2_list := null, a_source_file_mappings ut_file_mappings := null, a_test_file_mappings ut_file_mappings := null,
a_random_test_order integer,
+- -
+a_include_objects ut_varchar2_list := null, a_exclude_objects ut_varchar2_list := null
a_random_test_order_seed positive,
+- -
-) return ut_varchar2_rows pipelined is
- - 2 -
-l_reporter ut_reporter_base := coalesce(a_reporter, ut_documentation_reporter());
- - 2 -
+l_paths ut_varchar2_list := ut_varchar2_list(sys_context('userenv', 'current_schema'));
a_tags varchar2 := null
+ +- +
+ +) is
- +
+pragma autonomous_transaction;
- -
-l_lines sys_refcursor;
- -
-l_line varchar2(4000);
- -
begin
- - 2 -
+ +run_autonomous(
- + 102 +
+ +a_reporter := coalesce(a_reporter,ut_documentation_reporter());
- + 102 +
+ +ut_runner.run(
- +
+a_paths,
- -
+l_paths, l_reporter, a_color_console,
ut_reporters(a_reporter),
+- -
+a_coverage_schemes, a_source_file_mappings, a_test_file_mappings, a_include_objects, a_exclude_objects
ut_utils.int_to_boolean(a_color_console),
+- -
-);
- - 2 -
-l_lines := ut_output_buffer.get_lines_cursor(l_reporter.reporter_id);
- - 104 -
-loop
- - 104 -
-fetch l_lines into l_line;
- - 104 -
-exit when l_lines%notfound;
- - 102 -
+pipe row(l_line);
a_coverage_schemes,
+ +- +
+ +a_source_file_mappings,
- +
+ +a_test_file_mappings,
- +
+ +a_include_objects,
- +
+ +a_exclude_objects,
- +
+gc_fail_on_errors,
- -
-end loop;
- - 2 -
+close l_lines;
a_client_character_set,
+ +- +
+false,
- -
+end;
ut_utils.int_to_boolean(a_random_test_order),
+- -
+a_random_test_order_seed,
+- -
+function run(
a_tags
+- -
-a_reporter ut_reporter_base := null, a_color_console integer := 0,
- -
+a_coverage_schemes ut_varchar2_list := null, a_source_files ut_varchar2_list, a_test_files ut_varchar2_list,
);
+ +- + 101 +
+rollback;
- -
+a_include_objects ut_varchar2_list := null, a_exclude_objects ut_varchar2_list := null
end;
+- -
-) return ut_varchar2_rows pipelined is
- - 1 -
-l_reporter ut_reporter_base := coalesce(a_reporter, ut_documentation_reporter());
- - 1 -
+l_paths ut_varchar2_list := ut_varchar2_list(sys_context('userenv', 'current_schema'));
+ +
- +
+ +procedure run_autonomous(
- +
+a_paths ut_varchar2_list,
- -
+l_lines sys_refcursor;
a_reporter in out nocopy ut_reporter_base,
+- -
+l_line varchar2(4000);
a_color_console integer,
+- -
-begin
- - 1 -
+run_autonomous(
a_coverage_schemes ut_varchar2_list,
+ +- +
+a_source_files ut_varchar2_list,
- -
+l_paths, l_reporter, a_color_console, a_coverage_schemes, a_source_files, a_test_files,
a_test_files ut_varchar2_list,
+- -
+a_include_objects, a_exclude_objects
a_include_objects ut_varchar2_list,
+- -
-);
- - 1 -
-l_lines := ut_output_buffer.get_lines_cursor(l_reporter.reporter_id);
- - 56 -
-loop
- - 56 -
-fetch l_lines into l_line;
- - 56 -
-exit when l_lines%notfound;
- - 55 -
-pipe row(l_line);
- -
-end loop;
- - 1 -
-close l_lines;
- -
-end;
- -
-- -
+function run(
a_exclude_objects ut_varchar2_list,
+ +- +
+ +a_client_character_set varchar2,
- +
+ +a_random_test_order integer,
- +
+ +a_random_test_order_seed positive,
- +
+ +a_tags varchar2 := null
- +
+ +) is
- +
+ +pragma autonomous_transaction;
- +
+ +begin
- + 10 +
+ +a_reporter := coalesce(a_reporter,ut_documentation_reporter());
- + 10 +
+ +ut_runner.run(
- +
+a_paths,
- -
+a_paths ut_varchar2_list, a_reporter ut_reporter_base := null, a_color_console integer := 0,
ut_reporters(a_reporter),
+- -
+a_coverage_schemes ut_varchar2_list := null, a_source_file_mappings ut_file_mappings := null, a_test_file_mappings ut_file_mappings := null,
ut_utils.int_to_boolean(a_color_console),
+- -
+a_include_objects ut_varchar2_list := null, a_exclude_objects ut_varchar2_list := null
a_coverage_schemes,
+- -
-) return ut_varchar2_rows pipelined is
- - 2 -
+l_reporter ut_reporter_base := coalesce(a_reporter, ut_documentation_reporter());
ut_file_mapper.build_file_mappings(a_source_files),
+ +- +
+ut_file_mapper.build_file_mappings(a_test_files),
- -
+l_lines sys_refcursor;
a_include_objects,
+- -
+l_line varchar2(4000);
a_exclude_objects,
+- -
-begin
- - 2 -
+run_autonomous(
gc_fail_on_errors,
+ +- +
+a_client_character_set,
- -
+a_paths, l_reporter, a_color_console, a_coverage_schemes, a_source_file_mappings, a_test_file_mappings,
false,
+- -
+a_include_objects, a_exclude_objects
ut_utils.int_to_boolean(a_random_test_order),
+- +
+ +a_random_test_order_seed,
- +
+ +a_tags
- -
);
- - 2 -
-l_lines := ut_output_buffer.get_lines_cursor(l_reporter.reporter_id);
- - 51 -
-loop
- - 51 -
-fetch l_lines into l_line;
- - 51 -
-exit when l_lines%notfound;
- - 49 -
+ +pipe row(l_line);
- + 10 +
+ +rollback;
- +
+ +end;
- +
+- -
-end loop;
- - 2 -
+close l_lines;
function get_report_outputs( a_cursor sys_refcursor ) return varchar2 is
+ +- +
+l_clob clob;
- -
+end;
l_item_type varchar2(32767);
+- -
+l_result varchar2(4000);
+- -
-function run(
- -
-a_paths ut_varchar2_list, a_reporter ut_reporter_base := null, a_color_console integer := 0,
- -
-a_coverage_schemes ut_varchar2_list := null, a_source_files ut_varchar2_list, a_test_files ut_varchar2_list,
- -
-a_include_objects ut_varchar2_list := null, a_exclude_objects ut_varchar2_list := null
- -
-) return ut_varchar2_rows pipelined is
- - 1 -
-l_reporter ut_reporter_base := coalesce(a_reporter, ut_documentation_reporter());
- -
-l_lines sys_refcursor;
- -
-l_line varchar2(4000);
- -
begin
- - 1 -
-run_autonomous(
- -
-a_paths, l_reporter, a_color_console, a_coverage_schemes, a_source_files, a_test_files,
- -
+ +a_include_objects, a_exclude_objects
- + 18750 +
+ +if g_result_line_no is null then
- + 16627 +
+ +fetch a_cursor into l_clob, l_item_type;
- + 16627 +
+ +if a_cursor%notfound then
- + 81 +
+ +close a_cursor;
- + 81 +
+ +g_result_line_no := null;
- + 81 +
+ +g_result_lines := ut_varchar2_list();
- + 81 +
+ +raise_if_packages_invalidated();
- + 80 +
+ +raise no_data_found;
- +
+ +end if;
- + 16546 +
+ +g_result_lines := ut_utils.clob_to_table(l_clob, ut_utils.gc_max_storage_varchar2_len);
- + 16546 +
+g_result_line_no := g_result_lines.first;
- -
-);
- - 1 -
-l_lines := ut_output_buffer.get_lines_cursor(l_reporter.reporter_id);
- - 28 -
-loop
- - 28 -
-fetch l_lines into l_line;
- - 28 -
-exit when l_lines%notfound;
- - 27 -
-pipe row(l_line);
- -
-end loop;
- - 1 -
-close l_lines;
- +
+ +end if;
- +
+ +- + 18669 +
+ +if g_result_line_no is not null then
- + 18669 +
+ +l_result := g_result_lines(g_result_line_no);
- + 18669 +
+ +g_result_line_no := g_result_lines.next(g_result_line_no);
- +
+ +end if;
- + 18669 +
+ +return l_result;
- -
end;
- + +
- -
- + +
- + +
function run(
- +
+a_reporter ut_reporter_base := null,
- -
+a_path varchar2, a_reporter ut_reporter_base := null, a_color_console integer := 0,
a_color_console integer := 0,
+- -
+a_coverage_schemes ut_varchar2_list := null, a_source_file_mappings ut_file_mappings := null, a_test_file_mappings ut_file_mappings := null,
a_coverage_schemes ut_varchar2_list := null,
+- -
+a_include_objects ut_varchar2_list := null, a_exclude_objects ut_varchar2_list := null
a_source_file_mappings ut_file_mappings := null,
+- -
-) return ut_varchar2_rows pipelined is
- - 23 -
-l_reporter ut_reporter_base := coalesce(a_reporter, ut_documentation_reporter());
- - 22 -
+l_paths ut_varchar2_list := ut_varchar2_list(coalesce(a_path, sys_context('userenv', 'current_schema')));
a_test_file_mappings ut_file_mappings := null,
+ +- +
+ +a_include_objects ut_varchar2_list := null,
- +
+a_exclude_objects ut_varchar2_list := null,
- -
+l_lines sys_refcursor;
a_client_character_set varchar2 := null,
+- -
+l_line varchar2(4000);
a_random_test_order integer := 0,
+- -
-begin
- - 22 -
+run_autonomous(
a_random_test_order_seed positive := null,
+ +- +
+a_tags varchar2 := null
- -
-l_paths, l_reporter, a_color_console, a_coverage_schemes, a_source_file_mappings, a_test_file_mappings,
- -
+a_include_objects, a_exclude_objects
) return ut_varchar2_rows pipelined is
+ +- + 3 +
+l_reporter ut_reporter_base := a_reporter;
- -
-);
- - 21 -
-l_lines := ut_output_buffer.get_lines_cursor(l_reporter.reporter_id);
- - 19012 -
-loop
- - 19012 -
-fetch l_lines into l_line;
- - 19012 -
-exit when l_lines%notfound;
- - 18991 -
+pipe row(l_line);
l_results sys_refcursor;
+ +- +
+ +begin
- + 3 +
+ +run_autonomous(
- +
+ +ut_varchar2_list(),
- +
+ +l_reporter,
- +
+a_color_console,
- -
-end loop;
- - 21 -
+close l_lines;
a_coverage_schemes,
+ +- +
+a_source_file_mappings,
- -
+end;
a_test_file_mappings,
+- -
+a_include_objects,
+- -
+function run(
a_exclude_objects,
+- -
+a_path varchar2, a_reporter ut_reporter_base := null, a_color_console integer := 0,
a_client_character_set,
+- -
+a_coverage_schemes ut_varchar2_list := null, a_source_files ut_varchar2_list, a_test_files ut_varchar2_list,
a_random_test_order,
+- -
+a_include_objects ut_varchar2_list := null, a_exclude_objects ut_varchar2_list := null
a_random_test_order_seed,
+- -
-) return ut_varchar2_rows pipelined is
- - 1 -
-l_reporter ut_reporter_base := coalesce(a_reporter, ut_documentation_reporter());
- - 1 -
-l_paths ut_varchar2_list := ut_varchar2_list(coalesce(a_path, sys_context('userenv', 'current_schema')));
- -
-l_lines sys_refcursor;
- -
-l_line varchar2(4000);
- -
-begin
- - 1 -
+run_autonomous(
a_tags
+ +- +
+ +);
- + 3 +
+ +if l_reporter is of (ut_output_reporter_base) then
- + 3 +
+ +l_results := treat(l_reporter as ut_output_reporter_base).get_lines_cursor();
- + 90 +
+ +loop
- + 90 +
+ +pipe row( get_report_outputs( l_results ) );
- +
+end loop;
- -
-l_paths, l_reporter, a_color_console, a_coverage_schemes, a_source_files, a_test_files,
- -
+a_include_objects, a_exclude_objects
end if;
+ +- +
+return;
- -
-);
- - 1 -
-l_lines := ut_output_buffer.get_lines_cursor(l_reporter.reporter_id);
- - 27 -
-loop
- - 27 -
-fetch l_lines into l_line;
- - 27 -
-exit when l_lines%notfound;
- - 26 -
+pipe row(l_line);
end;
+ +- +
+ +- +
+ +function run(
- +
+ +a_reporter ut_reporter_base := null,
- +
+ +a_color_console integer := 0,
- +
+a_coverage_schemes ut_varchar2_list := null,
- -
-end loop;
- - 1 -
+close l_lines;
a_source_files ut_varchar2_list,
+ +- +
+a_test_files ut_varchar2_list,
- -
+end;
a_include_objects ut_varchar2_list := null,
+- -
+a_exclude_objects ut_varchar2_list := null,
+- -
+procedure run(
a_client_character_set varchar2 := null,
+- -
+a_reporter ut_reporter_base := null, a_color_console boolean := false,
a_random_test_order integer := 0,
+- -
+a_coverage_schemes ut_varchar2_list := null, a_source_file_mappings ut_file_mappings := null, a_test_file_mappings ut_file_mappings := null,
a_random_test_order_seed positive := null,
+- -
+a_include_objects ut_varchar2_list := null, a_exclude_objects ut_varchar2_list := null
a_tags varchar2 := null
+- -
-) is
- -
-begin
- - 2 -
+ut.run(
) return ut_varchar2_rows pipelined is
+ +- + 1 +
+ +l_reporter ut_reporter_base := a_reporter;
- +
+l_results sys_refcursor;
- -
-ut_varchar2_list(sys_context('userenv', 'current_schema')), a_reporter, a_color_console,
- -
+a_coverage_schemes, a_source_file_mappings, a_test_file_mappings, a_include_objects, a_exclude_objects
begin
+ +- + 1 +
+run_autonomous(
- -
+);
ut_varchar2_list(),
+- -
+end;
l_reporter,
+- -
+a_color_console,
+- -
+procedure run(
a_coverage_schemes,
+- -
+a_reporter ut_reporter_base := null, a_color_console boolean := false,
a_source_files,
+- -
+a_coverage_schemes ut_varchar2_list := null, a_source_files ut_varchar2_list, a_test_files ut_varchar2_list,
a_test_files,
+- -
+a_include_objects ut_varchar2_list := null, a_exclude_objects ut_varchar2_list := null
a_include_objects,
+- -
+) is
a_exclude_objects,
+- -
-begin
- - 1 -
+ut.run(
a_client_character_set,
+ +- +
+a_random_test_order,
- -
+ut_varchar2_list(sys_context('userenv', 'current_schema')), a_reporter, a_color_console,
a_random_test_order_seed,
+- -
+a_coverage_schemes, a_source_files, a_test_files, a_include_objects, a_exclude_objects
a_tags
+- -
);
- -
-end;
- -
-- -
-procedure run(
- -
+ +a_paths ut_varchar2_list, a_reporter ut_reporter_base := null, a_color_console boolean := false,
- + 1 +
+ +if l_reporter is of (ut_output_reporter_base) then
- + 1 +
+ +l_results := treat(l_reporter as ut_output_reporter_base).get_lines_cursor();
- + 30 +
+ +loop
- + 30 +
+pipe row( get_report_outputs( l_results ) );
- -
+a_coverage_schemes ut_varchar2_list := null, a_source_file_mappings ut_file_mappings := null, a_test_file_mappings ut_file_mappings := null,
end loop;
+- -
-a_include_objects ut_varchar2_list := null, a_exclude_objects ut_varchar2_list := null
- -
-) is
- - 16 -
+l_reporter ut_reporter_base := coalesce(a_reporter, ut_documentation_reporter());
end if;
+ +- +
+ +return;
- +
+end;
- -
-begin
- - 16 -
+ut_runner.run(
+ +
- +
+function run(
- -
+a_paths, l_reporter, a_color_console, a_coverage_schemes, a_source_file_mappings, a_test_file_mappings,
a_paths ut_varchar2_list,
+- -
+a_include_objects, a_exclude_objects
a_reporter ut_reporter_base := null,
+- -
-);
- - 16 -
+ut_output_buffer.lines_to_dbms_output(l_reporter.reporter_id);
a_color_console integer := 0,
+ +- +
+a_coverage_schemes ut_varchar2_list := null,
- -
+end;
a_source_file_mappings ut_file_mappings := null,
+- -
+a_test_file_mappings ut_file_mappings := null,
+- -
+procedure run(
a_include_objects ut_varchar2_list := null,
+- -
+a_paths ut_varchar2_list, a_reporter ut_reporter_base := null, a_color_console boolean := false,
a_exclude_objects ut_varchar2_list := null,
+- -
+a_coverage_schemes ut_varchar2_list := null, a_source_files ut_varchar2_list, a_test_files ut_varchar2_list,
a_client_character_set varchar2 := null,
+- -
+a_include_objects ut_varchar2_list := null, a_exclude_objects ut_varchar2_list := null
a_random_test_order integer := 0,
+- -
-) is
- - 2 -
+l_reporter ut_reporter_base := coalesce(a_reporter, ut_documentation_reporter());
a_random_test_order_seed positive := null,
+ +- +
+a_tags varchar2 := null
- -
-begin
- - 2 -
+ut_runner.run(
) return ut_varchar2_rows pipelined is
+ +- + 6 +
+l_reporter ut_reporter_base := a_reporter;
- -
+a_paths, l_reporter, a_color_console, a_coverage_schemes, a_source_files, a_test_files,
l_results sys_refcursor;
+- -
-a_include_objects, a_exclude_objects
- -
-);
- - 2 -
+ut_output_buffer.lines_to_dbms_output(l_reporter.reporter_id);
begin
+ +- + 6 +
+ +run_autonomous(
- +
+a_paths,
- -
+end;
l_reporter,
+- -
+a_color_console,
+- -
+procedure run(
a_coverage_schemes,
+- -
+a_path varchar2, a_reporter ut_reporter_base := null, a_color_console boolean := false,
a_source_file_mappings,
+- -
+a_coverage_schemes ut_varchar2_list := null, a_source_file_mappings ut_file_mappings := null, a_test_file_mappings ut_file_mappings := null,
a_test_file_mappings,
+- -
+a_include_objects ut_varchar2_list := null, a_exclude_objects ut_varchar2_list := null
a_include_objects,
+- -
-) is
- - 13 -
+l_paths ut_varchar2_list := ut_varchar2_list(coalesce(a_path, sys_context('userenv', 'current_schema')));
a_exclude_objects,
+ +- +
+a_client_character_set,
- -
-begin
- - 13 -
+ut.run(
a_random_test_order,
+ +- +
+a_random_test_order_seed,
- -
+l_paths, a_reporter, a_color_console, a_coverage_schemes, a_source_file_mappings, a_test_file_mappings,
a_tags
+- -
-a_include_objects, a_exclude_objects
- -
);
- -
-end;
- -
-- -
+ +procedure run(
- + 6 +
+ +if l_reporter is of (ut_output_reporter_base) then
- + 6 +
+ +l_results := treat(l_reporter as ut_output_reporter_base).get_lines_cursor();
- + 158 +
+ +loop
- + 158 +
+pipe row( get_report_outputs( l_results ) );
- -
+a_path varchar2, a_reporter ut_reporter_base := null, a_color_console boolean := false,
end loop;
+- -
-a_coverage_schemes ut_varchar2_list := null, a_source_files ut_varchar2_list, a_test_files ut_varchar2_list,
- -
+a_include_objects ut_varchar2_list := null, a_exclude_objects ut_varchar2_list := null
end if;
+ +- +
+return;
- -
-) is
- -
+l_paths ut_varchar2_list := ut_varchar2_list(coalesce(a_path, sys_context('userenv', 'current_schema')));
end;
+ +- +
+- -
-begin
- -
+ut.run(
function run(
+ +- +
+a_paths ut_varchar2_list,
- -
+l_paths, a_reporter, a_color_console, a_coverage_schemes, a_source_files, a_test_files,
a_reporter ut_reporter_base := null,
+- -
+a_include_objects, a_exclude_objects
a_color_console integer := 0,
+- -
+);
a_coverage_schemes ut_varchar2_list := null,
+- -
+end;
a_source_files ut_varchar2_list,
+- -
+a_test_files ut_varchar2_list,
+- -
+procedure set_nls is
a_include_objects ut_varchar2_list := null,
+- -
-begin
- - 2 -
-if g_nls_date_format is null then
- - 1 -
+select nsp.value
a_exclude_objects ut_varchar2_list := null,
+ +- +
+ +a_client_character_set varchar2 := null,
- +
+a_random_test_order integer := 0,
- -
+into g_nls_date_format
a_random_test_order_seed positive := null,
+- -
+from nls_session_parameters nsp
a_tags varchar2 := null
+- -
-where parameter = 'NLS_DATE_FORMAT';
- -
-end if;
- +
+ +) return ut_varchar2_rows pipelined is
- 1 -
+execute immediate 'alter session set nls_date_format = '''||ut_utils.gc_date_format||'''';
l_reporter ut_reporter_base := a_reporter;
+ +- +
+l_results sys_refcursor;
- -
-end;
- -
-- -
-procedure reset_nls is
- -
begin
- - 1 -
-if g_nls_date_format is not null then
- + +
- 1 -
+execute immediate 'alter session set nls_date_format = '''||g_nls_date_format||'''';
run_autonomous(
+ +- +
+ +a_paths,
- +
+ +l_reporter,
- +
+ +a_color_console,
- +
+a_coverage_schemes,
- -
-end if;
- - 1 -
+g_nls_date_format := null;
a_source_files,
+ +- +
+a_test_files,
- -
+end;
a_include_objects,
+- -
+a_exclude_objects,
+- -
end ut;
UT3.UT_RUNNER
75.68 % covered
37 relevant lines. 28 lines covered and 9 lines missed-
- -
-package body ut_runner is
- -
-- -
-/*
- -
-utPLSQL - Version X.X.X.X
- -
-Copyright 2016 - 2017 utPLSQL Project
- -
-- -
-Licensed under the Apache License, Version 2.0 (the "License"):
- -
-you may not use this file except in compliance with the License.
- -
-You may obtain a copy of the License at
- -
-- -
-http://www.apache.org/licenses/LICENSE-2.0
- -
-- -
-Unless required by applicable law or agreed to in writing, software
- -
-distributed under the License is distributed on an "AS IS" BASIS,
- -
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- -
-See the License for the specific language governing permissions and
- -
-limitations under the License.
- -
-*/
- -
-- -
-/**
- -
-* Private functions
- -
-*/
- -
-function to_ut_object_list(a_names ut_varchar2_list) return ut_object_names is
- -
-l_result ut_object_names;
- -
-begin
- - 94 -
-if a_names is not null then
- - 1 -
-l_result := ut_object_names();
- - 2 -
-for i in 1 .. a_names.count loop
- +
+ +a_client_character_set,
- +
+ +a_random_test_order,
- +
+ +a_random_test_order_seed,
- +
+ +a_tags
- +
+ +);
- 1 -
-l_result.extend;
- +
+ +if l_reporter is of (ut_output_reporter_base) then
- 1 -
-l_result(l_result.last) := ut_object_name(a_names(i));
- +
+ +l_results := treat(l_reporter as ut_output_reporter_base).get_lines_cursor();
- + 44 +
+ +loop
- + 44 +
+ +pipe row( get_report_outputs( l_results ) );
- -
end loop;
- + +
- -
end if;
- - 94 -
-return l_result;
- + +
- +
+ +return;
- -
end;
- -
-- -
-- + +
- -
- -
-/**
- -
-* Public functions
- -
-*/
- -
-function version return varchar2 is
- + +
- +
+ +function run(
- +
+ +a_path varchar2,
- +
+ +a_reporter ut_reporter_base := null,
- +
+ +a_color_console integer := 0,
- +
+ +a_coverage_schemes ut_varchar2_list := null,
- +
+ +a_source_file_mappings ut_file_mappings := null,
- +
+ +a_test_file_mappings ut_file_mappings := null,
- +
+ +a_include_objects ut_varchar2_list := null,
- +
+ +a_exclude_objects ut_varchar2_list := null,
- +
+ +a_client_character_set varchar2 := null,
- +
+ +a_random_test_order integer := 0,
- +
+ +a_random_test_order_seed positive := null,
- +
+ +a_tags varchar2 := null
- +
+ +) return ut_varchar2_rows pipelined is
- + 63 +
+ +l_reporter ut_reporter_base := a_reporter;
- +
+ +l_results sys_refcursor;
- -
begin
- -
-return ut_utils.gc_version;
- + +
- + 63 +
+ +run_autonomous(
- +
+ +ut_varchar2_list(a_path),
- +
+ +l_reporter,
- +
+ +a_color_console,
- +
+ +a_coverage_schemes,
- +
+ +a_source_file_mappings,
- +
+ +a_test_file_mappings,
- +
+ +a_include_objects,
- +
+ +a_exclude_objects,
- +
+ +a_client_character_set,
- +
+ +a_random_test_order,
- +
+ +a_random_test_order_seed,
- +
+ +a_tags
- +
+ +);
- + 62 +
+ +if l_reporter is of (ut_output_reporter_base) then
- + 62 +
+ +l_results := treat(l_reporter as ut_output_reporter_base).get_lines_cursor();
- + 18260 +
+ +loop
- + 18260 +
+ +pipe row( get_report_outputs( l_results ) );
- +
+ +end loop;
- +
+ +end if;
- +
+ +return;
- -
end;
- + +
- -
- -
-procedure run(
- -
-a_paths ut_varchar2_list, a_reporters ut_reporters, a_color_console boolean := false,
- -
-a_coverage_schemes ut_varchar2_list := null, a_source_file_mappings ut_file_mappings := null, a_test_file_mappings ut_file_mappings := null,
- -
-a_include_objects ut_varchar2_list := null, a_exclude_objects ut_varchar2_list := null, a_fail_on_errors boolean default false
- -
-) is
- -
-l_items_to_run ut_run;
- -
-l_listener ut_event_listener;
- + +
- +
+ +function run(
- +
+ +a_path varchar2,
- +
+ +a_reporter ut_reporter_base := null,
- +
+ +a_color_console integer := 0,
- +
+ +a_coverage_schemes ut_varchar2_list := null,
- +
+ +a_source_files ut_varchar2_list,
- +
+ +a_test_files ut_varchar2_list,
- +
+ +a_include_objects ut_varchar2_list := null,
- +
+ +a_exclude_objects ut_varchar2_list := null,
- +
+ +a_client_character_set varchar2 := null,
- +
+ +a_random_test_order integer := 0,
- +
+ +a_random_test_order_seed positive := null,
- +
+ +a_tags varchar2 := null
- +
+ +) return ut_varchar2_rows pipelined is
- + 8 +
+ +l_reporter ut_reporter_base := a_reporter;
- +
+ +l_results sys_refcursor;
- -
begin
- -
-begin
- - 49 -
-ut_output_buffer.cleanup_buffer();
- + +
- + 8 +
+ +run_autonomous(
- +
+ +ut_varchar2_list(a_path),
- +
+ +l_reporter,
- +
+ +a_color_console,
- +
+ +a_coverage_schemes,
- +
+ +a_source_files,
- +
+ +a_test_files,
- +
+ +a_include_objects,
- +
+ +a_exclude_objects,
- +
+ +a_client_character_set,
- +
+ +a_random_test_order,
- +
+ +a_random_test_order_seed,
- +
+ +a_tags
- +
+ +);
- + 8 +
+ +if l_reporter is of (ut_output_reporter_base) then
- + 8 +
+ +l_results := treat(l_reporter as ut_output_reporter_base).get_lines_cursor();
- + 168 +
+ +loop
- + 168 +
+ +pipe row( get_report_outputs( l_results ) );
- +
+ +end loop;
- +
+ +end if;
- +
+ +return;
- +
+ +end;
- -
- - 48 -
-ut_console_reporter_base.set_color_enabled(a_color_console);
- - 48 -
-if a_reporters is null or a_reporters.count = 0 then
- -
-l_listener := ut_event_listener(ut_reporters(ut_documentation_reporter()));
- -
-else
- - 48 -
-l_listener := ut_event_listener(a_reporters);
- -
-end if;
- - 48 -
-l_items_to_run := ut_run(
- -
-ut_suite_manager.configure_execution_by_path(a_paths),
- + +
- +
+ +procedure run(
- +
+ +a_paths ut_varchar2_list,
- +
+ +a_reporter ut_reporter_base := null,
- +
+ +a_color_console boolean := false,
- +
+ +a_coverage_schemes ut_varchar2_list := null,
- +
+ +a_source_file_mappings ut_file_mappings := null,
- +
+ +a_test_file_mappings ut_file_mappings := null,
- +
+ +a_include_objects ut_varchar2_list := null,
- +
+ +a_exclude_objects ut_varchar2_list := null,
- +
+ +a_client_character_set varchar2 := null,
- +
+ +a_force_manual_rollback boolean := false,
- +
+ +a_random_test_order boolean := false,
- +
+ +a_random_test_order_seed positive := null,
- +
+ +a_tags varchar2 := null
- +
+ +) is
- + 32 +
+ +l_reporter ut_reporter_base := a_reporter;
- +
+ +begin
- + 32 +
+ +if a_force_manual_rollback then
- + 2 +
+ +l_reporter := coalesce(l_reporter,ut_documentation_reporter());
- + 2 +
+ +ut_runner.run(
- -
a_paths,
- -
-ut_utils.convert_collection(a_coverage_schemes),
- -
-to_ut_object_list(a_exclude_objects),
- -
-to_ut_object_list(a_include_objects),
- -
-set(a_source_file_mappings),
- -
-set(a_test_file_mappings)
- + +
- +
+ +ut_reporters(l_reporter),
- +
+ +a_color_console,
- +
+ +a_coverage_schemes,
- +
+ +a_source_file_mappings,
- +
+ +a_test_file_mappings,
- +
+ +a_include_objects,
- +
+ +a_exclude_objects,
- +
+ +gc_fail_on_errors,
- +
+ +a_client_character_set,
- +
+ +a_force_manual_rollback,
- +
+ +a_random_test_order,
- +
+ +a_random_test_order_seed,
- +
+ +a_tags
- -
);
- - 47 -
-l_items_to_run.do_execute(l_listener);
- -
-- - 47 -
-ut_utils.cleanup_temp_tables;
- - 47 -
-ut_output_buffer.close(l_listener.reporters);
- -
-exception
- - 1 -
-when others then
- - 1 -
-ut_utils.cleanup_temp_tables;
- - 1 -
-ut_output_buffer.close(l_listener.reporters);
- - 1 -
-dbms_output.put_line(dbms_utility.format_error_backtrace);
- - 1 -
-dbms_output.put_line(dbms_utility.format_error_stack);
- - 1 -
-raise;
- -
-end;
- - 47 -
-if a_fail_on_errors and l_items_to_run.result in (ut_utils.tr_failure, ut_utils.tr_error) then
- -
-raise_application_error(ut_utils.gc_some_tests_failed, 'Some tests failed');
- + +
- +
+ +else
- + 30 +
+ +run_autonomous(
- +
+ +a_paths,
- +
+ +l_reporter,
- +
+ +ut_utils.boolean_to_int(a_color_console),
- +
+ +a_coverage_schemes,
- +
+ +a_source_file_mappings,
- +
+ +a_test_file_mappings,
- +
+ +a_include_objects,
- +
+ +a_exclude_objects,
- +
+ +a_client_character_set,
- +
+ +ut_utils.boolean_to_int(a_random_test_order),
- +
+ +a_random_test_order_seed,
- +
+ +a_tags
- +
+ +);
- -
end if;
- + +
- + 32 +
+ +if l_reporter is of (ut_output_reporter_base) then
- + 32 +
+ +treat(l_reporter as ut_output_reporter_base).lines_to_dbms_output();
- +
+ +end if;
- + 32 +
+ +raise_if_packages_invalidated();
- -
end;
- + +
- -
- + +
- -
procedure run(
- -
-a_paths ut_varchar2_list, a_reporters ut_reporters, a_color_console boolean := false,
- -
-a_coverage_schemes ut_varchar2_list := null, a_source_files ut_varchar2_list, a_test_files ut_varchar2_list,
- -
-a_include_objects ut_varchar2_list := null, a_exclude_objects ut_varchar2_list := null, a_fail_on_errors boolean default false
- + +
- +
+ +a_paths ut_varchar2_list,
- +
+ +a_reporter ut_reporter_base := null,
- +
+ +a_color_console boolean := false,
- +
+ +a_coverage_schemes ut_varchar2_list := null,
- +
+ +a_source_files ut_varchar2_list,
- +
+ +a_test_files ut_varchar2_list,
- +
+ +a_include_objects ut_varchar2_list := null,
- +
+ +a_exclude_objects ut_varchar2_list := null,
- +
+ +a_client_character_set varchar2 := null,
- +
+ +a_force_manual_rollback boolean := false,
- +
+ +a_random_test_order boolean := false,
- +
+ +a_random_test_order_seed positive := null,
- +
+ +a_tags varchar2 := null
- -
) is
- + +
- + 4 +
+ +l_reporter ut_reporter_base := a_reporter;
- -
begin
- - 5 -
-run(
- -
-a_paths, a_reporters, a_color_console, a_coverage_schemes,
- + +
- + 4 +
+ +ut.run(
- +
+ +a_paths,
- +
+ +l_reporter,
- +
+ +a_color_console,
- +
+ +a_coverage_schemes,
- -
ut_file_mapper.build_file_mappings(a_source_files),
- + +
- -
ut_file_mapper.build_file_mappings(a_test_files),
- -
-a_include_objects, a_exclude_objects, a_fail_on_errors
- + +
- +
+ +a_include_objects,
- +
+ +a_exclude_objects,
- +
+ +a_client_character_set,
- +
+ +a_force_manual_rollback,
- +
+ +a_random_test_order,
- +
+ +a_random_test_order_seed,
- +
+ +a_tags
- -
);
- + +
- -
end;
- + +
- -
- + +
- -
procedure run(
- -
-a_paths ut_varchar2_list, a_reporter ut_reporter_base := null, a_color_console boolean := false,
- -
-a_coverage_schemes ut_varchar2_list := null, a_source_file_mappings ut_file_mappings := null, a_test_file_mappings ut_file_mappings := null,
- -
-a_include_objects ut_varchar2_list := null, a_exclude_objects ut_varchar2_list := null, a_fail_on_errors boolean default false
- + +
- +
+ +a_reporter ut_reporter_base := null,
- +
+ +a_color_console boolean := false,
- +
+ +a_coverage_schemes ut_varchar2_list := null,
- +
+ +a_source_file_mappings ut_file_mappings := null,
- +
+ +a_test_file_mappings ut_file_mappings := null,
- +
+ +a_include_objects ut_varchar2_list := null,
- +
+ +a_exclude_objects ut_varchar2_list := null,
- +
+ +a_client_character_set varchar2 := null,
- +
+ +a_force_manual_rollback boolean := false,
- +
+ +a_random_test_order boolean := false,
- +
+ +a_random_test_order_seed positive := null,
- +
+ +a_tags varchar2 := null
- -
) is
- + +
- -
begin
- - 42 -
-run(
- - 1 -
-a_paths, ut_reporters(coalesce(a_reporter,ut_documentation_reporter())),
- -
-a_color_console, a_coverage_schemes, a_source_file_mappings, a_test_file_mappings,
- -
-a_include_objects, a_exclude_objects, a_fail_on_errors
- -
-);
- -
-end;
- -
-- -
-procedure run(
- -
-a_paths ut_varchar2_list, a_reporter ut_reporter_base := null, a_color_console boolean := false,
- -
-a_coverage_schemes ut_varchar2_list := null, a_source_files ut_varchar2_list, a_test_files ut_varchar2_list,
- -
-a_include_objects ut_varchar2_list := null, a_exclude_objects ut_varchar2_list := null, a_fail_on_errors boolean default false
- -
-) is
- -
-begin
- - 5 -
-run(
- - 1 -
-a_paths, ut_reporters(coalesce(a_reporter,ut_documentation_reporter())),
- -
-a_color_console, a_coverage_schemes, a_source_files, a_test_files,
- -
-a_include_objects, a_exclude_objects, a_fail_on_errors
- + +
- + 11 +
+ +ut.run(
- +
+ +ut_varchar2_list(),
- +
+ +a_reporter,
- +
+ +a_color_console,
- +
+ +a_coverage_schemes,
- +
+ +a_source_file_mappings,
- +
+ +a_test_file_mappings,
- +
+ +a_include_objects,
- +
+ +a_exclude_objects,
- +
+ +a_client_character_set,
- +
+ +a_force_manual_rollback,
- +
+ +a_random_test_order,
- +
+ +a_random_test_order_seed,
- +
+ +a_tags
- -
);
- + +
- -
end;
- -
-- + +
- -
- + +
- -
procedure run(
- -
-a_path in varchar2, a_reporter ut_reporter_base := null, a_color_console boolean := false,
- -
-a_coverage_schemes ut_varchar2_list := null, a_source_file_mappings ut_file_mappings := null, a_test_file_mappings ut_file_mappings := null,
- -
-a_include_objects ut_varchar2_list := null, a_exclude_objects ut_varchar2_list := null, a_fail_on_errors boolean default false
- + +
- +
+ +a_reporter ut_reporter_base := null,
- +
+ +a_color_console boolean := false,
- +
+ +a_coverage_schemes ut_varchar2_list := null,
- +
+ +a_source_files ut_varchar2_list,
- +
+ +a_test_files ut_varchar2_list,
- +
+ +a_include_objects ut_varchar2_list := null,
- +
+ +a_exclude_objects ut_varchar2_list := null,
- +
+ +a_client_character_set varchar2 := null,
- +
+ +a_force_manual_rollback boolean := false,
- +
+ +a_random_test_order boolean := false,
- +
+ +a_random_test_order_seed positive := null,
- +
+ +a_tags varchar2 := null
- -
) is
- + +
- -
begin
- -
-run(
- -
-ut_varchar2_list(coalesce(a_path, sys_context('userenv', 'current_schema'))),
- -
-a_reporter, a_color_console, a_coverage_schemes, a_source_file_mappings, a_test_file_mappings,
- -
-a_include_objects, a_exclude_objects, a_fail_on_errors
- + +
- +
+ +ut.run(
- +
+ +ut_varchar2_list(),
- +
+ +a_reporter,
- +
+ +a_color_console,
- +
+ +a_coverage_schemes,
- +
+ +a_source_files,
- +
+ +a_test_files,
- +
+ +a_include_objects,
- +
+ +a_exclude_objects,
- +
+ +a_client_character_set,
- +
+ +a_force_manual_rollback,
- +
+ +a_random_test_order,
- +
+ +a_random_test_order_seed,
- +
+ +a_tags
- -
);
- -
-end run;
- + +
- +
+ +end;
- -
- + +
- -
procedure run(
- -
-a_path in varchar2, a_reporter ut_reporter_base := null, a_color_console boolean := false,
- -
-a_coverage_schemes ut_varchar2_list := null, a_source_files ut_varchar2_list, a_test_files ut_varchar2_list,
- -
-a_include_objects ut_varchar2_list := null, a_exclude_objects ut_varchar2_list := null, a_fail_on_errors boolean default false
- + +
- +
+ +a_path varchar2,
- +
+ +a_reporter ut_reporter_base := null,
- +
+ +a_color_console boolean := false,
- +
+ +a_coverage_schemes ut_varchar2_list := null,
- +
+ +a_source_file_mappings ut_file_mappings := null,
- +
+ +a_test_file_mappings ut_file_mappings := null,
- +
+ +a_include_objects ut_varchar2_list := null,
- +
+ +a_exclude_objects ut_varchar2_list := null,
- +
+ +a_client_character_set varchar2 := null,
- +
+ +a_force_manual_rollback boolean := false,
- +
+ +a_random_test_order boolean := false,
- +
+ +a_random_test_order_seed positive := null,
- +
+ +a_tags varchar2 := null
- -
) is
- + +
- -
begin
- -
-run(
- -
-ut_varchar2_list(coalesce(a_path, sys_context('userenv', 'current_schema'))),
- -
-a_reporter, a_color_console, a_coverage_schemes, a_source_files, a_test_files,
- -
-a_include_objects, a_exclude_objects, a_fail_on_errors
- + +
- + 14 +
+ +ut.run(
- +
+ +ut_varchar2_list(a_path),
- +
+ +a_reporter,
- +
+ +a_color_console,
- +
+ +a_coverage_schemes,
- +
+ +a_source_file_mappings,
- +
+ +a_test_file_mappings,
- +
+ +a_include_objects,
- +
+ +a_exclude_objects,
- +
+ +a_client_character_set,
- +
+ +a_force_manual_rollback,
- +
+ +a_random_test_order,
- +
+ +a_random_test_order_seed,
- +
+ +a_tags
- -
);
- -
-end run;
- + +
- +
+ +end;
- -
- + +
- -
procedure run(
- -
-a_path in varchar2, a_reporters in ut_reporters, a_color_console boolean := false,
- -
-a_coverage_schemes ut_varchar2_list := null, a_source_file_mappings ut_file_mappings := null, a_test_file_mappings ut_file_mappings := null,
- -
-a_include_objects ut_varchar2_list := null, a_exclude_objects ut_varchar2_list := null, a_fail_on_errors boolean default false
- + +
- +
+ +a_path varchar2,
- +
+ +a_reporter ut_reporter_base := null,
- +
+ +a_color_console boolean := false,
- +
+ +a_coverage_schemes ut_varchar2_list := null,
- +
+ +a_source_files ut_varchar2_list,
- +
+ +a_test_files ut_varchar2_list,
- +
+ +a_include_objects ut_varchar2_list := null,
- +
+ +a_exclude_objects ut_varchar2_list := null,
- +
+ +a_client_character_set varchar2 := null,
- +
+ +a_force_manual_rollback boolean := false,
- +
+ +a_random_test_order boolean := false,
- +
+ +a_random_test_order_seed positive := null,
- +
+ +a_tags varchar2 := null
- -
) is
- + +
- -
begin
- - 1 -
-run(
- - 1 -
-ut_varchar2_list(coalesce(a_path, sys_context('userenv', 'current_schema'))),
- -
-a_reporters, a_color_console, a_coverage_schemes, a_source_file_mappings, a_test_file_mappings,
- -
-a_include_objects, a_exclude_objects, a_fail_on_errors
- + +
- + 3 +
+ +ut.run(
- +
+ +ut_varchar2_list(a_path),
- +
+ +a_reporter,
- +
+ +a_color_console,
- +
+ +a_coverage_schemes,
- +
+ +a_source_files,
- +
+ +a_test_files,
- +
+ +a_include_objects,
- +
+ +a_exclude_objects,
- +
+ +a_client_character_set,
- +
+ +a_force_manual_rollback,
- +
+ +a_random_test_order,
- +
+ +a_random_test_order_seed,
- +
+ +a_tags
- -
);
- -
-end run;
- + +
- +
+ +end;
- -
- -
-procedure run(
- -
-a_path in varchar2, a_reporters in ut_reporters, a_color_console boolean := false,
- -
-a_coverage_schemes ut_varchar2_list := null, a_source_files ut_varchar2_list, a_test_files ut_varchar2_list,
- -
-a_include_objects ut_varchar2_list := null, a_exclude_objects ut_varchar2_list := null, a_fail_on_errors boolean default false
- -
-) is
- + +
- +
+ +- +
+ +procedure set_nls is
- -
begin
- -
-run(
- -
-ut_varchar2_list(coalesce(a_path, sys_context('userenv', 'current_schema'))),
- -
-a_reporters, a_color_console, a_coverage_schemes, a_source_files, a_test_files,
- -
-a_include_objects, a_exclude_objects, a_fail_on_errors
- -
-);
- -
-end run;
- + +
- + 4 +
+ +if g_nls_date_format is null then
- + 4 +
+ +select nsp.value
- +
+ +into g_nls_date_format
- +
+ +from nls_session_parameters nsp
- +
+ +where parameter = 'NLS_DATE_FORMAT';
- +
+ +end if;
- + 4 +
+ +execute immediate 'alter session set nls_date_format = '''||ut_utils.gc_date_format||'''';
- +
+ +end;
- -
- -
end ut_runner;
+UT3.UT_COVERAGE
68.18 % covered
66 relevant lines. 45 lines covered and 21 lines missed+ +
- +
+ +procedure reset_nls is
- +
+ +begin
- + 4 +
+ +if g_nls_date_format is not null then
- + 4 +
+ +execute immediate 'alter session set nls_date_format = '''||g_nls_date_format||'''';
- +
+ +end if;
- + 4 +
+ +g_nls_date_format := null;
- +
+ +end;
- +
+ +- +
+end ut;
UT3.UT_RUNNER
93.5 % lines covered
123 relevant lines. 115 lines covered (including 1 lines partially covered ) and 8 lines missed+
- -
+package body ut_coverage is
package body ut_runner is
+- -
+/*
+
- -
+utPLSQL - Version X.X.X.X
/*
+- -
+Copyright 2016 - 2017 utPLSQL Project
utPLSQL - Version 3
+- -
+Copyright 2016 - 2019 utPLSQL Project
+- -
+Licensed under the Apache License, Version 2.0 (the "License"):
+
- -
+you may not use this file except in compliance with the License.
Licensed under the Apache License, Version 2.0 (the "License"):
+- -
+You may obtain a copy of the License at
you may not use this file except in compliance with the License.
+- -
+You may obtain a copy of the License at
+- -
-http://www.apache.org/licenses/LICENSE-2.0
- + +
- +
+http://www.apache.org/licenses/LICENSE-2.0
- -
+Unless required by applicable law or agreed to in writing, software
+
- -
+distributed under the License is distributed on an "AS IS" BASIS,
Unless required by applicable law or agreed to in writing, software
+- -
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
distributed under the License is distributed on an "AS IS" BASIS,
+- -
+See the License for the specific language governing permissions and
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+- -
+limitations under the License.
See the License for the specific language governing permissions and
+- -
+*/
limitations under the License.
+- -
+*/
+- -
+-- The source query has two important transformations done in it.
+
- -
+-- the flag: to_be_skipped ='Y' is set for a line of code that is badly reported by DBMS_PROFILER as executed 0 times.
/**
+- -
+-- This includes lines that are:
* Private functions
+- -
+-- - PACKAGE, PROCEDURE, FUNCTION definition line,
*/
+- -
+-- - BEGIN, END of a block
function to_ut_object_list(a_names ut_varchar2_list, a_schema_names ut_varchar2_rows) return ut_object_names is
+- -
+-- Another transformation is adjustment of line number for TRIGGER body.
l_result ut_object_names;
+- -
+-- DBMS_PROFILER is reporting line numbers for triggers not as defined in DBA_SOURCE, its usign line numbers as defined in DBA_TRIGGERS
l_object_name ut_object_name;
+- -
--- the DBA_TRIGGERS does not contain the trigger specification lines, only lines that define the trigger body.
- -
--- the query adjusts the line numbers for triggers by finding first occurrence of begin|declare|compound in the trigger body line.
- -
--- The subquery is optimized by:
- -
--- - COALESCE function -> it will execute only for TRIGGERS
- -
--- - scalar subquery cache -> it will only execute once for one trigger source code.
- -
-function get_populate_sources_tmp_sql(a_coverage_options ut_coverage_options) return varchar2 is
- -
-l_result varchar2(32767);
- -
-l_full_name varchar2(100);
- -
begin
- - 7 -
-if a_coverage_options.file_mappings is not null and a_coverage_options.file_mappings.count > 0 then
- - 4 -
-l_full_name := 'f.file_name';
- -
+ +else
- + 116 +
+ +if a_names is not empty then
- + 3 +
+ +l_result := ut_object_names();
- + 6 +
+ +for i in 1 .. a_names.count loop
- + 3 +
+ +l_object_name := ut_object_name(a_names(i));
- + 3 +
+ +if l_object_name.owner is null then
- +
+ +for i in 1 .. cardinality(a_schema_names) loop
- +
+ +l_result.extend;
- +
+ +l_result(l_result.last) := ut_object_name(a_schema_names(i)||'.'||l_object_name.name);
- +
+ +end loop;
- +
+ +else
- + 3 +
+l_result.extend;
- 3 -
+l_full_name := 'lower(s.owner||''.''||s.name)';
l_result(l_result.last) := l_object_name;
+- -
-end if;
- - 7 -
+l_result := '
end if;
+ +- +
+end loop;
- -
-insert /*+ append */ into ut_coverage_sources_tmp(full_name,owner,name,line,text, to_be_skipped)
- -
+select *
end if;
+ +- + 116 +
+return l_result;
- -
+from (
end;
+- -
+select '||l_full_name||q'[,
+
- -
+s.owner,
procedure finish_run(a_run ut_run, a_force_manual_rollback boolean) is
+- -
-s.name,
- -
-s.line -
- -
-coalesce(
- -
-case when type!='TRIGGER' then 0 end,
- -
-(select min(t.line) - 1
- -
-from all_source t
- -
-where t.owner = s.owner and t.type = s.type and t.name = s.name
- -
-and regexp_like( t.text, '[A-Za-z0-9$#_]*(begin|declare|compound).*','i'))
- -
+) as line,
begin
+ +- + 116 +
+ +ut_event_manager.trigger_event(ut_event_manager.gc_finalize, a_run);
- + 117 +
+ +ut_metadata.reset_source_definition_cache;
- + 116 +
+ +ut_utils.read_cache_to_dbms_output();
- + 222 +
+ +ut_coverage_helper.cleanup_tmp_table();
- + 232 +
+ +ut_compound_data_helper.cleanup_diff();
- + 116 +
+ +if not a_force_manual_rollback then
- + 114 +
+ +rollback;
- + 114 +
+ut_utils.cleanup_session_temp_tables;
- -
+s.text,
end if;
+- -
+case
end;
+- -
+when
+
- -
+-- to avoid execution of regexp_like on every line
+
- -
+-- first do a rough check for existence of search pattern keyword
/**
+- -
+(lower(s.text) like '%procedure%'
* Public functions
+- -
+or lower(s.text) like '%function%'
*/
+- -
+or lower(s.text) like '%begin%'
function version return varchar2 is
+- -
-or lower(s.text) like '%end%'
- -
+or lower(s.text) like '%package%'
begin
+ +- + 118 +
+return ut_utils.gc_version;
- -
+) and
end;
+- -
+regexp_like(
+
- -
-s.text,
- -
-'^\s*(((not)?\s*(overriding|final|instantiable)\s*)*(static|constructor|member)?\s*(procedure|function)|package(\s+body)|begin|end(\s+\S+)?\s*;)', 'i'
- -
-)
- -
+then 'Y'
function version_compatibility_check( a_requested varchar2, a_current varchar2 := null ) return integer is
+ +- + 16 +
+ +l_result boolean := false;
- + 16 +
+ +l_requested ut_utils.t_version := ut_utils.to_version(a_requested);
- + 15 +
+l_current ut_utils.t_version := ut_utils.to_version(coalesce(a_current,version()));
- -
-end as to_be_skipped
- -
-from all_source s]';
- - 7 -
-if a_coverage_options.file_mappings is not null and a_coverage_options.file_mappings.count > 0 then
- - 4 -
-l_result := l_result || '
- -
+join table(:file_mappings) f
begin
+ +- + 14 +
+ +if l_requested.major = l_current.major
- + 1 +
+ +and (l_requested.minor < l_current.minor or l_requested.minor is null
- + 1 +
+ +or l_requested.minor = l_current.minor and (l_requested.bugfix <= l_current.bugfix or l_requested.bugfix is null)) then
- + 10 +
+l_result := true;
- -
-on s.name = f.object_name
- -
+and s.type = f.object_type
end if;
+ +- + 14 +
+return ut_utils.boolean_to_int(l_result);
- -
+and s.owner = f.object_owner
end;
+- -
+where 1 = 1';
+
- -
-else
- - 3 -
+l_result := l_result || '
procedure run(
+ +- +
+a_paths ut_varchar2_list,
- -
+where s.owner in (select upper(t.column_value) from table(:l_schema_names) t)';
a_reporters ut_reporters,
+- -
-end if;
- - 7 -
+l_result := l_result || q'[
a_color_console boolean := false,
+ +- +
+a_coverage_schemes ut_varchar2_list := null,
- -
+and s.type not in ('PACKAGE', 'TYPE', 'JAVA SOURCE')
a_source_file_mappings ut_file_mappings := null,
+- -
+--Exclude calls to utPLSQL framework, Unit Test packages and objects from a_exclude_list parameter of coverage reporter
a_test_file_mappings ut_file_mappings := null,
+- -
-and (s.owner, s.name) not in (select el.owner, el.name from table(:l_skipped_objects) el)]';
- - 7 -
-if a_coverage_options.include_objects is null then
- - 6 -
+l_result := l_result || '
a_include_objects ut_varchar2_list := null,
+ +- +
+ +a_exclude_objects ut_varchar2_list := null,
- +
+a_fail_on_errors boolean := false,
- -
+and :include_objects is null';
a_client_character_set varchar2 := null,
+- -
-else
- - 1 -
+l_result := l_result || '
a_force_manual_rollback boolean := false,
+ +- +
+a_random_test_order boolean := false,
- -
+and (s.owner, s.name) in (select il.owner, il.name from table(:include_objects) il)';
a_random_test_order_seed positive := null,
+- -
-end if;
- - 7 -
+l_result := l_result || '
a_tags varchar2 := null
+ +- +
+) is
- -
+)
l_run ut_run;
+- -
-where line > 0';
- - 7 -
+return l_result;
l_coverage_schema_names ut_varchar2_rows;
+ +- + 116 +
+l_exclude_object_names ut_object_names := ut_object_names();
- -
-end;
- -
+l_include_object_names ut_object_names;
+ +- + 116 +
+l_paths ut_varchar2_list := ut_varchar2_list();
- -
-function is_tmp_table_populated return boolean is
- -
+l_result integer;
l_random_test_order_seed positive;
+ +- + 116 +
+l_tags ut_varchar2_rows := ut_varchar2_rows();
- -
begin
- -
-select 1 into l_result from ut_coverage_sources_tmp where rownum = 1;
- -
-return (l_result = 1);
- -
-exception
- -
-when no_data_found then
- -
+ +return false;
- + 232 +
+ +ut_event_manager.initialize();
- + 116 +
+ +if a_reporters is not empty then
- + 232 +
+ +for i in 1 .. a_reporters.count loop
- + 116 +
+ +ut_event_manager.add_listener( a_reporters(i) );
- +
+end loop;
- -
-end;
- -
+else
+ +- +
+ut_event_manager.add_listener( ut_documentation_reporter() );
- -
-procedure populate_tmp_table(a_coverage_options ut_coverage_options, a_skipped_objects ut_object_names) is
- -
+pragma autonomous_transaction;
end if;
+ +- + 116 +
+ut_event_manager.add_listener( ut_session_info() );
- -
-l_schema_names ut_varchar2_rows;
- -
-begin
- - 7 -
-delete from ut_coverage_sources_tmp;
- - 7 -
-l_schema_names := coalesce(a_coverage_options.schema_names, ut_varchar2_rows(sys_context('USERENV','CURRENT_SCHEMA')));
- - 7 -
-if a_coverage_options.file_mappings is not empty then
- +
+ +- + 116 +
+ +ut_event_manager.trigger_event(ut_event_manager.gc_initialize);
- + 116 +
+ +ut_event_manager.trigger_event(ut_event_manager.gc_debug, ut_run_info());
- + 116 +
+ +if a_random_test_order_seed is not null then
- 4 -
-execute immediate get_populate_sources_tmp_sql(a_coverage_options) using a_coverage_options.file_mappings, a_skipped_objects, a_coverage_options.include_objects;
- -
-else
- - 3 -
+execute immediate get_populate_sources_tmp_sql(a_coverage_options) using l_schema_names, a_skipped_objects, a_coverage_options.include_objects;
l_random_test_order_seed := a_random_test_order_seed;
+ +- + 112 +
+ +elsif a_random_test_order then
- +
+ +dbms_random.seed( to_char(systimestamp,'yyyyddmmhh24missffff') );
- +
+l_random_test_order_seed := trunc(dbms_random.value(1, 1000000000));
- -
end if;
- - 7 -
-commit;
- -
+ +end;
- + 116 +
+ +if a_paths is null or a_paths is empty or a_paths.count = 1 and a_paths(1) is null then
- + 21 +
+l_paths := ut_varchar2_list(sys_context('userenv', 'current_schema'));
- -
-- -
-- -
+/**
else
+ +- + 196 +
+ +for i in 1..a_paths.count loop
- + 101 +
+l_paths := l_paths multiset union ut_utils.string_to_table(a_string => a_paths(i),a_delimiter => ',');
- -
+* Public functions
end loop;
+- -
+*/
end if;
+- -
+procedure coverage_start is
+
- -
-begin
- - 4 -
-ut_coverage_helper.coverage_start('utPLSQL Code coverage run '||ut_utils.to_string(systimestamp));
- -
+end;
begin
+ +- + 232 +
+ +ut_expectation_processor.reset_invalidation_exception();
- + 116 +
+ut_utils.save_dbms_output_to_cache();
- -
- -
-procedure coverage_start_develop is
- -
-begin
- -
+ +ut_coverage_helper.coverage_start_develop();
- + 116 +
+ +ut_console_reporter_base.set_color_enabled(a_color_console);
- + 116 +
+ +if a_coverage_schemes is not empty then
- + 1 +
+l_coverage_schema_names := ut_utils.convert_collection(a_coverage_schemes);
- -
-end;
- -
+else
+ +- + 115 +
+l_coverage_schema_names := ut_suite_manager.get_schema_names(l_paths);
- -
+procedure coverage_pause is
end if;
+- -
-begin
- - 28 -
-ut_coverage_helper.coverage_pause();
- -
-end;
- + +
- + 116 +
+ +if a_exclude_objects is not empty then
- +
+ +l_exclude_object_names := to_ut_object_list(a_exclude_objects, l_coverage_schema_names);
- +
+end if;
- -
-procedure coverage_resume is
- -
-begin
- - 28 -
+ut_coverage_helper.coverage_resume();
+ +
- + 116 +
+ +if a_tags is not null then
- + 16 +
+l_tags := l_tags multiset union distinct ut_utils.convert_collection(
- -
+end;
ut_utils.trim_list_elements(ut_utils.filter_list(ut_utils.string_to_table(a_tags,','),ut_utils.gc_word_no_space))
+- -
+);
+- -
-procedure coverage_stop is
- -
-begin
- - 8 -
-ut_coverage_helper.coverage_stop();
- -
+end;
end if;
+ +- + 116 +
+ +l_exclude_object_names := l_exclude_object_names multiset union all ut_suite_manager.get_schema_ut_packages(l_coverage_schema_names);
- +
+ +- + 116 +
+l_include_object_names := to_ut_object_list(a_include_objects, l_coverage_schema_names);
- -
- -
+ +procedure coverage_stop_develop is
- + 116 +
+l_run := ut_run(
- -
-begin
- - 1 -
+ut_coverage_helper.coverage_stop_develop();
null,
+ +- +
+l_paths,
- -
+end;
l_coverage_schema_names,
+- -
+l_exclude_object_names,
+- -
+function get_coverage_data(a_coverage_options ut_coverage_options) return t_coverage is
l_include_object_names,
+- -
-l_line_calls ut_coverage_helper.unit_line_calls;
- - 7 -
-l_result t_coverage;
- - 7 -
-l_new_unit t_unit_coverage;
- - 7 -
+l_skipped_objects ut_object_names := ut_object_names();
set(a_source_file_mappings),
+ +- +
+ +set(a_test_file_mappings),
- +
+ +a_client_character_set,
- +
+l_random_test_order_seed,
- -
+l_tags
+- -
+type t_source_lines is table of binary_integer;
);
+- -
-line_no binary_integer;
- -
-begin
- -
- - 7 -
+ +if not ut_coverage_helper.is_develop_mode() then
- + 116 +
+ +ut_suite_manager.configure_execution_by_path(l_paths, l_run.items, l_random_test_order_seed, l_tags);
- + 115 +
+ +if a_force_manual_rollback then
- + 2 +
+l_run.set_rollback_type( a_rollback_type => ut_utils.gc_rollback_manual, a_force => true );
- -
---skip all the utplsql framework objects and all the unit test packages that could potentially be reported by coverage.
- -
-l_skipped_objects := ut_utils.get_utplsql_objects_list() multiset union all coalesce(a_coverage_options.exclude_objects, ut_object_names());
- -
-end if;
- +
+ +end if;
- -
- -
---prepare global temp table with sources
- - 7 -
-if ut_coverage_helper.is_develop_mode() or not is_tmp_table_populated() then
- - 7 -
-populate_tmp_table(a_coverage_options, l_skipped_objects);
- -
-end if;
- + +
- + 115 +
+ +l_run.do_execute();
- -
- - 340 -
+ +for src_object in (
- + 115 +
+ +finish_run(l_run, a_force_manual_rollback);
- +
+ +exception
- + 2 +
+ +when others then
- + 1 +
+ +finish_run(l_run, a_force_manual_rollback);
- + 1 +
+ +dbms_output.put_line(dbms_utility.format_error_backtrace);
- + 1 +
+dbms_output.put_line(dbms_utility.format_error_stack);
- 1 -
+select o.owner, o.name, o.full_name, max(o.line) lines_count,
raise;
+- -
-cast(
- -
-collect(decode(to_be_skipped, 'Y', to_char(line))) as ut_varchar2_list
- -
+) to_be_skipped_list
end;
+ +- + 1/2 + 115 +
+ +if a_fail_on_errors and l_run.result in (ut_utils.gc_failure, ut_utils.gc_error) then
- + 1 +
+raise_application_error(ut_utils.gc_some_tests_failed, 'Some tests failed');
- -
+from ut_coverage_sources_tmp o
end if;
+- -
+group by o.owner, o.name, o.full_name
end;
+- -
-) loop
- + +
- +
+procedure rebuild_annotation_cache(a_object_owner varchar2, a_object_type varchar2 := null) is
- -
---get coverage data
- - 326 -
+l_line_calls := ut_coverage_helper.get_raw_coverage_data( src_object.owner, src_object.name );
begin
+ +- + 2 +
+ut_annotation_manager.rebuild_annotation_cache(a_object_owner, coalesce(a_object_type,'PACKAGE'));
- -
+end;
+- -
---if there is coverage, we need to filter out the garbage (badly indicated data from dbms_profiler)
- - 326 -
+if l_line_calls.count > 0 then
+ +
- +
+procedure purge_cache(a_object_owner varchar2 := null, a_object_type varchar2 := null) is
- -
---remove lines that should not be indicted as meaningful
- -
-for i in 1 .. src_object.to_be_skipped_list.count loop
- -
-if src_object.to_be_skipped_list(i) is not null then
- -
-l_line_calls.delete(src_object.to_be_skipped_list(i));
- -
+end if;
begin
+ +- + 1 +
+ +ut_annotation_manager.purge_cache(a_object_owner, a_object_type);
- +
+ +end;
- +
+ +- +
+function get_suites_info(a_owner varchar2 := null, a_package_name varchar2 := null) return ut_suite_items_info pipelined is
- -
+end loop;
l_cursor sys_refcursor;
+- -
-end if;
- -
-- - 326 -
-if not l_result.objects.exists(src_object.full_name) then
- - 326 -
-l_result.objects(src_object.full_name) := l_new_unit;
- - 326 -
-l_result.objects(src_object.full_name).owner := src_object.owner;
- - 326 -
-l_result.objects(src_object.full_name).name := src_object.name;
- -
-end if;
- - 326 -
-l_result.total_lines := l_result.total_lines + src_object.lines_count;
- - 326 -
-l_result.objects(src_object.full_name).total_lines := src_object.lines_count;
- -
---map to results
- - 326 -
-line_no := l_line_calls.first;
- - 326 -
-if line_no is null then
- - 326 -
-l_result.uncovered_lines := l_result.uncovered_lines + src_object.lines_count;
- - 326 -
+l_result.objects(src_object.full_name).uncovered_lines := src_object.lines_count;
l_results ut_suite_items_info;
+ +- + 3 +
+ +c_bulk_limit constant integer := 100;
- +
+ +begin
- + 3 +
+ +l_cursor := ut_suite_manager.get_suites_info( nvl(a_owner,sys_context('userenv', 'current_schema')), a_package_name );
- + 3 +
+ +loop
- + 3 +
+ +fetch l_cursor bulk collect into l_results limit c_bulk_limit;
- + 13 +
+ +for i in 1 .. l_results.count loop
- + 10 +
+ +pipe row (l_results(i));
- +
+ +end loop;
- + 3 +
+ +exit when l_cursor%notfound;
- +
+ +end loop;
- + 3 +
+ +close l_cursor;
- + 3 +
+ +return;
- +
+end;
- -
-else
- -
-loop
- -
+exit when line_no is null;
+ +
- +
+ +function is_test(a_owner varchar2, a_package_name varchar2, a_procedure_name varchar2) return boolean is
- + 7 +
+l_result boolean := false;
- +
+ +begin
- + 7 +
+ +if a_owner is not null and a_package_name is not null and a_procedure_name is not null then
- -
- -
-if l_line_calls(line_no) > 0 then
- -
-l_result.covered_lines := l_result.covered_lines + 1;
- -
-l_result.executions := l_result.executions + l_line_calls(line_no);
- -
-l_result.objects(src_object.full_name).covered_lines := l_result.objects(src_object.full_name).covered_lines + 1;
- -
-l_result.objects(src_object.full_name).executions := l_result.objects(src_object.full_name).executions + l_line_calls(line_no);
- -
-elsif l_line_calls(line_no) = 0 then
- -
-l_result.uncovered_lines := l_result.uncovered_lines + 1;
- -
+ +l_result.objects(src_object.full_name).uncovered_lines := l_result.objects(src_object.full_name).uncovered_lines + 1;
- + 4 +
+ +l_result := ut_suite_manager.suite_item_exists( a_owner, a_package_name, a_procedure_name );
- +
+ +- +
+ +end if;
- +
+ +- + 7 +
+ +return l_result;
- +
+end;
- -
-end if;
- -
-l_result.objects(src_object.full_name).lines(line_no) := l_line_calls(line_no);
- -
- -
-line_no := l_line_calls.next(line_no);
- -
+ +end loop;
- +
+ +function is_suite(a_owner varchar2, a_package_name varchar2) return boolean is
- + 6 +
+ +l_result boolean := false;
- +
+ +begin
- + 6 +
+if a_owner is not null and a_package_name is not null then
- -
-end if;
- + +
- + 4 +
+l_result := ut_suite_manager.suite_item_exists( a_owner, a_package_name );
- +
- -
+end loop;
end if;
+- -
- - 7 + +
- + 6
+return l_result;
- -
+end get_coverage_data;
end;
+- +
- -
end;
UT3.UT_COVERAGE_HELPER
53.85 % covered
26 relevant lines. 14 lines covered and 12 lines missed-
- -
-package body ut_coverage_helper is
- -
-/*
- -
-utPLSQL - Version X.X.X.X
- -
-Copyright 2016 - 2017 utPLSQL Project
- -
-- -
-Licensed under the Apache License, Version 2.0 (the "License"):
- -
-you may not use this file except in compliance with the License.
- -
-You may obtain a copy of the License at
- -
-- -
-http://www.apache.org/licenses/LICENSE-2.0
- -
-- -
-Unless required by applicable law or agreed to in writing, software
- -
-distributed under the License is distributed on an "AS IS" BASIS,
- -
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- -
-See the License for the specific language governing permissions and
- -
-limitations under the License.
- -
-*/
- -
-- -
-g_coverage_id integer;
- -
-g_develop_mode boolean not null := false;
- -
-g_is_started boolean not null := false;
- -
-- -
-function is_develop_mode return boolean is
- -
-begin
- - 14 -
-return g_develop_mode;
- -
-end;
- -
-- -
-function is_started return boolean is
- -
-begin
- -
-return g_is_started;
- -
-end;
- -
-- -
-procedure coverage_start_internal(a_run_comment varchar2) is
- +
+ +function has_suites(a_owner varchar2) return boolean is
- + 5 +
+ +l_result boolean := false;
- -
begin
- - 1 -
-dbms_profiler.start_profiler(run_comment => a_run_comment, run_number => g_coverage_id);
- - 1 -
-g_is_started := true;
- - 1 -
-coverage_pause();
- -
-end;
- + +
- + 5 +
+ +if a_owner is not null then
- -
- -
-procedure coverage_start(a_run_comment varchar2) is
- -
-begin
- + +
- 4 -
-if not g_is_started then
- -
-g_develop_mode := false;
- -
-coverage_start_internal(a_run_comment);
- -
-end if;
- -
-end;
- +
+ +l_result := ut_suite_manager.suite_item_exists( a_owner );
- -
- -
-procedure coverage_start_develop is
- -
-begin
- -
-if not g_is_started then
- -
-g_develop_mode := true;
- -
-coverage_start_internal('utPLSQL Code coverage run in development MODE '||ut_utils.to_string(systimestamp));
- + +
- -
end if;
- -
-end;
- + +
- -
- -
-procedure coverage_pause is
- -
-l_return_code binary_integer;
- -
-begin
- - 29 -
-if not g_develop_mode then
- -
-l_return_code := dbms_profiler.pause_profiler();
- -
-end if;
- + +
- + 5 +
+ +return l_result;
- -
end;
- + +
- -
- -
-procedure coverage_resume is
- -
-l_return_code binary_integer;
- -
-begin
- - 28 -
-l_return_code := dbms_profiler.resume_profiler();
- -
-end;
- -
-- -
-procedure coverage_stop is
- + +
- +
+ +function get_reporters_list return tt_reporters_info pipelined is
- + 1 +
+ +l_owner varchar2(128) := upper(ut_utils.ut_owner());
- +
+ +l_reporters ut_reporters_info;
- +
+ +l_result t_reporter_rec;
- -
begin
- - 7 -
-if not g_develop_mode then
- -
-g_is_started := false;
- -
-dbms_profiler.stop_profiler();
- -
-end if;
- + +
- + 4 +
+ +loop
- + 4 +
+ +l_reporters := ut_utils.get_child_reporters( l_reporters );
- + 4 +
+ +exit when l_reporters is null or l_reporters.count = 0;
- + 18 +
+ +for i in 1 .. l_reporters.count loop
- + 15 +
+ +if l_reporters(i).is_instantiable = 'Y' then
- + 12 +
+ +l_result.reporter_object_name := l_owner||'.'||l_reporters(i).object_name;
- + 12 +
+ +l_result.is_output_reporter := l_reporters(i).is_output_reporter;
- + 12 +
+ +pipe row( l_result );
- +
+ +end if;
- +
+ +end loop;
- +
+ +end loop;
- -
end;
- + +
- -
- -
-procedure coverage_stop_develop is
- + +
- +
+ +function hash_suite_path(a_path varchar2, a_random_seed positiven) return varchar2 is
- + 16 +
+ +l_start_pos pls_integer := 1;
- + 16 +
+ +l_end_pos pls_integer := 1;
- +
+ +l_result varchar2(4000);
- +
+ +l_item varchar2(4000);
- + 16 +
+ +l_at_end boolean := false;
- -
begin
- - 1 -
-g_develop_mode := false;
- - 1 -
-g_is_started := false;
- - 2 -
-dbms_profiler.stop_profiler();
- + +
- + 16 +
+ +if a_random_seed is null then
- +
+ +l_result := a_path;
- +
+ +end if;
- + 16 +
+ +if a_path is not null then
- + 36 +
+ +loop
- + 36 +
+ +l_end_pos := instr(a_path,'.',l_start_pos);
- + 36 +
+ +if l_end_pos = 0 then
- + 16 +
+ +l_end_pos := length(a_path)+1;
- + 16 +
+ +l_at_end := true;
- +
+ +end if;
- + 36 +
+ +l_item := substr(a_path,l_start_pos,l_end_pos-l_start_pos);
- + 36 +
+ +if l_item is not null then
- + 36 +
+ +l_result :=
- +
+ +l_result ||
- +
+ +ut_utils.get_hash( to_char( dbms_utility.get_hash_value( l_item, 1, a_random_seed ) ) );
- +
+ +end if;
- + 36 +
+ +exit when l_at_end;
- + 20 +
+ +l_result := l_result || chr(0);
- + 20 +
+ +l_start_pos := l_end_pos + 1;
- +
+ +end loop;
- +
+ +end if;
- + 16 +
+ +return l_result;
- -
end;
- + +
- -
- -
-function get_raw_coverage_data(a_object_owner varchar2, a_object_name varchar2) return unit_line_calls is
- -
-type coverage_row is record (
- -
-line binary_integer,
- -
-calls number(38,0)
- -
-);
- -
-type coverage_rows is table of coverage_row;
- -
-l_tmp_data coverage_rows;
- -
-l_results unit_line_calls;
- -
-begin
- - 326 -
-select d.line#,
- -
--- This transformation addresses two issues:
- -
--- 1. dbms_profiler shows multiple unit_number for single code unit;
- -
--- to address this, we take a sum od all units by name
- -
--- 2. some lines show 0 total_occur while they were executed (time > 0)
- -
--- in this case we show 1 to indicate that there was execution even if we don't know how many there were
- -
-case when sum(d.total_occur) = 0 and sum(d.total_time) > 0 then 1 else sum(d.total_occur) end total_occur
- -
-bulk collect into l_tmp_data
- -
-from plsql_profiler_units u
- -
-join plsql_profiler_data d
- -
-on u.runid = d.runid
- -
-and u.unit_number = d.unit_number
- -
-where u.runid = g_coverage_id
- -
-and u.unit_owner = a_object_owner
- -
-and u.unit_name = a_object_name
- -
---exclude specification
- -
-and u.unit_type not in ('PACKAGE SPEC', 'TYPE SPEC', 'ANONYMOUS BLOCK')
- -
-group by d.line#;
- - 326 -
-for i in 1 .. l_tmp_data.count loop
- -
-l_results(l_tmp_data(i).line) := l_tmp_data(i).calls;
- -
-end loop;
- - 326 -
-return l_results;
- -
-end;
- -
end;
+UT3.UT_COVERAGE_REPORTER_BASE
100 % covered
16 relevant lines. 16 lines covered and 0 lines missed+ +
- +
+end ut_runner;
UT3.UT_SUITE_ITEM_INFO
100 % lines covered
12 relevant lines. 12 lines covered and 0 lines missed+
- -
+type body ut_coverage_reporter_base is
type body ut_suite_item_info is
+- +
/*
- -
+utPLSQL - Version X.X.X.X
utPLSQL - Version 3
+- -
+Copyright 2016 - 2017 utPLSQL Project
Copyright 2016 - 2019 utPLSQL Project
+- +
- +
Licensed under the Apache License, Version 2.0 (the "License"):
- +
you may not use this file except in compliance with the License.
- +
You may obtain a copy of the License at
- +
- +
http://www.apache.org/licenses/LICENSE-2.0
- +
- +
Unless required by applicable law or agreed to in writing, software
- +
distributed under the License is distributed on an "AS IS" BASIS,
- +
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
See the License for the specific language governing permissions and
- +
limitations under the License.
- +
*/
- -
+constructor function ut_suite_item_info(a_object_owner varchar2, a_object_name varchar2, a_item_name varchar2,
+- -
+overriding final member procedure before_calling_run(self in out nocopy ut_coverage_reporter_base, a_run ut_run) as
a_item_description varchar2, a_item_type varchar2, a_item_line_no integer, a_path varchar2, a_disabled_flag integer,
+- +
+ +a_tags ut_varchar2_rows) return self as result is
- -
begin
- - 4 -
-(self as ut_reporter_base).before_calling_run(a_run);
- - 8 -
-ut_coverage.coverage_start();
- + +
- + 10 +
+ +self.object_owner := a_object_owner;
- + 10 +
+ +self.object_name := a_object_name;
- + 10 +
+ +self.item_name := a_item_name;
- + 10 +
+ +self.item_description := a_item_description;
- + 10 +
+ +self.item_type := a_item_type;
- + 10 +
+ +self.item_line_no := a_item_line_no;
- + 10 +
+ +self.path := a_path;
- + 10 +
+ +self.disabled_flag := a_disabled_flag;
- + 10 +
+ +self.tags := case
- + 1 +
+ +when a_tags is null then null
- + 1 +
+ +when a_tags.count = 0 then null
- +
+ +else ut_utils.to_string(ut_utils.table_to_clob(a_tags,',') ,a_quote_char => null)
- +
+ +end;
- + 10 +
+ +return;
- -
end;
- -
-- -
-overriding final member procedure before_calling_before_all(self in out nocopy ut_coverage_reporter_base, a_suite in ut_logical_suite) is
- -
-begin
- - 2 -
-ut_coverage.coverage_resume();
- -
-end;
- -
-overriding final member procedure after_calling_before_all (self in out nocopy ut_coverage_reporter_base, a_suite in ut_logical_suite) is
- -
-begin
- - 2 -
-ut_coverage.coverage_pause();
- -
-end;
- -
-- -
-overriding final member procedure before_calling_before_each(self in out nocopy ut_coverage_reporter_base, a_suite in ut_test) is
- -
-begin
- - 6 -
+ut_coverage.coverage_resume();
- -
-end;
- -
-overriding final member procedure after_calling_before_each (self in out nocopy ut_coverage_reporter_base, a_suite in ut_test) is
- -
-begin
- - 6 -
-ut_coverage.coverage_pause();
- -
-end;
- -
-- -
-overriding final member procedure before_calling_before_test(self in out nocopy ut_coverage_reporter_base, a_test in ut_test) is
- -
-begin
- - 2 -
-ut_coverage.coverage_resume();
- -
-end;
- -
-overriding final member procedure after_calling_before_test (self in out nocopy ut_coverage_reporter_base, a_test in ut_test) is
- -
-begin
- - 2 -
-ut_coverage.coverage_pause();
- -
-end;
- -
-- -
-overriding final member procedure before_calling_test_execute(self in out nocopy ut_coverage_reporter_base, a_test in ut_test) is
- -
-begin
- - 8 -
-ut_coverage.coverage_resume();
- -
-end;
- -
-overriding final member procedure after_calling_test_execute (self in out nocopy ut_coverage_reporter_base, a_test in ut_test) is
- -
-begin
- - 8 -
-ut_coverage.coverage_pause();
- -
-end;
- -
-- -
-overriding final member procedure before_calling_after_test(self in out nocopy ut_coverage_reporter_base, a_test in ut_test) is
- -
-begin
- - 2 -
-ut_coverage.coverage_resume();
- -
-end;
- -
-overriding final member procedure after_calling_after_test (self in out nocopy ut_coverage_reporter_base, a_test in ut_test) is
- -
-begin
- - 2 -
-ut_coverage.coverage_pause();
- -
-end;
- -
-- -
-overriding final member procedure before_calling_after_each(self in out nocopy ut_coverage_reporter_base, a_suite in ut_test) is
- -
-begin
- - 6 -
-ut_coverage.coverage_resume();
- -
-end;
- -
-overriding final member procedure after_calling_after_each (self in out nocopy ut_coverage_reporter_base, a_suite in ut_test) is
- -
-begin
- - 6 -
-ut_coverage.coverage_pause();
- -
-end;
- -
-- -
-overriding final member procedure before_calling_after_all(self in out nocopy ut_coverage_reporter_base, a_suite in ut_logical_suite) is
- -
-begin
- - 2 -
-ut_coverage.coverage_resume();
- -
-end;
- -
-overriding final member procedure after_calling_after_all (self in out nocopy ut_coverage_reporter_base, a_suite in ut_logical_suite) is
- -
-begin
- - 2 -
-ut_coverage.coverage_pause();
- -
-end;
- -
-- -
end;
+UT3.UT_CONSOLE_REPORTER_BASE
71.43 % covered
7 relevant lines. 5 lines covered and 2 lines missed+
end;
+UT3.UT_ANNOTATION_CACHE_MANAGER
95.12 % lines covered
41 relevant lines. 39 lines covered and 2 lines missed+
- -
+type body ut_console_reporter_base is
package body ut_annotation_cache_manager as
+- +
/*
- -
+utPLSQL - Version X.X.X.X
utPLSQL - Version 3
+- -
+Copyright 2016 - 2017 utPLSQL Project
Copyright 2016 - 2019 utPLSQL Project
+- +
- +
Licensed under the Apache License, Version 2.0 (the "License"):
- +
you may not use this file except in compliance with the License.
- +
You may obtain a copy of the License at
- +
- +
http://www.apache.org/licenses/LICENSE-2.0
- +
- +
Unless required by applicable law or agreed to in writing, software
- +
distributed under the License is distributed on an "AS IS" BASIS,
- +
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
See the License for the specific language governing permissions and
- +
limitations under the License.
- +
*/
- +
- -
+static procedure set_color_enabled(a_flag boolean) is
procedure update_cache(a_object ut_annotated_object) is
+- -
-begin
- - 48 -
+ut_ansiconsole_helper.color_enabled(a_flag);
l_cache_id integer;
+ +- + 415 +
+l_timestamp timestamp := systimestamp;
- -
+end;
pragma autonomous_transaction;
+- -
-- -
-member procedure print_red_text(self in out nocopy ut_console_reporter_base, a_text varchar2) is
- -
begin
- - 95 -
+ +self.print_text(ut_ansiconsole_helper.red(a_text));
- + 415 +
+ +update ut_annotation_cache_schema s
- +
+ +set s.max_parse_time = l_timestamp
- +
+where s.object_type = a_object.object_type and s.object_owner = a_object.object_owner;
- -
-end;
- -
- -
+ +member procedure print_green_text(self in out nocopy ut_console_reporter_base, a_text varchar2) is
- + 415 +
+ +if sql%rowcount = 0 then
- + 5 +
+insert into ut_annotation_cache_schema s
- -
-begin
- - 64 -
+self.print_text(ut_ansiconsole_helper.green(a_text));
(object_owner, object_type, max_parse_time)
+ +- +
+values (a_object.object_owner, a_object.object_type, l_timestamp);
- -
+end;
end if;
+- +
- -
-member procedure print_yellow_text(self in out nocopy ut_console_reporter_base, a_text varchar2) is
- -
-begin
- - 13 -
-self.print_text(ut_ansiconsole_helper.yellow(a_text));
- -
-end;
- +
+ +-- if not in trigger, or object has annotations
- + 415 +
+ +if ora_sysevent is null or a_object.annotations is not null and a_object.annotations.count > 0 then
- + +
- + 376 +
+ +update ut_annotation_cache_info i
- +
+set i.parse_time = l_timestamp,
- -
+member procedure print_blue_text(self in out nocopy ut_console_reporter_base, a_text varchar2) is
i.is_annotated = case when a_object.annotations is not empty then 'Y' else 'N' end
+- -
-begin
- -
+self.print_text(ut_ansiconsole_helper.red(a_text));
where (i.object_owner, i.object_name, i.object_type)
+ +- +
+in ((a_object.object_owner, a_object.object_name, a_object.object_type))
- -
+end;
returning cache_id into l_cache_id;
+- -
- -
+ +member procedure print_cyan_text(self in out nocopy ut_console_reporter_base, a_text varchar2) is
- + 376 +
+if sql%rowcount = 0 then
- -
-begin
- - 13 -
+self.print_text(ut_ansiconsole_helper.cyan(a_text));
+ +
- + 85 +
+insert into ut_annotation_cache_info
- -
+end;
(cache_id, object_owner, object_name, object_type, parse_time, is_annotated)
+- -
+values (ut_annotation_cache_seq.nextval, a_object.object_owner, a_object.object_name, a_object.object_type, l_timestamp,
+- -
+member procedure print_magenta_text(self in out nocopy ut_console_reporter_base, a_text varchar2) is
case when a_object.annotations is not empty then 'Y' else 'N' end
+- -
-begin
- -
+self.print_text(ut_ansiconsole_helper.magenta(a_text));
)
+ +- +
+returning cache_id into l_cache_id;
- -
+end;
end if;
+- +
- -
end;
UT3.UT_EVENT_LISTENER
94 % covered
50 relevant lines. 47 lines covered and 3 lines missed-
- -
-type body ut_event_listener is
- -
-/*
- -
-utPLSQL - Version X.X.X.X
- -
-Copyright 2016 - 2017 utPLSQL Project
- -
-- -
-Licensed under the Apache License, Version 2.0 (the "License"):
- -
-you may not use this file except in compliance with the License.
- -
-You may obtain a copy of the License at
- +
+ +end if;
- -
- -
-http://www.apache.org/licenses/LICENSE-2.0
- + +
- + 415 +
+ +delete from ut_annotation_cache c where cache_id = l_cache_id;
- -
- -
-Unless required by applicable law or agreed to in writing, software
- -
-distributed under the License is distributed on an "AS IS" BASIS,
- -
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- -
-See the License for the specific language governing permissions and
- -
-limitations under the License.
- -
-*/
- -
-- -
-constructor function ut_event_listener(self in out nocopy ut_event_listener, a_reporters ut_reporters) return self as result is
- -
-begin
- - 77 -
-reporters := a_reporters;
- - 77 -
-return;
- -
-end;
- -
-- -
-overriding member procedure fire_before_event(self in out nocopy ut_event_listener, a_event_name varchar2, a_item ut_suite_item_base) is
- -
-begin
- - 1024 -
-self.fire_event('before', a_event_name, a_item);
- -
-end;
- -
-- -
-overriding member procedure fire_after_event(self in out nocopy ut_event_listener, a_event_name varchar2, a_item ut_suite_item_base) is
- -
-begin
- - 1024 -
-self.fire_event('after', a_event_name, a_item);
- -
-end;
- -
-- -
-overriding member procedure fire_event(self in out nocopy ut_event_listener, a_event_timing varchar2, a_event_name varchar2, a_item ut_suite_item_base) is
- -
-begin
- - 3992 -
-for i in 1..self.reporters.count loop
- - 1944 -
-if a_event_timing = 'before' then
- - 973 -
-if a_event_name = ut_utils.gc_run then
- - 48 -
-self.reporters(i).before_calling_run(treat(a_item as ut_run));
- - 924 -
-elsif a_event_name = ut_utils.gc_suite then
- - 130 -
-self.reporters(i).before_calling_suite(treat(a_item as ut_logical_suite));
- - 794 -
-elsif a_event_name = ut_utils.gc_before_all then
- - 22 -
-self.reporters(i).before_calling_before_all(treat(a_item as ut_logical_suite));
- - 772 -
-elsif a_event_name = ut_utils.gc_before_each then
- - 134 -
-self.reporters(i).before_calling_before_each(treat(a_item as ut_test));
- - 638 -
-elsif a_event_name = ut_utils.gc_test then
- - 203 -
-self.reporters(i).before_calling_test(treat(a_item as ut_test));
- - 435 -
-elsif a_event_name = ut_utils.gc_before_test then
- - 59 -
-self.reporters(i).before_calling_before_test(treat(a_item as ut_test));
- - 376 -
-elsif a_event_name = ut_utils.gc_test_execute then
- - 163 -
-self.reporters(i).before_calling_test_execute(treat(a_item as ut_test));
- - 213 -
-elsif a_event_name = ut_utils.gc_after_test then
- - 59 -
-self.reporters(i).before_calling_after_test(treat(a_item as ut_test));
- - 154 -
-elsif a_event_name = ut_utils.gc_after_each then
- - 134 -
-self.reporters(i).before_calling_after_each(treat(a_item as ut_test));
- - 20 -
-elsif a_event_name = ut_utils.gc_after_all then
- - 20 -
-self.reporters(i).before_calling_after_all(treat(a_item as ut_logical_suite));
- -
-else
- -
-raise_application_error(ut_utils.gc_invalid_rep_event_name,'Invalid reporting event name - '|| nvl(a_event_name,'NULL'));
- -
-end if;
- - 972 -
-elsif a_event_timing = 'after' then
- - 972 -
-if a_event_name = ut_utils.gc_run then
- - 48 -
-self.reporters(i).after_calling_run(treat(a_item as ut_run));
- - 924 -
-elsif a_event_name = ut_utils.gc_suite then
- - 130 -
-self.reporters(i).after_calling_suite(treat(a_item as ut_logical_suite));
- - 794 -
-elsif a_event_name = ut_utils.gc_before_all then
- - 22 -
-self.reporters(i).after_calling_before_all(treat(a_item as ut_logical_suite));
- - 772 -
-elsif a_event_name = ut_utils.gc_before_each then
- - 134 -
-self.reporters(i).after_calling_before_each(treat(a_item as ut_test));
- - 638 -
-elsif a_event_name = ut_utils.gc_test then
- - 203 -
-self.reporters(i).after_calling_test(treat(a_item as ut_test));
- - 435 -
-elsif a_event_name = ut_utils.gc_before_test then
- - 59 -
-self.reporters(i).after_calling_before_test(treat(a_item as ut_test));
- + +
- + 415 +
+ +if a_object.annotations is not null and a_object.annotations.count > 0 then
- 376 -
-elsif a_event_name = ut_utils.gc_test_execute then
- - 163 -
-self.reporters(i).after_calling_test_execute(treat(a_item as ut_test));
- - 213 -
-elsif a_event_name = ut_utils.gc_after_test then
- - 59 -
-self.reporters(i).after_calling_after_test(treat(a_item as ut_test));
- - 154 -
-elsif a_event_name = ut_utils.gc_after_each then
- - 134 -
-self.reporters(i).after_calling_after_each(treat(a_item as ut_test));
- - 20 -
-elsif a_event_name = ut_utils.gc_after_all then
- - 20 -
-self.reporters(i).after_calling_after_all(treat(a_item as ut_logical_suite));
- -
-else
- -
-raise_application_error(ut_utils.gc_invalid_rep_event_name,'Invalid reporting event name - '|| nvl(a_event_name,'NULL'));
- -
-end if;
- -
-else
- -
-raise_application_error(ut_utils.gc_invalid_rep_event_time,'Invalid reporting event time - '|| nvl(a_event_timing,'NULL'));
- -
-end if;
- -
-end loop;
- -
-- -
-end fire_event;
- -
-- -
end;
UT3.UT_EXECUTABLE
100 % covered
53 relevant lines. 53 lines covered and 0 lines missed-
- -
-type body ut_executable is
- -
-/*
- -
-utPLSQL - Version X.X.X.X
- -
-Copyright 2016 - 2017 utPLSQL Project
- -
-- -
-Licensed under the Apache License, Version 2.0 (the "License"):
- -
-you may not use this file except in compliance with the License.
- -
-You may obtain a copy of the License at
- -
-- -
-http://www.apache.org/licenses/LICENSE-2.0
- -
-- -
-Unless required by applicable law or agreed to in writing, software
- -
-distributed under the License is distributed on an "AS IS" BASIS,
- -
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- -
-See the License for the specific language governing permissions and
- -
-limitations under the License.
- -
-*/
- -
-- -
-constructor function ut_executable(
- -
-self in out nocopy ut_executable, a_context ut_suite_item,
- -
-a_procedure_name varchar2, a_associated_event_name varchar2
- -
-) return self as result is
- -
-begin
- - 4270 -
-self.associated_event_name := a_associated_event_name;
- - 4270 -
-self.owner_name := a_context.object_owner;
- - 4270 -
-self.object_name := a_context.object_name;
- - 4270 -
-self.procedure_name := a_procedure_name;
- - 4270 -
-return;
- -
-end;
- -
-- -
-member function is_defined return boolean is
- -
-begin
- - 2059 -
-return self.procedure_name is not null and self.object_name is not null;
- -
-end;
- -
-- -
-member function is_valid(self in out nocopy ut_executable) return boolean is
- - 627 -
-l_result boolean := false;
- - 627 -
-l_message_part varchar2(4000) := 'Call params for ' || self.associated_event_name || ' are not valid: ';
- -
-begin
- -
-- - 627 -
-if self.object_name is null then
- - 1 -
-self.error_stack := l_message_part || 'package is not defined';
- - 626 -
-elsif not ut_metadata.package_valid(self.owner_name, self.object_name) then
- - 3 -
-self.error_stack := l_message_part || 'package does not exist or is invalid: ' ||upper(self.owner_name||'.'||self.object_name);
- - 623 -
-elsif self.procedure_name is null then
- - 1 -
-self.error_stack := l_message_part || 'procedure is not defined';
- - 622 -
-elsif not ut_metadata.procedure_exists(self.owner_name, self.object_name, self.procedure_name) then
- - 5 -
-self.error_stack := l_message_part || 'package missing procedure '
- -
-|| upper(self.owner_name || '.' || self.object_name || '.' ||self.procedure_name);
- -
-else
- - 617 -
-l_result := true;
- -
-end if;
- -
-- - 627 -
-return l_result;
- -
-end is_valid;
- -
-- -
-member function form_name return varchar2 is
- -
-begin
- - 36 -
+return ut_metadata.form_name(owner_name, object_name, procedure_name);
insert into ut_annotation_cache
+- -
+end;
(cache_id, annotation_position, annotation_name, annotation_text, subobject_name)
+- -
+select l_cache_id, a.position, a.name, a.text, a.subobject_name
+- -
+member procedure do_execute(self in out nocopy ut_executable, a_item in out nocopy ut_suite_item, a_listener in out nocopy ut_event_listener_base) is
from table(a_object.annotations) a;
+- -
-l_completed_without_errors boolean;
- -
-begin
- - 544 -
+l_completed_without_errors := self.do_execute(a_item, a_listener);
end if;
+ +- + 415 +
+ +commit;
- +
+end;
- -
+end do_execute;
+
- +
- -
-member function do_execute(self in out nocopy ut_executable, a_item in out nocopy ut_suite_item, a_listener in out nocopy ut_event_listener_base) return boolean is
- -
+l_statement varchar2(4000);
procedure reset_objects_cache(a_objects ut_annotation_objs_cache_info) is
+ +- + 85 +
+l_timestamp timestamp := systimestamp;
- -
+l_status number;
pragma autonomous_transaction;
+- -
-l_cursor_number number;
- - 1102 -
-l_owner varchar2(200) := self.owner_name;
- - 1102 -
-l_object_name varchar2(200) := self.object_name;
- - 1102 -
-l_procedure_name varchar2(200) := self.procedure_name;
- +
+ +begin
- -
- - 1102 -
+ +l_completed_without_errors boolean := true;
- + 85 +
+ +delete from ut_annotation_cache c
- +
+ +where c.cache_id
- +
+ +in (select i.cache_id
- +
+from ut_annotation_cache_info i
- -
+l_start_transaction_id varchar2(250);
join table (a_objects) o
+- -
+l_end_transaction_id varchar2(250);
on o.object_name = i.object_name
+- -
+procedure save_dbms_output is
and o.object_type = i.object_type
+- -
+l_status number;
and o.object_owner = i.object_owner
+- -
+l_line varchar2(32767);
);
+- -
-begin
- - 614 -
-dbms_lob.createtemporary(self.serveroutput, true, dur => dbms_lob.session);
- -
- - 817 -
-loop
- - 817 -
-dbms_output.get_line(line => l_line, status => l_status);
- - 817 -
+ +exit when l_status = 1;
- + 85 +
+ +update ut_annotation_cache_schema s
- +
+ +set s.max_parse_time = l_timestamp
- +
+ +where (s.object_owner, s.object_type)
- +
+ +in (
- +
+select o.object_owner, o.object_type
- +
+ +from table(a_objects) o
- +
+ +);
- -
- - 203 -
-if l_line is not null then
- - 202 -
-ut_utils.append_to_clob(self.serveroutput, l_line);
- -
-end if;
- -
-- - 203 -
-dbms_lob.writeappend(self.serveroutput,1,chr(10));
- -
-end loop;
- -
+ +end save_dbms_output;
- + 85 +
+ +if sql%rowcount = 0 then
- + 1 +
+ +insert into ut_annotation_cache_schema s
- +
+ +(object_owner, object_type, max_parse_time)
- +
+ +select distinct o.object_owner, o.object_type, l_timestamp
- +
+from table(a_objects) o;
- -
-begin
- - 1102 -
-if self.is_defined() then
- - 614 -
+l_start_transaction_id := dbms_transaction.local_transaction_id(true);
end if;
+ +- +
+ +- + 85 +
+merge into ut_annotation_cache_info i
- -
---listener - before call to executable
- - 614 -
+a_listener.fire_before_event(self.associated_event_name, a_item);
using (select o.object_name, o.object_type, o.object_owner
+ +- +
+from table(a_objects) o ) o
- -
-- - 614 -
+ut_metadata.do_resolve(a_owner => l_owner, a_object => l_object_name, a_procedure_name => l_procedure_name);
on (o.object_name = i.object_name
+ +- +
+and o.object_type = i.object_type
- -
-- - 614 -
+l_statement :=
and o.object_owner = i.object_owner)
+ +- +
+when matched then
- -
+'declare' || chr(10) ||
update
+- -
+' l_error_stack varchar2(32767);' || chr(10) ||
set parse_time = l_timestamp,
+- -
+' l_error_backtrace varchar2(32767);' || chr(10) ||
is_annotated = 'N'
+- -
+'begin' || chr(10) ||
when not matched then insert
+- -
+' begin' || chr(10) ||
(cache_id, object_owner, object_name, object_type, parse_time, is_annotated)
+- -
+' ' || ut_metadata.form_name(l_owner, l_object_name, l_procedure_name) || ';' || chr(10) ||
values (ut_annotation_cache_seq.nextval, o.object_owner, o.object_name, o.object_type, l_timestamp, 'N');
+- -
-' exception' || chr(10) ||
- -
+' when others then ' || chr(10) ||
+ +
- + 85 +
+commit;
- -
+' l_error_stack := dbms_utility.format_error_stack;' || chr(10) ||
end;
+- -
+' l_error_backtrace := dbms_utility.format_error_backtrace;' || chr(10) ||
+
- -
+' --raise on ORA-04068, ORA-04061: existing state of packages has been discarded to avoid unrecoverable session exception' || chr(10) ||
function get_cached_objects_list(a_object_owner varchar2, a_object_type varchar2, a_parsed_after timestamp := null) return ut_annotation_objs_cache_info is
+- -
+' if l_error_stack like ''%ORA-04068%'' or l_error_stack like ''%ORA-04061%'' then' || chr(10) ||
l_result ut_annotation_objs_cache_info;
+- -
-' raise;' || chr(10) ||
- -
+' end if;' || chr(10) ||
begin
+ +- + 893 +
+select ut_annotation_obj_cache_info(
- -
+' end;' || chr(10) ||
object_owner => i.object_owner,
+- -
+' :a_error_stack := l_error_stack;' || chr(10) ||
object_name => i.object_name,
+- -
+' :a_error_backtrace := l_error_backtrace;' || chr(10) ||
object_type => i.object_type,
+- -
+'end;';
needs_refresh => 'N',
+- -
-- - 614 -
+ut_utils.debug_log('ut_executable.do_execute l_statement: ' || l_statement);
parse_time => i.parse_time
+ +- +
+)
- +
+ +bulk collect into l_result
- +
+ +from ut_annotation_cache_info i
- +
+ +where i.object_owner = a_object_owner
- +
+ +and i.object_type = a_object_type
- +
+ +and (i.parse_time > a_parsed_after or a_parsed_after is null);
- + 893 +
+ +return l_result;
- +
+ +end;
- -
- - 614 -
-l_cursor_number := dbms_sql.open_cursor;
- - 614 -
-dbms_sql.parse(l_cursor_number, statement => l_statement, language_flag => dbms_sql.native);
- - 614 -
-dbms_sql.bind_variable(l_cursor_number, 'a_error_stack', to_char(null), 32767);
- - 614 -
-dbms_sql.bind_variable(l_cursor_number, 'a_error_backtrace', to_char(null), 32767);
- -
-- - 614 -
-l_status := dbms_sql.execute(l_cursor_number);
- - 614 -
-dbms_sql.variable_value(l_cursor_number, 'a_error_stack', self.error_stack);
- - 614 -
-dbms_sql.variable_value(l_cursor_number, 'a_error_backtrace', self.error_backtrace);
- - 614 -
+ +dbms_sql.close_cursor(l_cursor_number);
- +
+ +function get_cache_schema_info(a_object_owner varchar2, a_object_type varchar2) return t_cache_schema_info is
- +
+l_result t_cache_schema_info;
- -
-- - 614 -
-save_dbms_output;
- -
-- - 614 -
+l_completed_without_errors := (self.error_stack||self.error_backtrace) is null;
begin
+ +- +
+ +begin
- + 327 +
+ +select *
- +
+into l_result
- -
+from ut_annotation_cache_schema s
+- -
---listener - after call to executable
- - 614 -
-a_listener.fire_after_event(self.associated_event_name, a_item);
- -
-- - 614 -
-l_end_transaction_id := dbms_transaction.local_transaction_id();
- - 614 -
-if l_start_transaction_id != l_end_transaction_id or l_end_transaction_id is null then
- - 9 -
+a_item.add_transaction_invalidator(self.form_name());
where s.object_type = a_object_type and s.object_owner = a_object_owner;
+ +- +
+ +exception
- + 6 +
+ +when no_data_found then
- + 3 +
+ +null;
- +
+ +end;
- + 327 +
+return l_result;
- -
+end if;
end;
+- -
-end if;
- -
- - 1102 -
+ +return l_completed_without_errors;
- +
+ +procedure set_fully_refreshed(a_object_owner varchar2, a_object_type varchar2) is
- +
+pragma autonomous_transaction;
- -
-end do_execute;
- -
+begin
+ +- + 13 +
+update ut_annotation_cache_schema s
- -
+member function get_error_stack_trace return varchar2 is
set s.full_refresh_time = s.max_parse_time
+- -
-begin
- - 1159 -
-return rtrim(self.error_stack||self.error_backtrace, chr(10));
- -
+end;
where s.object_owner = a_object_owner
+ +- +
+ +and s.object_type = a_object_type;
- + 13 +
+commit;
- -
end;
UT3.UT_EXPECTATION_RESULT
92.86 % covered
14 relevant lines. 13 lines covered and 1 lines missed-
- -
-type body ut_expectation_result is
- -
-/*
- -
-utPLSQL - Version X.X.X.X
- -
-Copyright 2016 - 2017 utPLSQL Project
- +
+ +end;
- -
- -
-Licensed under the Apache License, Version 2.0 (the "License"):
- -
-you may not use this file except in compliance with the License.
- -
-You may obtain a copy of the License at
- + +
- +
+ +procedure remove_from_cache(a_objects ut_annotation_objs_cache_info) is
- +
+ +pragma autonomous_transaction;
- +
+ +begin
- -
- -
-http://www.apache.org/licenses/LICENSE-2.0
- + +
- + 388 +
+ +delete from ut_annotation_cache_info i
- +
+ +where exists (
- +
+ +select 1 from table (a_objects) o
- +
+ +where o.object_name = i.object_name
- +
+ +and o.object_type = i.object_type
- +
+ +and o.object_owner = i.object_owner
- +
+ +);
- -
- -
-Unless required by applicable law or agreed to in writing, software
- -
-distributed under the License is distributed on an "AS IS" BASIS,
- -
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- -
-See the License for the specific language governing permissions and
- -
-limitations under the License.
- -
-*/
- + +
- + 388 +
+ +commit;
- +
+ +end;
- -
- -
-constructor function ut_expectation_result(self in out nocopy ut_expectation_result, a_status integer, a_description varchar2, a_message clob)
- -
-return self as result is
- + +
- +
+ +function get_annotations_parsed_since(a_object_owner varchar2, a_object_type varchar2, a_parsed_after timestamp) return sys_refcursor is
- +
+ +l_results sys_refcursor;
- -
begin
- - 943 -
-self.status := a_status;
- - 943 -
-self.description := a_description;
- - 943 -
-self.message := a_message;
- - 943 -
-if self.status = ut_utils.tr_failure then
- - 288 -
-self.caller_info := ut_expectation_processor.who_called_expectation(dbms_utility.format_call_stack());
- -
-end if;
- - 943 -
-return;
- + +
- + 317 +
+ +open l_results for
- +
+ +select ut_annotated_object(
- +
+ +i.object_owner, i.object_name, i.object_type, i.parse_time,
- +
+ +cast(
- +
+ +collect(
- +
+ +ut_annotation(
- +
+ +c.annotation_position, c.annotation_name, c.annotation_text, c.subobject_name
- +
+ +) order by c.annotation_position
- +
+ +) as ut_annotations
- +
+ +)
- +
+ +) as annotated_object
- +
+ +from ut_annotation_cache_info i
- +
+ +join ut_annotation_cache c on i.cache_id = c.cache_id
- +
+ +where i.object_owner = a_object_owner and i.object_type = a_object_type
- +
+ +and (i.parse_time > a_parsed_after or a_parsed_after is null)
- +
+ +group by i.object_owner, i.object_type, i.object_name, i.parse_time;
- + 317 +
+ +return l_results;
- -
end;
- + +
- -
- -
-member function get_result_clob(self in ut_expectation_result) return clob is
- -
-l_result clob;
- + +
- +
+ +procedure purge_cache(a_object_owner varchar2, a_object_type varchar2) is
- +
+ +l_filter varchar2(32767);
- +
+ +l_cache_filter varchar2(32767);
- +
+ +pragma autonomous_transaction;
- -
begin
- - 72 -
-if self.description is not null then
- - 10 -
-ut_utils.append_to_clob(l_result, '"'||self.description||'"');
- - 10 -
-if self.message is not null then
- - 10 -
-ut_utils.append_to_clob(l_result, chr(10));
- -
-end if;
- + +
- + 2 +
+ +if a_object_owner is null and a_object_type is null then
- +
+ +l_filter := ':a_object_owner is null and :a_object_type is null';
- +
+ +l_cache_filter := l_filter;
- +
+ +else
- + 2 +
+ +l_filter := case when a_object_owner is null then ':a_object_owner is null' else 'object_owner = :a_object_owner' end;
- + 2 +
+ +l_filter := l_filter || ' and ' || case when a_object_type is null then ':a_object_type is null' else 'object_type = :a_object_type' end;
- + 2 +
+ +l_cache_filter := ' c.cache_id in (select i.cache_id from ut_annotation_cache_info i where ' || l_filter || ' )';
- -
end if;
- - 72 -
-ut_utils.append_to_clob(l_result, self.message);
- - 72 -
-return l_result;
- -
-end;
- + +
- + 2 +
+ +execute immediate 'delete from ut_annotation_cache c where ' || l_cache_filter
- +
+ +using a_object_owner, a_object_type;
- -
- -
-member function get_result_lines(self in ut_expectation_result) return ut_varchar2_list is
- -
-begin
- - 18 -
-return ut_utils.clob_to_table(get_result_clob(), 4000 );
- -
-end;
- + +
- + 2 +
+ +execute immediate ' delete from ut_annotation_cache_info i where ' || l_filter
- +
+ +using a_object_owner, a_object_type;
- -
- -
-member function result return integer is
- -
-begin
- -
-return self.status;
- + +
- + 2 +
+ +execute immediate ' delete from ut_annotation_cache_schema s where ' || l_filter
- +
+ +using a_object_owner, a_object_type;
- +
+ +- + 2 +
+ +commit;
- -
end;
- + +
- -
- -
end;
+UT3.UT_LOGICAL_SUITE
72.34 % covered
47 relevant lines. 34 lines covered and 13 lines missed+ +
- +
+end;
UT3.UT_ANNOTATION_MANAGER
98.86 % lines covered
88 relevant lines. 87 lines covered and 1 lines missed+
- -
+type body ut_logical_suite as
package body ut_annotation_manager as
+- +
/*
- -
+utPLSQL - Version X.X.X.X
utPLSQL - Version 3
+- -
+Copyright 2016 - 2017 utPLSQL Project
Copyright 2016 - 2019 utPLSQL Project
+- +
- +
Licensed under the Apache License, Version 2.0 (the "License"):
- +
you may not use this file except in compliance with the License.
- +
You may obtain a copy of the License at
- +
- +
http://www.apache.org/licenses/LICENSE-2.0
- +
- +
Unless required by applicable law or agreed to in writing, software
- +
distributed under the License is distributed on an "AS IS" BASIS,
- +
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
See the License for the specific language governing permissions and
- +
limitations under the License.
- +
*/
- +
- -
+constructor function ut_logical_suite(
------------------------------
+- -
+self in out nocopy ut_logical_suite,a_object_owner varchar2, a_object_name varchar2, a_name varchar2, a_description varchar2 := null, a_path varchar2
--private definitions
+- -
+) return self as result is
+
- +
+ +function user_can_see_whole_schema( a_schema_name varchar2 ) return boolean is
- -
begin
- - 94 -
-self.self_type := $$plsql_unit;
- - 94 -
-self.init(a_object_owner, a_object_name, a_name, a_description, a_path, ut_utils.gc_rollback_auto, false);
- - 94 -
-self.items := ut_suite_items();
- - 94 -
+ +return;
- + 345 +
+ +return sys_context('userenv','current_schema') = a_schema_name
- + 1 +
+ +or ut_metadata.user_has_execute_any_proc()
- + 1 +
+or ut_metadata.is_object_visible('dba_objects');
- +
end;
- +
- -
-member function is_valid(self in out nocopy ut_logical_suite) return boolean is
- -
-begin
- -
+return true;
function get_non_existing_objects( a_object_owner varchar2, a_object_type varchar2 ) return ut_annotation_objs_cache_info is
+ +- + 265 +
+ +l_objects_view varchar2(200) := ut_metadata.get_objects_view_name();
- + 265 +
+l_object_to_delete ut_annotation_objs_cache_info := ut_annotation_objs_cache_info();
- -
+end;
l_cached_objects ut_annotation_objs_cache_info;
+- +
+ +begin
- + 265 +
+ +l_cached_objects := ut_annotation_cache_manager.get_cached_objects_list( a_object_owner, a_object_type );
- -
- -
-member function item_index(a_name varchar2) return pls_integer is
- - 49 -
-l_item_index pls_integer := self.items.first;
- - 49 -
-c_lowered_name constant varchar2(4000 char) := lower(trim(a_name));
- -
+ +l_result pls_integer;
- + 265 +
+ +if l_cached_objects is not empty then
- + 262 +
+execute immediate 'select /*+ cardinality(i '||ut_utils.scale_cardinality(cardinality(l_cached_objects))||') */
- -
-begin
- - 49 -
-while l_item_index is not null loop
- - 44 -
-if self.items(l_item_index).name = c_lowered_name then
- - 44 -
-l_result := l_item_index;
- - 44 -
+exit;
value(i)
+ +- +
+ +from table( :l_data ) i
- +
+ +where
- +
+ +not exists (
- +
+select 1 from '||l_objects_view||q'[ o
- -
-end if;
- -
+l_item_index := self.items.next(l_item_index);
where o.owner = i.object_owner
+ +- +
+and o.object_name = i.object_name
- -
-end loop;
- - 49 -
+return l_result;
and o.object_type = i.object_type
+ +- +
+and o.owner = ']'||ut_utils.qualified_sql_name(a_object_owner)||q'['
- -
+end item_index;
and o.object_type = ']'||ut_utils.qualified_sql_name(a_object_type)||q'['
+- -
+)]'
+- -
+member procedure add_item(self in out nocopy ut_logical_suite, a_item ut_suite_item) is
bulk collect into l_object_to_delete
+- -
-begin
- - 844 -
-self.items.extend;
- - 844 -
+self.items(self.items.last) := a_item;
using l_cached_objects;
+ +- +
+ +end if;
- + 265 +
+return l_object_to_delete;
- +
end;
- +
- -
+overriding member function do_execute(self in out nocopy ut_logical_suite, a_listener in out nocopy ut_event_listener_base) return boolean is
function get_objects_to_refresh(
+- -
+l_suite_savepoint varchar2(30);
a_object_owner varchar2,
+- -
+l_item_savepoint varchar2(30);
a_object_type varchar2,
+- -
+l_completed_without_errors boolean;
a_modified_after timestamp
+- -
-begin
- - 34 -
+ut_utils.debug_log('ut_logical_suite.execute');
) return ut_annotation_objs_cache_info is
+ +- + 327 +
+l_ut_owner varchar2(250) := ut_utils.ut_owner;
- -
-- - 34 -
-a_listener.fire_before_event(ut_utils.gc_suite,self);
- - 34 -
+self.start_time := current_timestamp;
l_refresh_needed boolean;
+ +- + 327 +
+ +l_objects_view varchar2(200) := ut_metadata.get_objects_view_name();
- +
+l_cached_objects ut_annotation_objs_cache_info;
- +
+ +l_result ut_annotation_objs_cache_info;
- +
+ +begin
- + 327 +
+ +ut_event_manager.trigger_event( 'get_objects_to_refresh - start' );
- -
- - 68 -
-for i in 1 .. self.items.count loop
- -
--- execute the item (test or suite)
- - 34 -
-self.items(i).do_execute(a_listener);
- -
-end loop;
- -
-- - 34 -
-self.calc_execution_result();
- - 34 -
+ +self.end_time := current_timestamp;
- + 327 +
+ +l_refresh_needed := ( ut_trigger_check.is_alive() = false ) or a_modified_after is null;
- + 327 +
+ +l_cached_objects := ut_annotation_cache_manager.get_cached_objects_list( a_object_owner, a_object_type, a_modified_after );
- + 327 +
+ +if l_refresh_needed then
- +
+--limit the list to objects that exist and are visible to the invoking user
- -
-- - 34 -
+a_listener.fire_after_event(ut_utils.gc_suite,self);
--enrich the list by info about cache validity
+ +- + 29 +
+execute immediate
- -
-- - 34 -
+return l_completed_without_errors;
'select /*+ cardinality(i '||ut_utils.scale_cardinality(cardinality(l_cached_objects))||') */
+ +- +
+'||l_ut_owner||q'[.ut_annotation_obj_cache_info(
- -
+end;
object_owner => o.owner,
+- -
+object_name => o.object_name,
+- -
+overriding member procedure calc_execution_result(self in out nocopy ut_logical_suite) is
object_type => o.object_type,
+- -
+l_result integer(1);
needs_refresh => 'Y',
+- -
-begin
- - 132 -
-if self.items is not null and self.items.count > 0 then
- - 391 -
-for i in 1 .. self.items.count loop
- - 259 -
+self.results_count.sum_counter_values( self.items(i).results_count );
parse_time => c.parse_time
+ +- +
+ +)
- +
+ +from ]'||l_objects_view||' o
- +
+left join table( cast(:l_cached_objects as '||l_ut_owner||q'[.ut_annotation_objs_cache_info ) ) c
- -
-end loop;
- - 132 -
+l_result := self.results_count.result_status();
on o.owner = c.object_owner
+ +- +
+and o.object_name = c.object_name
- -
+else
and o.object_type = c.object_type
+- -
---if suite is empty then it's successful (no errors)
- -
+l_result := ut_utils.tr_success;
where o.owner = ']'||ut_utils.qualified_sql_name(a_object_owner)||q'['
+ +- +
+and o.object_type = ']'||ut_utils.qualified_sql_name(a_object_type)||q'['
- -
+end if;
and case when o.last_ddl_time < cast(c.parse_time as date) then 'N' else 'Y' end = 'Y'
+- -
-- - 132 -
-self.result := l_result;
- -
+end;
and ]'
+ +- + 1 +
+ +|| case
- + 1 +
+when a_modified_after is null
- -
+then ':a_modified_after is null'
+- -
+overriding member procedure mark_as_errored(self in out nocopy ut_logical_suite, a_listener in out nocopy ut_event_listener_base, a_error_stack_trace varchar2) is
else 'o.last_ddl_time >= cast(:a_modified_after as date)'
+- -
-begin
- -
-ut_utils.debug_log('ut_logical_suite.fail');
- -
-a_listener.fire_before_event(ut_utils.gc_suite, self);
- -
-self.start_time := current_timestamp;
- -
-for i in 1 .. self.items.count loop
- -
--- execute the item (test or suite)
- -
+self.items(i).mark_as_errored(a_listener, a_error_stack_trace);
end
+ +- +
+ +bulk collect into l_result using l_cached_objects, a_modified_after;
- +
+ +else
- + 298 +
+ +l_result := l_cached_objects;
- +
+ +end if;
- + 327 +
+ +ut_event_manager.trigger_event('get_objects_to_refresh - end (count='||l_result.count||')');
- + 327 +
+return l_result;
- -
-end loop;
- -
-self.calc_execution_result();
- -
-self.end_time := self.start_time;
- -
-a_listener.fire_after_event(ut_utils.gc_suite, self);
- -
end;
- + +
- + +
- +
+ +function get_sources_to_annotate(a_object_owner varchar2, a_object_type varchar2, a_objects_to_refresh ut_annotation_objs_cache_info) return sys_refcursor is
- +
+ +l_result sys_refcursor;
- + 85 +
+ +l_sources_view varchar2(200) := ut_metadata.get_source_view_name();
- +
+l_card natural;
- -
-overriding member function get_error_stack_traces return ut_varchar2_list is
- -
begin
- -
+ +return ut_varchar2_list();
- + 85 +
+ +l_card := ut_utils.scale_cardinality(cardinality(a_objects_to_refresh));
- + 85 +
+open l_result for
- -
+end;
q'[select x.name, x.text
+- -
+from (select /*+ cardinality( r ]'||l_card||q'[ )*/
+- -
+overriding member function get_serveroutputs return clob is
s.name, s.text, s.line,
+- -
-begin
- -
+return null;
max(case when s.text like '%--%\%%' escape '\'
+ +- +
+and regexp_like(s.text,'^\s*--\s*%')
- -
+end;
then 'Y' else 'N' end
+- -
+)
+- -
+overriding member function get_transaction_invalidators return ut_varchar2_list is
over(partition by s.name) is_annotated
+- -
+l_result ut_varchar2_list;
from table(:a_objects_to_refresh) r
+- -
+l_child_results ut_varchar2_list;
join ]'||l_sources_view||q'[ s
+- -
-begin
- - 2 -
-l_result := self.transaction_invalidators;
- - 5 -
-for i in 1 .. self.items.count loop
- - 3 -
-l_child_results := self.items(i).get_transaction_invalidators();
- - 9 -
-for j in 1 .. l_child_results.count loop
- - 6 -
-if l_child_results(j) not member of l_result then
- - 8 -
+l_result.extend; l_result(l_result.last) := l_child_results(j);
on s.name = r.object_name
+ +- +
+ +and s.owner = r.object_owner
- +
+ +and s.type = r.object_type
- +
+ +where s.owner = ']'||ut_utils.qualified_sql_name(a_object_owner)||q'['
- +
+ +and s.type = ']'||ut_utils.qualified_sql_name(a_object_type)||q'['
- +
+ +) x
- +
+where x.is_annotated = 'Y'
- -
+end if;
order by x.name, x.line]'
+- -
+end loop;
using a_objects_to_refresh;
+- -
-end loop;
- - 2 +
+ +- + 85
+return l_result;
- +
end;
- +
- -
end;
UT3.UT_OBJECT_NAME
100 % covered
8 relevant lines. 8 lines covered and 0 lines missed-
- -
-type body ut_object_name as
- -
-/*
- -
-utPLSQL - Version X.X.X.X
- -
-Copyright 2016 - 2017 utPLSQL Project
- -
-- -
-Licensed under the Apache License, Version 2.0 (the "License"):
- -
-you may not use this file except in compliance with the License.
- -
-You may obtain a copy of the License at
- -
-- -
-http://www.apache.org/licenses/LICENSE-2.0
- -
-- -
-Unless required by applicable law or agreed to in writing, software
- -
-distributed under the License is distributed on an "AS IS" BASIS,
- -
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- -
-See the License for the specific language governing permissions and
- -
-limitations under the License.
- -
-*/
- -
-constructor function ut_object_name(self in out nocopy ut_object_name, owner varchar2, name varchar2) return self as result is
- -
-begin
- - 432 -
-self.owner := upper(owner);
- - 432 -
-self.name := upper(name);
- - 432 -
-return;
- -
-end;
- -
-- -
-constructor function ut_object_name(self in out nocopy ut_object_name, a_unit_name varchar2) return self as result is
- -
-begin
- - 1 -
-self.owner := upper(regexp_substr(a_unit_name,'[^\.]+', 1, 1));
- - 1 -
-self.name := upper(regexp_substr(a_unit_name,'[^\.]+', 1, 2));
- - 1 -
-return;
- +
+ +procedure build_annot_cache_for_sources(
- +
+ +a_object_owner varchar2,
- +
+ +a_object_type varchar2,
- +
+ +a_sources_cursor sys_refcursor
- +
+ +) is
- +
+ +l_annotations ut_annotations;
- + 216 +
+ +c_lines_fetch_limit constant integer := 10000;
- +
+ +l_lines dbms_preprocessor.source_lines_t;
- +
+ +l_names dbms_preprocessor.source_lines_t;
- +
+ +l_name varchar2(250);
- +
+ +l_object_lines dbms_preprocessor.source_lines_t;
- + 216 +
+ +l_parse_time date := sysdate;
- +
+ +pragma autonomous_transaction;
- +
+ +begin
- + 216 +
+ +loop
- + 216 +
+ +fetch a_sources_cursor bulk collect into l_names, l_lines limit c_lines_fetch_limit;
- + 16196 +
+ +for i in 1 .. l_names.count loop
- + 15980 +
+ +if l_names(i) != l_name then
- + 211 +
+ +l_annotations := ut_annotation_parser.parse_object_annotations(l_object_lines, a_object_type);
- + 211 +
+ +ut_annotation_cache_manager.update_cache(
- +
+ +ut_annotated_object(a_object_owner, l_name, a_object_type, l_parse_time, l_annotations)
- +
+ +);
- + 211 +
+ +l_object_lines.delete;
- +
+ +end if;
- +
+ +- + 15980 +
+ +l_name := l_names(i);
- + 15980 +
+ +l_object_lines(l_object_lines.count+1) := l_lines(i);
- +
+ +end loop;
- + 216 +
+ +exit when a_sources_cursor%notfound;
- +
+ +- +
+ +end loop;
- + 216 +
+ +if a_sources_cursor%rowcount > 0 then
- + 204 +
+ +l_annotations := ut_annotation_parser.parse_object_annotations(l_object_lines, a_object_type);
- + 204 +
+ +ut_annotation_cache_manager.update_cache(
- +
+ +ut_annotated_object(a_object_owner, l_name, a_object_type, l_parse_time, l_annotations)
- +
+ +);
- + 204 +
+ +l_object_lines.delete;
- +
+ +end if;
- + 216 +
+ +close a_sources_cursor;
- -
end;
- + +
- -
- + +
- -
- - 1 -
-map member function identity return varchar2 is
- + +
- +
+ +procedure validate_annotation_cache(
- +
+ +a_object_owner varchar2,
- +
+ +a_object_type varchar2,
- +
+ +a_modified_after timestamp := null
- +
+ +) is
- +
+ +l_objects_to_refresh ut_annotation_objs_cache_info;
- + 327 +
+ +l_modified_after timestamp := a_modified_after;
- -
begin
- - 1353 -
-return owner||'.'||name;
- -
-end;
- -
end;
UT3.UT_REPORTER_BASE
100 % covered
29 relevant lines. 29 lines covered and 0 lines missed-
- -
-type body ut_reporter_base is
- -
-/*
- -
-utPLSQL - Version X.X.X.X
- -
-Copyright 2016 - 2017 utPLSQL Project
- + +
- + 327 +
+ +if ut_annotation_cache_manager.get_cache_schema_info(a_object_owner, a_object_type).full_refresh_time is null then
- + 10 +
+ +l_modified_after := null;
- +
+ +end if;
- -
- -
-Licensed under the Apache License, Version 2.0 (the "License"):
- -
-you may not use this file except in compliance with the License.
- -
-You may obtain a copy of the License at
- + +
- + 327 +
+ +l_objects_to_refresh := get_objects_to_refresh(a_object_owner, a_object_type, l_modified_after);
- -
- -
-http://www.apache.org/licenses/LICENSE-2.0
- + +
- + 327 +
+ +ut_event_manager.trigger_event('validate_annotation_cache - start (l_objects_to_refresh.count = '||l_objects_to_refresh.count||')');
- -
- -
-Unless required by applicable law or agreed to in writing, software
- -
-distributed under the License is distributed on an "AS IS" BASIS,
- -
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- -
-See the License for the specific language governing permissions and
- -
-limitations under the License.
- -
-*/
- + +
- -
- -
-final member procedure init(self in out nocopy ut_reporter_base, a_self_type varchar2) is
- -
-begin
- - 55 -
-self.self_type := a_self_type;
- - 55 -
-self.reporter_id := sys_guid();
- - 55 -
-self.start_date := sysdate();
- - 55 -
-return;
- -
-end;
- + +
- + 327 +
+ +if user_can_see_whole_schema( a_object_owner ) then
- +
+ +--Remove non existing objects from cache only when user can see whole schema
- + 265 +
+ +ut_annotation_cache_manager.remove_from_cache( get_non_existing_objects( a_object_owner, a_object_type ) );
- +
+ +end if;
- -
- -
-member procedure print_text(self in out nocopy ut_reporter_base, a_text varchar2) is
- -
-begin
- - 45615 -
-ut_output_buffer.send_line(self,a_text);
- -
-end;
- + +
- +
+ +--if some source needs parsing and putting into cache
- + 327 +
+ +if l_objects_to_refresh.count > 0 then
- +
+ +--Delete annotations for objects that are to be refreshed
- + 85 +
+ +ut_annotation_cache_manager.reset_objects_cache(l_objects_to_refresh);
- +
+ +--Rebuild cache from objects source
- + 85 +
+ +build_annot_cache_for_sources(
- +
+ +a_object_owner, a_object_type,
- +
+ +get_sources_to_annotate(a_object_owner, a_object_type, l_objects_to_refresh)
- +
+ +);
- +
+ +end if;
- -
- -
-member procedure print_clob(self in out nocopy ut_reporter_base, a_clob clob) is
- -
-l_lines ut_varchar2_list;
- -
-begin
- - 166 -
-if a_clob is not null and dbms_lob.getlength(a_clob) > 0 then
- - 54 -
-l_lines := ut_utils.clob_to_table(a_clob);
- - 44825 -
-for i in 1 .. l_lines.count loop
- - 44771 -
-self.print_text(l_lines(i));
- -
-end loop;
- + +
- + 327 +
+ +if l_modified_after is null then
- + 18 +
+ +if user_can_see_whole_schema( a_object_owner ) then
- + 13 +
+ +ut_annotation_cache_manager.set_fully_refreshed( a_object_owner, a_object_type );
- +
+ +else
- +
+ +-- if user cannot see full schema - we dont mark it as fully refreshed
- +
+ +-- it will get refreshed each time until someone with proper privs will refresh it
- + 5 +
+ +null;
- +
+ +end if;
- -
end if;
- + +
- + 327 +
+ +ut_event_manager.trigger_event('validate_annotation_cache - end');
- -
end;
- + +
- -
- -
--- run hooks
- -
-member procedure before_calling_run(self in out nocopy ut_reporter_base, a_run in ut_run) is
- -
-begin
- - 42 -
-null;
- -
-end;
- -
-- -
--- suite hooks
- -
-member procedure before_calling_suite(self in out nocopy ut_reporter_base, a_suite in ut_logical_suite) is
- + +
- +
+ +------------------------------------------------------------
- +
+ +--public definitions
- +
+ +------------------------------------------------------------
- +
+ +procedure rebuild_annotation_cache(a_object_owner varchar2, a_object_type varchar2) is
- -
begin
- - 16 -
-null;
- + +
- + 10 +
+ +validate_annotation_cache( a_object_owner, a_object_type );
- -
end;
- + +
- -
- -
-member procedure before_calling_before_all(self in out nocopy ut_reporter_base, a_suite in ut_logical_suite) is
- -
-begin
- - 20 -
-null;
- -
-end;
- -
-member procedure after_calling_before_all (self in out nocopy ut_reporter_base, a_suite in ut_logical_suite) is
- -
-begin
- - 9 -
-null;
- -
-end;
- + +
- +
+ +procedure trigger_obj_annotation_rebuild is
- +
+ +l_sql_text ora_name_list_t;
- +
+ +l_parts binary_integer;
- +
+ +l_restricted_users ora_name_list_t;
- -
- -
-member procedure before_calling_before_each(self in out nocopy ut_reporter_base, a_suite in ut_test) is
- -
-begin
- + +
- +
+ +function get_source_from_sql_text(a_object_name varchar2, a_sql_text ora_name_list_t, a_parts binary_integer) return sys_refcursor is
- +
+ +l_sql_clob clob;
- 128 -
-null;
- -
-end;
- -
-member procedure after_calling_before_each (self in out nocopy ut_reporter_base, a_suite in ut_test) is
- -
-begin
- +
+ +l_sql_lines ut_varchar2_rows := ut_varchar2_rows();
- +
+ +l_result sys_refcursor;
- +
+ +begin
- 128 -
-null;
- -
-end;
- +
+ +if a_parts > 0 then
- + 747 +
+ +for i in 1..a_parts loop
- + 619 +
+ +ut_utils.append_to_clob(l_sql_clob, a_sql_text(i));
- +
+ +end loop;
- + 128 +
+ +l_sql_clob := ut_utils.replace_multiline_comments(l_sql_clob);
- +
+ +-- replace comment lines that contain "-- create or replace"
- + 128 +
+ +l_sql_clob := regexp_replace(l_sql_clob, '^.*[-]{2,}\s*create(\s+or\s+replace).*$', modifier => 'mi');
- +
+ +-- remove the "create [or replace] [[non]editionable] " so that we have only "type|package" for parsing
- +
+ +-- needed for dbms_preprocessor
- + 128 +
+ +l_sql_clob := regexp_replace(l_sql_clob, '^(.*?\s*create(\s+or\s+replace)?(\s+(editionable|noneditionable))?\s+?)((package|type).*)', '\5', 1, 1, 'ni');
- + 128 +
+ +l_sql_lines := ut_utils.convert_collection( ut_utils.clob_to_table(l_sql_clob) );
- +
+ +end if;
- + 128 +
+ +open l_result for
- +
+ +select a_object_name as name, column_value||chr(10) as text from table(l_sql_lines);
- + 128 +
+ +return l_result;
- +
+ +end;
- -
- -
--- test hooks
- -
-member procedure before_calling_test(self in out nocopy ut_reporter_base, a_test in ut_test) is
- -
-begin
- - 161 -
-null;
- -
-end;
- + +
- +
+ +function get_source_for_object(a_object_owner varchar2, a_object_name varchar2, a_object_type varchar2) return sys_refcursor is
- +
+ +l_result sys_refcursor;
- + 3 +
+ +l_sources_view varchar2(200) := ut_metadata.get_source_view_name();
- +
+ +begin
- + 3 +
+ +open l_result for
- +
+ +q'[select :a_object_name, s.text
- +
+ +from ]'||l_sources_view||q'[ s
- +
+ +where s.type = :a_object_type
- +
+ +and s.owner = :a_object_owner
- +
+ +and s.name = :a_object_name
- +
+ +order by s.line]'
- +
+ +using a_object_name, a_object_type, a_object_owner, a_object_name;
- + 3 +
+ +return l_result;
- +
+ +end;
- -
- -
-member procedure before_calling_before_test(self in out nocopy ut_reporter_base, a_test in ut_test) is
- -
-begin
- - 57 -
-null;
- -
-end;
- -
-member procedure after_calling_before_test (self in out nocopy ut_reporter_base, a_test in ut_test) is
- + +
- -
begin
- - 57 -
-null;
- + +
- + 254 +
+ +if ora_dict_obj_type in ('PACKAGE','PROCEDURE','FUNCTION','TYPE') then
- +
+ +$if dbms_db_version.version < 12 $then
- +
+ +l_restricted_users := ora_name_list_t(
- +
+ +'ANONYMOUS','APPQOSSYS','AUDSYS','DBSFWUSER','DBSNMP','DIP','GGSYS','GSMADMIN_INTERNAL',
- +
+ +'GSMCATUSER','GSMUSER','ORACLE_OCM','OUTLN','REMOTE_SCHEDULER_AGENT','SYS','SYS$UMF',
- +
+ +'SYSBACKUP','SYSDG','SYSKM','SYSRAC','SYSTEM','WMSYS','XDB','XS$NULL');
- +
+ +$else
- + 254 +
+ +select username bulk collect into l_restricted_users
- +
+ +from all_users where oracle_maintained = 'Y';
- +
+ +$end
- + 254 +
+ +if ora_dict_obj_owner member of l_restricted_users then
- +
+ +return;
- +
+ +end if;
- +
+ +- + 254 +
+ +if ora_sysevent = 'CREATE' then
- + 128 +
+ +l_parts := ORA_SQL_TXT(l_sql_text);
- + 128 +
+ +build_annot_cache_for_sources(
- +
+ +ora_dict_obj_owner, ora_dict_obj_type,
- +
+ +get_source_from_sql_text(ora_dict_obj_name, l_sql_text, l_parts)
- +
+ +);
- + 126 +
+ +elsif ora_sysevent = 'ALTER' then
- + 3 +
+ +build_annot_cache_for_sources(
- +
+ +ora_dict_obj_owner, ora_dict_obj_type,
- +
+ +get_source_for_object(ora_dict_obj_owner, ora_dict_obj_name, ora_dict_obj_type)
- +
+ +);
- + 123 +
+ +elsif ora_sysevent = 'DROP' then
- + 123 +
+ +ut_annotation_cache_manager.remove_from_cache(
- +
+ +ut_annotation_objs_cache_info(
- +
+ +ut_annotation_obj_cache_info(ora_dict_obj_owner, ora_dict_obj_name, ora_dict_obj_type, 'Y', null)
- +
+ +)
- +
+ +);
- +
+ +end if;
- +
+ +end if;
- -
end;
- + +
- -
- -
-member procedure before_calling_test_execute(self in out nocopy ut_reporter_base, a_test in ut_test) is
- + +
- +
+ +function get_annotated_objects(a_object_owner varchar2, a_object_type varchar2, a_modified_after timestamp) return sys_refcursor is
- +
+ +l_cursor sys_refcursor;
- -
begin
- - 155 -
-null;
- -
-end;
- -
-member procedure after_calling_test_execute (self in out nocopy ut_reporter_base, a_test in ut_test) is
- -
-begin
- - 155 -
-null;
- -
-end;
- -
-- -
-member procedure before_calling_after_test(self in out nocopy ut_reporter_base, a_test in ut_test) is
- -
-begin
- - 57 -
-null;
- -
-end;
- -
-member procedure after_calling_after_test (self in out nocopy ut_reporter_base, a_test in ut_test) is
- -
-begin
- - 57 -
-null;
- -
-end;
- -
-- -
-member procedure after_calling_test(self in out nocopy ut_reporter_base, a_test in ut_test) is
- -
-begin
- - 20 -
-null;
- -
-end;
- -
-- -
---suite hooks continued
- -
-member procedure before_calling_after_each(self in out nocopy ut_reporter_base, a_suite in ut_test) is
- -
-begin
- - 128 -
-null;
- -
-end;
- -
-member procedure after_calling_after_each (self in out nocopy ut_reporter_base, a_suite in ut_test) is
- -
-begin
- - 128 -
-null;
- -
-end;
- -
-- -
-member procedure before_calling_after_all(self in out nocopy ut_reporter_base, a_suite in ut_logical_suite) is
- -
-begin
- - 18 -
-null;
- -
-end;
- -
-member procedure after_calling_after_all (self in out nocopy ut_reporter_base, a_suite in ut_logical_suite) is
- -
-begin
- - 9 -
-null;
- -
-end;
- + +
- + 317 +
+ +ut_event_manager.trigger_event('get_annotated_objects - start: a_modified_after='||ut_utils.to_string(a_modified_after));
- + 317 +
+ +validate_annotation_cache(a_object_owner, a_object_type, a_modified_after);
- -
- -
-member procedure after_calling_suite(self in out nocopy ut_reporter_base, a_suite in ut_logical_suite) is
- -
-begin
- - 16 -
-null;
- + +
- +
+ +--pipe annotations from cache
- + 317 +
+ +l_cursor := ut_annotation_cache_manager.get_annotations_parsed_since(a_object_owner, a_object_type, a_modified_after);
- + 317 +
+ +ut_event_manager.trigger_event('get_annotated_objects - end');
- + 317 +
+ +return l_cursor;
- -
end;
- + +
- -
- -
--- run hooks continued
- -
-member procedure after_calling_run (self in out nocopy ut_reporter_base, a_run in ut_run) is
- + +
- +
+ +procedure purge_cache(a_object_owner varchar2, a_object_type varchar2) is
- -
begin
- - 42 -
-ut_output_buffer.close(self);
- + +
- + 2 +
+ +ut_annotation_cache_manager.purge_cache(a_object_owner, a_object_type);
- -
end;
- + +
- -
- -
end;
+UT3.UT_RESULTS_COUNTER
100 % covered
26 relevant lines. 26 lines covered and 0 lines missed+ +
- +
+end;
UT3.UT_ANNOTATION_PARSER
97.26 % lines covered
73 relevant lines. 71 lines covered and 2 lines missed+
- -
+type body ut_results_counter as
package body ut_annotation_parser as
+- +
/*
- -
+utPLSQL - Version X.X.X.X
utPLSQL - Version 3
+- -
+Copyright 2016 - 2017 utPLSQL Project
Copyright 2016 - 2019 utPLSQL Project
+- +
- +
Licensed under the Apache License, Version 2.0 (the "License"):
- +
you may not use this file except in compliance with the License.
- +
You may obtain a copy of the License at
- +
- +
http://www.apache.org/licenses/LICENSE-2.0
- +
- +
Unless required by applicable law or agreed to in writing, software
- +
distributed under the License is distributed on an "AS IS" BASIS,
- +
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
See the License for the specific language governing permissions and
- +
limitations under the License.
- +
*/
- -
+constructor function ut_results_counter(self in out nocopy ut_results_counter) return self as result is
+
- -
-begin
- - 1188 -
-self.disabled_count := 0;
- - 1188 -
-self.success_count := 0;
- - 1188 -
-self.failure_count := 0;
- - 1188 -
-self.errored_count := 0;
- - 1188 -
-self.warnings_count := 0;
- - 1188 -
-return;
- -
-end;
- +
+ +------------------------------
- +
+ +--private definitions
- -
- -
-member procedure set_counter_values(self in out nocopy ut_results_counter, a_status integer) is
- -
-begin
- - 231 -
-self.disabled_count := case when a_status = ut_utils.tr_disabled then 1 else 0 end;
- - 231 -
-self.success_count := case when a_status = ut_utils.tr_success then 1 else 0 end;
- - 231 -
-self.failure_count := case when a_status = ut_utils.tr_failure then 1 else 0 end;
- - 231 -
+ +self.errored_count := case when a_status = ut_utils.tr_error then 1 else 0 end;
- +
+ +type tt_comment_list is table of varchar2(32767) index by binary_integer;
- +
+ +- + 1 +
+ +gc_annotation_qualifier constant varchar2(1) := '%';
- + 1 +
+ +gc_annot_comment_pattern constant varchar2(30) := '^( |'||chr(09)||')*-- *('||gc_annotation_qualifier||'.*?)$'; -- chr(09) is a tab character
- + 1 +
+ +gc_comment_replacer_patter constant varchar2(50) := '{COMMENT#%N%}';
- + 1 +
+ +gc_comment_replacer_regex_ptrn constant varchar2(25) := '{COMMENT#(\d+)}';
- + 1 +
+ +gc_regexp_identifier constant varchar2(50) := '[a-zA-Z][a-zA-Z0-9#_$]*';
- + 1 +
+ +gc_annotation_block_pattern constant varchar2(200) := '(({COMMENT#.+}'||chr(10)||')+)( |'||chr(09)||')*(procedure|function)\s+(' ||
- +
+ +gc_regexp_identifier || ')';
- + 1 +
+ +gc_annotation_pattern constant varchar2(50) := gc_annotation_qualifier || gc_regexp_identifier || '[ '||chr(9)||']*(\(.*?\)\s*?$)?';
- +
+ +- +
+- -
+end;
procedure add_annotation(
+- -
+a_annotations in out nocopy ut_annotations,
+- -
+member procedure sum_counter_values(self in out nocopy ut_results_counter, a_item ut_results_counter) is
a_position positiven,
+- -
-begin
- - 334 -
-self.disabled_count := self.disabled_count + a_item.disabled_count;
- - 334 -
-self.success_count := self.success_count + a_item.success_count;
- - 334 -
-self.failure_count := self.failure_count + a_item.failure_count;
- - 334 -
-self.errored_count := self.errored_count + a_item.errored_count;
- - 334 -
+self.warnings_count := self.warnings_count + a_item.warnings_count;
a_comment varchar2,
+ +- +
+ +a_subobject_name varchar2 := null
- +
+ +) is
- +
+ +l_annotation_str varchar2(32767);
- +
+ +l_annotation_text varchar2(32767);
- +
+l_annotation_name varchar2(1000);
- -
+end;
begin
+- +
+ +-- strip everything except the annotation itself (spaces and others)
- + 6031 +
+ +l_annotation_str := regexp_substr(a_comment, gc_annotation_pattern, 1, 1, modifier => 'i');
- + 6031 +
+ +if l_annotation_str is not null then
- -
- -
-member procedure increase_warning_count(self in out nocopy ut_results_counter) is
- -
-begin
- - 6 -
+self.warnings_count := self.warnings_count + 1;
- -
-end;
- -
-- -
+member function total_count return integer is
-- get the annotation name and it's parameters if present
+ +- + 6031 +
+ +l_annotation_name := lower(regexp_substr(l_annotation_str ,'%(' || gc_regexp_identifier || ')', subexpression => 1));
- + 6031 +
+l_annotation_text := trim(regexp_substr(l_annotation_str, '\((.*?)\)\s*$', subexpression => 1));
- -
-begin
- -
---skip warnings here
- - 27 -
+return self.disabled_count + self.success_count + self.failure_count + self.errored_count;
+ +
- + 6031 +
+ +a_annotations.extend;
- + 6031 +
+a_annotations( a_annotations.last) :=
- -
+end;
ut_annotation(a_position, l_annotation_name, l_annotation_text, a_subobject_name);
+- -
-- -
-member function result_status return integer is
- -
-l_result integer;
- -
-begin
- - 179 -
-if self.errored_count > 0 then
- - 50 -
-l_result := ut_utils.tr_error;
- - 129 -
-elsif self.failure_count > 0 then
- - 8 -
-l_result := ut_utils.tr_failure;
- - 121 -
-elsif self.success_count > 0 then
- - 118 -
-l_result := ut_utils.tr_success;
- - 3 -
-elsif self.disabled_count > 0 then
- - 3 -
-l_result := ut_utils.tr_disabled;
- -
-else
- -
-l_result := ut_utils.tr_error;
- -
end if;
- - 179 -
-return l_result;
- -
-end;
- -
-- -
end;
UT3.UT_RUN
53.85 % covered
52 relevant lines. 28 lines covered and 24 lines missed-
- -
-type body ut_run as
- -
-/*
- -
-utPLSQL - Version X.X.X.X
- -
-Copyright 2016 - 2017 utPLSQL Project
- -
-- -
-Licensed under the Apache License, Version 2.0 (the "License"):
- -
-you may not use this file except in compliance with the License.
- -
-You may obtain a copy of the License at
- -
-- -
-http://www.apache.org/licenses/LICENSE-2.0
- -
-- -
-Unless required by applicable law or agreed to in writing, software
- -
-distributed under the License is distributed on an "AS IS" BASIS,
- -
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- -
-See the License for the specific language governing permissions and
- -
-limitations under the License.
- -
-*/
- -
-- -
-constructor function ut_run(
- -
-self in out nocopy ut_run,
- -
-a_items ut_suite_items,
- -
-a_run_paths ut_varchar2_list := null,
- -
-a_schema_names ut_varchar2_rows := null,
- -
-a_exclude_objects ut_object_names := null,
- -
-a_include_objects ut_object_names := null,
- -
-a_project_file_mappings ut_file_mappings := null,
- -
-a_test_file_mappings ut_file_mappings := null
- -
-) return self as result is
- -
-l_coverage_schema_names ut_varchar2_rows;
- -
-l_coverage_options ut_coverage_options;
- -
-l_exclude_objects ut_object_names;
- -
-begin
- - 48 -
-l_coverage_schema_names := coalesce(a_schema_names, get_run_schemes());
- - 48 -
-l_exclude_objects := coalesce(a_exclude_objects,ut_object_names());
- -
-- - 48 -
-self.run_paths := a_run_paths;
- - 48 -
-self.self_type := $$plsql_unit;
- - 48 -
-self.items := a_items;
- - 48 -
-self.results_count := ut_results_counter();
- - 48 -
-self.test_file_mappings := coalesce(a_test_file_mappings, ut_file_mappings());
- - 48 -
-self.coverage_options := ut_coverage_options(
- -
-l_coverage_schema_names,
- -
-l_exclude_objects multiset union all ut_suite_manager.get_schema_ut_packages(l_coverage_schema_names),
- -
-a_include_objects,
- -
-a_project_file_mappings
- -
-);
- - 48 -
-return;
- -
-end;
- -
-- -
-overriding member function do_execute(self in out nocopy ut_run, a_listener in out nocopy ut_event_listener_base) return boolean is
- -
-l_completed_without_errors boolean;
- -
-begin
- - 47 -
-ut_utils.debug_log('ut_run.execute');
- -
-- - 47 -
+a_listener.fire_before_event(ut_utils.gc_run, self);
- +
+ +end;
- -
- - 47 -
+self.start_time := current_timestamp;
- -
-- -
--- clear anything that might stay in the session's cache
- - 94 -
-ut_expectation_processor.clear_expectations;
- -
-- - 122 -
-for i in 1 .. self.items.count loop
- - 75 -
-l_completed_without_errors := self.items(i).do_execute(a_listener);
- -
+end loop;
procedure delete_processed_comments( a_comments in out nocopy tt_comment_list, a_annotations ut_annotations ) is
+ +- + 429 +
+ +l_loop_index binary_integer := 1;
- +
+ +begin
- + 429 +
+ +l_loop_index := a_annotations.first;
- + 4929 +
+ +while l_loop_index is not null loop
- + 4500 +
+ +a_comments.delete( a_annotations(l_loop_index).position );
- + 4500 +
+l_loop_index := a_annotations.next( l_loop_index );
- -
-- - 47 -
+self.calc_execution_result();
end loop;
+ +- +
+end;
- -
- - 47 -
+ +self.end_time := current_timestamp;
- +
+procedure add_annotations(
- -
-- - 47 -
+a_listener.fire_after_event(ut_utils.gc_run, self);
a_annotations in out nocopy ut_annotations,
+ +- +
+a_source varchar2,
- -
-- - 47 -
+return l_completed_without_errors;
a_comments tt_comment_list,
+ +- +
+a_subobject_name varchar2 := null
- -
-end;
- -
+) is
+ +- + 3705 +
+l_loop_index binary_integer := 1;
- -
+overriding member procedure calc_execution_result(self in out nocopy ut_run) is
l_annotation_index binary_integer;
+- -
-l_result integer(1);
- -
begin
- - 47 -
-if self.items is not null and self.items.count > 0 then
- - 122 -
-for i in 1 .. self.items.count loop
- - 75 -
+ +self.results_count.sum_counter_values( self.items(i).results_count );
- +
+ +-- loop while there are unprocessed comment blocks
- + 8205 +
+ +while 0 != nvl(regexp_instr(srcstr => a_source
- +
+ +,pattern => gc_comment_replacer_regex_ptrn
- +
+,occurrence => l_loop_index
- -
-end loop;
- - 47 -
+l_result := self.results_count.result_status();
,subexpression => 1)
+ +- +
+,0) loop
- -
-else
- -
---if suite is empty then it's successful (no errors)
- -
-l_result := ut_utils.tr_success;
- -
-end if;
- -
- - 47 -
+ +self.result := l_result;
- +
+ +-- define index of the comment block and get it's content from cache
- + 4500 +
+ +l_annotation_index := regexp_substr( a_source ,gc_comment_replacer_regex_ptrn ,1 ,l_loop_index ,subexpression => 1);
- + 4500 +
+ +add_annotation( a_annotations, l_annotation_index, a_comments( l_annotation_index ), a_subobject_name );
- + 4500 +
+ +l_loop_index := l_loop_index + 1;
- +
+end loop;
- -
-end;
- + +
- +
+end add_annotations;
- -
+overriding member procedure mark_as_errored(self in out nocopy ut_run, a_listener in out nocopy ut_event_listener_base, a_error_stack_trace varchar2) is
+
- -
-begin
- -
+ut_utils.debug_log('ut_run.fail');
procedure add_procedure_annotations(a_annotations in out nocopy ut_annotations, a_source clob, a_comments in out nocopy tt_comment_list) is
+ +- +
+l_proc_comments varchar2(32767);
- -
-- -
-a_listener.fire_before_event(ut_utils.gc_run, self);
- -
+self.start_time := current_timestamp;
l_proc_name varchar2(250);
+ +- +
+ +l_annot_proc_ind number;
- +
+l_annot_proc_block varchar2(32767);
- -
-- -
-for i in 1 .. self.items.count loop
- -
-self.items(i).mark_as_errored(a_listener, a_error_stack_trace);
- -
+end loop;
begin
+ +- +
+ +-- loop through procedures and functions of the package and get all the comment blocks just before it's declaration
- + 429 +
+ +l_annot_proc_ind := 1;
- + 4134 +
+loop
- -
-- -
-self.calc_execution_result();
- -
+self.end_time := self.start_time;
--find annotated procedure index
+ +- + 4134 +
+ +l_annot_proc_ind := regexp_instr(srcstr => a_source
- +
+,pattern => gc_annotation_block_pattern
- -
-- -
+a_listener.fire_after_event(ut_utils.gc_run, self);
,occurrence => 1
+ +- +
+,modifier => 'i'
- -
-end;
- -
+,position => l_annot_proc_ind);
+ +- + 4134 +
+exit when l_annot_proc_ind = 0;
- -
+member function get_run_schemes return ut_varchar2_rows is
+
- -
-l_schema varchar2(128);
- - 47 -
+c_current_schema constant varchar2(128) := sys_context('USERENV','CURRENT_SCHEMA');
--get the annotations with procedure name
+ +- + 3705 +
+l_annot_proc_block := regexp_substr(srcstr => a_source
- -
+l_path varchar2(32767);
,pattern => gc_annotation_block_pattern
+- -
+l_schemes ut_varchar2_rows;
,position => l_annot_proc_ind
+- -
-begin
- - 47 -
-if run_paths is not null then
- -
-l_schemes := ut_varchar2_rows();
- -
-for i in 1 .. self.run_paths.count loop
- -
-l_path := self.run_paths(i);
- -
-if regexp_like(l_path, '^([A-Za-z0-9$#_]+)?:') then
- -
-l_schema := regexp_substr(l_path, '^([A-Za-z0-9$#_]+)?:',subexpression => 1);
- -
-if l_schema is not null then
- -
-l_schema := sys.dbms_assert.schema_name(upper(l_schema));
- -
-else
- -
+l_schema := c_current_schema;
,occurrence => 1
+ +- +
+ +,modifier => 'i');
- +
+ +- +
+ +--extract the annotations
- + 3705 +
+ +l_proc_comments := trim(regexp_substr(srcstr => l_annot_proc_block
- +
+ +,pattern => gc_annotation_block_pattern
- +
+ +,modifier => 'i'
- +
+ +,subexpression => 1));
- +
+ +--extract the procedure name
- + 3705 +
+ +l_proc_name := trim(regexp_substr(srcstr => l_annot_proc_block
- +
+,pattern => gc_annotation_block_pattern
- -
+end if;
,modifier => 'i'
+- -
+else
,subexpression => 5));
+- -
-begin
- -
-l_schema := sys.dbms_assert.schema_name(upper(regexp_substr(l_path, '^[A-Za-z0-9$#_]+')));
- -
-exception
- -
-when sys.dbms_assert.invalid_schema_name then
- -
+l_schema := c_current_schema;
+ +
- +
+ +-- parse the comment block for the syntactically correct annotations and store them as an array
- + 3705 +
+ +add_annotations(a_annotations, l_proc_comments, a_comments, l_proc_name);
- +
+ +- + 3705 +
+l_annot_proc_ind := instr(a_source, ';', l_annot_proc_ind + length(l_annot_proc_block) );
- -
+end;
end loop;
+- -
+end add_procedure_annotations;
+- -
-end if;
- -
-l_schemes.extend;
- -
+l_schemes(l_schemes.last) := l_schema;
+ +
- +
+ +function extract_and_replace_comments(a_source in out nocopy clob) return tt_comment_list is
- +
+l_comments tt_comment_list;
- -
+end loop;
l_comment_pos binary_integer;
+- -
-else
- - 47 -
-l_schemes := ut_varchar2_rows(c_current_schema);
- -
-end if;
- - 47 -
-return l_schemes;
- -
-- -
+end;
l_comment_line binary_integer;
+ +- +
+ +l_comment_replacer varchar2(50);
- + 429 +
+ +l_source clob := a_source;
- +
+ +begin
- + 429 +
+ +l_comment_pos := 1;
- + 6460 +
+loop
- -
- -
+ +overriding member function get_error_stack_traces return ut_varchar2_list is
- + 6460 +
+l_comment_pos := regexp_instr(srcstr => a_source
- -
-begin
- -
+return ut_varchar2_list();
,pattern => gc_annot_comment_pattern
+ +- +
+,occurrence => 1
- -
+end;
,modifier => 'm'
+- -
+,position => l_comment_pos);
+- -
-overriding member function get_serveroutputs return clob is
- -
-begin
- -
+return null;
+ +
- + 6460 +
+ +exit when l_comment_pos = 0;
- +
+- -
+end;
-- position index is shifted by 1 because gc_annot_comment_pattern contains ^ as first sign
+- +
+ +-- but after instr index already points to the char on that line
- + 6031 +
+ +l_comment_pos := l_comment_pos-1;
- + 6031 +
+ +l_comment_line := length(substr(a_source,1,l_comment_pos))-length(replace(substr(a_source,1,l_comment_pos),chr(10)))+1;
- + 6031 +
+ +l_comments(l_comment_line) := trim(regexp_substr(srcstr => a_source
- +
+ +,pattern => gc_annot_comment_pattern
- +
+ +,occurrence => 1
- +
+ +,position => l_comment_pos
- +
+ +,modifier => 'm'
- +
+ +,subexpression => 2));
- -
- -
-- -
end;
UT3.UT_SUITE
88.1 % covered
42 relevant lines. 37 lines covered and 5 lines missed-
- -
-type body ut_suite as
- -
-/*
- -
-utPLSQL - Version X.X.X.X
- -
-Copyright 2016 - 2017 utPLSQL Project
- + +
- + 6031 +
+ +l_comment_replacer := replace(gc_comment_replacer_patter, '%N%', l_comment_line);
- -
- -
-Licensed under the Apache License, Version 2.0 (the "License"):
- -
-you may not use this file except in compliance with the License.
- -
-You may obtain a copy of the License at
- + +
- + 6031 +
+ +l_source := regexp_replace(srcstr => a_source
- +
+ +,pattern => gc_annot_comment_pattern
- +
+ +,replacestr => l_comment_replacer
- +
+ +,position => l_comment_pos
- +
+ +,occurrence => 1
- +
+ +,modifier => 'm');
- + 6031 +
+ +dbms_lob.freetemporary(a_source);
- + 6031 +
+ +a_source := l_source;
- + 6031 +
+ +dbms_lob.freetemporary(l_source);
- + 6031 +
+ +l_comment_pos := l_comment_pos + length(l_comment_replacer);
- -
- -
-http://www.apache.org/licenses/LICENSE-2.0
- + +
- +
+ +end loop;
- -
- -
-Unless required by applicable law or agreed to in writing, software
- -
-distributed under the License is distributed on an "AS IS" BASIS,
- -
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- -
-See the License for the specific language governing permissions and
- -
-limitations under the License.
- -
-*/
- + +
- + 429 +
+ +ut_utils.debug_log(a_source);
- + 429 +
+ +return l_comments;
- +
+ +end extract_and_replace_comments;
- -
- -
-constructor function ut_suite (
- -
-self in out nocopy ut_suite , a_object_owner varchar2 := null, a_object_name varchar2, a_name varchar2, a_path varchar2, a_description varchar2 := null,
- -
-a_rollback_type integer := null, a_disabled_flag boolean := false, a_before_all_proc_name varchar2 := null,
- -
-a_after_all_proc_name varchar2 := null
- -
-) return self as result is
- -
-begin
- - 320 -
-self.self_type := $$plsql_unit;
- - 320 -
-self.init(a_object_owner, a_object_name, a_name, a_description, a_path, a_rollback_type, a_disabled_flag);
- - 320 -
-self.before_all := ut_executable(self, a_before_all_proc_name, ut_utils.gc_before_all);
- - 320 -
-self.items := ut_suite_items();
- - 320 -
-self.after_all := ut_executable(self, a_after_all_proc_name, ut_utils.gc_after_all);
- - 320 -
-return;
- -
-end;
- + +
- +
+ +------------------------------------------------------------
- +
+ +--public definitions
- +
+ +------------------------------------------------------------
- -
- -
-overriding member function is_valid(self in out nocopy ut_suite) return boolean is
- -
-l_is_valid boolean;
- + +
- +
+ +function parse_object_annotations(a_source clob) return ut_annotations is
- + 429 +
+ +l_source clob := a_source;
- +
+ +l_comments tt_comment_list;
- + 429 +
+ +l_annotations ut_annotations := ut_annotations();
- +
+ +l_result ut_annotations;
- +
+ +l_comment_index positive;
- -
begin
- - 97 -
-l_is_valid :=
- - 1 -
-( not self.before_all.is_defined() or self.before_all.is_valid() ) and
- - 1 -
-( not self.after_all.is_defined() or self.after_all.is_valid() );
- - 97 -
-return l_is_valid;
- -
-end;
- + +
- -
- -
-overriding member function do_execute(self in out nocopy ut_suite, a_listener in out nocopy ut_event_listener_base) return boolean is
- -
-l_suite_savepoint varchar2(30);
- -
-l_item_savepoint varchar2(30);
- -
-l_suite_step_without_errors boolean;
- + +
- + 429 +
+ +l_source := ut_utils.replace_multiline_comments(l_source);
- -
- -
-procedure propagate_error(a_error_stack_trace varchar2) is
- -
-begin
- - 9 -
-for i in 1..self.items.count loop
- - 6 -
-self.items(i).mark_as_errored(a_listener, a_error_stack_trace);
- -
-end loop;
- -
-end;
- -
-begin
- - 98 -
-ut_utils.debug_log('ut_suite.execute');
- - 98 -
-a_listener.fire_before_event(ut_utils.gc_suite,self);
- + +
- +
+ +-- replace all single line comments with {COMMENT#12} element and store it's content for easier processing
- +
+ +-- this call modifies l_source
- + 429 +
+ +l_comments := extract_and_replace_comments(l_source);
- -
- - 98 -
-self.start_time := current_timestamp;
- + +
- + 429 +
+ +add_procedure_annotations(l_annotations, l_source, l_comments);
- -
- - 98 -
-if self.get_disabled_flag() then
- - 3 -
-for i in 1 .. self.items.count loop
- - 2 -
-self.items(i).do_execute(a_listener);
- -
-end loop;
- - 1 -
-ut_utils.debug_log('ut_suite.execute - disabled');
- -
-else
- + +
- + 429 +
+ +delete_processed_comments(l_comments, l_annotations);
- -
- - 97 -
-if self.is_valid() then
- + +
- +
+ +--at this point, only the comments not related to procedures are left, so we process them all as top-level
- + 429 +
+ +l_comment_index := l_comments.first;
- + 1960 +
+ +while l_comment_index is not null loop
- + 1531 +
+ +add_annotation( l_annotations, l_comment_index, l_comments( l_comment_index ) );
- + 1531 +
+ +l_comment_index := l_comments.next(l_comment_index);
- +
+ +end loop;
- -
- - 97 -
-l_suite_savepoint := self.create_savepoint_if_needed();
- + +
- + 429 +
+ +dbms_lob.freetemporary(l_source);
- -
- -
---includes listener calls for before and after actions
- - 97 -
-l_suite_step_without_errors := self.before_all.do_execute(self, a_listener);
- + +
- + 429 +
+ +select value(x) bulk collect into l_result from table(l_annotations) x order by x.position;
- -
- - 97 -
-if l_suite_step_without_errors then
- - 311 -
-for i in 1 .. self.items.count loop
- - 217 -
-self.items(i).do_execute(a_listener);
- -
-end loop;
- -
-else
- - 3 -
-propagate_error(self.before_all.get_error_stack_trace());
- -
-end if;
- + +
- + 429 +
+ +return l_result;
- +
+ +end parse_object_annotations;
- -
- - 97 -
-l_suite_step_without_errors := self.after_all.do_execute(self, a_listener);
- - 97 -
-if not l_suite_step_without_errors then
- - 1 -
-self.put_warning(self.after_all.get_error_stack_trace());
- + +
- +
+ +function parse_object_annotations(a_source_lines dbms_preprocessor.source_lines_t, a_object_type varchar2) return ut_annotations is
- +
+ +l_processed_lines dbms_preprocessor.source_lines_t;
- +
+ +l_source clob;
- + 416 +
+ +l_annotations ut_annotations := ut_annotations();
- +
+ +ex_package_is_wrapped exception;
- +
+ +pragma exception_init(ex_package_is_wrapped, -24241);
- +
+ +source_text_is_empty exception;
- +
+ +pragma exception_init(source_text_is_empty, -24236);
- +
+ +begin
- + 416 +
+ +if a_source_lines.count > 0 then
- +
+ +--convert to post-processed source clob
- +
+ +begin
- +
+ +--get post-processed source
- + 416 +
+ +if a_object_type = 'TYPE' then
- + 10 +
+ +l_processed_lines := a_source_lines;
- +
+ +else
- + 406 +
+ +l_processed_lines := sys.dbms_preprocessor.get_post_processed_source(a_source_lines);
- -
end if;
- -
-- - 97 -
-self.rollback_to_savepoint(l_suite_savepoint);
- -
-- -
-else
- -
-propagate_error(ut_utils.table_to_clob(self.get_error_stack_traces()));
- -
-end if;
- + +
- +
+ +--convert to clob
- + 16678 +
+ +for i in 1..l_processed_lines.count loop
- + 16262 +
+ +ut_utils.append_to_clob(l_source, replace(l_processed_lines(i), chr(13)||chr(10), chr(10)));
- +
+ +end loop;
- +
+ +--parse annotations
- + 416 +
+ +l_annotations := parse_object_annotations(l_source);
- + 416 +
+ +dbms_lob.freetemporary(l_source);
- +
+ +exception
- +
+ +when ex_package_is_wrapped or source_text_is_empty then
- +
+ +null;
- +
+ +end;
- -
end if;
- - 98 -
-self.calc_execution_result();
- - 98 -
-self.end_time := current_timestamp;
- - 98 -
-a_listener.fire_after_event(ut_utils.gc_suite,self);
- -
-- - 98 -
-return l_suite_step_without_errors;
- -
-end;
- -
-- -
-overriding member function get_error_stack_traces(self ut_suite) return ut_varchar2_list is
- -
-l_stack_traces ut_varchar2_list := ut_varchar2_list();
- -
-begin
- -
-ut_utils.append_to_varchar2_list(l_stack_traces, self.before_all.get_error_stack_trace());
- -
-ut_utils.append_to_varchar2_list(l_stack_traces, self.after_all.get_error_stack_trace());
- -
-return l_stack_traces;
- -
-end;
- -
-- -
-overriding member function get_serveroutputs return clob is
- -
-l_outputs clob;
- -
-begin
- - 1 -
-ut_utils.append_to_clob(l_outputs, self.before_all.serveroutput );
- - 1 -
-ut_utils.append_to_clob(l_outputs, self.after_all.serveroutput );
- - 1 -
-return l_outputs;
- + +
- + 416 +
+ +return l_annotations;
- -
end;
- + +
- -
- -
end;
+UT3.UT_SUITE_ITEM
96.67 % covered
30 relevant lines. 29 lines covered and 1 lines missed+ +
- +
+end;
UT3.UT_TRIGGER_CHECK
100 % lines covered
7 relevant lines. 7 lines covered and 0 lines missed+
- -
+type body ut_suite_item as
package body ut_trigger_check is
+- +
/*
- -
+utPLSQL - Version X.X.X.X
utPLSQL - Version 3
+- -
+Copyright 2016 - 2017 utPLSQL Project
Copyright 2016 - 2019 utPLSQL Project
+- +
- +
Licensed under the Apache License, Version 2.0 (the "License"):
- +
you may not use this file except in compliance with the License.
- +
You may obtain a copy of the License at
- +
- +
http://www.apache.org/licenses/LICENSE-2.0
- +
- +
Unless required by applicable law or agreed to in writing, software
- +
distributed under the License is distributed on an "AS IS" BASIS,
- +
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
See the License for the specific language governing permissions and
- +
limitations under the License.
- +
*/
- -
- -
-member procedure init(self in out nocopy ut_suite_item, a_object_owner varchar2, a_object_name varchar2, a_name varchar2, a_description varchar2, a_path varchar2, a_rollback_type integer, a_disabled_flag boolean) is
- -
-begin
- - 1140 -
-self.object_owner := a_object_owner;
- - 1140 -
-self.object_name := lower(trim(a_object_name));
- - 1140 -
-self.name := lower(trim(a_name));
- - 1140 -
-self.description := a_description;
- - 1140 -
-self.path := nvl(lower(trim(a_path)), self.object_name);
- - 1140 -
-self.rollback_type := a_rollback_type;
- - 1140 -
-self.disabled_flag := ut_utils.boolean_to_int(a_disabled_flag);
- - 1140 -
-self.results_count := ut_results_counter();
- - 1140 -
-self.warnings := ut_varchar2_list();
- - 1140 -
-self.transaction_invalidators := ut_varchar2_list();
- -
-end;
- -
-- -
-member procedure set_disabled_flag(self in out nocopy ut_suite_item, a_disabled_flag boolean) is
- -
-begin
- -
-self.disabled_flag := ut_utils.boolean_to_int(a_disabled_flag);
- -
-end;
- -
-- -
-member function get_disabled_flag return boolean is
- -
-begin
- - 323 -
-return ut_utils.int_to_boolean(self.disabled_flag);
- -
-end;
- -
-- -
-final member procedure do_execute(self in out nocopy ut_suite_item, a_listener in out nocopy ut_event_listener_base) is
- -
-l_completed_without_errors boolean;
- -
-begin
- - 329 -
-l_completed_without_errors := self.do_execute(a_listener);
- -
-end;
- -
-- -
-member function create_savepoint_if_needed return varchar2 is
- -
-l_savepoint varchar2(30);
- -
-begin
- - 280 -
-if self.rollback_type = ut_utils.gc_rollback_auto then
- - 260 -
-l_savepoint := ut_utils.gen_savepoint_name();
- - 260 -
-execute immediate 'savepoint ' || l_savepoint;
- -
-end if;
- - 280 -
-return l_savepoint;
- -
-end;
- -
-- -
-member procedure rollback_to_savepoint(self in out nocopy ut_suite_item, a_savepoint varchar2) is
- -
-ex_savepoint_not_exists exception;
- -
-pragma exception_init(ex_savepoint_not_exists, -1086);
- -
-begin
- - 280 -
-if self.rollback_type = ut_utils.gc_rollback_auto and a_savepoint is not null then
- - 260 -
-execute immediate 'rollback to ' || a_savepoint;
- -
-end if;
- -
-exception
- - 5 -
-when ex_savepoint_not_exists then
- - 5 -
-put_warning(
- -
-'Unable to perform automatic rollback after test'
- + +
- 1 -
-|| case when self_type like '%SUITE' then ' suite' end || '. '
- -
-||'An implicit or explicit commit/rollback occurred in procedures:'||chr(10)
- -
-||lower(ut_utils.indent_lines(ut_utils.table_to_clob(self.get_transaction_invalidators()), 2, true))||chr(10)
- -
-||'Use the "--%rollback(manual)" annotation or remove commit/rollback/ddl statements that are causing the issue.'
- -
-);
- -
-end;
- -
-- -
-member function execution_time return number is
- -
-begin
- - 216 -
-return ut_utils.time_diff(start_time, end_time);
- -
-end;
- -
-- -
-member procedure put_warning(self in out nocopy ut_suite_item, a_message varchar2) is
- -
-begin
- - 6 -
-self.warnings.extend;
- - 6 -
-self.warnings(self.warnings.last) := a_message;
- - 6 -
-self.results_count.increase_warning_count;
- -
-end;
- +
+ +gc_check_object_name constant varchar2(128) := 'UT3_TRIGGER_ALIVE';
- + 1 +
+ +g_is_trigger_live boolean := false;
- -
- -
-member function get_transaction_invalidators return ut_varchar2_list is
- + +
- +
+ +function is_alive return boolean is
- +
+ +pragma autonomous_transaction;
- -
begin
- - 6 -
-return transaction_invalidators;
- + +
- + 418 +
+ +execute immediate 'create or replace synonym '||ut_utils.ut_owner||'.'||gc_check_object_name||' for no_object';
- + 418 +
+ +return g_is_trigger_live;
- -
end;
- + +
- -
- -
-member procedure add_transaction_invalidator(a_object_name varchar2) is
- + +
- +
+ +procedure is_alive is
- -
begin
- - 9 -
-if a_object_name not member of transaction_invalidators then
- - 9 -
-transaction_invalidators.extend();
- - 9 -
-transaction_invalidators(transaction_invalidators.last) := a_object_name;
- + +
- + 404 +
+ +if ora_dict_obj_owner is not null and ora_dict_obj_name is not null and ora_dict_obj_type is not null then
- + 400 +
+ +g_is_trigger_live := true;
- +
+ +else
- + 4 +
+ +g_is_trigger_live := false;
- -
end if;
- + +
- -
end;
- + +
- -
- -
end;
+UT3.UT_TEST
100 % covered
62 relevant lines. 62 lines covered and 0 lines missed+ +
- +
+end;
UT3.UT_COVERAGE
88.1 % lines covered
84 relevant lines. 74 lines covered and 10 lines missed+
- -
+type body ut_test as
package body ut_coverage is
+- +
/*
- -
+utPLSQL - Version X.X.X.X
utPLSQL - Version 3
+- -
+Copyright 2016 - 2017 utPLSQL Project
Copyright 2016 - 2019 utPLSQL Project
+- +
- +
Licensed under the Apache License, Version 2.0 (the "License"):
- +
you may not use this file except in compliance with the License.
- +
You may obtain a copy of the License at
- +
- +
http://www.apache.org/licenses/LICENSE-2.0
- +
- +
Unless required by applicable law or agreed to in writing, software
- +
distributed under the License is distributed on an "AS IS" BASIS,
- +
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
See the License for the specific language governing permissions and
- +
limitations under the License.
- +
*/
- +
- -
-constructor function ut_test(
- -
-self in out nocopy ut_test, a_object_owner varchar2 := null, a_object_name varchar2, a_name varchar2, a_description varchar2 := null,
- -
+a_path varchar2 := null, a_rollback_type integer := null, a_disabled_flag boolean := false,
g_coverage_id tt_coverage_id_arr;
+ +- + 1 +
+ +g_develop_mode boolean not null := false;
- + 1 +
+g_is_started boolean not null := false;
- -
+a_before_each_proc_name varchar2 := null, a_before_test_proc_name varchar2 := null,
+
- -
+a_after_test_proc_name varchar2 := null, a_after_each_proc_name varchar2 := null
procedure set_develop_mode(a_develop_mode in boolean) is
+- -
-) return self as result is
- -
-begin
- - 726 -
-self.self_type := $$plsql_unit;
- - 726 -
-self.init(a_object_owner, a_object_name, a_name, a_description, a_path, a_rollback_type, a_disabled_flag);
- - 726 -
-self.before_each := ut_executable(self, a_before_each_proc_name, ut_utils.gc_before_each);
- - 726 -
-self.before_test := ut_executable(self, a_before_test_proc_name, ut_utils.gc_before_test);
- - 726 -
-self.item := ut_executable(self, a_name, ut_utils.gc_test_execute);
- - 726 -
-self.after_test := ut_executable(self, a_after_test_proc_name, ut_utils.gc_after_test);
- - 726 -
-self.after_each := ut_executable(self, a_after_each_proc_name, ut_utils.gc_after_each);
- - 726 -
-return;
- -
-end;
- -
-- -
-member function is_valid(self in out nocopy ut_test) return boolean is
- -
-l_is_valid boolean;
- -
-begin
- - 193 -
-l_is_valid :=
- - 1 -
-( not self.before_each.is_defined() or self.before_each.is_valid() ) and
- - 1 -
-( not self.before_test.is_defined() or self.before_test.is_valid() ) and
- -
-( self.item.is_valid() ) and
- - 1 -
-( not self.after_test.is_defined() or self.after_test.is_valid() ) and
- - 1 -
-( not self.after_each.is_defined() or self.after_each.is_valid() );
- - 193 -
-return l_is_valid;
- -
-end;
- +
+ +begin
- + 2 +
+ +g_develop_mode := a_develop_mode;
- +
+ +end;
- -
- -
-overriding member function do_execute(self in out nocopy ut_test, a_listener in out nocopy ut_event_listener_base) return boolean is
- -
+ +l_completed_without_errors boolean;
- +
+ +function get_coverage_id(a_coverage_type in varchar2) return integer is
- +
+ +begin
- + 20 +
+ +return g_coverage_id(a_coverage_type);
- +
+ +end;
- +
+ +- +
+ +function is_develop_mode return boolean is
- +
+ +begin
- + 52 +
+ +return g_develop_mode;
- +
+ +end;
- +
+ +- +
+ +function get_cov_sources_sql(a_coverage_options ut_coverage_options, a_skip_objects ut_object_names) return varchar2 is
- +
+ +l_result varchar2(32767);
- +
+ +l_full_name varchar2(32767);
- +
+ +l_join_mappings varchar2(32767);
- +
+ +l_filters varchar2(32767);
- + 10 +
+ +l_mappings_cardinality integer := 0;
- +
+ +begin
- + 10 +
+ +l_result := q'[
- +
+ +with
- +
+ +trigger_source_offsets as (
- +
+ +select min(s.line) - 1 offset, s.owner, s.name, s.type
- +
+from {sources_view} s
- -
+l_savepoint varchar2(30);
where s.type = 'TRIGGER'
+- -
+begin
{filters}
+- -
-- - 225 -
+ut_utils.debug_log('ut_test.execute');
and (lower(s.text) like '%begin%' or lower(s.text) like '%declare%' or lower(s.text) like '%compound%')
+ +- +
+group by s.owner, s.name, s.type
- -
-- - 225 -
-a_listener.fire_before_event(ut_utils.gc_test,self);
- - 225 -
+self.start_time := current_timestamp;
),
+ +- +
+ +sources as (
- +
+select /*+ cardinality(f {mappings_cardinality}) */
- -
-- - 225 -
-if self.get_disabled_flag() then
- - 32 -
-self.result := ut_utils.tr_disabled;
- - 32 -
-ut_utils.debug_log('ut_test.execute - disabled');
- - 32 -
-self.results_count.set_counter_values(self.result);
- - 32 -
+self.end_time := self.start_time;
{l_full_name} as full_name, s.owner, s.name,
+ +- +
+ +s.line - case when s.type = 'TRIGGER' then o.offset else 0 end as line,
- +
+ +s.text
- +
+ +from {sources_view} s {join_file_mappings}
- +
+ +left join trigger_source_offsets o
- +
+on (s.owner = o.owner and s.name = o.name and s.type = o.type)
- -
-else
- - 193 -
+if self.is_valid() then
where s.type in ('PACKAGE BODY', 'TYPE BODY', 'PROCEDURE', 'FUNCTION', 'TRIGGER')
+ +- +
+{filters}
- -
-- - 183 -
+l_savepoint := self.create_savepoint_if_needed();
),
+ +- +
+coverage_sources as (
- -
+select full_name, owner, name, line, text,
+- -
---includes listener calls for before and after actions
- - 183 -
+l_completed_without_errors := self.before_each.do_execute(self, a_listener);
case
+ +- +
+when
- -
-- - 183 -
-if l_completed_without_errors then
- - 181 -
+l_completed_without_errors := self.before_test.do_execute(self, a_listener);
-- to avoid execution of regexp_like on every line
+ +- +
+ +-- first do a rough check for existence of search pattern keyword
- +
+(lower(s.text) like '%procedure%'
- -
-- - 181 -
+if l_completed_without_errors then
or lower(s.text) like '%function%'
+ +- +
+or lower(s.text) like '%begin%'
- -
--- execute the test
- - 180 -
+self.item.do_execute(self, a_listener);
or lower(s.text) like '%end%'
+ +- +
+or lower(s.text) like '%package%'
- -
+) and
+- -
+end if;
regexp_like(
+- -
--- perform cleanup regardless of the test or setup failure
- - 181 -
+self.after_test.do_execute(self, a_listener);
s.text,
+ +- +
+'^([\t ]*(((not)?\s*(overriding|final|instantiable)[\t ]*)*(static|constructor|member)?[\t ]*(procedure|function)|package([\t ]+body)|begin|end([\t ]+\S+)*[ \t]*;))', 'i'
- -
+end if;
)
+- -
-- - 183 -
-self.after_each.do_execute(self, a_listener);
- - 183 -
+self.rollback_to_savepoint(l_savepoint);
then 'Y'
+ +- +
+ +end as to_be_skipped
- +
+from sources s
- -
+end if;
)
+- -
-- - 193 -
-self.calc_execution_result();
- - 193 -
+self.end_time := current_timestamp;
select full_name, owner, name, line, to_be_skipped, text
+ +- +
+ +from coverage_sources s
- +
+-- Exclude calls to utPLSQL framework, Unit Test packages and objects from a_exclude_list parameter of coverage reporter
- -
-end if;
- - 225 -
-a_listener.fire_after_event(ut_utils.gc_test,self);
- - 225 -
+return l_completed_without_errors;
where (s.owner, s.name) not in ( select /*+ cardinality(el {skipped_objects_cardinality})*/el.owner, el.name from table(:l_skipped_objects) el )
+ +- +
+ +and line > 0
- +
+]';
- -
-end;
- -
- -
-overriding member procedure calc_execution_result(self in out nocopy ut_test) is
- -
-begin
- - 199 -
-if self.get_error_stack_traces().count = 0 then
- - 157 -
+ +self.result := ut_expectation_processor.get_status();
- + 10 +
+ +if a_coverage_options.file_mappings is not empty then
- + 5 +
+ +l_mappings_cardinality := ut_utils.scale_cardinality(cardinality(a_coverage_options.file_mappings));
- + 5 +
+ +l_full_name := 'f.file_name';
- + 5 +
+ +l_join_mappings := '
- +
+join table(:file_mappings) f
- -
-else
- - 42 -
+self.result := ut_utils.tr_error;
on s.name = f.object_name
+ +- +
+and s.type = f.object_type
- -
+end if;
and s.owner = f.object_owner';
+- -
---expectation results need to be part of test results
- - 199 -
-self.results := ut_expectation_processor.get_expectations_results();
- - 199 -
-self.results_count.set_counter_values(self.result);
- -
+end;
else
+ +- + 5 +
+ +l_full_name := q'[lower(s.owner||'.'||s.name)]';
- + 5 +
+ +l_filters := case
- + 1 +
+when a_coverage_options.include_objects is not empty then '
- -
+and (s.owner, s.name) in (
+- -
+overriding member procedure mark_as_errored(self in out nocopy ut_test, a_listener in out nocopy ut_event_listener_base, a_error_stack_trace varchar2) is
select /*+ cardinality(il '||ut_utils.scale_cardinality(cardinality(a_coverage_options.include_objects))||') */
+- -
-begin
- - 6 -
-ut_utils.debug_log('ut_test.fail');
- - 6 -
-a_listener.fire_before_event(ut_utils.gc_test, self);
- - 6 -
-self.start_time := current_timestamp;
- - 6 -
-self.parent_error_stack_trace := a_error_stack_trace;
- - 6 -
-self.calc_execution_result();
- - 6 -
-self.end_time := self.start_time;
- - 6 -
+a_listener.fire_after_event(ut_utils.gc_test, self);
il.owner, il.name
+ +- +
+ +from table(:include_objects) il
- +
+ +)'
- +
+ +else '
- +
+ +and s.owner in (
- +
+ +select /*+ cardinality(t '||ut_utils.scale_cardinality(cardinality(a_coverage_options.schema_names))||') */
- +
+ +upper(t.column_value)
- +
+from table(:l_schema_names) t)'
- -
+end;
end;
+- -
+end if;
+- -
-overriding member function get_error_stack_traces(self ut_test) return ut_varchar2_list is
- - 231 -
-l_stack_traces ut_varchar2_list := ut_varchar2_list();
- -
-begin
- - 231 -
-ut_utils.append_to_varchar2_list(l_stack_traces, self.parent_error_stack_trace);
- - 231 -
-ut_utils.append_to_varchar2_list(l_stack_traces, self.before_each.get_error_stack_trace());
- - 231 -
-ut_utils.append_to_varchar2_list(l_stack_traces, self.before_test.get_error_stack_trace());
- - 231 -
-ut_utils.append_to_varchar2_list(l_stack_traces, self.item.get_error_stack_trace());
- - 231 -
-ut_utils.append_to_varchar2_list(l_stack_traces, self.after_test.get_error_stack_trace());
- - 231 -
-ut_utils.append_to_varchar2_list(l_stack_traces, self.after_each.get_error_stack_trace());
- - 231 -
-return l_stack_traces;
- -
-end;
- -
-overriding member function get_serveroutputs return clob is
- -
-l_outputs clob;
- -
-begin
- - 137 -
-ut_utils.append_to_clob(l_outputs, self.before_each.serveroutput );
- - 137 -
-ut_utils.append_to_clob(l_outputs, self.before_test.serveroutput );
- - 137 -
-ut_utils.append_to_clob(l_outputs, self.item.serveroutput );
- - 137 -
-ut_utils.append_to_clob(l_outputs, self.after_test.serveroutput );
- - 137 -
-ut_utils.append_to_clob(l_outputs, self.after_each.serveroutput );
- - 137 -
-return l_outputs;
- -
-end;
- -
end;
UT3.UT_ANNOTATIONS
100 % covered
68 relevant lines. 68 lines covered and 0 lines missed-
- -
-package body ut_annotations as
- -
-/*
- -
-utPLSQL - Version X.X.X.X
- -
-Copyright 2016 - 2017 utPLSQL Project
- -
-- -
-Licensed under the Apache License, Version 2.0 (the "License"):
- -
-you may not use this file except in compliance with the License.
- -
-You may obtain a copy of the License at
- -
- -
-http://www.apache.org/licenses/LICENSE-2.0
- + +
- + 10 +
+ +l_result := replace(l_result, '{sources_view}', ut_metadata.get_source_view_name());
- + 10 +
+ +l_result := replace(l_result, '{l_full_name}', l_full_name);
- + 10 +
+ +l_result := replace(l_result, '{join_file_mappings}', l_join_mappings);
- + 10 +
+ +l_result := replace(l_result, '{filters}', l_filters);
- + 10 +
+ +l_result := replace(l_result, '{mappings_cardinality}', l_mappings_cardinality);
- + 10 +
+ +l_result := replace(l_result, '{skipped_objects_cardinality}', ut_utils.scale_cardinality(cardinality(a_skip_objects)));
- -
- -
-Unless required by applicable law or agreed to in writing, software
- -
-distributed under the License is distributed on an "AS IS" BASIS,
- -
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- -
-See the License for the specific language governing permissions and
- -
-limitations under the License.
- -
-*/
- + +
- + 10 +
+ +return l_result;
- -
- -
-------------------------------
- -
---private definitions
- + +
- +
+ +end;
- -
- -
-type tt_comment_list is table of varchar2(32767) index by pls_integer;
- + +
- +
+ +function get_cov_sources_cursor(a_coverage_options in ut_coverage_options) return sys_refcursor is
- +
+ +l_cursor sys_refcursor;
- +
+ +l_skip_objects ut_object_names;
- +
+ +l_sql varchar2(32767);
- +
+ +begin
- + 10 +
+ +if not is_develop_mode() then
- +
+ +--skip all the utplsql framework objects and all the unit test packages that could potentially be reported by coverage.
- +
+ +l_skip_objects := ut_utils.get_utplsql_objects_list() multiset union all coalesce(a_coverage_options.exclude_objects, ut_object_names());
- +
+ +end if;
- -
- - 1 -
-gc_annotation_qualifier constant varchar2(1) := '%';
- - 1 -
-c_multiline_comment_pattern constant varchar2(50) := '/\*.*?\*/';
- - 1 -
-c_annot_comment_pattern constant varchar2(30) := '^( |'||chr(09)||')*-- *('||gc_annotation_qualifier||'.*?)$'; -- chr(09) is a tab character
- -
---c_nonannotat_comment_pattern constant varchar2(30) := '^( |'||chr(09)||')*--+ *[^'||gc_annotation_qualifier||']*?$';
- - 1 -
-c_comment_replacer_patter constant varchar2(50) := '{COMMENT#%N%}';
- - 1 -
-c_comment_replacer_regex_ptrn constant varchar2(25) := '{COMMENT#(\d+)}';
- - 1 -
-c_rgexp_identifier constant varchar2(50) := '[a-z][a-z0-9#_$]*';
- - 1 -
-c_annotation_block_pattern constant varchar2(200) := '(({COMMENT#.+}'||chr(10)||')+)( |'||chr(09)||')*(procedure|function)\s+(' ||
- -
-c_rgexp_identifier || ')';
- - 1 -
-c_annotation_pattern constant varchar2(50) := gc_annotation_qualifier || c_rgexp_identifier || '[ '||chr(9)||']*(\(.*?\)\s*?$)?';
- + +
- + 10 +
+ +l_sql := get_cov_sources_sql(a_coverage_options, l_skip_objects);
- -
- + +
- + 10 +
+ +ut_event_manager.trigger_event(ut_event_manager.gc_debug, ut_key_anyvalues().put('l_sql',l_sql) );
- -
- -
-function delete_multiline_comments(a_source in clob) return clob is
- -
-begin
- - 1085 -
-return regexp_replace(srcstr => a_source
- -
-,pattern => c_multiline_comment_pattern
- -
-,modifier => 'n');
- + +
- + 10 +
+ +if a_coverage_options.file_mappings is not empty then
- + 5 +
+ +open l_cursor for l_sql using a_coverage_options.file_mappings, l_skip_objects;
- + 5 +
+ +elsif a_coverage_options.include_objects is not empty then
- + 3 +
+ +open l_cursor for l_sql using a_coverage_options.include_objects, a_coverage_options.include_objects, l_skip_objects;
- +
+ +else
- + 2 +
+ +open l_cursor for l_sql using a_coverage_options.schema_names, a_coverage_options.schema_names, l_skip_objects;
- +
+ +end if;
- + 10 +
+ +return l_cursor;
- -
end;
- + +
- -
- -
-function get_annotations(a_source varchar2, a_comments tt_comment_list) return tt_annotations is
- - 1561 -
-l_loop_index pls_integer := 1;
- -
-l_comment_index pls_integer;
- -
-l_comment varchar2(32767);
- -
-l_annotation_str varchar2(32767);
- -
-l_annotation_params_str varchar2(32767);
- -
-l_annotation_name varchar2(1000);
- -
-l_annotation_params tt_annotation_params;
- -
-l_annotation t_annotation;
- -
-l_annotations_list tt_annotations;
- + +
- +
+ +procedure populate_tmp_table(a_coverage_options ut_coverage_options) is
- +
+ +pragma autonomous_transaction;
- +
+ +l_cov_sources_crsr sys_refcursor;
- +
+ +l_cov_sources_data ut_coverage_helper.t_coverage_sources_tmp_rows;
- -
begin
- -
--- loop while there are unprocessed comment blocks
- - 4012 -
-while 0 != nvl(regexp_instr(srcstr => a_source
- -
-,pattern => c_comment_replacer_regex_ptrn
- -
-,occurrence => l_loop_index
- -
-,subexpression => 1)
- -
-,0) loop
- -
-- -
--- define index of the comment block and get it's content from cache
- - 2451 -
-l_comment_index := to_number(regexp_substr(a_source
- -
-,c_comment_replacer_regex_ptrn
- -
-,1
- -
-,l_loop_index
- -
-,subexpression => 1));
- + +
- -
- - 2451 -
-l_comment := a_comments(l_comment_index);
- + +
- + 10 +
+ +if not ut_coverage_helper.is_tmp_table_populated() or is_develop_mode() then
- + 10 +
+ +ut_coverage_helper.cleanup_tmp_table();
- + 10 +
+ +l_cov_sources_crsr := get_cov_sources_cursor(a_coverage_options);
- -
- -
--- strip everything except the annotation itself (spaces and others)
- - 2451 -
-l_annotation_str := regexp_substr(l_comment, c_annotation_pattern, 1, 1, modifier => 'i');
- - 2451 -
-if l_annotation_str is not null then
- + +
- + 11 +
+ +loop
- + 11 +
+ +fetch l_cov_sources_crsr bulk collect into l_cov_sources_data limit 10000;
- -
- - 2451 -
-l_annotation_params.delete;
- + +
- + 11 +
+ +ut_coverage_helper.insert_into_tmp_table(l_cov_sources_data);
- -
- -
--- get the annotation name and it's parameters if present
- - 2451 -
-l_annotation_name := lower(regexp_substr(l_annotation_str
- -
-,'%(' || c_rgexp_identifier || ')'
- -
-,modifier => 'i'
- -
-,subexpression => 1));
- - 2451 -
-l_annotation_params_str := trim(regexp_substr(l_annotation_str, '\((.*?)\)\s*$', subexpression => 1));
- + +
- + 11 +
+ +exit when l_cov_sources_crsr%notfound;
- +
+ +end loop;
- -
- - 2451 -
-if l_annotation_params_str is not null then
- + +
- + 10 +
+ +close l_cov_sources_crsr;
- +
+ +end if;
- + 10 +
+ +commit;
- +
+ +end;
- -
- -
--- parse the annotation parameters and store them as key-value pair array
- - 2305 -
-for param_ind in 1 .. regexp_count(l_annotation_params_str, '(.+?)(,|$)') loop
- - 1159 -
-declare
- -
-l_param_str varchar2(32767);
- -
-l_param_item typ_annotation_param;
- -
-begin
- - 1159 -
-l_param_str := regexp_substr(srcstr => l_annotation_params_str
- -
-,pattern => '(.+?)(,|$)'
- -
-,occurrence => param_ind
- -
-,subexpression => 1);
- + +
- -
- - 1159 -
-l_param_item.key := regexp_substr(srcstr => l_param_str
- -
-,pattern => '(' || c_rgexp_identifier || ')\s*='
- -
-,modifier => 'i'
- -
-,subexpression => 1);
- - 1159 -
-l_param_item.val := trim(regexp_substr(l_param_str, '(.+?=)?(.*$)', subexpression => 2));
- -
-- - 1159 -
-l_annotation_params(l_annotation_params.count + 1) := l_param_item;
- -
-end;
- -
-end loop;
- -
-end if;
- - 2451 -
-l_annotation.text := l_annotation_params_str;
- - 2451 -
-l_annotation.params := l_annotation_params;
- - 2451 -
-l_annotations_list(l_annotation_name) := l_annotation;
- -
-end if;
- - 2451 -
-l_loop_index := l_loop_index + 1;
- -
-end loop;
- -
-- - 1561 -
-return l_annotations_list;
- -
-- -
-end get_annotations;
- -
-- -
-function get_package_annotations(a_source clob, a_comments tt_comment_list) return tt_annotations is
- -
-l_package_comments varchar2(32767);
- -
-begin
- - 1085 -
-l_package_comments := regexp_substr(srcstr => a_source
- -
-,pattern => '^\s*(CREATE\s+(OR\s+REPLACE)?(\s+(NON)?EDITIONABLE)?\s+)?PACKAGE\s[^;]*?(\s+(AS|IS)\s+)((.*?{COMMENT#\d+}\s?)+)'
- -
-,modifier => 'i'
- -
-,subexpression => 7);
- -
-- -
--- parsing for package annotations
- - 1085 -
-return
- - 1 -
-case when l_package_comments is not null then
- -
-get_annotations(l_package_comments, a_comments)
- -
-end;
- -
-end;
- -
-- -
-function get_procedure_list(a_source clob, a_comments tt_comment_list) return tt_procedure_list is
- -
-l_proc_comments varchar2(32767);
- -
-l_proc_name t_annotation_name;
- -
-l_annot_proc_ind number;
- -
-l_annot_proc_block varchar2(32767);
- -
-l_procedure_annotations tt_procedure_annotations;
- -
-l_procedure_list tt_procedure_list;
- -
-begin
- -
--- loop through procedures and functions of the package and get all the comment blocks just before it's declaration
- - 1085 -
-l_annot_proc_ind := 1;
- - 2325 -
-loop
- -
---find annotated procedure index
- - 2325 -
-l_annot_proc_ind := regexp_instr(srcstr => a_source
- -
-,pattern => c_annotation_block_pattern
- -
-,occurrence => 1
- -
-,modifier => 'i'
- -
-,position => l_annot_proc_ind);
- - 2325 -
-exit when l_annot_proc_ind = 0;
- -
-- -
---get the annotataions with procedure name
- - 1240 -
-l_annot_proc_block := regexp_substr(srcstr => a_source
- -
-,pattern => c_annotation_block_pattern
- -
-,position => l_annot_proc_ind
- -
-,occurrence => 1
- -
-,modifier => 'i');
- -
-- -
---extract the annotations
- - 1240 -
-l_proc_comments := trim(regexp_substr(srcstr => l_annot_proc_block
- -
-,pattern => c_annotation_block_pattern
- -
-,modifier => 'i'
- -
-,subexpression => 1));
- -
---extract the procedure name
- - 1240 -
-l_proc_name := trim(regexp_substr(srcstr => l_annot_proc_block
- -
-,pattern => c_annotation_block_pattern
- -
-,modifier => 'i'
- -
-,subexpression => 5));
- -
-- -
--- parse the comment block for the syntactically correct annotations and store them as an array
- - 1240 -
-l_procedure_annotations.name := l_proc_name;
- - 1240 -
-l_procedure_annotations.annotations := get_annotations(l_proc_comments, a_comments);
- -
-- - 1240 -
-l_procedure_list(l_procedure_list.count+1) := l_procedure_annotations;
- -
-- -
---l_annot_proc_ind := l_annot_proc_ind + length(l_annot_proc_block);
- - 1240 -
+l_annot_proc_ind := regexp_instr(srcstr => a_source
- -
+,pattern => ';'
/**
+- -
+,occurrence => 1
* Public functions
+- -
+,position => l_annot_proc_ind + length(l_annot_proc_block));
*/
+- -
-end loop;
- - 1085 -
+return l_procedure_list;
procedure coverage_start(a_coverage_options ut_coverage_options default null) is
+ +- + 10 +
+l_run_comment varchar2(200) := 'utPLSQL Code coverage run '||ut_utils.to_string(systimestamp);
- +
+ +begin
- + 10 +
+ +if not is_develop_mode() and not g_is_started then
- +
+ +ut_coverage_helper_block.coverage_start( l_run_comment, g_coverage_id(gc_block_coverage) );
- +
+ +ut_coverage_helper_profiler.coverage_start( l_run_comment, g_coverage_id(gc_proftab_coverage) );
- +
+ +coverage_pause();
- +
+ +g_is_started := true;
- +
+ +end if;
- -
end;
- + +
- -
- -
-function extract_and_replace_comments(a_source in out nocopy clob) return tt_comment_list is
- -
-l_comments tt_comment_list;
- -
-l_comment_pos pls_integer;
- -
-l_comment_replacer varchar2(50);
- -
-begin
- - 1085 -
-l_comment_pos := 1;
- - 3539 -
+loop
- -
-- - 3539 -
-l_comment_pos := regexp_instr(srcstr => a_source
- -
-,pattern => c_annot_comment_pattern
- -
+,occurrence => 1
procedure coverage_pause is
+ +- +
+ +begin
- + 22 +
+ +if not is_develop_mode() then
- +
+ut_coverage_helper_profiler.coverage_pause();
- -
+,modifier => 'm'
end if;
+- -
+,position => l_comment_pos);
end;
+- -
- - 3539 -
+ +exit when l_comment_pos = 0;
- +
+procedure coverage_resume is
- -
-- -
+-- position index is shifted by 1 because c_annot_comment_pattern contains ^ as first sign
begin
+ +- + 32 +
+ut_coverage_helper_profiler.coverage_resume();
- -
--- but after instr index already points to the char on that line
- - 2454 -
-l_comment_pos := l_comment_pos-1;
- - 2454 -
+l_comments(l_comments.count + 1) := trim(regexp_substr(srcstr => a_source
end;
+ +- +
+ +- +
+procedure mock_coverage_id(a_coverage_id integer,a_coverage_type in varchar2) is
- -
-,pattern => c_annot_comment_pattern
- -
-,occurrence => 1
- -
-,position => l_comment_pos
- -
+,modifier => 'm'
begin
+ +- + 3 +
+ +g_develop_mode := true;
- + 3 +
+ +g_is_started := true;
- + 3 +
+g_coverage_id(a_coverage_type) := a_coverage_id;
- -
+,subexpression => 2));
end;
+- -
- - 2454 -
+ +l_comment_replacer := replace(c_comment_replacer_patter, '%N%', l_comments.count);
- +
+procedure mock_coverage_id(a_coverage_id tt_coverage_id_arr) is
- -
-- - 2454 -
-a_source := regexp_replace(srcstr => a_source
- -
-,pattern => c_annot_comment_pattern
- -
+,replacestr => l_comment_replacer
begin
+ +- + 1 +
+ +g_develop_mode := true;
- + 1 +
+ +g_is_started := true;
- + 1 +
+g_coverage_id := a_coverage_id;
- -
+,position => l_comment_pos
end;
+- -
-,occurrence => 1
- -
-,modifier => 'm');
- - 2454 -
-l_comment_pos := l_comment_pos + length(l_comment_replacer);
- -
-- -
-end loop;
- -
-- - 1085 -
-ut_utils.debug_log(a_source);
- -
-- - 1085 -
-return l_comments;
- -
-end extract_and_replace_comments;
- -
- -
-$if $$ut_trace $then
- -
-procedure print_parse_results(a_annotated_pkg typ_annotated_package) is
- -
-l_name t_annotation_name := a_annotated_pkg.package_annotations.first;
- -
-l_proc_name t_annotation_name;
- + +
- +
+ +procedure coverage_stop is
- -
begin
- -
-dbms_output.put_line('Annotations count: ' || a_annotated_pkg.package_annotations.count);
- -
-- -
-while l_name is not null loop
- -
-dbms_output.put_line(' @' || l_name);
- -
+ +if a_annotated_pkg.package_annotations(l_name).count > 0 then
- + 10 +
+ +if not is_develop_mode() then
- +
+ +g_is_started := false;
- +
+ +ut_coverage_helper_block.coverage_stop();
- +
+ +ut_coverage_helper_profiler.coverage_stop();
- +
+ +g_is_started := false;
- +
+ +end if;
- +
+ +end;
- +
+ +- +
+ +function get_coverage_data(a_coverage_options ut_coverage_options) return t_coverage is
- + 10 +
+ +l_result_block ut_coverage.t_coverage;
- + 10 +
+ +l_result_profiler_enrich ut_coverage.t_coverage;
- +
+ +l_object ut_coverage.t_full_name;
- +
+ +l_line_no binary_integer;
- +
+ +begin
- +
+ +--prepare global temp table with sources
- + 10 +
+ +ut_event_manager.trigger_event('about to populate coverage temp table');
- + 10 +
+ +populate_tmp_table(a_coverage_options);
- + 10 +
+ut_event_manager.trigger_event('coverage temp table populated');
- -
-dbms_output.put_line(' Parameters:');
- + +
- +
+-- Get raw data for both reporters, order is important as tmp table will skip headers and dont populate
- -
-for j in 1 .. a_annotated_pkg.package_annotations(l_name).count loop
- -
-dbms_output.put_line(' ' || nvl(a_annotated_pkg.package_annotations(l_name)(j).key, '<Anonymous>') || ' = ' ||
- -
+nvl(a_annotated_pkg.package_annotations(l_name)(j).val, 'NULL'));
-- tmp table for block again.
+ +- + 10 +
+ +l_result_profiler_enrich:= ut_coverage_profiler.get_coverage_data( a_coverage_options, get_coverage_id(gc_proftab_coverage) );
- + 10 +
+ut_event_manager.trigger_event('profiler coverage data retrieved');
- -
+end loop;
+
- -
+else
-- If block coverage available we will use it.
+- -
-dbms_output.put_line(' No parameters.');
- -
-end if;
- -
+$if dbms_db_version.version = 12 and dbms_db_version.release >= 2 or dbms_db_version.version > 12 $then
+ +- + 10 +
+ +l_result_block := ut_coverage_block.get_coverage_data( a_coverage_options, get_coverage_id(gc_block_coverage) );
- + 10 +
+ut_event_manager.trigger_event('block coverage data retrieved');
- -
-l_name := a_annotated_pkg.package_annotations.next(l_name);
- -
-- -
-end loop;
- + +
- +
+ +-- Enrich profiler results with some of the block results
- + 10 +
+ +l_object := l_result_profiler_enrich.objects.first;
- + 56 +
+while (l_object is not null) loop
- -
-dbms_output.put_line('Procedures count: ' || a_annotated_pkg.procedure_annotations.count);
- + +
- + 46 +
+l_line_no := l_result_profiler_enrich.objects(l_object).lines.first;
- -
+for i in 1 .. a_annotated_pkg.procedure_annotations.count loop
+
- -
-l_proc_name := a_annotated_pkg.procedure_annotations(i).name;
- -
-dbms_output.put_line(rpad('-', 80, '-'));
- -
+dbms_output.put_line(' Procedure: ' || l_proc_name);
-- to avoid no data found check if we got object in profiler
+ +- + 46 +
+ +if l_result_block.objects.exists(l_object) then
- + 59 +
+while (l_line_no is not null) loop
- -
-dbms_output.put_line(' Annotations count: ' || a_annotated_pkg.procedure_annotations(i).annotations.count);
- -
+l_name := a_annotated_pkg.procedure_annotations(i).annotations.first;
-- To avoid no data check for object line
+ +- + 16 +
+if l_result_block.objects(l_object).lines.exists(l_line_no) then
- -
-while l_name is not null loop
- -
-dbms_output.put_line(' @' || l_name);
- -
-if a_annotated_pkg.procedure_annotations(i).annotations(l_name).count > 0 then
- -
+dbms_output.put_line(' Parameters:');
-- enrich line level stats
+ +- + 12 +
+ +l_result_profiler_enrich.objects(l_object).lines(l_line_no).partcove := l_result_block.objects(l_object).lines(l_line_no).partcove;
- + 12 +
+ +l_result_profiler_enrich.objects(l_object).lines(l_line_no).covered_blocks := l_result_block.objects(l_object).lines(l_line_no).covered_blocks;
- + 12 +
+l_result_profiler_enrich.objects(l_object).lines(l_line_no).no_blocks := l_result_block.objects(l_object).lines(l_line_no).no_blocks;
- -
-for j in 1 .. a_annotated_pkg.procedure_annotations(i).annotations(l_name).count loop
- -
+dbms_output.put_line(' ' ||
-- enrich object level stats
+ +- + 12 +
+l_result_profiler_enrich.objects(l_object).partcovered_lines := nvl(l_result_profiler_enrich.objects(l_object).partcovered_lines,0) + l_result_block.objects(l_object).lines(l_line_no).partcove;
- -
+nvl(a_annotated_pkg.procedure_annotations(i).annotations(l_name)(j).key, '<Anonymous>') ||
end if;
+- -
-' = ' || nvl(a_annotated_pkg.procedure_annotations(i).annotations(l_name)(j).val, 'NULL'));
- -
+end loop;
--At the end go to next line
+ +- + 16 +
+l_line_no := l_result_profiler_enrich.objects(l_object).lines.next(l_line_no);
- -
+else
end loop;
+- -
-dbms_output.put_line(' No parameters.');
- -
+end if;
--total level stats enrich
+ +- + 43 +
+l_result_profiler_enrich.partcovered_lines := nvl(l_result_profiler_enrich.partcovered_lines,0) + l_result_profiler_enrich.objects(l_object).partcovered_lines;
- -
+-- At the end go to next object
+- -
+l_name := a_annotated_pkg.procedure_annotations(i).annotations.next(l_name);
end if;
+- -
-end loop;
- -
-end loop;
- -
- -
+ +end print_parse_results;
- + 46 +
+ +l_object := l_result_profiler_enrich.objects.next(l_object);
- +
+ +end loop;
- + 10 +
+ut_event_manager.trigger_event('coverage data combined');
- -
+$end
$end
+- -
- -
-function parse_package_annotations(a_source clob) return typ_annotated_package is
- - 1085 -
+ +l_source clob := a_source;
- + 10 +
+ +return l_result_profiler_enrich;
- +
+end get_coverage_data;
- -
-l_comments tt_comment_list;
- -
-l_annotated_pkg typ_annotated_package;
- -
-begin
- -
-- - 1085 -
-l_source := delete_multiline_comments(l_source);
- -
-- -
--- replace all single line comments with {COMMENT#12} element and store it's content for easier processing
- -
--- this call modifies a_source
- - 1085 -
-l_comments := extract_and_replace_comments(l_source);
- -
-- - 1085 -
-l_annotated_pkg.package_annotations := get_package_annotations(l_source, l_comments);
- -
-- - 1085 -
-l_annotated_pkg.procedure_annotations := get_procedure_list(l_source, l_comments);
- -
-- -
--- printing out parsed structure for debugging
- -
-$if $$ut_trace $then
- -
-print_parse_results(l_annotated_pkg);
- -
-$end
- -
-- - 1085 -
-return l_annotated_pkg;
- -
-end parse_package_annotations;
- -
-- -
-------------------------------
- -
---public definitions
- -
-- -
-function get_package_annotations(a_owner_name varchar2, a_name varchar2) return typ_annotated_package is
- -
-l_source clob;
- -
-ex_package_is_wrapped exception;
- -
-pragma exception_init(ex_package_is_wrapped, -24241);
- -
-begin
- -
-- -
--- TODO: Add cache of annotations. Cache invalidation should be based on DDL timestamp.
- -
--- Cache garbage collection should be executed once in a while to remove annotations cache for packages that were dropped.
- -
-- -
-begin
- - 1076 -
-l_source := ut_metadata.get_package_spec_source(a_owner_name, a_name);
- -
-exception
- - 1 -
-when ex_package_is_wrapped then
- - 1 -
-null;
- -
-end;
- -
-- - 1076 -
-if l_source is null or sys.dbms_lob.getlength(l_source)=0 then
- - 1 -
-return null;
- -
-else
- - 1075 -
-return parse_package_annotations(l_source);
- -
-end if;
- -
-end;
- -
-- -
--- function get_annotation_param(a_param_list tt_annotation_params, a_def_index pls_integer) return varchar2 is
- -
--- l_result varchar2(32767);
- -
--- begin
- -
--- if a_param_list.exists(a_def_index) then
- -
--- l_result := a_param_list(a_def_index).val;
- -
--- end if;
- -
--- return l_result;
- -
--- end get_annotation_param;
- -
- -
end ut_annotations;
+UT3.UT_EXPECTATION_PROCESSOR
95.35 % covered
43 relevant lines. 41 lines covered and 2 lines missed+ +
- +
+end;
UT3.UT_COVERAGE_BLOCK
92.31 % lines covered
52 relevant lines. 48 lines covered and 4 lines missed+
- -
+package body ut_expectation_processor as
package body ut_coverage_block is
+- +
/*
- -
+utPLSQL - Version X.X.X.X
utPLSQL - Version 3
+- -
+Copyright 2016 - 2017 utPLSQL Project
Copyright 2016 - 2019 utPLSQL Project
+- +
- +
Licensed under the Apache License, Version 2.0 (the "License"):
- +
you may not use this file except in compliance with the License.
- +
You may obtain a copy of the License at
- +
- +
http://www.apache.org/licenses/LICENSE-2.0
- +
- +
Unless required by applicable law or agreed to in writing, software
- +
distributed under the License is distributed on an "AS IS" BASIS,
- +
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
See the License for the specific language governing permissions and
- +
limitations under the License.
- +
*/
- +
- -
-type tt_nls_params is table of nls_session_parameters%rowtype;
- + +
- +
+type t_source_lines is table of binary_integer;
- -
-g_session_params tt_nls_params;
- -
- - 1 -
+ +g_expectations_called ut_expectation_results := ut_expectation_results();
- +
+ +/**
- +
+* Public functions
- +
+ +*/
- -
- - 1 -
+g_nulls_are_equal boolean_not_null := gc_default_nulls_are_equal;
- -
+function get_coverage_data(a_coverage_options ut_coverage_options, a_coverage_id integer) return ut_coverage.t_coverage is
+- -
-function nulls_are_equal return boolean is
- -
-begin
- - 565 -
+return g_nulls_are_equal;
l_line_calls ut_coverage_helper.t_unit_line_calls;
+ +- + 10 +
+ +l_result ut_coverage.t_coverage;
- + 10 +
+l_new_unit ut_coverage.t_unit_coverage;
- -
+end;
l_line_no binary_integer;
+- -
+l_source_objects_crsr ut_coverage_helper.t_tmp_table_objects_crsr;
+- -
+procedure nulls_are_equal(a_setting boolean_not_null) is
l_source_object ut_coverage_helper.t_tmp_table_object;
+- -
begin
- - 2 -
-g_nulls_are_equal := a_setting;
- -
-end;
- + +
- -
- -
-function get_status return integer is
- - 640 -
+ +l_result integer := ut_utils.tr_success;
- +
+ +$if dbms_db_version.version = 12 and dbms_db_version.release >= 2 or dbms_db_version.version > 12 $then
- + 10 +
+ +l_source_objects_crsr := ut_coverage_helper.get_tmp_table_objects_cursor();
- + 56 +
+ +loop
- + 56 +
+fetch l_source_objects_crsr
- -
-begin
- - 640 -
+ut_utils.debug_log('ut_expectation_processor.get_status');
into l_source_object;
+ +- + 56 +
+exit when l_source_objects_crsr%notfound;
- -
- - 1536 -
-for i in 1 .. g_expectations_called.count loop
- - 896 -
-l_result := greatest(l_result, g_expectations_called(i).status);
- - 896 -
-exit when l_result = ut_utils.tr_error;
- -
-end loop;
- - 640 -
-return l_result;
- -
-end get_status;
- -
-- -
+ +procedure clear_expectations is
- +
+ +--get coverage data
- + 46 +
+ +l_line_calls := ut_coverage_helper_block.get_raw_coverage_data(l_source_object.owner, l_source_object.name, a_coverage_id);
- +
+ +--if there is coverage, we need to filter out the garbage (badly indicated data)
- + 46 +
+ +if l_line_calls.count > 0 then
- +
+ +--remove lines that should not be indicted as meaningful
- + 40 +
+ +for i in 1 .. l_source_object.to_be_skipped_list.count loop
- + 36 +
+ +if l_source_object.to_be_skipped_list(i) is not null then
- + 36 +
+l_line_calls.delete(l_source_object.to_be_skipped_list(i));
- -
-begin
- - 952 -
-ut_utils.debug_log('ut_expectation_processor.clear_expectations');
- - 952 -
+g_expectations_called.delete;
end if;
+ +- +
+ +end loop;
- +
+end if;
- -
+end;
+
- +
+ +--if there are no file mappings or object was actually captured by profiler
- + 46 +
+ +if a_coverage_options.file_mappings is null or l_line_calls.count > 0 then
- -
- -
-function get_expectations_results return ut_expectation_results is
- - 268 -
+l_expectations_results ut_expectation_results := ut_expectation_results();
- -
-begin
- - 268 -
-ut_utils.debug_log('ut_expectation_processor.get_expectations_results: .count='||g_expectations_called.count);
- - 268 -
-l_expectations_results := g_expectations_called;
- - 268 -
-clear_expectations();
- - 268 -
-return l_expectations_results;
- -
-end get_expectations_results;
- -
-- -
-procedure add_expectation_result(a_expectation_result ut_expectation_result) is
- -
-begin
- - 943 -
-ut_utils.debug_log('ut_expectation_processor.add_expectation_result');
- - 943 -
-g_expectations_called.extend;
- - 943 -
-g_expectations_called(g_expectations_called.last) := a_expectation_result;
- -
-end;
- +
+ +--populate total stats
- + 43 +
+ +l_result.total_lines := nvl(l_result.total_lines,0) + l_source_object.lines_count;
- -
- -
-procedure report_failure(a_message in varchar2) is
- -
-begin
- + +
- +
+ +--populate object level coverage stats
- + 43 +
+ +if not l_result.objects.exists(l_source_object.full_name) then
- + 43 +
+ +l_result.objects(l_source_object.full_name) := l_new_unit;
- + 43 +
+ +l_result.objects(l_source_object.full_name).owner := l_source_object.owner;
- + 43 +
+ +l_result.objects(l_source_object.full_name).name := l_source_object.name;
- + 43 +
+ +l_result.objects(l_source_object.full_name).total_lines := l_source_object.lines_count;
- +
+ +end if;
- +
+ +--map to results
- + 43 +
+ +l_line_no := l_line_calls.first;
- + 43 +
+ +if l_line_no is null then
- + 39 +
+ +l_result.uncovered_lines := l_result.uncovered_lines + l_source_object.lines_count;
- + 39 +
+ +l_result.objects(l_source_object.full_name).uncovered_lines := l_source_object.lines_count;
- 1 -
-add_expectation_result(ut_expectation_result(ut_utils.tr_failure, null, a_message));
- -
+end;
else
+ +- + 16 +
+ +loop
- + 16 +
+exit when l_line_no is null;
- +
- -
+function get_session_parameters return tt_nls_params is
--turn the block coverage into a line coverage format to allow for reading.
+- -
+l_session_params tt_nls_params;
--whenever the linst is a part covered treat that line as a hit and execution but only part covered
+- -
-begin
- - 45 -
+select nsp.parameter, nsp.value
+ +
- +
+--total stats
- -
-bulk collect into l_session_params
- -
-from nls_session_parameters nsp
- -
-where parameter
- -
+in ( 'NLS_DATE_FORMAT', 'NLS_TIMESTAMP_FORMAT', 'NLS_TIMESTAMP_TZ_FORMAT');
--Get total blocks ,blocks covered, blocks not covered this will be used for PCT calc
+ +- + 12 +
+ +l_result.total_blocks := nvl(l_result.total_blocks, 0) + l_line_calls(l_line_no).blocks;
- + 12 +
+ +l_result.covered_blocks := nvl(l_result.covered_blocks, 0) + l_line_calls(l_line_no).covered_blocks;
- + 12 +
+l_result.uncovered_blocks := nvl(l_result.uncovered_blocks, 0) +
- +
+ +(l_line_calls(l_line_no).blocks - l_line_calls(l_line_no).covered_blocks);
- -
- - 45 -
+return l_session_params;
- -
-end;
- -
-- -
+procedure set_xml_nls_params is
--If line is partially covered add as part line cover and covered for line reporter
+ +- + 12 +
+ +if l_line_calls(l_line_no).partcovered = 1 then
- + 4 +
+l_result.partcovered_lines := l_result.partcovered_lines + 1;
- -
+insuf_privs exception;
end if;
+- -
-pragma exception_init(insuf_privs, -1031);
- -
-begin
- - 45 -
-g_session_params := get_session_parameters();
- + +
- + 12 +
+ +if l_line_calls(l_line_no).covered_blocks > 0 then
- + 12 +
+ +l_result.covered_lines := l_result.covered_lines + 1;
- +
+end if;
- -
-begin
- - 45 -
-execute immediate q'[alter session set events '19119 trace name context forever, level 0x8']';
- -
-exception
- -
-when insuf_privs then NULL;
- -
-end;
- -
-- - 45 -
-execute immediate 'alter session set nls_date_format = '''||ut_utils.gc_date_format||'''';
- - 45 -
-execute immediate 'alter session set nls_timestamp_format = '''||ut_utils.gc_timestamp_format||'''';
- - 45 -
-execute immediate 'alter session set nls_timestamp_tz_format = '''||ut_utils.gc_timestamp_tz_format||'''';
- -
-end;
- + +
- +
+ +-- Use nvl as be default is null and screw the calcs
- +
+ +--Increase total blocks
- + 12 +
+ +l_result.objects(l_source_object.full_name).lines(l_line_no).no_blocks := l_line_calls(l_line_no).blocks;
- + 12 +
+ +l_result.objects(l_source_object.full_name).lines(l_line_no).covered_blocks := l_line_calls(l_line_no).covered_blocks;
- + 12 +
+ +l_result.objects(l_source_object.full_name).total_blocks := nvl(l_result.objects(l_source_object.full_name)
- +
+ +.total_blocks
- +
+ +,0) + l_line_calls(l_line_no).blocks;
- +
+ +- +
+ +--Total uncovered blocks is a line blocks minus covered blocsk
- + 12 +
+l_result.objects(l_source_object.full_name).uncovered_blocks := nvl(l_result.objects(l_source_object.full_name)
- -
+procedure reset_nls_params is
.uncovered_blocks
+- -
+insuf_privs exception;
,0) +
+- -
+pragma exception_init(insuf_privs, -1031);
(l_line_calls(l_line_no).blocks - l_line_calls(l_line_no)
+- -
+begin
.covered_blocks);
+- -
-begin
- - 45 -
-execute immediate q'[alter session set events '19119 trace name context off']';
- -
-exception
- -
-when insuf_privs then NULL;
- -
-end;
- -
- - 45 -
-if g_session_params is not null then
- - 180 -
-for i in 1 .. g_session_params.count loop
- - 135 -
+ +execute immediate 'alter session set '||g_session_params(i).parameter||' = '''||g_session_params(i).value||'''';
- +
+ +--If we have any covered blocks in line
- + 12 +
+ +if l_line_calls(l_line_no).covered_blocks > 0 then
- +
+ +--If any block is covered then we have a hit on that line
- + 12 +
+ +l_result.executions := l_result.executions + 1;
- +
+ +--object level stats
- +
+ +--If its part covered then mark it else treat as full cov
- + 12 +
+ +if l_line_calls(l_line_no).partcovered = 1 then
- + 4 +
+l_result.objects(l_source_object.full_name).partcovered_lines := l_result.objects(l_source_object.full_name)
- -
+end loop;
.partcovered_lines + 1;
+- -
-end if;
- -
+end if;
+ +- + 12 +
+l_result.objects(l_source_object.full_name).covered_lines := l_result.objects(l_source_object.full_name)
- -
+end;
.covered_lines + 1;
+- +
- -
-function who_called_expectation(a_call_stack varchar2) return varchar2 is
- -
+l_caller_stack_line varchar2(4000);
--How many blocks we covered
+ +- + 12 +
+l_result.objects(l_source_object.full_name).covered_blocks := nvl(l_result.objects(l_source_object.full_name)
- -
+l_line_no integer;
.covered_blocks
+- -
+l_owner varchar2(1000);
,0) + l_line_calls(l_line_no)
+- -
+l_object_name varchar2(1000);
.covered_blocks;
+- -
+l_result varchar2(4000);
+
- -
--- in 12.2 format_call_stack reportes not only package name, but also the procedure name
- -
--- when 11g and 12c reports only package name
- - 290 -
+c_expectation_search_pattern constant varchar2(500) :=
--Object line executions
+ +- + 12 +
+ +l_result.objects(l_source_object.full_name).executions := nvl(l_result.objects(l_source_object.full_name)
- +
+.executions
- -
+'(.*\.(UT_EXPECTATION[A-Z0-9#_$]*|UT|UTASSERT2?)(\.[A-Z0-9#_$]+)?\s+)+(.*)';
,0) + 1;
+- -
-begin
- - 290 -
-l_caller_stack_line := regexp_substr( a_call_stack, c_expectation_search_pattern, 1, 1, 'm', 4);
- - 290 -
-if l_caller_stack_line like '%.%' then
- - 25 -
-l_line_no := to_number( regexp_substr(l_caller_stack_line,'(0x)?[0-9a-f]+\s+(\d+)',subexpression => 2) );
- - 25 -
-l_owner := regexp_substr(l_caller_stack_line,'([A-Za-z0-9$#_]+)\.([A-Za-z0-9$#_]|\.)+',subexpression => 1);
- - 25 -
-l_object_name := regexp_substr(l_caller_stack_line,'([A-Za-z0-9$#_]+)\.(([A-Za-z0-9$#_]|\.)+)',subexpression => 2);
- - 25 -
-if l_owner is not null and l_object_name is not null and l_line_no is not null then
- - 25 -
+l_result := 'at "' || l_owner || '.' || l_object_name || '", line '|| l_line_no || ' '
+ +
- + 12 +
+ +l_result.objects(l_source_object.full_name).lines(l_line_no).executions := 1;
- +
+ +- +
+ +--Whenever there is no covered block treat as uncovered (query returns only lines where the blocks are in code so we
- +
+ +--dont have a false results here when there is no blocks
- +
+ +elsif l_line_calls(l_line_no).covered_blocks = 0 then
- +
+ +l_result.uncovered_lines := l_result.uncovered_lines + 1;
- +
+l_result.objects(l_source_object.full_name).uncovered_lines := l_result.objects(l_source_object.full_name)
- -
-|| ut_metadata.get_source_definition_line(l_owner, l_object_name, l_line_no);
- -
+end if;
.uncovered_lines + 1;
+ +- +
+l_result.objects(l_source_object.full_name).lines(l_line_no).executions := 0;
- -
-end if;
- - 290 +
+ +end if;
- +
+ +--increase part covered counter (+ 1/0)
- + 12 +
+ +l_result.objects(l_source_object.full_name).lines(l_line_no).partcove := l_line_calls(l_line_no).partcovered;
- + 12 +
+ +l_line_no := l_line_calls.next(l_line_no);
- +
+ +end loop;
- +
+ +end if;
- +
+ +end if;
- +
+ +- +
+ +end loop;
- +
+ +- + 10 +
+ +close l_source_objects_crsr;
- +
+ +$end
- +
+ +- + 10
-return l_result;
- -
-end;
- -
end;
+UT3.UT_FILE_MAPPER
100 % covered
21 relevant lines. 21 lines covered and 0 lines missed+ +
- +
+ +end get_coverage_data;
- +
+ +- +
+end;
UT3.UT_COVERAGE_HELPER
90 % lines covered
10 relevant lines. 9 lines covered and 1 lines missed+
- -
+package body ut_file_mapper is
package body ut_coverage_helper is
+- +
/*
- -
+utPLSQL - Version X.X.X.X
utPLSQL - Version 3
+- -
+Copyright 2016 - 2017 utPLSQL Project
Copyright 2016 - 2019 utPLSQL Project
+- +
- +
Licensed under the Apache License, Version 2.0 (the "License"):
- +
you may not use this file except in compliance with the License.
- +
You may obtain a copy of the License at
- +
- +
http://www.apache.org/licenses/LICENSE-2.0
- +
- +
Unless required by applicable law or agreed to in writing, software
- +
distributed under the License is distributed on an "AS IS" BASIS,
- +
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
See the License for the specific language governing permissions and
- +
limitations under the License.
- +
*/
- +
- -
+type tt_key_values is table of varchar2(4000) index by varchar2(4000);
+
- +
- -
+/**
type t_proftab_row is record (
+- -
+* Private functions
line binary_integer,
+- -
+*/
calls number(38,0)
+- -
+);
+- -
+function to_hash_table(a_key_value_tab ut_key_value_pairs) return tt_key_values is
+
- -
+l_result tt_key_values;
type t_proftab_rows is table of t_proftab_row;
+- -
-begin
- - 12 -
-if a_key_value_tab is not null then
- - 84 -
-for i in 1 .. a_key_value_tab.count loop
- - 72 -
+l_result(upper(a_key_value_tab(i).key)) := a_key_value_tab(i).value;
+ +
- +
+ +type t_block_row is record(
- +
+ +line binary_integer
- +
+,blocks binary_integer
- -
+end loop;
,covered_blocks binary_integer);
+- -
-end if;
- - 12 -
+return l_result;
+ +
- +
+type t_block_rows is table of t_block_row;
- -
-end;
- + +
- +
+procedure insert_into_tmp_table(a_data t_coverage_sources_tmp_rows) is
- -
-/**
- -
+* Public functions
begin
+ +- + 11 +
+forall i in 1 .. a_data.count
- -
+*/
insert into ut_coverage_sources_tmp
+- -
+function default_file_to_obj_type_map return ut_key_value_pairs is
(full_name,owner,name,line,text, to_be_skipped)
+- -
-begin
- - 13 -
+return ut_key_value_pairs(
values(a_data(i).full_name,a_data(i).owner,a_data(i).name,a_data(i).line,a_data(i).text,a_data(i).to_be_skipped);
+ +- +
+end;
- -
+ut_key_value_pair('fnc', 'FUNCTION'),
+
- -
+ut_key_value_pair('prc', 'PROCEDURE'),
procedure cleanup_tmp_table is
+- -
+ut_key_value_pair('tpb', 'TYPE BODY'),
pragma autonomous_transaction;
+- -
-ut_key_value_pair('pkb', 'PACKAGE BODY'),
- -
+ut_key_value_pair('bdy', 'PACKAGE BODY'),
begin
+ +- + 126 +
+execute immediate 'truncate table ut_coverage_sources_tmp';
- -
+ut_key_value_pair('trg', 'TRIGGER')
end;
+- -
+);
+
- -
+end;
function is_tmp_table_populated return boolean is
+- -
+l_result integer;
+- -
-function build_file_mappings(
- -
-a_file_paths ut_varchar2_list,
- -
+a_file_to_object_type_mapping ut_key_value_pairs := default_file_to_obj_type_map(),
begin
+ +- + 10 +
+ +select 1 into l_result from ut_coverage_sources_tmp where rownum = 1;
- +
+return (l_result = 1);
- -
-a_regex_pattern varchar2 := gc_file_mapping_regex,
- -
-a_object_owner_subexpression positive := gc_regex_owner_subexpression,
- -
+a_object_name_subexpression positive := gc_regex_name_subexpression,
exception
+ +- + 20 +
+ +when no_data_found then
- + 10 +
+return false;
- -
+a_object_type_subexpression positive := gc_regex_type_subexpression
end;
+- -
+) return ut_file_mappings is
+
- -
-begin
- - 10 -
+return build_file_mappings(
function get_tmp_table_objects_cursor return t_tmp_table_objects_crsr is
+ +- +
+l_result t_tmp_table_objects_crsr;
- -
-null, a_file_paths, a_file_to_object_type_mapping, a_regex_pattern,
- -
+a_object_owner_subexpression, a_object_name_subexpression, a_object_type_subexpression
begin
+ +- + 20 +
+open l_result for
- -
+);
select o.owner, o.name, o.full_name, max(o.line) lines_count,
+- -
+end;
cast(
+- -
+collect(decode(to_be_skipped, 'Y', to_char(line))) as ut_varchar2_list
+- -
+function build_file_mappings(
) to_be_skipped_list
+- -
+a_object_owner varchar2,
from ut_coverage_sources_tmp o
+- -
+a_file_paths ut_varchar2_list,
group by o.owner, o.name, o.full_name;
+- -
-a_file_to_object_type_mapping ut_key_value_pairs := default_file_to_obj_type_map(),
- -
+a_regex_pattern varchar2 := gc_file_mapping_regex,
+ +
- + 20 +
+return l_result;
- -
+a_object_owner_subexpression positive := gc_regex_owner_subexpression,
end;
+- -
+a_object_name_subexpression positive := gc_regex_name_subexpression,
+
- -
+a_object_type_subexpression positive := gc_regex_type_subexpression
function get_tmp_table_object_lines(a_owner varchar2, a_object_name varchar2) return ut_varchar2_list is
+- -
+) return ut_file_mappings is
l_result ut_varchar2_list;
+- -
-l_key_values tt_key_values;
- -
+l_mappings ut_file_mappings;
begin
+ +- + 1 +
+select rtrim(s.text,chr(10)) text
- -
+l_mapping ut_file_mapping;
bulk collect into l_result
+- -
+l_object_type_key varchar2(4000);
from ut_coverage_sources_tmp s
+- -
+l_object_type varchar2(4000);
where s.owner = a_owner
+- -
+l_object_owner varchar2(4000);
and s.name = a_object_name
+- -
-begin
- - 13 -
-if a_file_paths is not null then
- - 12 -
-l_key_values := to_hash_table(a_file_to_object_type_mapping);
- - 12 -
-l_mappings := ut_file_mappings();
- - 231 -
-for i in 1 .. a_file_paths.count loop
- - 219 -
-l_object_type_key := upper(regexp_substr(a_file_paths(i), a_regex_pattern,1,1,'i',a_object_type_subexpression));
- - 219 -
-if l_key_values.exists(l_object_type_key) then
- - 93 -
-l_object_type := upper(l_key_values(l_object_type_key));
- -
-else
- - 126 -
-l_object_type := null;
- -
-end if;
- - 219 -
-l_object_owner := upper(regexp_substr(a_file_paths(i), a_regex_pattern, 1, 1, 'i', a_object_owner_subexpression));
- - 219 -
-if l_object_owner is null then
- - 219 -
-l_object_owner := coalesce( a_object_owner, sys_context('USERENV', 'CURRENT_SCHEMA') );
- -
-end if;
- - 219 -
-l_mapping := ut_file_mapping(
- -
-file_name => a_file_paths(i),
- -
-object_owner => l_object_owner,
- -
-object_name => upper(regexp_substr(a_file_paths(i), a_regex_pattern, 1, 1, 'i', a_object_name_subexpression)),
- -
-object_type => l_object_type
- -
-);
- - 219 -
-l_mappings.extend();
- - 219 -
-l_mappings(l_mappings.last) := l_mapping;
- -
-end loop;
- -
-end if;
- - 13 -
-return l_mappings;
- +
+ +order by s.line;
- +
+ +- + 1 +
+ +return l_result;
- -
end;
- + +
- -
- -
end;
+UT3.UT_METADATA
94.29 % covered
35 relevant lines. 33 lines covered and 2 lines missed+ +
- +
+end;
UT3.UT_COVERAGE_HELPER_BLOCK
83.33 % lines covered
12 relevant lines. 10 lines covered (including 1 lines partially covered ) and 2 lines missed+
- -
+package body ut_metadata as
package body ut_coverage_helper_block is
+- +
/*
- -
+utPLSQL - Version X.X.X.X
utPLSQL - Version 3
+- -
+Copyright 2016 - 2017 utPLSQL Project
Copyright 2016 - 2019 utPLSQL Project
+- +
- +
Licensed under the Apache License, Version 2.0 (the "License"):
- +
you may not use this file except in compliance with the License.
- +
You may obtain a copy of the License at
- +
- +
http://www.apache.org/licenses/LICENSE-2.0
- +
- +
Unless required by applicable law or agreed to in writing, software
- +
distributed under the License is distributed on an "AS IS" BASIS,
- +
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
See the License for the specific language governing permissions and
- +
limitations under the License.
- +
*/
- +
- -
+------------------------------
type t_proftab_row is record (
+- -
+--public definitions
line binary_integer,
+- -
+calls number(38,0)
+- -
+procedure do_resolve(a_owner in out nocopy varchar2, a_object in out nocopy varchar2) is
);
+- -
+l_procedure_name varchar2(200);
+
- -
-begin
- - 1076 -
+do_resolve(a_owner, a_object, l_procedure_name );
type t_proftab_rows is table of t_proftab_row;
+ +- +
+- -
+end do_resolve;
type t_block_row is record(
+- -
+line binary_integer
+- -
+procedure do_resolve(a_owner in out nocopy varchar2, a_object in out nocopy varchar2, a_procedure_name in out nocopy varchar2) is
,blocks binary_integer
+- -
-l_name varchar2(200);
- - 2938 -
+l_context integer := 1; --plsql
,covered_blocks binary_integer);
+ +- +
+- -
+l_dblink varchar2(200);
type t_block_rows is table of t_block_row;
+- -
+l_part1_type number;
+
- -
+l_object_number number;
procedure coverage_start(a_run_comment varchar2, a_coverage_id out integer) is
+- -
begin
- - 2938 -
-l_name := form_name(a_owner, a_object, a_procedure_name);
- -
-- - 2938 -
+ +dbms_utility.name_resolve(name => l_name
- +
+ +$if dbms_db_version.version = 12 and dbms_db_version.release >= 2 or dbms_db_version.version > 12 $then
- +
+ +a_coverage_id := dbms_plsql_code_coverage.start_coverage(run_comment => a_run_comment);
- +
+$else
- -
+,context => l_context
null;
+- -
+,schema => a_owner
$end
+- -
+,part1 => a_object
end;
+- -
+,part2 => a_procedure_name
+
- -
+,dblink => l_dblink
procedure coverage_stop is
+- -
+,part1_type => l_part1_type
begin
+- -
-,object_number => l_object_number);
- -
-- -
-end do_resolve;
- -
+$if dbms_db_version.version = 12 and dbms_db_version.release >= 2 or dbms_db_version.version > 12 $then
+ +- +
+ +dbms_plsql_code_coverage.stop_coverage();
- +
+ +$else
- +
+null;
- -
+function form_name(a_owner_name varchar2, a_object varchar2, a_subprogram varchar2 default null) return varchar2 is
$end
+- -
+l_name varchar2(200);
end;
+- +
+ +- +
+ +function block_results(a_object_owner varchar2, a_object_name varchar2, a_coverage_id integer) return t_block_rows is
- +
+ +l_coverage_rows t_block_rows;
- -
begin
- - 3589 -
-l_name := trim(a_object);
- - 3589 -
-if trim(a_owner_name) is not null then
- - 3496 -
+l_name := trim(a_owner_name) || '.' || l_name;
- -
-end if;
- - 3589 -
-if trim(a_subprogram) is not null then
- - 1886 -
+l_name := l_name || '.' || trim(a_subprogram);
+ +
- + 46 +
+ +select ccb.line as line,
- +
+count(ccb.block) as blocks,
- -
-end if;
- - 3589 -
+return l_name;
sum(ccb.covered) as covered_blocks
+ +- +
+bulk collect into l_coverage_rows
- -
+end form_name;
from dbmspcc_units ccu
+- -
+left outer join dbmspcc_blocks ccb
+- -
+function package_valid(a_owner_name varchar2, a_package_name in varchar2) return boolean as
on ccu.run_id = ccb.run_id
+- -
+l_cnt number;
and ccu.object_id = ccb.object_id
+- -
+l_schema varchar2(200);
where ccu.run_id = a_coverage_id
+- -
+l_package_name varchar2(200);
and ccu.owner = a_object_owner
+- -
+l_procedure_name varchar2(200);
and ccu.name = a_object_name
+- -
+begin
group by ccb.line
+- +
+ +order by 1;
- -
- - 626 -
-l_schema := a_owner_name;
- - 626 -
+ +l_package_name := a_package_name;
- + 46 +
+return l_coverage_rows;
- +
+ +end;
- -
- - 626 -
+do_resolve(l_schema, l_package_name, l_procedure_name);
- -
-- - 624 -
+select count(decode(status, 'VALID', 1, null)) / count(*)
function get_raw_coverage_data(a_object_owner varchar2, a_object_name varchar2, a_coverage_id integer) return ut_coverage_helper.t_unit_line_calls is
+ +- +
+l_tmp_data t_block_rows;
- -
+into l_cnt
l_results ut_coverage_helper.t_unit_line_calls;
+- -
+from all_objects
+
- -
+where owner = l_schema
begin
+- -
-and object_name = l_package_name
- -
+and object_type in ('PACKAGE');
$if dbms_db_version.version = 12 and dbms_db_version.release >= 2 or dbms_db_version.version > 12 $then
+ +- + 46 +
+l_tmp_data := block_results(a_object_owner, a_object_name, a_coverage_id);
- -
- -
--- expect both package and body to be valid
- - 624 -
-return l_cnt = 1;
- -
-exception
- - 2 -
-when others then
- - 2 -
-return false;
- -
+ +end;
- + 58 +
+ +for i in 1 .. l_tmp_data.count loop
- + 12 +
+ +l_results(l_tmp_data(i).line).blocks := l_tmp_data(i).blocks;
- + 12 +
+ +l_results(l_tmp_data(i).line).covered_blocks := l_tmp_data(i).covered_blocks;
- + 12 +
+ +l_results(l_tmp_data(i).line).partcovered := case
- + 1/2 + 1 +
+ +when (l_tmp_data(i).covered_blocks > 0) and
- + 1 +
+(l_tmp_data(i).blocks > l_tmp_data(i).covered_blocks) then
- -
+1
+- -
+function procedure_exists(a_owner_name varchar2, a_package_name in varchar2, a_procedure_name in varchar2)
else
+- -
+return boolean as
0
+- -
+l_cnt number;
end;
+- -
+l_schema varchar2(200);
end loop;
+- -
-l_package_name varchar2(200);
- -
+l_procedure_name varchar2(200);
$end
+ +- + 46 +
+return l_results;
- -
-begin
- -
-- - 622 -
-l_schema := a_owner_name;
- - 622 -
-l_package_name := a_package_name;
- - 622 -
-l_procedure_name := a_procedure_name;
- -
-- - 622 -
-do_resolve(l_schema, l_package_name, l_procedure_name);
- -
-- - 619 -
-select count(*)
- -
-into l_cnt
- -
-from all_procedures
- -
-where owner = l_schema
- -
-and object_name = l_package_name
- -
-and procedure_name = l_procedure_name;
- -
-- -
---expect one method only for the package with that name.
- - 619 -
-return l_cnt = 1;
- -
-exception
- - 3 -
-when others then
- - 3 -
-return false;
- -
-end;
- -
-- -
-function get_package_spec_source(a_owner varchar2, a_object_name varchar2) return clob is
- -
-l_lines sys.dbms_preprocessor.source_lines_t;
- -
-l_source clob;
- -
-begin
- -
-begin
- - 1076 -
-l_lines := sys.dbms_preprocessor.get_post_processed_source(object_type => 'PACKAGE',
- -
-schema_name => a_owner,
- -
-object_name => a_object_name);
- -
-- - 57682 -
-for i in 1..l_lines.count loop
- - 56607 -
-ut_utils.append_to_clob(l_source, l_lines(i));
- -
-end loop;
- -
-- -
-end;
- - 1075 -
-return l_source;
- -
-end;
- -
-- -
-function get_source_definition_line(a_owner varchar2, a_object_name varchar2, a_line_no integer) return varchar2 is
- -
-l_line varchar2(4000);
- -
-l_cursor sys_refcursor;
- -
-begin
- - 25 -
-open l_cursor for
- -
-select text from all_source s
- -
-where s.owner = a_owner and s.name = a_object_name and s.line = a_line_no
- -
--- skip the declarations, consider only definitions
- -
-and s.type not in ('PACKAGE','TYPE');
- - 25 -
-fetch l_cursor into l_line;
- - 25 -
-close l_cursor;
- - 25 -
-return ltrim(rtrim( l_line, chr(10) ));
- -
-exception
- -
-when no_data_found then
- -
-return null;
- -
end;
- -
-- -
end;
+UT3.UT_OUTPUT_BUFFER
90 % covered
40 relevant lines. 36 lines covered and 4 lines missed+ +
- +
+end;
UT3.UT_COVERAGE_HELPER_PROFILER
70 % lines covered
10 relevant lines. 7 lines covered and 3 lines missed+
- -
+package body ut_output_buffer is
package body ut_coverage_helper_profiler is
+- +
/*
- -
+utPLSQL - Version X.X.X.X
utPLSQL - Version 3
+- -
+Copyright 2016 - 2017 utPLSQL Project
Copyright 2016 - 2019 utPLSQL Project
+- +
- +
Licensed under the Apache License, Version 2.0 (the "License"):
- +
you may not use this file except in compliance with the License.
- +
You may obtain a copy of the License at
- +
- +
http://www.apache.org/licenses/LICENSE-2.0
- +
- +
Unless required by applicable law or agreed to in writing, software
- +
distributed under the License is distributed on an "AS IS" BASIS,
- +
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
See the License for the specific language governing permissions and
- +
limitations under the License.
- +
*/
- +
- -
+procedure send_line(a_reporter ut_reporter_base, a_text varchar2) is
type t_proftab_row is record (
+- -
+l_text_list ut_varchar2_rows;
line binary_integer,
+- -
+pragma autonomous_transaction;
calls number(38,0)
+- -
-begin
- - 45619 -
-if a_reporter is not null and a_reporter.reporter_id is not null and a_reporter.start_date is not null and a_text is not null then
- - 45601 -
-if length(a_text) > ut_utils.gc_max_storage_varchar2_len then
- -
-l_text_list := ut_utils.convert_collection(ut_utils.clob_to_table(a_text, ut_utils.gc_max_storage_varchar2_len));
- -
+insert /*+ append */
);
+ +- +
+ +- +
+ +type t_proftab_rows is table of t_proftab_row;
- +
+ +- +
+type t_block_row is record(
- -
+into ut_output_buffer_tmp(start_date, reporter_id, message_id, text)
line binary_integer
+- -
+select a_reporter.start_date, a_reporter.reporter_id, ut_message_id_seq.nextval, t.column_value
,blocks binary_integer
+- -
+from table(l_text_list) t;
,covered_blocks binary_integer);
+- -
-else
- - 45601 -
+insert /*+ append */ into ut_output_buffer_tmp(start_date, reporter_id, message_id, text)
+ +
- +
+type t_block_rows is table of t_block_row;
- -
+values (a_reporter.start_date, a_reporter.reporter_id, ut_message_id_seq.nextval, a_text);
+
- -
-end if;
- - 45601 -
+commit;
+ +
- +
+procedure coverage_start(a_run_comment varchar2,a_coverage_id out integer) is
- -
-end if;
- -
+end;
begin
+ +- +
+dbms_profiler.start_profiler(run_comment => a_run_comment, run_number => a_coverage_id);
- -
-- -
+procedure close(a_reporter ut_reporter_base) is
end;
+ +- +
+- -
+pragma autonomous_transaction;
procedure coverage_pause is
+- +
+ +l_return_code binary_integer;
- -
begin
- - 42 -
-insert /*+ append */ into ut_output_buffer_tmp(start_date, reporter_id, message_id, is_finished)
- -
-values (a_reporter.start_date, a_reporter.reporter_id, ut_message_id_seq.nextval, 1);
- - 42 -
-commit;
- + +
- +
+ +l_return_code := dbms_profiler.pause_profiler();
- -
end;
- + +
- + +
- +
+procedure coverage_resume is
- -
+procedure close(a_reporters ut_reporters) is
l_return_code binary_integer;
+- -
-pragma autonomous_transaction;
- -
begin
- - 48 -
-if a_reporters is not null then
- - 48 -
+ +forall i in 1 .. a_reporters.count
- + 22 +
+ +l_return_code := dbms_profiler.resume_profiler();
- +
+ +end;
- +
+- -
+insert /*+ append */ into ut_output_buffer_tmp(start_date, reporter_id, message_id, is_finished)
procedure coverage_stop is
+- -
-values (a_reporters(i).start_date, a_reporters(i).reporter_id, ut_message_id_seq.nextval, 1);
- -
-end if;
- - 48 -
-commit;
- +
+ +begin
- +
+ +dbms_profiler.stop_profiler();
- -
end;
- + +
- + +
- +
+function proftab_results(a_object_owner varchar2, a_object_name varchar2, a_coverage_id integer) return t_proftab_rows is
- -
+function get_lines(a_reporter_id varchar2, a_timeout_sec naturaln := gc_max_wait_sec) return ut_varchar2_rows pipelined is
l_coverage_rows t_proftab_rows;
+- -
-l_buffer_data ut_varchar2_rows;
- - 48 -
-l_wait_wait_time number(10,1) := 0;
- - 48 -
+l_finished boolean := false;
begin
+ +- + 46 +
+ +select
- +
+d.line#,
- -
+function get_data_from_buffer return ut_varchar2_rows is
case when sum(d.total_occur) = 0 and sum(d.total_time) > 0 then 1 else sum(d.total_occur) end total_occur
+- -
+l_results ut_varchar2_rows;
bulk collect into l_coverage_rows
+- -
+pragma autonomous_transaction;
from plsql_profiler_units u
+- -
-begin
- - 48 -
+delete from (
join plsql_profiler_data d
+ +- +
+on u.runid = d.runid
- -
+select *
and u.unit_number = d.unit_number
+- -
+from ut_output_buffer_tmp where reporter_id = a_reporter_id order by message_id
where u.runid = a_coverage_id
+- -
+)
and u.unit_owner = a_object_owner
+- -
-returning text bulk collect into l_results;
- - 48 -
-commit;
- - 48 -
+return l_results;
and u.unit_name = a_object_name
+ +- +
+ +and u.unit_type in ('PACKAGE BODY', 'TYPE BODY', 'PROCEDURE', 'FUNCTION', 'TRIGGER')
- +
+group by d.line#;
- -
-end;
- -
-begin
- - 48 -
-loop
- - 48 -
-l_buffer_data := get_data_from_buffer();
- -
---nothing fetched from output, wait and try again
- - 48 -
-if l_buffer_data.count = 0 then
- -
-dbms_lock.sleep(gc_sleep_time);
- -
-l_wait_wait_time := l_wait_wait_time + gc_sleep_time;
- -
-else
- - 50 -
-for i in 1 .. l_buffer_data.count loop
- - 19741 -
-if l_buffer_data(i) is not null then
- - 19694 -
-pipe row(l_buffer_data(i));
- -
-else
- - 47 -
-l_finished := true;
- - 47 -
-exit;
- -
-end if;
- -
-end loop;
- -
-end if;
- - 48 -
-exit when l_wait_wait_time >= a_timeout_sec or l_finished;
- -
-end loop;
- - 48 -
-return;
- -
-end;
- -
- -
-function get_lines_cursor(a_reporter_id varchar2, a_timeout_sec naturaln := gc_max_wait_sec) return sys_refcursor is
- -
-l_lines sys_refcursor;
- -
-begin
- - 46 -
-open l_lines for
- -
-select column_value as text
- -
-from table(ut_output_buffer.get_lines(a_reporter_id, a_timeout_sec));
- + +
- 46 -
-return l_lines;
- +
+ +return l_coverage_rows;
- -
end;
- + +
- -
- -
-procedure lines_to_dbms_output(a_reporter_id varchar2, a_timeout_sec naturaln := gc_max_wait_sec) is
- -
-l_lines sys_refcursor;
- -
-l_line varchar2(32767);
- + +
- +
+ +function get_raw_coverage_data(a_object_owner varchar2, a_object_name varchar2, a_coverage_id integer) return ut_coverage_helper.t_unit_line_calls is
- +
+ +l_tmp_data t_proftab_rows;
- +
+ +l_results ut_coverage_helper.t_unit_line_calls;
- -
begin
- - 18 -
-l_lines := ut_output_buffer.get_lines_cursor(a_reporter_id, a_timeout_sec);
- - 460 -
-loop
- - 460 -
-fetch l_lines into l_line;
- - 460 -
-exit when l_lines%notfound;
- - 442 -
-dbms_output.put_line(l_line);
- -
-end loop;
- - 18 -
-close l_lines;
- -
-end;
- + +
- + 46 +
+ +l_tmp_data := proftab_results(a_object_owner, a_object_name, a_coverage_id);
- -
- -
-procedure cleanup_buffer(a_retention_time_sec naturaln := gc_buffer_retention_sec) is
- - 48 -
-l_retention_days number := a_retention_time_sec / (60 * 60 * 24);
- - 48 -
-l_max_retention_date date := sysdate - l_retention_days;
- -
-pragma autonomous_transaction; -- the cleanup should initiate transaction
- -
-begin
- - 48 -
-delete from ut_output_buffer_tmp t
- -
-where t.start_date <= l_max_retention_date;
- - 48 -
-commit;
- + +
- + 71 +
+ +for i in 1 .. l_tmp_data.count loop
- + 25 +
+ +l_results(l_tmp_data(i).line).calls := l_tmp_data(i).calls;
- +
+ +end loop;
- + 46 +
+ +return l_results;
- -
end;
- + +
- -
- -
end;
+UT3.UT_SUITE_MANAGER
94.85 % covered
194 relevant lines. 184 lines covered and 10 lines missed+ +
- +
+end;
+UT3.UT_COVERAGE_PROFILER
100 % lines covered
37 relevant lines. 37 lines covered and 0 lines missed+
- -
+package body ut_suite_manager is
package body ut_coverage_profiler is
+- +
/*
- -
+utPLSQL - Version X.X.X.X
utPLSQL - Version 3
+- -
+Copyright 2016 - 2017 utPLSQL Project
Copyright 2016 - 2019 utPLSQL Project
+- +
- +
Licensed under the Apache License, Version 2.0 (the "License"):
- +
you may not use this file except in compliance with the License.
- +
You may obtain a copy of the License at
- +
- +
http://www.apache.org/licenses/LICENSE-2.0
- +
- +
Unless required by applicable law or agreed to in writing, software
- +
distributed under the License is distributed on an "AS IS" BASIS,
- +
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
See the License for the specific language governing permissions and
- +
limitations under the License.
- +
*/
- +
- -
+type t_schema_info is record (changed_at date, obj_cnt integer);
/**
+- -
+* Public functions
+- -
+type tt_schema_suites is table of ut_logical_suite index by varchar2(4000 char);
*/
+- -
+type t_schema_cache is record(
function get_coverage_data(a_coverage_options ut_coverage_options, a_coverage_id integer) return ut_coverage.t_coverage is
+- -
-schema_suites tt_schema_suites
- -
-,changed_at date
- -
+,obj_cnt integer);
l_line_calls ut_coverage_helper.t_unit_line_calls;
+ +- + 10 +
+ +l_result ut_coverage.t_coverage;
- + 10 +
+l_new_unit ut_coverage.t_unit_coverage;
- -
+type tt_schema_suites_list is table of t_schema_cache index by varchar2(128 char);
l_line_no binary_integer;
+- -
+l_source_objects_crsr ut_coverage_helper.t_tmp_table_objects_crsr;
+- -
+g_schema_suites tt_schema_suites_list;
l_source_object ut_coverage_helper.t_tmp_table_object;
+- -
-- -
-function trim_path(a_path varchar2, a_part varchar2) return varchar2 is
- -
begin
- - 182 -
-return substr(a_path, nvl(length(a_part), 0) + 1);
- -
-end;
- + +
- -
- -
-function get_schema_info(a_owner_name varchar2) return t_schema_info is
- -
-l_info t_schema_info;
- -
-begin
- - 171 -
-select nvl(max(t.last_ddl_time), date '4999-12-31'), count(*)
- -
-into l_info
- -
-from all_objects t
- -
-where t.owner = a_owner_name
- -
-and t.object_type in ('PACKAGE');
- - 171 -
-return l_info;
- -
-end;
- + +
- + 10 +
+ +l_source_objects_crsr := ut_coverage_helper.get_tmp_table_objects_cursor();
- + 56 +
+ +loop
- + 56 +
+ +fetch l_source_objects_crsr into l_source_object;
- + 56 +
+ +exit when l_source_objects_crsr%notfound;
- + +
- +
+ +--get coverage data
- + 46 +
+ +l_line_calls := ut_coverage_helper_profiler.get_raw_coverage_data( l_source_object.owner, l_source_object.name, a_coverage_id);
- +
+ +- +
+ +--if there is coverage, we need to filter out the garbage (badly indicated data from dbms_profiler)
- + 46 +
+ +if l_line_calls.count > 0 then
- +
+ +--remove lines that should not be indicted as meaningful
- + 70 +
+ +for i in 1 .. l_source_object.to_be_skipped_list.count loop
- + 63 +
+ +if l_source_object.to_be_skipped_list(i) is not null then
- + 63 +
+ +l_line_calls.delete(l_source_object.to_be_skipped_list(i));
- +
+end if;
- -
+function config_package(a_owner_name varchar2, a_object_name varchar2) return ut_logical_suite is
end loop;
+- -
+l_annotation_data ut_annotations.typ_annotated_package;
end if;
+- -
+l_suite_name ut_annotations.t_annotation_name;
+
- -
-l_test ut_test;
- -
+l_proc_annotations ut_annotations.tt_annotations;
--if there are no file mappings or object was actually captured by profiler
+ +- + 46 +
+if a_coverage_options.file_mappings is null or l_line_calls.count > 0 then
- +
- -
-l_default_setup_proc varchar2(250 char);
- -
+l_default_teardown_proc varchar2(250 char);
--populate total stats
+ +- + 46 +
+l_result.total_lines := nvl(l_result.total_lines,0) + l_source_object.lines_count;
- -
-l_suite_setup_proc varchar2(250 char);
- -
-l_suite_teardown_proc varchar2(250 char);
- -
-l_suite_path varchar2(4000 char);
- -
-- -
-l_proc_name ut_annotations.t_procedure_name;
- -
+--populate object level coverage stats
+ +- + 46 +
+ +if not l_result.objects.exists(l_source_object.full_name) then
- + 46 +
+ +l_result.objects(l_source_object.full_name) := l_new_unit;
- + 46 +
+ +l_result.objects(l_source_object.full_name).owner := l_source_object.owner;
- + 46 +
+ +l_result.objects(l_source_object.full_name).name := l_source_object.name;
- + 46 +
+l_result.objects(l_source_object.full_name).total_lines := l_source_object.lines_count;
- -
+l_owner_name varchar2(250 char);
end if;
+- -
-l_object_name varchar2(250 char);
- -
-l_suite ut_logical_suite;
- +
+ +--map to results
- + 46 +
+ +l_line_no := l_line_calls.first;
- + 46 +
+ +if l_line_no is null then
- + 39 +
+ +l_result.uncovered_lines := l_result.uncovered_lines + l_source_object.lines_count;
- + 39 +
+ +l_result.objects(l_source_object.full_name).uncovered_lines := l_source_object.lines_count;
- + 1 +
+ +else
- + 32 +
+ +loop
- + 32 +
+ +exit when l_line_no is null;
- -
- -
-l_suite_rollback integer;
- -
-l_suite_rollback_annotation varchar2(4000);
- -
-e_insufficient_priv exception;
- -
-pragma exception_init(e_insufficient_priv,-01031);
- -
-begin
- - 1076 -
-l_owner_name := a_owner_name;
- - 1076 -
+ +l_object_name := a_object_name;
- + 25 +
+if l_line_calls(l_line_no).calls > 0 then
- -
-begin
- - 1076 -
-ut_metadata.do_resolve(a_owner => l_owner_name, a_object => l_object_name);
- -
-exception
- -
-when e_insufficient_priv then
- -
-return null;
- -
-end;
- - 1075 -
-l_annotation_data := ut_annotations.get_package_annotations(a_owner_name => l_owner_name, a_name => l_object_name);
- -
-- - 1075 -
+if l_annotation_data.package_annotations.exists('suite') then
--total stats
+ +- + 18 +
+ +l_result.covered_lines := l_result.covered_lines + 1;
- + 18 +
+ +l_result.executions := l_result.executions + l_line_calls(l_line_no).calls;
- +
+ +--object level stats
- + 18 +
+ +l_result.objects(l_source_object.full_name).covered_lines := l_result.objects(l_source_object.full_name).covered_lines + 1;
- + 18 +
+ +l_result.objects(l_source_object.full_name).executions := l_result.objects(l_source_object.full_name).executions + l_line_calls(l_line_no).calls;
- + 7 +
+ +elsif l_line_calls(l_line_no).calls = 0 then
- + 7 +
+ +l_result.uncovered_lines := l_result.uncovered_lines + 1;
- + 7 +
+l_result.objects(l_source_object.full_name).uncovered_lines := l_result.objects(l_source_object.full_name).uncovered_lines + 1;
- +
+ +end if;
- + 25 +
+ +l_result.objects(l_source_object.full_name).lines(l_line_no).executions := l_line_calls(l_line_no).calls;
- -
- - 311 -
-if l_annotation_data.package_annotations.exists('displayname') then
- - 50 -
-l_suite_name := l_annotation_data.package_annotations('displayname').text;
- -
-else
- - 261 -
+ +l_suite_name := l_annotation_data.package_annotations('suite').text;
- + 25 +
+ +l_line_no := l_line_calls.next(l_line_no);
- +
+end loop;
- -
+end if;
end if;
+- +
+ +end if;
- -
- - 311 -
-if l_annotation_data.package_annotations.exists('suitepath') and l_annotation_data.package_annotations('suitepath').text is not null then
- - 149 -
+ +l_suite_path := l_annotation_data.package_annotations('suitepath').text || '.' || lower(l_object_name);
- +
+end loop;
- -
-end if;
- -
- - 311 -
-if l_annotation_data.package_annotations.exists('rollback') then
- - 52 -
-l_suite_rollback_annotation := l_annotation_data.package_annotations('rollback').text;
- - 52 -
-if lower(l_suite_rollback_annotation) = 'manual' then
- -
-l_suite_rollback := ut_utils.gc_rollback_manual;
- -
-else
- - 311 -
-l_suite_rollback := ut_utils.gc_rollback_auto;
- -
-end if;
- -
-else
- -
-l_suite_rollback := ut_utils.gc_rollback_auto;
- -
-end if;
- + +
- + 10 +
+ +close l_source_objects_crsr;
- -
- - 1549 -
-for i in 1 .. l_annotation_data.procedure_annotations.count loop
- - 1238 -
-exit when l_default_setup_proc is not null and l_default_teardown_proc is not null and l_suite_setup_proc is not null and l_suite_teardown_proc is not null;
- - 1238 -
-l_proc_name := l_annotation_data.procedure_annotations(i).name;
- - 1238 -
-l_proc_annotations := l_annotation_data.procedure_annotations(i).annotations;
- + +
- + 10 +
+ +return l_result;
- +
+ +end get_coverage_data;
- -
- - 1238 -
-if l_proc_annotations.exists('beforeeach') and l_default_setup_proc is null then
- - 207 -
-l_default_setup_proc := l_proc_name;
- - 1031 -
-elsif l_proc_annotations.exists('aftereach') and l_default_teardown_proc is null then
- - 206 -
-l_default_teardown_proc := l_proc_name;
- - 825 -
-elsif l_proc_annotations.exists('beforeall') and l_suite_setup_proc is null then
- - 68 -
-l_suite_setup_proc := l_proc_name;
- - 757 -
-elsif l_proc_annotations.exists('afterall') and l_suite_teardown_proc is null then
- - 60 -
-l_suite_teardown_proc := l_proc_name;
- -
-end if;
- + +
- +
+end;
+UT3.UT_COVERAGE_REPORTER_BASE
100 % lines covered
16 relevant lines. 16 lines covered and 0 lines missed+ +
- +
+ +type body ut_coverage_reporter_base is
- +
+ +/*
- +
+ +utPLSQL - Version 3
- +
+ +Copyright 2016 - 2019 utPLSQL Project
- -
- -
-end loop;
- - 311 -
-l_suite := ut_suite (
- -
-a_object_owner => l_owner_name,
- -
-a_object_name => l_object_name,
- -
-a_name => l_object_name, --this could be different for sub-suite (context)
- -
-a_path => l_suite_path, --a patch for this suite (excluding the package name of current suite)
- -
-a_description => l_suite_name,
- -
-a_rollback_type => l_suite_rollback,
- -
-a_disabled_flag => l_annotation_data.package_annotations.exists('disabled'),
- -
-a_before_all_proc_name => l_suite_setup_proc,
- -
-a_after_all_proc_name => l_suite_teardown_proc
- -
-);
- + +
- +
+ +Licensed under the Apache License, Version 2.0 (the "License"):
- +
+ +you may not use this file except in compliance with the License.
- +
+ +You may obtain a copy of the License at
- -
- + +
- +
+ +http://www.apache.org/licenses/LICENSE-2.0
- -
- - 1549 -
-for i in 1 .. l_annotation_data.procedure_annotations.count loop
- - 1238 -
-l_proc_name := l_annotation_data.procedure_annotations(i).name;
- - 1238 -
-l_proc_annotations := l_annotation_data.procedure_annotations(i).annotations;
- - 1238 -
-if l_proc_annotations.exists('test') then
- - 697 -
-declare
- -
-l_beforetest_procedure varchar2(30 char);
- -
-l_aftertest_procedure varchar2(30 char);
- -
-l_rollback_annotation varchar2(4000);
- - 697 -
-l_rollback_type integer := l_suite_rollback;
- -
-l_displayname varchar2(4000);
- -
-begin
- - 697 -
-if l_proc_annotations.exists('beforetest') then
- - 204 -
-l_beforetest_procedure := l_proc_annotations('beforetest').text;
- -
-end if;
- -
-- - 697 -
-if l_proc_annotations.exists('aftertest') then
- - 205 -
-l_aftertest_procedure := l_proc_annotations('aftertest').text;
- -
-end if;
- -
-- - 697 -
-if l_proc_annotations.exists('displayname') then
- - 52 -
-l_displayname := l_proc_annotations('displayname').text;
- -
-else
- - 645 -
-l_displayname := l_proc_annotations('test').text;
- -
-end if;
- + +
- +
+ +Unless required by applicable law or agreed to in writing, software
- +
+ +distributed under the License is distributed on an "AS IS" BASIS,
- +
+ +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
+ +See the License for the specific language governing permissions and
- +
+ +limitations under the License.
- +
+ +*/
- -
- - 697 -
-if l_proc_annotations.exists('rollback') then
- - 54 -
-l_rollback_annotation := l_proc_annotations('rollback').text;
- - 54 -
-if lower(l_rollback_annotation) = 'manual' then
- - 2 -
-l_rollback_type := ut_utils.gc_rollback_manual;
- - 52 -
-elsif lower(l_rollback_annotation) = 'auto' then
- - 52 -
-l_rollback_type := ut_utils.gc_rollback_auto;
- -
-else
- -
-l_rollback_type := l_suite_rollback;
- -
-end if;
- -
-end if;
- + +
- +
+ +overriding final member procedure before_calling_run(self in out nocopy ut_coverage_reporter_base, a_run ut_run) as
- +
+ +begin
- + 10 +
+ +(self as ut_output_reporter_base).before_calling_run(a_run);
- + 10 +
+ +ut_coverage.coverage_start(a_coverage_options => a_run.coverage_options);
- +
+ +end;
- -
- - 697 -
-l_test := ut_test(a_object_owner => l_owner_name
- -
-,a_object_name => l_object_name
- -
-,a_name => l_proc_name
- -
-,a_description => l_displayname
- -
-,a_path => l_suite.path || '.' || l_proc_name
- -
-,a_rollback_type => l_rollback_type
- + +
- +
+ +overriding final member procedure before_calling_before_all(self in out nocopy ut_coverage_reporter_base, a_executable in ut_executable) is
- +
+ +begin
- 1 -
-,a_disabled_flag => l_annotation_data.package_annotations.exists('disabled') or l_proc_annotations.exists('disabled')
- -
-,a_before_test_proc_name => l_beforetest_procedure
- -
-,a_after_test_proc_name => l_aftertest_procedure
- -
-,a_before_each_proc_name => l_default_setup_proc
- -
-,a_after_each_proc_name => l_default_teardown_proc);
- +
+ +ut_coverage.coverage_resume();
- +
+ +end;
- +
+ +overriding final member procedure after_calling_before_all (self in out nocopy ut_coverage_reporter_base, a_executable in ut_executable) is
- +
+ +begin
- + 1 +
+ +ut_coverage.coverage_pause();
- +
+ +end;
- -
- - 697 -
-l_suite.add_item(l_test);
- -
-end;
- -
-end if;
- + +
- +
+ +overriding final member procedure before_calling_before_each(self in out nocopy ut_coverage_reporter_base, a_executable in ut_executable) is
- +
+ +begin
- + 3 +
+ +ut_coverage.coverage_resume();
- +
+ +end;
- +
+ +overriding final member procedure after_calling_before_each (self in out nocopy ut_coverage_reporter_base, a_executable in ut_executable) is
- +
+ +begin
- + 3 +
+ +ut_coverage.coverage_pause();
- +
+ +end;
- -
- -
-end loop;
- -
-end if;
- - 1075 -
-return l_suite;
- + +
- +
+ +overriding final member procedure before_calling_before_test(self in out nocopy ut_coverage_reporter_base, a_executable in ut_executable) is
- +
+ +begin
- + 1 +
+ +ut_coverage.coverage_resume();
- +
+ +end;
- +
+ +overriding final member procedure after_calling_before_test (self in out nocopy ut_coverage_reporter_base, a_executable in ut_executable) is
- +
+ +begin
- + 1 +
+ +ut_coverage.coverage_pause();
- +
+ +end;
- -
- -
-end config_package;
- + +
- +
+ +overriding final member procedure before_calling_test_execute(self in out nocopy ut_coverage_reporter_base, a_executable in ut_executable) is
- +
+ +begin
- + 12 +
+ +ut_coverage.coverage_resume();
- +
+ +end;
- +
+ +overriding final member procedure after_calling_test_execute (self in out nocopy ut_coverage_reporter_base, a_executable in ut_executable) is
- +
+ +begin
- + 12 +
+ +ut_coverage.coverage_pause();
- +
+ +end;
- -
- -
-procedure update_cache(a_owner_name varchar2, a_schema_suites tt_schema_suites, a_total_obj_cnt integer) is
- + +
- +
+ +overriding final member procedure before_calling_after_test(self in out nocopy ut_coverage_reporter_base, a_executable in ut_executable) is
- -
begin
- - 46 -
-if a_schema_suites.count > 0 then
- - 45 -
-g_schema_suites(a_owner_name).schema_suites := a_schema_suites;
- - 45 -
-g_schema_suites(a_owner_name).changed_at := sysdate;
- - 45 -
-g_schema_suites(a_owner_name).obj_cnt := a_total_obj_cnt;
- + +
- 1 -
-elsif g_schema_suites.exists(a_owner_name) then
- -
-g_schema_suites.delete(a_owner_name);
- -
-end if;
- +
+ +ut_coverage.coverage_resume();
- -
end;
- + +
- +
+ +overriding final member procedure after_calling_after_test (self in out nocopy ut_coverage_reporter_base, a_executable in ut_executable) is
- +
+ +begin
- + 1 +
+ +ut_coverage.coverage_pause();
- +
+ +end;
- -
- -
-procedure config_schema(a_owner_name varchar2) is
- -
-l_suite ut_logical_suite;
- + +
- +
+ +overriding final member procedure before_calling_after_each(self in out nocopy ut_coverage_reporter_base, a_executable in ut_executable) is
- +
+ +begin
- + 3 +
+ +ut_coverage.coverage_resume();
- +
+ +end;
- +
+ +overriding final member procedure after_calling_after_each (self in out nocopy ut_coverage_reporter_base, a_executable in ut_executable) is
- +
+ +begin
- + 3 +
+ +ut_coverage.coverage_pause();
- +
+ +end;
- -
- -
-l_all_suites tt_schema_suites;
- -
-l_ind varchar2(4000 char);
- -
-l_path varchar2(4000 char);
- -
-l_root varchar2(4000 char);
- -
-l_root_suite ut_logical_suite;
- -
-- -
-l_schema_suites tt_schema_suites;
- -
-- -
-procedure put(a_root_suite in out nocopy ut_logical_suite, a_path varchar2, a_suite ut_logical_suite, a_parent_path varchar2 default null) is
- -
-l_temp_root varchar2(4000 char);
- -
-l_path varchar2(4000 char);
- -
-l_cur_item ut_logical_suite;
- -
-l_ind pls_integer;
- -
-begin
- - 396 -
-if a_path like '%.%' then
- - 138 -
-l_temp_root := regexp_substr(a_path, '^[^.]+');
- - 138 -
-l_path := ltrim(a_parent_path || '.' || l_temp_root, '.');
- + +
- +
+ +overriding final member procedure before_calling_after_all(self in out nocopy ut_coverage_reporter_base, a_executable in ut_executable) is
- +
+ +begin
- + 1 +
+ +ut_coverage.coverage_resume();
- +
+ +end;
- +
+ +overriding final member procedure after_calling_after_all (self in out nocopy ut_coverage_reporter_base, a_executable in ut_executable) is
- +
+ +begin
- + 1 +
+ +ut_coverage.coverage_pause();
- +
+ +end;
- -
- - 138 -
-if a_root_suite is not null then
- + +
- +
+end;
UT3.UT_EVENT_MANAGER
75.68 % lines covered
37 relevant lines. 28 lines covered and 9 lines missed+ +
- +
+ +package body ut_event_manager as
- +
+ +/*
- +
+ +utPLSQL - Version 3
- +
+ +Copyright 2016 - 2019 utPLSQL Project
- -
- - 49 -
-l_ind := a_root_suite.item_index(l_temp_root);
- + +
- +
+ +Licensed under the Apache License, Version 2.0 (the "License"):
- +
+ +you may not use this file except in compliance with the License.
- +
+ +You may obtain a copy of the License at
- -
- - 49 -
-if l_ind is null then
- -
---this only happens when a path of a real suite contains a parent-suite that is not a real package.
- - 5 -
-l_cur_item := ut_logical_suite(a_object_owner => a_owner_name, a_object_name => l_temp_root, a_name => l_temp_root, a_path => l_path);
- -
-else
- - 44 -
-l_cur_item := treat(a_root_suite.items(l_ind) as ut_logical_suite);
- -
-end if;
- + +
- +
+ +http://www.apache.org/licenses/LICENSE-2.0
- -
- - 49 -
-put(l_cur_item, trim_path(a_path, l_temp_root || '.'), a_suite, l_path);
- + +
- +
+ +Unless required by applicable law or agreed to in writing, software
- +
+ +distributed under the License is distributed on an "AS IS" BASIS,
- +
+ +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
+ +See the License for the specific language governing permissions and
- +
+ +limitations under the License.
- +
+ +*/
- -
- - 49 -
-if l_ind is null then
- - 5 -
-a_root_suite.add_item(l_cur_item);
- -
-else
- - 44 -
-a_root_suite.items(l_ind) := l_cur_item;
- -
-end if;
- + +
- +
+ +type t_listeners is table of ut_event_listener;
- +
+ +subtype t_listener_number is binary_integer;
- +
+ +type t_listener_numbers is table of boolean index by t_listener_number;
- +
+ +type t_events_listeners is table of t_listener_numbers index by t_event_name;
- -
- -
-else
- - 89 -
-a_root_suite := ut_logical_suite(a_object_owner => a_owner_name, a_object_name => l_temp_root, a_name => l_temp_root, a_path => l_path);
- - 89 -
-put(a_root_suite, trim_path(a_path, l_temp_root || '.'), a_suite, l_path);
- -
-end if;
- -
-else
- - 258 -
-if a_root_suite is not null then
- - 133 -
-a_root_suite.add_item(a_suite);
- -
-else
- - 125 -
-a_root_suite := a_suite;
- -
-end if;
- -
-end if;
- -
-end;
- + +
- +
+ +type t_event_manager is record (
- +
+ +event_listener_index t_events_listeners,
- +
+ +listeners t_listeners
- +
+ +);
- +
+ +type t_event_managers is table of t_event_manager;
- -
- -
-$if $$ut_trace $then
- -
-procedure print(a_item ut_suite_item, a_pad pls_integer) is
- -
-l_suite ut_logical_suite;
- -
-l_pad varchar2(1000) := lpad(' ', a_pad, ' ');
- -
-begin
- -
-if a_item is of (ut_logical_suite) then
- -
-dbms_output.put_line(l_pad || 'Suite: ' || a_item.name || '(' || a_item.path || ')');
- -
-dbms_output.put_line(l_pad || 'Items: ');
- -
-l_suite := treat(a_item as ut_logical_suite);
- -
-for i in 1 .. l_suite.items.count loop
- -
-print(l_suite.items(i), a_pad + 2);
- -
-end loop;
- -
-else
- -
-dbms_output.put_line(l_pad || 'Test: ' || a_item.name || '(' || a_item.path || ')' );
- -
-end if;
- -
-end print;
- -
-$end
- + +
- +
+ +g_event_listeners_index t_events_listeners;
- +
+ +g_listeners t_listeners;
- +
+ +g_suspended_event_managers t_event_managers;
- -
- + +
- +
+ +procedure initialize is
- -
begin
- -
--- form the single-dimension list of suites constructed from parsed packages
- - 137 -
-for rec in (select t.owner
- -
-,t.object_name
- -
-from all_objects t
- -
-where t.owner = a_owner_name
- -
-and t.status = 'VALID' -- scan only valid specifications
- -
-and t.object_type in ('PACKAGE')) loop
- -
--- parse the source of the package
- - 1022 -
-l_suite := config_package(rec.owner, rec.object_name);
- -
-- - 1022 -
-if l_suite is not null then
- - 258 -
-l_all_suites(l_suite.path) := l_suite;
- -
-end if;
- -
-- -
-end loop;
- + +
- + 116 +
+ +if g_listeners is not null and g_listeners.count > 0 then
- +
+ +if g_suspended_event_managers is null then
- +
+ +g_suspended_event_managers := t_event_managers();
- +
+ +end if;
- +
+ +g_suspended_event_managers.extend;
- +
+ +g_suspended_event_managers(g_suspended_event_managers.count).event_listener_index := g_event_listeners_index;
- +
+ +g_suspended_event_managers(g_suspended_event_managers.count).listeners := g_listeners;
- +
+ +end if;
- + 116 +
+ +g_event_listeners_index.delete;
- + 116 +
+ +g_listeners := t_listeners();
- +
+ +end;
- -
- - 46 -
-l_schema_suites.delete;
- + +
- +
+ +procedure dispose_listeners is
- +
+ +begin
- + 116 +
+ +if g_suspended_event_managers is not null and g_suspended_event_managers.count > 0 then
- +
+ +g_event_listeners_index := g_suspended_event_managers(g_suspended_event_managers.count).event_listener_index;
- +
+ +g_listeners := g_suspended_event_managers(g_suspended_event_managers.count).listeners;
- +
+ +g_suspended_event_managers.trim(1);
- +
+ +else
- + 116 +
+ +g_event_listeners_index.delete;
- + 116 +
+ +g_listeners := t_listeners();
- +
+ +end if;
- +
+ +end;
- -
- -
--- Restructure single-dimenstion list into hierarchy of suites by the value of %suitepath attribute value
- -
--- All root suite compose the root-suite list of the schema
- - 46 -
-l_ind := l_all_suites.first;
- - 304 -
-while l_ind is not null loop
- + +
- +
+ +procedure trigger_event( a_event_name t_event_name, a_event_object ut_event_item := null ) is
- -
- - 258 -
-l_root := regexp_substr(l_ind, '^[^.]+');
- -
-- - 258 -
-if l_schema_suites.exists(l_root) then
- - 44 -
-l_root_suite := l_schema_suites(l_root);
- - 44 -
-l_path := trim_path(l_ind, l_root || '.');
- -
-else
- - 214 -
-l_root_suite := null;
- - 214 -
-l_path := l_ind;
- + +
- +
+ +procedure trigger_listener_event(
- +
+ +a_listener_numbers t_listener_numbers,
- +
+ +a_event_name t_event_name,
- +
+ +a_event_object ut_event_item
- +
+ +) is
- + 2721 +
+ +l_listener_number t_listener_number := a_listener_numbers.first;
- +
+ +begin
- + 7923 +
+ +while l_listener_number is not null loop
- + 5202 +
+ +g_listeners(l_listener_number).on_event(a_event_name, a_event_object);
- + 5202 +
+ +l_listener_number := a_listener_numbers.next(l_listener_number);
- +
+ +end loop;
- +
+ +end;
- +
+ +begin
- + 7619 +
+ +if a_event_name is not null then
- + 7619 +
+ +if g_event_listeners_index.exists(gc_all) then
- + 76 +
+ +trigger_listener_event( g_event_listeners_index(gc_all), a_event_name, a_event_object );
- -
end if;
- - 258 -
-put(l_root_suite, l_path, l_all_suites(l_ind));
- -
-- - 258 -
-l_schema_suites(l_root) := l_root_suite;
- -
-- - 258 -
-l_ind := l_all_suites.next(l_ind);
- -
-end loop;
- -
-- -
--- Caching
- - 46 -
-update_cache(a_owner_name, l_schema_suites, get_schema_info(a_owner_name).obj_cnt );
- -
-- -
--- printing results for debugging purpose
- -
-$if $$ut_trace $then
- -
-l_ind := l_schema_suites.first;
- -
-while l_ind is not null loop
- -
-print(l_schema_suites(l_ind), 0);
- -
-l_ind := l_schema_suites.next(l_ind);
- -
-end loop;
- -
-$end
- -
-- -
-end config_schema;
- + +
- + 7619 +
+ +if g_event_listeners_index.exists(a_event_name) then
- + 2645 +
+ +trigger_listener_event( g_event_listeners_index(a_event_name), a_event_name, a_event_object );
- +
+ +end if;
- + 7619 +
+ +if a_event_name = ut_event_manager.gc_finalize then
- + 116 +
+ +dispose_listeners();
- +
+ +end if;
- +
+ +end if;
- +
+ +end;
- -
- -
-function get_schema_suites(a_schema_name in varchar2) return tt_schema_suites is
- -
-l_schema_info t_schema_info;
- + +
- +
+ +procedure add_event( a_event_name t_event_name, a_listener_pos binary_integer ) is
- -
begin
- -
--- Currently cache invalidation on DDL is not implemented so schema is rescaned each time
- - 125 -
-l_schema_info := get_schema_info(a_schema_name);
- - 125 -
-if not g_schema_suites.exists(a_schema_name) or g_schema_suites(a_schema_name).changed_at <= l_schema_info.changed_at or
- -
-g_schema_suites(a_schema_name).obj_cnt != l_schema_info.obj_cnt then
- - 46 -
-ut_utils.debug_log('Rescanning schema ' || a_schema_name);
- - 46 -
-config_schema(a_schema_name);
- -
-end if;
- + +
- + 4967 +
+ +g_event_listeners_index(a_event_name)(a_listener_pos) := true;
- +
+ +end;
- -
- - 125 -
-if g_schema_suites.exists(a_schema_name) then
- - 124 -
-return g_schema_suites(a_schema_name).schema_suites;
- -
-else
- - 1 -
-return cast(null as tt_schema_suites);
- -
-end if;
- -
-end get_schema_suites;
- + +
- +
+ +procedure add_events( a_event_names ut_varchar2_list, a_listener_pos binary_integer ) is
- +
+ +begin
- + 5199 +
+ +for i in 1 .. a_event_names.count loop
- + 4967 +
+ +add_event( a_event_names(i), a_listener_pos );
- +
+ +end loop;
- +
+ +end;
- -
- -
-function get_schema_ut_packages(a_schema_names ut_varchar2_rows) return ut_object_names is
- - 49 -
-l_schema_ut_packages ut_object_names := ut_object_names();
- -
-l_schema_suites tt_schema_suites;
- -
-l_iter varchar2(4000);
- -
-procedure populate_suite_ut_packages(a_suite ut_logical_suite, a_packages in out nocopy ut_object_names) is
- -
-l_sub_suite ut_logical_suite;
- -
-begin
- - 358 -
-if a_suite is of (ut_suite) then
- - 258 -
-a_packages.extend;
- - 258 -
-a_packages(a_packages.last) := ut_object_name(a_suite.object_owner, a_suite.object_name);
- -
-end if;
- - 1104 -
-for i in 1 .. a_suite.items.count loop
- - 746 -
-if a_suite.items(i) is of (ut_logical_suite) then
- - 147 -
-l_sub_suite := treat(a_suite.items(i) as ut_logical_suite);
- - 147 -
-populate_suite_ut_packages(l_sub_suite, a_packages);
- -
-end if;
- -
-end loop;
- -
-end;
- + +
- +
+ +function add_listener( a_listener ut_event_listener ) return t_listener_number is
- -
begin
- - 49 -
-if a_schema_names is not null then
- - 98 -
-for i in 1 .. a_schema_names.count loop
- - 49 -
-l_schema_suites := get_schema_suites(a_schema_names(i));
- - 49 -
-l_iter := l_schema_suites.first;
- - 260 -
-while l_iter is not null loop
- - 211 -
-populate_suite_ut_packages(l_schema_suites(l_iter), l_schema_ut_packages);
- - 211 -
-l_iter := l_schema_suites.next(l_iter);
- -
-end loop;
- -
-end loop;
- - 49 -
-l_schema_ut_packages := set(l_schema_ut_packages);
- + +
- + 232 +
+ +if g_listeners is null then
- +
+ +g_listeners := t_listeners();
- -
end if;
- -
-- - 49 -
-return l_schema_ut_packages;
- + +
- + 232 +
+ +g_listeners.extend;
- + 232 +
+ +g_listeners(g_listeners.last) := a_listener;
- + 232 +
+ +return g_listeners.last;
- -
end;
- + +
- -
- -
--- Validate all paths are correctly formatted
- -
-procedure validate_paths(a_paths in ut_varchar2_list) is
- -
-l_path varchar2(32767);
- + +
- +
+ +procedure add_listener( a_listener ut_event_listener ) is
- +
+ +l_event_names ut_varchar2_list;
- -
begin
- - 72 -
-if a_paths is null or a_paths.count = 0 then
- -
-raise_application_error(ut_utils.gc_path_list_is_empty, 'Path list is empty');
- -
-else
- - 148 -
-for i in 1 .. a_paths.count loop
- - 76 -
-l_path := a_paths(i);
- - 76 -
-if l_path is null or not (regexp_like(l_path, '^[A-Za-z0-9$#_]+(\.[A-Za-z0-9$#_]+){0,2}$') or regexp_like(l_path, '^([A-Za-z0-9$#_]+)?:[A-Za-z0-9$#_]+(\.[A-Za-z0-9$#_]+)*$')) then
- -
-raise_application_error(ut_utils.gc_invalid_path_format, 'Invalid path format: ' || nvl(l_path, 'NULL'));
- -
-end if;
- -
-end loop;
- + +
- + 232 +
+ +if a_listener is not null then
- + 232 +
+ +l_event_names := a_listener.get_supported_events();
- + 232 +
+ +if l_event_names is not empty then
- + 232 +
+ +add_events( l_event_names, add_listener( a_listener ) );
- +
+ +end if;
- -
end if;
- -
-end validate_paths;
- + +
- +
+ +end;
- -
- -
-function configure_execution_by_path(a_paths in ut_varchar2_list) return ut_suite_items is
- -
-l_paths ut_varchar2_list;
- -
-l_path varchar2(32767);
- -
-l_schema varchar2(4000);
- -
-l_schema_suites tt_schema_suites;
- -
-l_index varchar2(4000 char);
- -
-l_suite ut_logical_suite;
- -
-l_suite_path varchar2(4000);
- -
-l_root_suite_name varchar2(4000);
- -
-l_objects_to_run ut_suite_items;
- - 72 -
-c_current_schema constant all_tables.owner%type := sys_context('USERENV','CURRENT_SCHEMA');
- -
-- -
-function clean_paths(a_paths ut_varchar2_list) return ut_varchar2_list is
- - 72 -
-l_paths_temp ut_varchar2_list := ut_varchar2_list();
- -
-begin
- - 72 -
-l_paths_temp.extend(a_paths.count);
- - 148 -
-for i in 1 .. a_paths.count loop
- - 76 -
-l_paths_temp(i) := trim(lower(a_paths(i)));
- -
-end loop;
- - 72 -
-l_paths_temp := set(l_paths_temp);
- - 72 -
-return l_paths_temp;
- -
-end clean_paths;
- -
-- -
-procedure skip_by_path(a_suite in out nocopy ut_suite_item, a_path varchar2) is
- - 105 -
-c_root constant varchar2(32767) := replace(regexp_substr(a_path, '[A-Za-z0-9$#_]+'), '$', '\$');
- - 105 -
-c_rest_path constant varchar2(32767) := regexp_substr(a_path, '\.(.+)', subexpression => 1);
- -
-l_suite ut_logical_suite;
- -
-l_item ut_suite_item;
- - 105 -
-l_items ut_suite_items := ut_suite_items();
- -
-l_item_name varchar2(32767);
- -
-- -
-begin
- - 105 -
-if a_path is not null and a_suite is not null and a_suite is of (ut_logical_suite) then
- - 40 -
-l_suite := treat(a_suite as ut_logical_suite);
- -
-- - 98 -
-for i in 1 .. l_suite.items.count loop
- -
-- - 58 -
-l_item := l_suite.items(i);
- -
-- - 58 -
-l_item_name := l_item.name;
- -
---l_item_name := regexp_substr(l_item_name,'[A-Za-z0-9$#_]+$'); -- temporary fix. seems like suite have suitepath in object_name
- - 58 -
-if regexp_like(l_item_name, c_root, modifier => 'i') then
- -
-- - 40 -
-skip_by_path(l_item, c_rest_path);
- - 40 -
-l_items.extend;
- - 40 -
-l_items(l_items.count) := l_item;
- -
-- -
-end if;
- -
-- -
-end loop;
- -
-- - 40 -
-if l_items.count = 0 then
- -
---not l_found then
- -
-raise_application_error(-20203, 'Suite not found');
- -
-end if;
- -
-- - 40 -
-l_suite.items := l_items;
- - 40 -
-a_suite := l_suite;
- -
-- -
-end if;
- -
-end skip_by_path;
- -
-- -
-function package_exists_in_cur_schema(a_package_name varchar2) return boolean is
- -
-l_cnt number;
- -
-begin
- - 47 -
-select count(*)
- -
-into l_cnt
- -
-from all_objects t
- -
-where t.object_name = upper(a_package_name)
- -
-and t.object_type = 'PACKAGE'
- -
-and t.owner = c_current_schema;
- - 47 -
-return l_cnt > 0;
- -
-end package_exists_in_cur_schema;
- -
-- -
-begin
- - 72 -
-l_paths := clean_paths(a_paths);
- -
-- - 72 -
-validate_paths(l_paths);
- - 72 -
-l_objects_to_run := ut_suite_items();
- -
-- -
--- current implementation operates only on a single path
- -
--- to be improved later
- - 146 -
-for i in 1 .. l_paths.count loop
- - 76 -
-l_path := l_paths(i);
- -
-- - 76 -
-if regexp_like(l_path, '^([A-Za-z0-9$#_]+)?:') then
- - 13 -
-l_schema := regexp_substr(l_path, '^([A-Za-z0-9$#_]+)?:',subexpression => 1);
- -
--- transform ":path1[.path2]" to "schema:path1[.path2]"
- - 13 -
-if l_schema is not null then
- - 7 -
-l_schema := sys.dbms_assert.schema_name(upper(l_schema));
- -
-else
- - 6 -
-l_path := c_current_schema || l_path;
- - 6 -
-l_schema := c_current_schema;
- -
-end if;
- -
-else
- -
--- When path is one of: schema or schema.package[.object] or package[.object]
- -
--- transform it back to schema[.package[.object]]
- -
-begin
- - 63 -
-l_schema := regexp_substr(l_path, '^[A-Za-z0-9$#_]+');
- - 63 -
-l_schema := sys.dbms_assert.schema_name(upper(l_schema));
- -
-exception
- - 47 -
-when sys.dbms_assert.invalid_schema_name then
- - 47 -
-if package_exists_in_cur_schema(l_schema) then
- - 47 -
-l_path := c_current_schema || '.' || l_path;
- - 47 -
-l_schema := c_current_schema;
- -
-else
- -
-raise;
- -
-end if;
- -
-end;
- -
-- -
-end if;
- -
-- - 76 -
-l_schema_suites := get_schema_suites(upper(l_schema));
- -
-- - 76 -
-if regexp_like(l_path, '^[A-Za-z0-9$#_]+$') then
- -
--- run whole schema
- - 9 -
-l_index := l_schema_suites.first;
- - 45 -
-while l_index is not null loop
- - 36 -
-l_objects_to_run.extend;
- - 36 -
-l_objects_to_run(l_objects_to_run.count) := l_schema_suites(l_index);
- - 36 -
-l_index := l_schema_suites.next(l_index);
- -
-end loop;
- -
-else
- -
--- convert SCHEMA.PACKAGE.PROCEDURE syntax to fully qualified path
- - 67 -
-if regexp_like(l_path, '^[A-Za-z0-9$#_]+(\.[A-Za-z0-9$#_]+){1,2}$') then
- - 54 -
-declare
- -
-l_temp_suite ut_logical_suite;
- -
-l_package_name varchar2(4000);
- -
-l_procedure_name varchar2(4000);
- -
-begin
- - 54 -
-l_package_name := regexp_substr(l_path, '^[A-Za-z0-9$#_]+\.([A-Za-z0-9$#_]+)(\.([A-Za-z0-9$#_]+))?$', subexpression => 1);
- - 54 -
-l_procedure_name := regexp_substr(l_path, '^[A-Za-z0-9$#_]+\.([A-Za-z0-9$#_]+)(\.([A-Za-z0-9$#_]+))?$', subexpression => 3);
- -
-- - 54 -
-l_temp_suite := config_package(l_schema, l_package_name);
- -
-- - 53 -
-if l_temp_suite is null then
- -
-raise_application_error(ut_utils.gc_suite_package_not_found,'Suite package '||l_schema||'.'||l_package_name|| ' not found');
- -
-end if;
- -
-- - 53 -
-l_path := rtrim(l_schema || ':' || l_temp_suite.path || '.' || l_procedure_name, '.');
- -
-end;
- -
-end if;
- -
-- -
--- fully qualified path branch in the form
- -
--- by this time it's the only format left
- -
--- schema:suite.suite.suite
- - 66 -
-l_suite_path := regexp_substr(l_path, ':(.+)', subexpression => 1);
- - 66 -
-l_root_suite_name := regexp_substr(l_suite_path, '^[A-Za-z0-9$#_]+');
- -
-- -
-begin
- - 66 -
-l_suite := l_schema_suites(l_root_suite_name);
- -
-exception
- - 1 -
-when no_data_found then
- - 1 -
-raise_application_error(-20203, 'Suite ' || l_root_suite_name || ' does not exist or is invalid');
- -
-end;
- -
-- - 65 -
-skip_by_path(l_suite, regexp_substr(l_suite_path, '\.(.+)', subexpression => 1));
- -
-- - 65 -
-l_objects_to_run.extend;
- - 65 -
-l_objects_to_run(l_objects_to_run.count) := l_suite;
- -
-- -
-end if;
- -
-- -
-end loop;
- - 70 -
-return l_objects_to_run;
- -
-end configure_execution_by_path;
- -
-- -
end ut_suite_manager;
+UT3.UT_UTILS
96 % covered
125 relevant lines. 120 lines covered and 5 lines missed-
- -
-package body ut_utils is
- -
-/*
- -
-utPLSQL - Version X.X.X.X
- -
-Copyright 2016 - 2017 utPLSQL Project
- + +
- +
+end;
+UT3.UT_OUTPUT_BUFFER_BASE
100 % lines covered
26 relevant lines. 26 lines covered and 0 lines missed+ +
- +
+ +type body ut_output_buffer_base is
- +
+ +/*
- +
+ +utPLSQL - Version 3
- +
+ +Copyright 2016 - 2019 utPLSQL Project
- +
- +
Licensed under the Apache License, Version 2.0 (the "License"):
- +
you may not use this file except in compliance with the License.
- +
You may obtain a copy of the License at
- +
- +
http://www.apache.org/licenses/LICENSE-2.0
- +
- +
Unless required by applicable law or agreed to in writing, software
- +
distributed under the License is distributed on an "AS IS" BASIS,
- +
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
See the License for the specific language governing permissions and
- +
limitations under the License.
- +
*/
- +
- -
+function surround_with(a_value varchar2, a_quote_char varchar2) return varchar2 is
member procedure init(self in out nocopy ut_output_buffer_base, a_output_id raw := null, a_self_type varchar2 := null) is
+- -
-begin
- - 444 -
+return case when a_quote_char is not null then a_quote_char||a_value||a_quote_char else a_value end;
pragma autonomous_transaction;
+ +- +
+l_exists int;
- -
-end;
- -
-- -
-function test_result_to_char(a_test_result integer) return varchar2 as
- -
-l_result varchar2(20);
- -
begin
- - 6 -
-if a_test_result = tr_success then
- - 1 -
-l_result := tr_success_char;
- - 5 -
-elsif a_test_result = tr_failure then
- - 1 -
-l_result := tr_failure_char;
- - 4 -
-elsif a_test_result = tr_error then
- - 1 -
-l_result := tr_error_char;
- - 3 -
-elsif a_test_result = tr_disabled then
- - 1 -
-l_result := tr_disabled_char;
- + +
- + 247 +
+ +cleanup_buffer();
- + 247 +
+ +self.self_type := coalesce(a_self_type,self.self_type);
- + 247 +
+ +self.output_id := coalesce(a_output_id, self.output_id, sys_guid());
- + 247 +
+ +self.start_date := coalesce(self.start_date, sysdate);
- + 247 +
+ +self.last_message_id := 0;
- + 247 +
+ +select count(*) into l_exists from ut_output_buffer_info_tmp where output_id = self.output_id;
- + 247 +
+ +if ( l_exists > 0 ) then
- + 119 +
+ +update ut_output_buffer_info_tmp set start_date = self.start_date where output_id = self.output_id;
- -
else
- - 2 -
+ +l_result := 'Unknown(' || coalesce(to_char(a_test_result),'NULL') || ')';
- + 128 +
+ +insert into ut_output_buffer_info_tmp(output_id, start_date) values (self.output_id, self.start_date);
- +
+ +end if;
- + 247 +
+ +commit;
- + 247 +
+ +self.is_closed := 0;
- +
+end;
- -
-end if ;
- - 6 -
+return l_result;
+ +
- +
+member function get_lines_cursor(a_initial_timeout natural := null, a_timeout_sec natural := null) return sys_refcursor is
- -
+end test_result_to_char;
l_lines sys_refcursor;
+- -
-- -
+begin
+ +- + 117 +
+open l_lines for
- -
+function to_test_result(a_test boolean) return integer is
select text, item_type
+- -
-l_result integer;
- -
-begin
- - 1494 -
-if a_test then
- - 1066 -
+l_result := tr_success;
from table(self.get_lines(a_initial_timeout, a_timeout_sec));
+ +- + 117 +
+ +return l_lines;
- +
+ +end;
- +
+- -
-else
- - 428 -
+l_result := tr_failure;
member procedure lines_to_dbms_output(self in ut_output_buffer_base, a_initial_timeout natural := null, a_timeout_sec natural := null) is
+ +- +
+l_data sys_refcursor;
- -
-end if;
- - 1494 -
+return l_result;
l_clob clob;
+ +- +
+l_item_type varchar2(32767);
- -
+end;
l_lines ut_varchar2_list;
+- -
-- -
-function gen_savepoint_name return varchar2 is
- -
begin
- - 260 -
-return 'ut_'||to_char(systimestamp,'yymmddhh24mmssff');
- -
-end;
- -
-- -
-/*
- -
+ +Procedure: validate_rollback_type
- + 32 +
+ +l_data := self.get_lines_cursor(a_initial_timeout, a_timeout_sec);
- + 629 +
+ +loop
- + 629 +
+ +fetch l_data into l_clob, l_item_type;
- + 629 +
+ +exit when l_data%notfound;
- + 597 +
+ +l_lines := ut_utils.clob_to_table(l_clob);
- + 1206 +
+ +for i in 1 .. l_lines.count loop
- + 609 +
+dbms_output.put_line(l_lines(i));
- -
+end loop;
+- -
-Validates passed value against supported rollback types
- -
+*/
end loop;
+ +- + 32 +
+close l_data;
- -
+procedure validate_rollback_type(a_rollback_type number) is
end;
+- -
-begin
- -
-if a_rollback_type not in (gc_rollback_auto, gc_rollback_manual) then
- -
-raise_application_error(-20200,'Rollback type is not supported');
- -
-end if;
- -
-end validate_rollback_type;
- + +
- +
+ +member procedure cleanup_buffer(self in ut_output_buffer_base, a_retention_time_sec natural := null) is
- + 247 +
+ +gc_buffer_retention_sec constant naturaln := coalesce(a_retention_time_sec, 60 * 60 * 24); -- 24 hours
- + 247 +
+ +l_retention_days number := gc_buffer_retention_sec / (60 * 60 * 24);
- + 247 +
+ +l_max_retention_date date := sysdate - l_retention_days;
- +
+pragma autonomous_transaction;
- -
-procedure debug_log(a_message varchar2) is
- -
begin
- -
+ +$if $$ut_trace $then
- + 247 +
+ +delete from ut_output_buffer_info_tmp i where i.start_date <= l_max_retention_date;
- + 247 +
+commit;
- -
-dbms_output.put_line(a_message);
- -
-$else
- - 6373 -
-null;
- -
-$end
- -
end;
- + +
- -
- -
-procedure debug_log(a_message clob) is
- -
-l_varchars ut_varchar2_list;
- -
-begin
- -
-$if $$ut_trace $then
- -
-l_varchars := clob_to_table(a_message);
- -
-for i in 1..l_varchars.count loop
- -
-dbms_output.put_line(l_varchars(i));
- -
-end loop;
- -
-$else
- - 1085 -
-null;
- -
-$end
- -
-end;
- + +
- +
+end;
+UT3.UT_OUTPUT_CLOB_TABLE_BUFFER
98.21 % lines covered
56 relevant lines. 55 lines covered (including 1 lines partially covered ) and 1 lines missed+ +
- +
+ +type body ut_output_clob_table_buffer is
- +
+ +/*
- +
+ +utPLSQL - Version 3
- +
+ +Copyright 2016 - 2019 utPLSQL Project
- -
- -
-function to_string(a_value varchar2, a_qoute_char varchar2 := '''') return varchar2 is
- - 396 -
-l_len integer := coalesce(length(a_value),0);
- -
-l_result varchar2(32767);
- + +
- +
+ +Licensed under the Apache License, Version 2.0 (the "License"):
- +
+ +you may not use this file except in compliance with the License.
- +
+ +You may obtain a copy of the License at
- +
+ +- +
+ +http://www.apache.org/licenses/LICENSE-2.0
- +
+ +- +
+ +Unless required by applicable law or agreed to in writing, software
- +
+ +distributed under the License is distributed on an "AS IS" BASIS,
- +
+ +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
+ +See the License for the specific language governing permissions and
- +
+ +limitations under the License.
- +
+ +*/
- +
+ +- +
+ +constructor function ut_output_clob_table_buffer(self in out nocopy ut_output_clob_table_buffer, a_output_id raw := null) return self as result is
- -
begin
- - 396 -
-if l_len = 0 then
- - 45 -
-l_result := gc_null_string;
- - 351 -
-elsif l_len <= gc_max_input_string_length then
- - 345 -
-l_result := surround_with(a_value, a_qoute_char);
- -
-else
- - 6 -
-l_result := surround_with(substr(a_value,1,gc_overflow_substr_len),a_qoute_char) || gc_more_data_string;
- -
-end if ;
- - 396 -
-return l_result;
- + +
- + 5 +
+ +self.init(a_output_id, $$plsql_unit);
- + 5 +
+ +return;
- -
end;
- + +
- -
- -
-function to_string(a_value clob, a_qoute_char varchar2 := '''') return varchar2 is
- - 94 -
-l_len integer := coalesce(dbms_lob.getlength(a_value), 0);
- -
-l_result varchar2(32767);
- -
-begin
- - 94 -
-if l_len = 0 then
- - 19 -
-l_result := gc_null_string;
- - 75 -
-elsif l_len <= gc_max_input_string_length then
- - 58 -
-l_result := surround_with(a_value,a_qoute_char);
- -
-else
- - 17 -
-l_result := surround_with(dbms_lob.substr(a_value, gc_overflow_substr_len),a_qoute_char) || gc_more_data_string;
- -
-end if;
- - 94 -
-return l_result;
- -
-end;
- -
-- -
-function to_string(a_value blob, a_qoute_char varchar2 := '''') return varchar2 is
- - 35 -
-l_len integer := coalesce(dbms_lob.getlength(a_value), 0);
- -
-l_result varchar2(32767);
- + +
- +
+ +overriding member procedure close(self in out nocopy ut_output_clob_table_buffer) is
- +
+ +pragma autonomous_transaction;
- -
begin
- - 35 -
-if l_len = 0 then
- - 16 -
-l_result := gc_null_string;
- - 19 -
-elsif l_len <= gc_max_input_string_length then
- - 18 -
-l_result := surround_with(rawtohex(a_value),a_qoute_char);
- -
-else
- - 1 -
-l_result := to_string( rawtohex(dbms_lob.substr(a_value, gc_overflow_substr_len)) );
- -
-end if ;
- - 35 -
-return l_result;
- + +
- + 4 +
+ +self.last_message_id := self.last_message_id + 1;
- + 4 +
+ +insert into ut_output_clob_buffer_tmp(output_id, message_id, is_finished)
- +
+ +values (self.output_id, self.last_message_id, 1);
- + 4 +
+ +commit;
- + 4 +
+ +self.is_closed := 1;
- -
end;
- + +
- -
- -
-function to_string(a_value boolean) return varchar2 is
- + +
- +
+ +overriding member procedure send_line(self in out nocopy ut_output_clob_table_buffer, a_text varchar2, a_item_type varchar2 := null) is
- +
+ +pragma autonomous_transaction;
- -
begin
- - 89 -
-return case a_value when true then 'TRUE' when false then 'FALSE' else gc_null_string end;
- + +
- + 309 +
+ +if a_text is not null or a_item_type is not null then
- + 309 +
+ +self.last_message_id := self.last_message_id + 1;
- + 309 +
+ +insert into ut_output_clob_buffer_tmp(output_id, message_id, text, item_type)
- +
+ +values (self.output_id, self.last_message_id, a_text, a_item_type);
- +
+ +end if;
- + 309 +
+ +commit;
- -
end;
- + +
- -
- -
-function to_string(a_value number) return varchar2 is
- + +
- +
+ +overriding member procedure send_lines(self in out nocopy ut_output_clob_table_buffer, a_text_list ut_varchar2_rows, a_item_type varchar2 := null) is
- +
+ +pragma autonomous_transaction;
- -
begin
- - 621 -
-return coalesce(to_char(a_value,gc_number_format), gc_null_string);
- + +
- + 53 +
+ +insert into ut_output_clob_buffer_tmp(output_id, message_id, text, item_type)
- +
+ +select self.output_id, self.last_message_id + rownum, t.column_value, a_item_type
- +
+ +from table(a_text_list) t
- +
+ +where t.column_value is not null or a_item_type is not null;
- + 53 +
+ +self.last_message_id := self.last_message_id + SQL%rowcount;
- + 53 +
+ +commit;
- -
end;
- + +
- -
- -
-function to_string(a_value date) return varchar2 is
- + +
- +
+ +overriding member procedure send_clob(self in out nocopy ut_output_clob_table_buffer, a_text clob, a_item_type varchar2 := null) is
- +
+ +pragma autonomous_transaction;
- -
begin
- - 89 -
-return coalesce(to_char(a_value,gc_date_format), gc_null_string);
- + +
- + 1/2 + 31 +
+ +if a_text is not null and a_text != empty_clob() or a_item_type is not null then
- + 31 +
+ +self.last_message_id := self.last_message_id + 1;
- + 31 +
+ +insert into ut_output_clob_buffer_tmp(output_id, message_id, text, item_type)
- +
+ +values (self.output_id, self.last_message_id, a_text, a_item_type);
- +
+ +end if;
- + 31 +
+ +commit;
- -
end;
- + +
- -
- -
-function to_string(a_value timestamp_unconstrained) return varchar2 is
- -
-begin
- - 92 -
-return coalesce(to_char(a_value,gc_timestamp_format), gc_null_string);
- -
-end;
- + +
- +
+ +overriding member function get_lines(a_initial_timeout natural := null, a_timeout_sec natural := null) return ut_output_data_rows pipelined is
- +
+ +type t_rowid_tab is table of urowid;
- +
+ +l_message_rowids t_rowid_tab;
- +
+ +l_buffer_data ut_output_data_rows;
- +
+ +l_finished_flags ut_integer_list;
- + 4 +
+ +l_already_waited_for number(10,2) := 0;
- + 4 +
+ +l_finished boolean := false;
- + 4 +
+ +lc_init_wait_sec constant naturaln := coalesce(a_initial_timeout, 60 ); -- 1 minute
- + 4 +
+ +lc_max_wait_sec constant naturaln := coalesce(a_timeout_sec, 60 * 60 * 4); -- 4 hours
- + 4 +
+ +l_wait_for integer := lc_init_wait_sec;
- + 4 +
+ +lc_short_sleep_time constant number(1,1) := 0.1; --sleep for 100 ms between checks
- + 4 +
+ +lc_long_sleep_time constant number(1) := 1; --sleep for 1 s when waiting long
- + 4 +
+ +lc_long_wait_time constant number(1) := 1; --waiting more than 1 sec
- + 4 +
+ +l_sleep_time number(2,1) := lc_short_sleep_time;
- + 4 +
+ +lc_bulk_limit constant integer := 5000;
- + 4 +
+ +l_max_message_id integer := lc_bulk_limit;
- -
- -
-function to_string(a_value timestamp_tz_unconstrained) return varchar2 is
- -
-begin
- - 95 -
-return coalesce(to_char(a_value,gc_timestamp_tz_format), gc_null_string);
- -
-end;
- + +
- +
+ +procedure remove_read_data(a_message_rowids t_rowid_tab) is
- +
+ +pragma autonomous_transaction;
- +
+ +begin
- + 3 +
+ +forall i in 1 .. a_message_rowids.count
- + 1 +
+ +delete from ut_output_clob_buffer_tmp a
- +
+ +where rowid = a_message_rowids(i);
- + 3 +
+ +commit;
- +
+ +end;
- -
- -
-function to_string(a_value timestamp_ltz_unconstrained) return varchar2 is
- -
-begin
- - 91 -
-return coalesce(to_char(a_value,gc_timestamp_format), gc_null_string);
- -
-end;
- + +
- +
+ +procedure remove_buffer_info is
- +
+ +pragma autonomous_transaction;
- +
+ +begin
- + 4 +
+ +delete from ut_output_buffer_info_tmp a
- +
+ +where a.output_id = self.output_id;
- + 4 +
+ +commit;
- +
+ +end;
- -
- -
-function to_string(a_value yminterval_unconstrained) return varchar2 IS
- -
-begin
- - 78 -
-return coalesce(to_char(a_value), gc_null_string);
- -
-end;
- + +
- +
+ +begin
- + 7 +
+ +while not l_finished loop
- + 4 +
+ +with ordered_buffer as (
- +
+ +select /*+ index(a) */ a.rowid, ut_output_data_row(a.text, a.item_type), is_finished
- +
+ +from ut_output_clob_buffer_tmp a
- +
+ +where a.output_id = self.output_id
- +
+ +and a.message_id <= l_max_message_id
- +
+ +order by a.message_id
- +
+ +)
- +
+ +select b.*
- +
+ +bulk collect into l_message_rowids, l_buffer_data, l_finished_flags
- +
+ +from ordered_buffer b;
- -
- -
-function to_string(a_value dsinterval_unconstrained) return varchar2 IS
- -
-begin
- - 78 -
-return coalesce(to_char(a_value), gc_null_string);
- + +
- +
+ +--nothing fetched from output, wait and try again
- + 4 +
+ +if l_buffer_data.count = 0 then
- +
+ +$if dbms_db_version.version >= 18 $then
- + 1 +
+ +dbms_session.sleep(l_sleep_time);
- +
+ +$else
- +
+ +dbms_lock.sleep(l_sleep_time);
- +
+ +$end
- + 1 +
+ +l_already_waited_for := l_already_waited_for + l_sleep_time;
- + 1 +
+ +if l_already_waited_for > lc_long_wait_time then
- +
+ +l_sleep_time := lc_long_sleep_time;
- +
+ +end if;
- +
+ +else
- +
+ +--reset wait time
- +
+ +-- we wait lc_max_wait_sec for new message
- + 3 +
+ +l_wait_for := lc_max_wait_sec;
- + 3 +
+ +l_already_waited_for := 0;
- + 3 +
+ +l_sleep_time := lc_short_sleep_time;
- + 59 +
+ +for i in 1 .. l_buffer_data.count loop
- + 2540 +
+ +if l_buffer_data(i).text is not null then
- + 2482 +
+ +pipe row(l_buffer_data(i));
- + 58 +
+ +elsif l_finished_flags(i) = 1 then
- + 3 +
+ +l_finished := true;
- + 3 +
+ +exit;
- +
+ +end if;
- +
+ +end loop;
- + 3 +
+ +remove_read_data(l_message_rowids);
- + 3 +
+ +l_max_message_id := l_max_message_id + lc_bulk_limit;
- +
+ +end if;
- + 4 +
+ +if l_finished or l_already_waited_for >= l_wait_for then
- + 4 +
+ +remove_buffer_info();
- + 4 +
+ +if l_already_waited_for > 0 and l_already_waited_for >= l_wait_for then
- + 1 +
+ +raise_application_error(
- +
+ +ut_utils.gc_out_buffer_timeout,
- +
+ +'Timeout occurred while waiting for output data. Waited for: '||l_already_waited_for||' seconds.'
- +
+ +);
- +
+ +end if;
- +
+ +end if;
- +
+ +end loop;
- + 3 +
+ +return;
- -
end;
- + +
- -
- + +
- +
+end;
UT3.UT_OUTPUT_TABLE_BUFFER
86.21 % lines covered
58 relevant lines. 50 lines covered and 8 lines missed+ +
- +
+ +type body ut_output_table_buffer is
- +
+ +/*
- +
+ +utPLSQL - Version 3
- +
+ +Copyright 2016 - 2019 utPLSQL Project
- -
- -
-function boolean_to_int(a_value boolean) return integer is
- + +
- +
+ +Licensed under the Apache License, Version 2.0 (the "License"):
- +
+ +you may not use this file except in compliance with the License.
- +
+ +You may obtain a copy of the License at
- +
+ +- +
+ +http://www.apache.org/licenses/LICENSE-2.0
- +
+ +- +
+ +Unless required by applicable law or agreed to in writing, software
- +
+ +distributed under the License is distributed on an "AS IS" BASIS,
- +
+ +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
+ +See the License for the specific language governing permissions and
- +
+ +limitations under the License.
- +
+ +*/
- +
+ +- +
+ +constructor function ut_output_table_buffer(self in out nocopy ut_output_table_buffer, a_output_id raw := null) return self as result is
- -
begin
- - 1891 -
-return case a_value when true then 1 when false then 0 end;
- + +
- + 123 +
+ +self.init(a_output_id, $$plsql_unit);
- + 123 +
+ +return;
- -
end;
- + +
- -
- -
-function int_to_boolean(a_value integer) return boolean is
- + +
- +
+ +overriding member procedure close(self in out nocopy ut_output_table_buffer) is
- +
+ +pragma autonomous_transaction;
- -
begin
- - 1623 -
-return case a_value when 1 then true when 0 then false end;
- + +
- + 117 +
+ +self.last_message_id := self.last_message_id + 1;
- + 117 +
+ +insert into ut_output_buffer_tmp(output_id, message_id, is_finished)
- +
+ +values (self.output_id, self.last_message_id, 1);
- + 117 +
+ +commit;
- + 117 +
+ +self.is_closed := 1;
- -
end;
- + +
- -
- -
-function string_to_table(a_string varchar2, a_delimiter varchar2:= chr(10), a_skip_leading_delimiter varchar2 := 'N') return ut_varchar2_list is
- - 963 -
-l_offset integer := 1;
- -
-l_delimiter_position integer;
- - 963 -
-l_skip_leading_delimiter boolean := coalesce(a_skip_leading_delimiter = 'Y',false);
- - 963 -
-l_result ut_varchar2_list := ut_varchar2_list();
- + +
- +
+ +overriding member procedure send_line(self in out nocopy ut_output_table_buffer, a_text varchar2, a_item_type varchar2 := null) is
- +
+ +pragma autonomous_transaction;
- -
begin
- - 963 -
-if a_string is null then
- - 961 -
-return l_result;
- -
-end if;
- - 963 -
-if a_delimiter is null then
- - 2 -
-return ut_varchar2_list(a_string);
- -
-end if;
- -
-- - 45748 -
-loop
- - 45748 -
-l_delimiter_position := instr(a_string, a_delimiter, l_offset);
- - 45748 -
-if not (l_delimiter_position = 1 and l_skip_leading_delimiter) then
- - 45747 -
-l_result.extend;
- - 45747 -
-if l_delimiter_position > 0 then
- - 44786 -
-l_result(l_result.last) := substr(a_string, l_offset, l_delimiter_position - l_offset);
- -
-else
- - 961 -
-l_result(l_result.last) := substr(a_string, l_offset);
- -
-end if;
- + +
- + 1505 +
+ +if a_text is not null or a_item_type is not null then
- + 1504 +
+ +if length(a_text) > ut_utils.gc_max_storage_varchar2_len then
- +
+ +self.send_lines(
- +
+ +ut_utils.convert_collection(
- +
+ +ut_utils.clob_to_table(a_text, ut_utils.gc_max_storage_varchar2_len)
- +
+ +),
- +
+ +a_item_type
- +
+ +);
- +
+ +else
- + 1504 +
+ +self.last_message_id := self.last_message_id + 1;
- + 1504 +
+ +insert into ut_output_buffer_tmp(output_id, message_id, text, item_type)
- +
+ +values (self.output_id, self.last_message_id, a_text, a_item_type);
- -
end if;
- - 45747 -
-exit when l_delimiter_position = 0;
- - 44787 -
-l_offset := l_delimiter_position + 1;
- -
-end loop;
- -
-return l_result;
- + +
- + 1504 +
+ +commit;
- +
+ +end if;
- -
end;
- + +
- -
- -
-function clob_to_table(a_clob clob, a_max_amount integer := 8191, a_delimiter varchar2:= chr(10)) return ut_varchar2_list is
- - 77 -
-l_offset integer := 1;
- - 77 -
-l_length integer := dbms_lob.getlength(a_clob);
- -
-l_amount integer;
- -
-l_buffer varchar2(32767);
- -
-l_last_line varchar2(32767);
- -
-l_string_results ut_varchar2_list;
- - 77 -
-l_results ut_varchar2_list := ut_varchar2_list();
- -
-l_has_last_line boolean;
- - 77 -
-l_skip_leading_delimiter varchar2(1) := 'N';
- + +
- +
+ +overriding member procedure send_lines(self in out nocopy ut_output_table_buffer, a_text_list ut_varchar2_rows, a_item_type varchar2 := null) is
- +
+ +pragma autonomous_transaction;
- -
begin
- - 546 -
-while l_offset <= l_length loop
- - 76 -
-l_amount := a_max_amount - coalesce( length(l_last_line), 0 );
- - 469 -
-dbms_lob.read(a_clob, l_amount, l_offset, l_buffer);
- - 469 -
-l_offset := l_offset + l_amount;
- -
-- - 469 -
-l_string_results := string_to_table( l_last_line || l_buffer, a_delimiter, l_skip_leading_delimiter );
- - 45675 -
-for i in 1 .. l_string_results.count loop
- -
---if a split of lines was not done or not at the last line
- - 45206 -
-if l_string_results.count = 1 or i < l_string_results.count then
- - 44752 -
-l_results.extend;
- - 44752 -
-l_results(l_results.last) := l_string_results(i);
- -
-end if;
- -
-end loop;
- -
-- -
---check if we need to append the last line to the next element
- - 469 -
-if l_string_results.count = 1 then
- - 15 -
-l_has_last_line := false;
- - 15 -
-l_last_line := null;
- - 454 -
-elsif l_string_results.count > 1 then
- - 454 -
-l_has_last_line := true;
- - 454 -
-l_last_line := l_string_results(l_string_results.count);
- -
-end if;
- -
-- - 469 -
-l_skip_leading_delimiter := 'Y';
- -
-end loop;
- - 77 -
-if l_has_last_line then
- - 66 -
-l_results.extend;
- - 66 -
-l_results(l_results.last) := l_last_line;
- -
-end if;
- - 77 -
-return l_results;
- + +
- + 282 +
+ +insert into ut_output_buffer_tmp(output_id, message_id, text, item_type)
- +
+ +select self.output_id, self.last_message_id + rownum, t.column_value, a_item_type
- +
+ +from table(a_text_list) t
- +
+ +where t.column_value is not null or a_item_type is not null;
- + 282 +
+ +self.last_message_id := self.last_message_id + SQL%rowcount;
- + 282 +
+ +commit;
- -
end;
- + +
- -
- -
-function table_to_clob(a_text_table ut_varchar2_list, a_delimiter varchar2:= chr(10)) return clob is
- -
-l_result clob;
- - 59 -
-l_text_table_rows integer := coalesce(cardinality(a_text_table),0);
- + +
- +
+ +overriding member procedure send_clob(self in out nocopy ut_output_table_buffer, a_text clob, a_item_type varchar2 := null) is
- +
+ +pragma autonomous_transaction;
- -
begin
- - 19067 -
-for i in 1 .. l_text_table_rows loop
- - 19008 -
-if i < l_text_table_rows then
- - 18961 -
-append_to_clob(l_result, a_text_table(i)||a_delimiter);
- + +
- +
+ +if a_text is not null and a_text != empty_clob() or a_item_type is not null then
- +
+ +if length(a_text) > ut_utils.gc_max_storage_varchar2_len then
- +
+ +self.send_lines(
- +
+ +ut_utils.convert_collection(
- +
+ +ut_utils.clob_to_table(a_text, ut_utils.gc_max_storage_varchar2_len)
- +
+ +),
- +
+ +a_item_type
- +
+ +);
- -
else
- - 47 -
-append_to_clob(l_result, a_text_table(i));
- + +
- +
+ +self.last_message_id := self.last_message_id + 1;
- +
+ +insert into ut_output_buffer_tmp(output_id, message_id, text, item_type)
- +
+ +values (self.output_id, self.last_message_id, a_text, a_item_type);
- -
end if;
- -
-end loop;
- - 59 -
-return l_result;
- -
-end;
- -
-- -
-function time_diff(a_start_time timestamp with time zone, a_end_time timestamp with time zone) return number is
- -
-begin
- - 216 -
-return
- -
-extract(day from(a_end_time - a_start_time)) * 24 * 60 * 60 +
- -
-extract(hour from(a_end_time - a_start_time)) * 60 * 60 +
- -
-extract(minute from(a_end_time - a_start_time)) * 60 +
- -
-extract(second from(a_end_time - a_start_time));
- -
-end;
- -
-- -
-function indent_lines(a_text varchar2, a_indent_size integer := 4, a_include_first_line boolean := false) return varchar2 is
- -
-begin
- - 1737 -
-if a_include_first_line then
- - 5 -
-return rtrim(lpad( ' ', a_indent_size ) || replace( a_text, chr(10), chr(10) || lpad( ' ', a_indent_size ) ));
- -
-else
- - 1732 -
-return rtrim(replace( a_text, chr(10), chr(10) || lpad( ' ', a_indent_size ) ));
- + +
- +
+ +commit;
- -
end if;
- -
-end;
- -
-- -
-function get_utplsql_objects_list return ut_object_names is
- -
-l_result ut_object_names;
- -
-begin
- -
-select distinct ut_object_name(sys_context('userenv','current_user'), o.object_name)
- -
-bulk collect into l_result
- -
-from user_objects o
- -
-where o.object_name = 'UT' or object_name like 'UT\_%' escape '\'
- -
-and o.object_type <> 'SYNONYM';
- -
-return l_result;
- + +
- -
end;
- + +
- -
- -
-procedure append_to_varchar2_list(a_list in out nocopy ut_varchar2_list, a_line varchar2) is
- -
-begin
- - 1386 -
-if a_line is not null then
- - 64 -
-if a_list is null then
- -
-a_list := ut_varchar2_list();
- -
-end if;
- - 64 -
-a_list.extend;
- - 64 -
-a_list(a_list.last) := a_line;
- -
-end if;
- -
-end append_to_varchar2_list;
- + +
- +
+ +overriding member function get_lines(a_initial_timeout natural := null, a_timeout_sec natural := null) return ut_output_data_rows pipelined is
- +
+ +l_buffer_data ut_varchar2_rows;
- +
+ +l_item_types ut_varchar2_rows;
- +
+ +l_finished_flags ut_integer_list;
- + 116 +
+ +l_already_waited_for number(10,2) := 0;
- + 116 +
+ +l_finished boolean := false;
- + 116 +
+ +lc_init_wait_sec constant naturaln := coalesce(a_initial_timeout, 60 ); -- 1 minute
- + 116 +
+ +lc_max_wait_sec constant naturaln := coalesce(a_timeout_sec, 60 * 60 * 4); -- 4 hours
- + 116 +
+ +l_wait_for integer := lc_init_wait_sec;
- + 116 +
+ +lc_short_sleep_time constant number(1,1) := 0.1; --sleep for 100 ms between checks
- + 116 +
+ +lc_long_sleep_time constant number(1) := 1; --sleep for 1 s when waiting long
- + 116 +
+ +lc_long_wait_time constant number(1) := 1; --waiting more than 1 sec
- + 116 +
+ +l_sleep_time number(2,1) := lc_short_sleep_time;
- + 116 +
+ +lc_bulk_limit constant integer := 5000;
- + 116 +
+ +l_max_message_id integer := lc_bulk_limit;
- -
- -
-procedure append_to_clob(a_src_clob in out nocopy clob, a_new_data clob) is
- -
-begin
- - 687 -
-if a_new_data is not null and dbms_lob.getlength(a_new_data) > 0 then
- - 107 -
-if a_src_clob is null then
- - 30 -
-dbms_lob.createtemporary(a_src_clob, true);
- -
-end if;
- - 107 -
-dbms_lob.append(a_src_clob, a_new_data);
- -
-end if;
- -
-end;
- + +
- +
+ +procedure get_data_from_buffer(
- +
+ +a_max_message_id integer,
- +
+ +a_buffer_data out nocopy ut_varchar2_rows,
- +
+ +a_item_types out nocopy ut_varchar2_rows,
- +
+ +a_finished_flags out nocopy ut_integer_list
- +
+ +) is
- +
+ +pragma autonomous_transaction;
- +
+ +begin
- + 128 +
+ +delete from (
- +
+ +select *
- +
+ +from ut_output_buffer_tmp o
- +
+ +where o.output_id = self.output_id
- +
+ +and o.message_id <= a_max_message_id
- +
+ +order by o.message_id
- +
+ +) d
- +
+ +returning d.text, d.item_type, d.is_finished
- +
+ +bulk collect into a_buffer_data, a_item_types, a_finished_flags;
- + 128 +
+ +commit;
- -
- -
-procedure append_to_clob(a_src_clob in out nocopy clob, a_new_data varchar2) is
- -
-begin
- - 111847 -
-if a_new_data is not null then
- - 111846 -
-if a_src_clob is null then
- - 1197 -
-dbms_lob.createtemporary(a_src_clob, true);
- -
-end if;
- - 111846 -
-dbms_lob.writeappend(a_src_clob, dbms_lob.getlength(a_new_data), a_new_data);
- -
-end if;
- -
-end;
- + +
- +
+ +end;
- -
- -
-function convert_collection(a_collection ut_varchar2_list) return ut_varchar2_rows is
- -
-l_result ut_varchar2_rows;
- -
-begin
- - 47 -
-if a_collection is not null then
- - 1 -
-l_result := ut_varchar2_rows();
- - 2 -
-for i in 1 .. a_collection.count loop
- - 1 -
-l_result.extend();
- - 1 -
-l_result(i) := substr(a_collection(i),1,gc_max_storage_varchar2_len);
- -
-end loop;
- -
-end if;
- - 47 -
-return l_result;
- -
-end;
- + +
- +
+ +procedure remove_buffer_info is
- +
+ +pragma autonomous_transaction;
- +
+ +begin
- + 116 +
+ +delete from ut_output_buffer_info_tmp a
- +
+ +where a.output_id = self.output_id;
- + 116 +
+ +commit;
- +
+ +end;
- -
- -
-procedure cleanup_temp_tables is
- -
-pragma autonomous_transaction;
- -
-begin
- - 48 -
-execute immediate 'truncate table ut_cursor_data';
- - 48 -
-execute immediate 'truncate table ut_coverage_sources_tmp$';
- - 48 -
-commit;
- + +
- +
+ +begin
- + 242 +
+ +while not l_finished loop
- + 128 +
+ +get_data_from_buffer( l_max_message_id, l_buffer_data, l_item_types, l_finished_flags);
- +
+ +--nothing fetched from output, wait and try again
- + 128 +
+ +if l_buffer_data.count = 0 then
- +
+ +$if dbms_db_version.version >= 18 $then
- + 11 +
+ +dbms_session.sleep(l_sleep_time);
- +
+ +$else
- +
+ +dbms_lock.sleep(l_sleep_time);
- +
+ +$end
- + 11 +
+ +l_already_waited_for := l_already_waited_for + l_sleep_time;
- + 11 +
+ +if l_already_waited_for > lc_long_wait_time then
- +
+ +l_sleep_time := lc_long_sleep_time;
- +
+ +end if;
- +
+ +else
- +
+ +--reset wait time
- +
+ +-- we wait lc_max_wait_sec for new message
- + 117 +
+ +l_wait_for := lc_max_wait_sec;
- + 117 +
+ +l_already_waited_for := 0;
- + 117 +
+ +l_sleep_time := lc_short_sleep_time;
- + 232 +
+ +for i in 1 .. l_buffer_data.count loop
- + 14921 +
+ +if l_buffer_data(i) is not null then
- + 14695 +
+ +pipe row(ut_output_data_row(l_buffer_data(i),l_item_types(i)));
- + 226 +
+ +elsif l_finished_flags(i) = 1 then
- + 114 +
+ +l_finished := true;
- + 114 +
+ +exit;
- +
+ +end if;
- +
+ +end loop;
- + 117 +
+ +l_max_message_id := l_max_message_id + lc_bulk_limit;
- +
+ +end if;
- + 128 +
+ +if l_finished or l_already_waited_for >= l_wait_for then
- + 116 +
+ +remove_buffer_info();
- + 116 +
+ +if l_already_waited_for > 0 and l_already_waited_for >= l_wait_for then
- + 2 +
+ +raise_application_error(
- +
+ +ut_utils.gc_out_buffer_timeout,
- +
+ +'Timeout occurred while waiting for output data. Waited for: '||l_already_waited_for||' seconds.'
- +
+ +);
- +
+ +end if;
- +
+ +end if;
- +
+ +end loop;
- + 114 +
+ +return;
- -
end;
- + +
- -
- -
end ut_utils;
+UT3.UT_DATA_VALUE_ANYDATA
93.33 % covered
15 relevant lines. 14 lines covered and 1 lines missed+ +
- +
+end;
UT3.UT_SESSION_CONTEXT
85.71 % lines covered
7 relevant lines. 6 lines covered and 1 lines missed+
- -
+type body ut_data_value_anydata as
package body ut_session_context as
+- +
/*
- -
+utPLSQL - Version X.X.X.X
utPLSQL - Version 3
+- -
+Copyright 2016 - 2017 utPLSQL Project
Copyright 2016 - 2019 utPLSQL Project
+- +
- +
Licensed under the Apache License, Version 2.0 (the "License"):
- +
you may not use this file except in compliance with the License.
- +
You may obtain a copy of the License at
- +
- +
http://www.apache.org/licenses/LICENSE-2.0
- +
- +
Unless required by applicable law or agreed to in writing, software
- +
distributed under the License is distributed on an "AS IS" BASIS,
- +
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
See the License for the specific language governing permissions and
- +
limitations under the License.
- +
*/
- -
+$IF $$SELF_TESTING_INSTALL $THEN
+- -
+constructor function ut_data_value_anydata(self in out nocopy ut_data_value_anydata) return self as result is
gc_context_name constant varchar2(30) := ut_utils.ut_owner()||'_INFO';
+- -
-begin
- - 35 -
-self.self_type := $$plsql_unit;
- - 35 -
-self.data_type := 'undefined';
- - 35 -
+return;
$ELSE
+ +- + 1 +
+ +gc_context_name constant varchar2(30) := 'UT3_INFO';
- +
+ +$END
- +
+- -
+end;
procedure set_context(a_name varchar2, a_value varchar2) is
+- -
-- -
-overriding member function is_null return boolean is
- -
begin
- - 3 -
-return true;
- + +
- + 3288 +
+ +dbms_session.set_context( gc_context_name, a_name, a_value );
- -
end;
- + +
- -
- -
-overriding member function to_string return varchar2 is
- + +
- +
+ +procedure clear_context(a_name varchar2) is
- -
begin
- - 3 -
-return ut_utils.to_string( to_char(null) );
- + +
- + 3284 +
+ +dbms_session.clear_context( namespace => gc_context_name, attribute => a_name );
- -
end;
- + +
- -
- -
-overriding member function compare_implementation( a_other ut_data_value ) return integer is
- + +
- +
+ +procedure clear_all_context is
- -
begin
- - 1 -
-return null;
- + +
- + 120 +
+ +dbms_session.clear_all_context( namespace => gc_context_name );
- -
end;
- + +
- + +
- +
+ +function is_ut_run return boolean is
- +
+l_paths varchar2(32767);
- -
-static function get_instance(a_data_value anydata) return ut_data_value_anydata is
- - 35 -
-l_result ut_data_value_anydata := ut_data_value_anydata();
- -
+l_type anytype;
begin
+ +- + 799 +
+ +l_paths := sys_context(gc_context_name, 'RUN_PATHS');
- + 799 +
+return l_paths is not null;
- -
+l_type_code integer;
end;
+- +
+ +- +
+ +function get_namespace return varchar2 is
- -
begin
- - 35 -
-if a_data_value is not null then
- - 26 -
-l_type_code := a_data_value.gettype(l_type);
- - 28 -
-if l_type_code = dbms_types.typecode_object then
- - 18 -
-l_result := ut_data_value_object(a_data_value);
- - 8 -
-elsif l_type_code in (dbms_types.typecode_table, dbms_types.typecode_varray, dbms_types.typecode_namedcollection) then
- - 8 -
-l_result := ut_data_value_collection(a_data_value);
- -
-else
- -
-raise_application_error(-20000, 'Data type '||a_data_value.gettypename||' in ANYDATA is not supported by utPLSQL');
- -
-end if;
- -
-end if;
- - 35 -
-return l_result;
- + +
- +
+ +return gc_context_name;
- -
end;
- + +
- -
- -
end;
+UT3.UT_DATA_VALUE_BLOB
100 % covered
11 relevant lines. 11 lines covered and 0 lines missed+ +
- +
+end;
UT3.UT_SESSION_INFO
98.68 % lines covered
76 relevant lines. 75 lines covered and 1 lines missed+
- -
+type body ut_data_value_blob as
type body ut_session_info as
+- +
/*
- -
+utPLSQL - Version X.X.X.X
utPLSQL - Version 3
+- -
+Copyright 2016 - 2017 utPLSQL Project
Copyright 2016 - 2019 utPLSQL Project
+- +
- +
Licensed under the Apache License, Version 2.0 (the "License"):
- +
you may not use this file except in compliance with the License.
- +
You may obtain a copy of the License at
- +
- +
http://www.apache.org/licenses/LICENSE-2.0
- +
- +
Unless required by applicable law or agreed to in writing, software
- +
distributed under the License is distributed on an "AS IS" BASIS,
- +
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
See the License for the specific language governing permissions and
- +
limitations under the License.
- +
*/
- +
- -
+constructor function ut_data_value_blob(self in out nocopy ut_data_value_blob, a_value blob) return self as result is
constructor function ut_session_info(self in out nocopy ut_session_info) return self as result is
+- -
begin
- - 36 -
-self.data_value := a_value;
- - 36 -
-self.self_type := $$plsql_unit;
- - 36 -
-self.data_type := 'blob';
- - 36 + +
- + 116 +
+ +self.self_type := $$plsql_unit;
- + 116 +
+ +dbms_application_info.read_client_info( client_info );
- + 116 +
+ +dbms_application_info.read_module( module, action );
- + 116
+return;
- +
end;
- +
- -
+overriding member function is_null return boolean is
-- run hooks
+- +
+ +member procedure before_calling_run(self in out nocopy ut_session_info, a_run in ut_run) is
- -
begin
- - 86 -
-return (self.data_value is null);
- -
-end;
- -
+ +- + 115 +
+ +ut_session_context.set_context( 'run_paths', ut_utils.to_string( ut_utils.table_to_clob( a_run.run_paths,',' ), null ) );
- + 115 +
+dbms_application_info.set_module( 'utPLSQL', null );
- -
-overriding member function to_string return varchar2 is
- -
-begin
- - 32 -
-return self.format_multi_line( ut_utils.to_string(self.data_value) );
- -
end;
- + +
- -
- -
-overriding member function compare_implementation(a_other ut_data_value) return integer is
- -
+ +l_result integer;
- +
+ +member procedure after_calling_run(self in out nocopy ut_session_info, a_run in ut_run) is
- +
+ +begin
- + 115 +
+ +ut_session_context.clear_context( 'run_paths' );
- + 115 +
+ +dbms_application_info.set_module( module, action );
- + 115 +
+dbms_application_info.set_client_info( client_info );
- -
+l_other ut_data_value_blob;
end;
+- +
+ +- +
+ +-- suite hooks
- +
+ +member procedure before_calling_suite(self in out nocopy ut_session_info, a_suite in ut_logical_suite) is
- -
begin
- - 13 -
-if a_other is of (ut_data_value_blob) then
- - 13 -
-l_other := treat(a_other as ut_data_value_blob);
- - 13 -
-l_result := dbms_lob.compare( self.data_value, l_other.data_value);
- + +
- + 333 +
+ +if a_suite is not of (ut_suite_context) then
- + 322 +
+ +ut_session_context.set_context( 'suite_path', a_suite.path );
- + 322 +
+ +ut_session_context.set_context( 'suite_package', a_suite.object_owner||'.'||a_suite.object_name );
- + 322 +
+ +ut_session_context.set_context( 'suite_description', a_suite.description );
- + 322 +
+ +ut_session_context.set_context( 'suite_start_time', ut_utils.to_string(a_suite.start_time) );
- + 322 +
+ +dbms_application_info.set_module( 'utPLSQL', a_suite.object_name );
- +
+ +else
- + 11 +
+ +ut_session_context.set_context( 'context_name', a_suite.name );
- + 11 +
+ +ut_session_context.set_context( 'context_path', a_suite.path);
- + 11 +
+ +ut_session_context.set_context( 'context_description', a_suite.description );
- + 11 +
+ +ut_session_context.set_context( 'context_start_time', ut_utils.to_string(a_suite.start_time) );
- -
end if;
- - 13 -
-return l_result;
- + +
- -
end;
- + +
- -
- -
-overriding member function is_multi_line return boolean is
- + +
- +
+ +member procedure after_calling_suite(self in out nocopy ut_session_info, a_suite in ut_logical_suite) is
- -
begin
- - 64 -
-return not self.is_null() and dbms_lob.getlength(self.data_value) > 100;
- + +
- + 333 +
+ +if a_suite is not of (ut_suite_context) then
- + 322 +
+ +ut_session_context.clear_context( 'suite_package' );
- + 322 +
+ +ut_session_context.clear_context( 'suite_path' );
- + 322 +
+ +ut_session_context.clear_context( 'suite_description' );
- + 322 +
+ +ut_session_context.clear_context( 'suite_start_time' );
- +
+ +else
- + 11 +
+ +ut_session_context.clear_context( 'context_name' );
- + 11 +
+ +ut_session_context.clear_context( 'context_path' );
- + 11 +
+ +ut_session_context.clear_context( 'context_description' );
- + 11 +
+ +ut_session_context.clear_context( 'context_start_time' );
- +
+ +end if;
- -
end;
- -
end;
UT3.UT_DATA_VALUE_BOOLEAN
87.5 % covered
16 relevant lines. 14 lines covered and 2 lines missed-
- -
-type body ut_data_value_boolean as
- -
-/*
- -
-utPLSQL - Version X.X.X.X
- -
-Copyright 2016 - 2017 utPLSQL Project
- -
-- -
-Licensed under the Apache License, Version 2.0 (the "License"):
- -
-you may not use this file except in compliance with the License.
- -
-You may obtain a copy of the License at
- -
-- -
-http://www.apache.org/licenses/LICENSE-2.0
- + +
- -
- -
-Unless required by applicable law or agreed to in writing, software
- -
-distributed under the License is distributed on an "AS IS" BASIS,
- -
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- -
-See the License for the specific language governing permissions and
- -
-limitations under the License.
- -
-*/
- + +
- -
- -
-constructor function ut_data_value_boolean(self in out nocopy ut_data_value_boolean, a_value boolean) return self as result is
- + +
- +
+ +member procedure before_calling_test(self in out nocopy ut_session_info, a_test in ut_test) is
- -
begin
- - 91 -
-self.data_value := ut_utils.boolean_to_int(a_value);
- - 91 -
-self.self_type := $$plsql_unit;
- - 91 -
-self.data_type := 'boolean';
- - 91 -
-return;
- + +
- + 319 +
+ +ut_session_context.set_context( 'test_name', a_test.object_owner||'.'||a_test.object_name||'.'||a_test.name );
- + 319 +
+ +ut_session_context.set_context( 'test_description', a_test.description );
- + 319 +
+ +ut_session_context.set_context( 'test_start_time', ut_utils.to_string(a_test.start_time) );
- -
end;
- + +
- -
- -
-overriding member function is_null return boolean is
- + +
- +
+ +member procedure after_calling_test (self in out nocopy ut_session_info, a_test in ut_test) is
- -
begin
- - 22 -
-return (self.data_value is null);
- + +
- + 319 +
+ +ut_session_context.clear_context( 'test_name' );
- + 319 +
+ +ut_session_context.clear_context( 'test_description' );
- + 319 +
+ +ut_session_context.clear_context( 'test_start_time' );
- -
end;
- + +
- -
- -
-overriding member function to_string return varchar2 is
- + +
- +
+ +member procedure before_calling_executable(self in out nocopy ut_session_info, a_executable in ut_executable) is
- -
begin
- - 89 -
-return ut_utils.to_string(ut_utils.int_to_boolean(self.data_value));
- + +
- + 440 +
+ +ut_session_context.set_context( 'current_executable_type', a_executable.executable_type );
- + 440 +
+ +ut_session_context.set_context(
- +
+ +'current_executable_name',
- +
+ +a_executable.owner_name||'.'||a_executable.object_name||'.'||a_executable.procedure_name
- +
+ +);
- + 440 +
+ +dbms_application_info.set_client_info( a_executable.procedure_name );
- -
end;
- + +
- -
- -
-overriding member function compare_implementation(a_other ut_data_value) return integer is
- -
-l_other ut_data_value_boolean;
- -
-l_result integer;
- + +
- +
+ +member procedure after_calling_executable(self in out nocopy ut_session_info, a_executable in ut_executable) is
- -
begin
- - 13 -
-if a_other is of (ut_data_value_boolean) then
- - 13 -
-l_other := treat(a_other as ut_data_value_boolean);
- - 13 -
-if self.data_value = l_other.data_value then
- - 3 -
-l_result := 0;
- - 10 -
-elsif self.data_value > l_other.data_value then
- -
-l_result := 1;
- - 10 -
-elsif self.data_value < l_other.data_value then
- - 2 -
-l_result := -1;
- -
-end if;
- -
-else
- -
-raise value_error;
- -
-end if;
- - 13 -
-return l_result;
- + +
- + 440 +
+ +ut_session_context.clear_context( 'current_executable_type' );
- + 440 +
+ +ut_session_context.clear_context( 'current_executable_name' );
- + 440 +
+ +dbms_application_info.set_client_info( null );
- -
end;
- -
-- -
end;
UT3.UT_DATA_VALUE_CLOB
100 % covered
11 relevant lines. 11 lines covered and 0 lines missed-
- -
-type body ut_data_value_clob as
- -
-/*
- -
-utPLSQL - Version X.X.X.X
- -
-Copyright 2016 - 2017 utPLSQL Project
- -
-- -
-Licensed under the Apache License, Version 2.0 (the "License"):
- -
-you may not use this file except in compliance with the License.
- -
-You may obtain a copy of the License at
- -
-- -
-http://www.apache.org/licenses/LICENSE-2.0
- -
-- -
-Unless required by applicable law or agreed to in writing, software
- -
-distributed under the License is distributed on an "AS IS" BASIS,
- -
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- -
-See the License for the specific language governing permissions and
- -
-limitations under the License.
- -
-*/
- + +
- -
- -
-constructor function ut_data_value_clob(self in out nocopy ut_data_value_clob, a_value clob) return self as result is
- + +
- +
+ +member procedure on_finalize(self in out nocopy ut_session_info, a_run in ut_run) is
- -
begin
- - 59 -
-self.data_value := a_value;
- - 59 -
-self.self_type := $$plsql_unit;
- - 59 -
-self.data_type := 'clob';
- - 59 -
-return;
- + +
- + 116 +
+ +dbms_application_info.set_client_info( client_info );
- + 116 +
+ +dbms_application_info.set_module( module, action );
- + 117 +
+ +ut_session_context.clear_all_context();
- -
end;
- + +
- -
- -
-overriding member function is_null return boolean is
- + +
- +
+ +overriding member function get_supported_events return ut_varchar2_list is
- -
begin
- - 124 -
-return (self.data_value is null);
- -
-end;
- -
-- -
-overriding member function to_string return varchar2 is
- -
-begin
- - 51 -
-return self.format_multi_line( ut_utils.to_string(self.data_value) );
- -
-end;
- -
-- -
-overriding member function compare_implementation(a_other ut_data_value) return integer is
- -
-l_result integer;
- -
-l_other ut_data_value_clob;
- -
-begin
- - 13 -
-if a_other is of (ut_data_value_clob) then
- - 13 -
-l_other := treat(a_other as ut_data_value_clob);
- - 13 -
-l_result := dbms_lob.compare( self.data_value, l_other.data_value);
- -
-end if;
- - 13 -
-return l_result;
- + +
- + 116 +
+ +return ut_varchar2_list(
- +
+ +ut_event_manager.gc_before_run,
- +
+ +ut_event_manager.gc_before_suite,
- +
+ +ut_event_manager.gc_before_test,
- +
+ +ut_event_manager.gc_before_before_all,
- +
+ +ut_event_manager.gc_before_before_each,
- +
+ +ut_event_manager.gc_before_before_test,
- +
+ +ut_event_manager.gc_before_test_execute,
- +
+ +ut_event_manager.gc_before_after_test,
- +
+ +ut_event_manager.gc_before_after_each,
- +
+ +ut_event_manager.gc_before_after_all,
- +
+ +ut_event_manager.gc_after_run,
- +
+ +ut_event_manager.gc_after_suite,
- +
+ +ut_event_manager.gc_after_test,
- +
+ +ut_event_manager.gc_after_before_all,
- +
+ +ut_event_manager.gc_after_before_each,
- +
+ +ut_event_manager.gc_after_before_test,
- +
+ +ut_event_manager.gc_after_test_execute,
- +
+ +ut_event_manager.gc_after_after_test,
- +
+ +ut_event_manager.gc_after_after_each,
- +
+ +ut_event_manager.gc_after_after_all,
- +
+ +ut_event_manager.gc_finalize
- +
+ +);
- -
end;
- + +
- -
- -
-overriding member function is_multi_line return boolean is
- + +
- +
+ +overriding member procedure on_event( self in out nocopy ut_session_info, a_event_name varchar2, a_event_item ut_event_item) is
- -
begin
- - 102 -
-return not self.is_null() and (dbms_lob.getlength(self.data_value) > 100 or dbms_lob.instr(self.data_value,chr(10)) > 0);
- + +
- + 2530 +
+ +case
- + 2530 +
+ +when a_event_name in (
- +
+ +ut_event_manager.gc_before_before_all,
- + 1 +
+ +ut_event_manager.gc_before_before_each,
- + 1 +
+ +ut_event_manager.gc_before_before_test,
- + 1 +
+ +ut_event_manager.gc_before_test_execute,
- + 1 +
+ +ut_event_manager.gc_before_after_test,
- + 1 +
+ +ut_event_manager.gc_before_after_each,
- + 1 +
+ +ut_event_manager.gc_before_after_all
- +
+ +)
- + 440 +
+ +then before_calling_executable(treat(a_event_item as ut_executable));
- + 2090 +
+ +when a_event_name in (
- +
+ +ut_event_manager.gc_after_before_all,
- + 1 +
+ +ut_event_manager.gc_after_before_each,
- + 1 +
+ +ut_event_manager.gc_after_before_test,
- + 1 +
+ +ut_event_manager.gc_after_test_execute,
- + 1 +
+ +ut_event_manager.gc_after_after_test,
- + 1 +
+ +ut_event_manager.gc_after_after_each,
- + 1 +
+ +ut_event_manager.gc_after_after_all
- +
+ +)
- + 440 +
+ +then after_calling_executable(treat(a_event_item as ut_executable));
- + 1650 +
+ +when a_event_name = ut_event_manager.gc_before_test
- + 319 +
+ +then self.before_calling_test(treat(a_event_item as ut_test));
- + 1331 +
+ +when a_event_name = ut_event_manager.gc_after_test
- + 319 +
+ +then self.after_calling_test(treat(a_event_item as ut_test));
- + 1012 +
+ +when a_event_name = ut_event_manager.gc_after_suite
- + 333 +
+ +then after_calling_suite(treat(a_event_item as ut_logical_suite));
- + 679 +
+ +when a_event_name = ut_event_manager.gc_before_suite
- + 333 +
+ +then before_calling_suite(treat(a_event_item as ut_logical_suite));
- + 346 +
+ +when a_event_name = ut_event_manager.gc_before_run
- + 115 +
+ +then before_calling_run(treat(a_event_item as ut_run));
- + 231 +
+ +when a_event_name = ut_event_manager.gc_after_run
- + 115 +
+ +then after_calling_run(treat(a_event_item as ut_run));
- + 116 +
+ +when a_event_name = ut_event_manager.gc_finalize
- + 116 +
+ +then on_finalize(treat(a_event_item as ut_run));
- +
+ +else null;
- +
+ +end case;
- -
end;
- + +
- -
- -
end;
+UT3.UT_DATA_VALUE_COLLECTION
83.33 % covered
42 relevant lines. 35 lines covered and 7 lines missed+ +
- +
+end;
UT3.UT_CONSOLE_REPORTER_BASE
100 % lines covered
5 relevant lines. 5 lines covered and 0 lines missed+
- -
+type body ut_data_value_collection as
type body ut_console_reporter_base is
+- +
/*
- -
+utPLSQL - Version X.X.X.X
utPLSQL - Version 3
+- -
+Copyright 2016 - 2017 utPLSQL Project
Copyright 2016 - 2019 utPLSQL Project
+- +
- +
Licensed under the Apache License, Version 2.0 (the "License"):
- +
you may not use this file except in compliance with the License.
- +
You may obtain a copy of the License at
- +
- +
http://www.apache.org/licenses/LICENSE-2.0
- +
- +
Unless required by applicable law or agreed to in writing, software
- +
distributed under the License is distributed on an "AS IS" BASIS,
- +
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
See the License for the specific language governing permissions and
- +
limitations under the License.
- +
*/
- +
- -
+constructor function ut_data_value_collection(self in out nocopy ut_data_value_collection, a_value anydata) return self as result is
static procedure set_color_enabled(a_flag boolean) is
+- -
begin
- - 8 -
-self.data_value := a_value;
- - 8 -
-self.self_type := $$plsql_unit;
- - 8 -
-self.data_type := case when a_value is not null then lower(a_value.gettypename) else 'undefined' end;
- - 8 -
-return;
- + +
- + 116 +
+ +ut_ansiconsole_helper.color_enabled(a_flag);
- -
end;
- + +
- + +
- +
+ +member procedure print_red_text(self in out nocopy ut_console_reporter_base, a_text varchar2) is
- +
+ +begin
- + 207 +
+self.print_text(ut_ansiconsole_helper.red(a_text));
- -
+overriding member function is_null return boolean is
end;
+- -
+l_is_null boolean;
+
- -
+l_data_is_null pls_integer;
member procedure print_green_text(self in out nocopy ut_console_reporter_base, a_text varchar2) is
+- -
-l_sql varchar2(32767);
- -
+l_cursor number;
begin
+ +- + 180 +
+self.print_text(ut_ansiconsole_helper.green(a_text));
- -
+l_status number;
end;
+- +
+ +- +
+ +member procedure print_yellow_text(self in out nocopy ut_console_reporter_base, a_text varchar2) is
- -
begin
- - 28 -
-if self.data_value is null then
- -
-l_is_null := true;
- -
+ +--check if typename is a schema based object
- + 1 +
+self.print_text(ut_ansiconsole_helper.yellow(a_text));
- -
+else
end;
+- -
---XMLTYPE doesn't like the null being passed to ANYDATA so we need to check if anydata holds null Object/collection
- - 28 -
+l_sql := '
+ +
- +
+member procedure print_cyan_text(self in out nocopy ut_console_reporter_base, a_text varchar2) is
- -
-declare
- -
+l_data '||self.data_value.gettypename()||';
begin
+ +- + 10 +
+self.print_text(ut_ansiconsole_helper.cyan(a_text));
- -
-l_value anydata := :a_value;
- -
-x integer;
- -
-begin
- -
-x := l_value.getCollection(l_data);
- -
-:l_data_is_null := case when l_data is null then 1 else 0 end;
- -
-end;';
- - 28 -
-l_cursor := sys.dbms_sql.open_cursor();
- - 28 -
-sys.dbms_sql.parse(l_cursor, l_sql, dbms_sql.native);
- - 28 -
-sys.dbms_sql.bind_variable(l_cursor,'a_value',self.data_value);
- - 28 -
-sys.dbms_sql.bind_variable(l_cursor,'l_data_is_null',l_data_is_null);
- -
-begin
- - 28 -
-l_status := sys.dbms_sql.execute(l_cursor);
- - 28 -
-sys.dbms_sql.variable_value(l_cursor,'l_data_is_null',l_data_is_null);
- - 28 -
-sys.dbms_sql.close_cursor(l_cursor);
- -
-exception when others then
- -
-if sys.dbms_sql.is_open(l_cursor) then
- -
-sys.dbms_sql.close_cursor(l_cursor);
- -
-end if;
- -
-raise;
- -
-end;
- - 28 -
-l_is_null := ut_utils.int_to_boolean(l_data_is_null);
- -
-end if;
- - 28 -
-return l_is_null;
- -
-end;
- -
-- -
-member function is_empty return boolean is
- -
-begin
- - 4 -
-if not self.is_null() then
- - 4 -
-return xmltype(self.data_value).getclobval()
- -
-= '<' || substr(self.data_value.gettypename, instr(self.data_value.gettypename, '.') + 1) || '/>';
- -
-else
- -
-return null;
- -
-end if;
- -
-end;
- -
-- -
-overriding member function to_string return varchar2 is
- -
-l_result varchar2(32767);
- -
-l_clob clob;
- -
-begin
- - 7 -
-if self.is_null() then
- - 1 -
-l_result := ut_utils.to_string( to_char(null) );
- -
-else
- - 10 -
-ut_expectation_processor.set_xml_nls_params();
- - 6 -
-select xmlserialize(content xmltype(self.data_value) indent) into l_clob from dual;
- - 6 -
-l_result := ut_utils.to_string( l_clob, null );
- - 6 -
-ut_expectation_processor.reset_nls_params();
- -
-end if;
- - 7 -
-return self.format_multi_line( l_result );
- -
-end;
- -
-- -
-overriding member function compare_implementation(a_other ut_data_value) return integer is
- -
-l_self_data xmltype;
- -
-l_other_data xmltype;
- -
-l_other ut_data_value_collection;
- -
-l_result integer;
- -
-begin
- - 1 -
-if a_other is of (ut_data_value_collection) then
- - 1 -
-l_other := treat(a_other as ut_data_value_collection);
- -
---needed for 11g xe as it fails on constructing XMLTYPE from null ANYDATA
- - 1 -
-if not self.is_null() and not l_other.is_null() then
- - 2 -
-ut_expectation_processor.set_xml_nls_params();
- - 1 -
-l_self_data := xmltype.createxml(self.data_value);
- - 1 -
-l_other_data := xmltype.createxml(l_other.data_value);
- - 1 -
-ut_expectation_processor.reset_nls_params();
- - 1 -
-if l_self_data is not null and l_other_data is not null then
- - 1 -
-l_result := dbms_lob.compare( l_self_data.getclobval(), l_other_data.getclobval() );
- -
-end if;
- -
-end if;
- -
-else
- -
-raise value_error;
- -
-end if;
- - 1 -
-return l_result;
- -
-end;
- -
-- -
-overriding member function is_multi_line return boolean is
- -
-begin
- - 14 -
-return not self.is_null();
- -
end;
- + +
- -
- -
end;
+UT3.UT_DATA_VALUE_DATE
93.75 % covered
16 relevant lines. 15 lines covered and 1 lines missed+ +
- +
+end;
UT3.UT_EXECUTABLE
92.75 % lines covered
69 relevant lines. 64 lines covered and 5 lines missed+
- -
+type body ut_data_value_date as
type body ut_executable is
+- +
/*
- -
+utPLSQL - Version X.X.X.X
utPLSQL - Version 3
+- -
+Copyright 2016 - 2017 utPLSQL Project
Copyright 2016 - 2019 utPLSQL Project
+- +
- +
Licensed under the Apache License, Version 2.0 (the "License"):
- +
you may not use this file except in compliance with the License.
- +
You may obtain a copy of the License at
- +
- +
http://www.apache.org/licenses/LICENSE-2.0
- +
- +
Unless required by applicable law or agreed to in writing, software
- +
distributed under the License is distributed on an "AS IS" BASIS,
- +
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
See the License for the specific language governing permissions and
- +
limitations under the License.
- +
*/
- +
- -
+constructor function ut_data_value_date(self in out nocopy ut_data_value_date, a_value date) return self as result is
constructor function ut_executable(
+- +
+ +self in out nocopy ut_executable, a_owner varchar2, a_package varchar2,
- +
+ +a_procedure_name varchar2, a_executable_type varchar2
- +
+ +) return self as result is
- -
begin
- - 90 -
-self.data_value := a_value;
- - 90 -
-self.self_type := $$plsql_unit;
- - 90 -
-self.data_type := 'date';
- - 90 + +
- + 848 +
+ +self.self_type := $$plsql_unit;
- + 848 +
+ +self.executable_type := a_executable_type;
- + 848 +
+ +self.owner_name := a_owner;
- + 848 +
+ +self.object_name := a_package;
- + 848 +
+ +self.procedure_name := a_procedure_name;
- + 848
-return;
- -
-end;
- -
-- -
-overriding member function is_null return boolean is
- -
-begin
- - 22 -
+return (self.data_value is null);
- +
end;
- +
- -
-overriding member function to_string return varchar2 is
- +
+ +member function form_name(a_skip_current_user_schema boolean := false) return varchar2 is
- + 563 +
+ +l_owner_name varchar2(250) := owner_name;
- -
begin
- - 84 -
-return ut_utils.to_string(self.data_value);
- -
-end;
- -
+ +- + 563 +
+ +if a_skip_current_user_schema and sys_context('userenv', 'current_schema') = owner_name then
- + 379 +
+l_owner_name := null;
- -
-overriding member function compare_implementation(a_other ut_data_value) return integer is
- -
+l_result integer;
end if;
+ +- + 563 +
+return ut_metadata.form_name(l_owner_name, object_name, procedure_name);
- -
+l_other ut_data_value_date;
end;
+- +
+ +- +
+ +member procedure do_execute(self in out nocopy ut_executable, a_item in out nocopy ut_suite_item) is
- +
+ +l_completed_without_errors boolean;
- -
begin
- - 43 -
-if a_other is of (ut_data_value_date) then
- - 43 -
-l_other := treat(a_other as ut_data_value_date);
- - 43 -
-if self.data_value = l_other.data_value then
- - 7 -
-l_result := 0;
- - 36 -
-elsif self.data_value > l_other.data_value then
- - 13 -
-l_result := 1;
- - 23 -
-elsif self.data_value < l_other.data_value then
- - 9 -
+ +l_result := -1;
- + 396 +
+ +l_completed_without_errors := self.do_execute(a_item);
- +
+ +end do_execute;
- +
+ +- + 505 +
+ +member function do_execute(self in out nocopy ut_executable, a_item in out nocopy ut_suite_item) return boolean is
- +
+l_statement varchar2(4000);
- -
+end if;
l_status number;
+- -
-else
- -
-raise value_error;
- -
-end if;
- - 43 -
+return l_result;
l_cursor_number number;
+ +- + 505 +
+ +l_completed_without_errors boolean := true;
- + 505 +
+ +l_failed_with_invalid_pck boolean := true;
- +
+l_start_transaction_id varchar2(250);
- -
+end;
l_end_transaction_id varchar2(250);
+- +
- -
end;
UT3.UT_DATA_VALUE_DSINTERVAL
100 % covered
15 relevant lines. 15 lines covered and 0 lines missed-
- -
-type body ut_data_value_dsinterval as
- -
-/*
- -
-utPLSQL - Version X.X.X.X
- -
-Copyright 2016 - 2017 utPLSQL Project
- +
+ +function is_defined return boolean is
- + 505 +
+ +l_result boolean := false;
- + 505 +
+ +l_message_part varchar2(4000) := 'Call params for ' || self.executable_type || ' are not valid: ';
- +
+ +begin
- -
- -
-Licensed under the Apache License, Version 2.0 (the "License"):
- -
-you may not use this file except in compliance with the License.
- -
-You may obtain a copy of the License at
- + +
- + 505 +
+ +if self.object_name is null then
- + 1 +
+ +self.error_stack := l_message_part || 'package is not defined';
- + 504 +
+ +elsif self.procedure_name is null then
- + 5 +
+ +self.error_stack := l_message_part || 'procedure is not defined';
- +
+ +else
- + 499 +
+ +l_result := true;
- +
+ +end if;
- -
- -
-http://www.apache.org/licenses/LICENSE-2.0
- + +
- + 505 +
+ +return l_result;
- +
+ +end is_defined;
- -
- -
-Unless required by applicable law or agreed to in writing, software
- -
-distributed under the License is distributed on an "AS IS" BASIS,
- -
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- -
-See the License for the specific language governing permissions and
- -
-limitations under the License.
- -
-*/
- + +
- +
+ +function is_invalid return boolean is
- + 12 +
+ +l_result boolean := true;
- + 12 +
+ +l_message_part varchar2(4000) := 'Call params for ' || self.executable_type || ' are not valid: ';
- +
+ +begin
- -
- -
-constructor function ut_data_value_dsinterval(self in out nocopy ut_data_value_dsinterval, a_value dsinterval_unconstrained) return self as result is
- -
-begin
- - 82 -
-self.data_value := a_value;
- - 82 -
-self.self_type := $$plsql_unit;
- - 82 -
-self.data_type := 'interval day to second';
- - 82 -
-return;
- -
-end;
- + +
- + 12 +
+ +if not ut_metadata.package_valid(self.owner_name, self.object_name) then
- + 6 +
+ +self.error_stack := l_message_part || 'package '||upper(self.owner_name||'.'||self.object_name)||' does not exist or is invalid.';
- + 6 +
+ +elsif not ut_metadata.procedure_exists(self.owner_name, self.object_name, self.procedure_name) then
- + 6 +
+ +self.error_stack := l_message_part || 'procedure '||upper(self.owner_name || '.' || self.object_name || '.' ||self.procedure_name)||' does not exist.';
- +
+ +else
- +
+ +l_result := false;
- +
+ +end if;
- -
- -
-overriding member function is_null return boolean is
- -
-begin
- - 16 -
-return (self.data_value is null);
- -
-end;
- + +
- + 12 +
+ +return l_result;
- +
+ +end is_invalid;
- -
- -
-overriding member function to_string return varchar2 is
- -
-begin
- - 78 -
-return ut_utils.to_string(self.data_value);
- -
-end;
- + +
- +
+ +procedure save_dbms_output is
- +
+ +l_status number;
- +
+ +l_line varchar2(32767);
- +
+ +begin
- -
- -
-overriding member function compare_implementation(a_other ut_data_value) return integer is
- -
-l_result integer;
- -
-l_other ut_data_value_dsinterval;
- -
-begin
- - 43 -
-if a_other is of (ut_data_value_dsinterval) then
- - 43 -
-l_other := treat(a_other as ut_data_value_dsinterval);
- - 43 -
-if self.data_value = l_other.data_value then
- - 7 -
-l_result := 0;
- - 36 -
-elsif self.data_value > l_other.data_value then
- - 15 -
-l_result := 1;
- - 21 -
-elsif self.data_value < l_other.data_value then
- - 7 -
-l_result := -1;
- + +
- + 499 +
+ +dbms_output.get_line(line => l_line, status => l_status);
- + 499 +
+ +if l_status != 1 then
- + 326 +
+ +dbms_lob.createtemporary(self.serveroutput, true, dur => dbms_lob.session);
- -
end if;
- -
-end if;
- - 43 -
-return l_result;
- -
-end;
- -
-- -
end;
UT3.UT_DATA_VALUE_NUMBER
93.75 % covered
16 relevant lines. 15 lines covered and 1 lines missed-
- -
-type body ut_data_value_number as
- -
-/*
- -
-utPLSQL - Version X.X.X.X
- -
-Copyright 2016 - 2017 utPLSQL Project
- -
-- -
-Licensed under the Apache License, Version 2.0 (the "License"):
- -
-you may not use this file except in compliance with the License.
- -
-You may obtain a copy of the License at
- + +
- + 951 +
+ +while l_status != 1 loop
- + 452 +
+ +if l_line is not null then
- + 451 +
+ +ut_utils.append_to_clob(self.serveroutput, l_line||chr(10));
- +
+ +end if;
- + 452 +
+ +dbms_output.get_line(line => l_line, status => l_status);
- +
+ +end loop;
- +
+ +end save_dbms_output;
- +
+ +begin
- + 505 +
+ +l_start_transaction_id := dbms_transaction.local_transaction_id(true);
- -
- -
-http://www.apache.org/licenses/LICENSE-2.0
- + +
- +
+ +--listener - before call to executable
- + 505 +
+ +ut_event_manager.trigger_event('before_'||self.executable_type, self);
- -
- -
-Unless required by applicable law or agreed to in writing, software
- -
-distributed under the License is distributed on an "AS IS" BASIS,
- -
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- -
-See the License for the specific language governing permissions and
- -
-limitations under the License.
- -
-*/
- + +
- + 505 +
+ +l_completed_without_errors := is_defined();
- + 505 +
+ +if l_completed_without_errors then
- + 499 +
+ +l_statement :=
- +
+ +'declare' || chr(10) ||
- +
+ +' l_error_stack varchar2(32767);' || chr(10) ||
- +
+ +' l_error_backtrace varchar2(32767);' || chr(10) ||
- +
+ +'begin' || chr(10) ||
- +
+ +' begin' || chr(10) ||
- +
+ +' ' || self.form_name( a_skip_current_user_schema => true ) || ';' || chr(10) ||
- +
+ +' exception' || chr(10) ||
- +
+ +' when others then ' || chr(10) ||
- +
+ +' l_error_stack := dbms_utility.format_error_stack;' || chr(10) ||
- +
+ +' l_error_backtrace := dbms_utility.format_error_backtrace;' || chr(10) ||
- +
+ +' --raise on ORA-04068, ORA-04061: existing state of packages has been discarded to avoid unrecoverable session exception' || chr(10) ||
- +
+ +' end;' || chr(10) ||
- +
+ +' :a_error_stack := l_error_stack;' || chr(10) ||
- +
+ +' :a_error_backtrace := l_error_backtrace;' || chr(10) ||
- +
+ +'end;';
- -
- -
-constructor function ut_data_value_number(self in out nocopy ut_data_value_number, a_value number) return self as result is
- -
-begin
- - 627 -
-self.data_value := a_value;
- - 627 -
-self.self_type := $$plsql_unit;
- - 627 -
-self.data_type := 'number';
- - 627 -
-return;
- -
-end;
- + +
- + 499 +
+ +ut_utils.debug_log('ut_executable.do_execute l_statement: ' || l_statement);
- -
- -
-overriding member function is_null return boolean is
- -
-begin
- - 44 -
-return (self.data_value is null);
- -
-end;
- + +
- + 499 +
+ +l_cursor_number := dbms_sql.open_cursor;
- -
- -
-overriding member function to_string return varchar2 is
- -
-begin
- - 618 -
-return ut_utils.to_string(self.data_value);
- -
-end;
- + +
- +
+ +/**
- +
+ +* The code will allow to execute once we check if packages are defined
- +
+ +* If it fail with 6550 (usually invalid package) it will check if because of invalid state or missing
- +
+ +* if for any other reason we will propagate it up as we didnt expected.
- +
+ +**/
- +
+ +begin
- + 499 +
+ +dbms_sql.parse(l_cursor_number, statement => l_statement, language_flag => dbms_sql.native);
- + 492 +
+ +dbms_sql.bind_variable(l_cursor_number, 'a_error_stack', to_char(null), 32767);
- + 492 +
+ +dbms_sql.bind_variable(l_cursor_number, 'a_error_backtrace', to_char(null), 32767);
- + 492 +
+ +l_status := dbms_sql.execute(l_cursor_number);
- + 487 +
+ +dbms_sql.variable_value(l_cursor_number, 'a_error_stack', self.error_stack);
- + 487 +
+ +dbms_sql.variable_value(l_cursor_number, 'a_error_backtrace', self.error_backtrace);
- + 487 +
+ +dbms_sql.close_cursor(l_cursor_number);
- +
+ +exception
- + 24 +
+ +when ut_utils.ex_invalid_package then
- + 12 +
+ +l_failed_with_invalid_pck := is_invalid();
- + 12 +
+ +dbms_sql.close_cursor(l_cursor_number);
- + 12 +
+ +if not l_failed_with_invalid_pck then
- +
+ +raise;
- +
+ +end if;
- +
+ +when others then
- +
+ +dbms_sql.close_cursor(l_cursor_number);
- +
+ +raise;
- +
+ +end;
- -
- -
-overriding member function compare_implementation(a_other ut_data_value) return integer is
- -
-l_result integer;
- -
-l_other ut_data_value_number;
- -
-begin
- - 310 -
-if a_other is of (ut_data_value_number) then
- - 310 -
-l_other := treat(a_other as ut_data_value_number);
- - 310 -
-if self.data_value = l_other.data_value then
- - 245 -
-l_result := 0;
- - 65 -
-elsif self.data_value > l_other.data_value then
- - 43 -
-l_result := 1;
- - 22 -
-elsif self.data_value < l_other.data_value then
- - 8 -
-l_result := -1;
- + +
- + 499 +
+ +save_dbms_output;
- +
+ +- + 499 +
+ +l_completed_without_errors := (self.error_stack||self.error_backtrace) is null;
- + 499 +
+ +if self.error_stack like '%ORA-04068%' or self.error_stack like '%ORA-04061%' then
- + 2 +
+ +ut_expectation_processor.set_invalidation_exception();
- -
end if;
- -
-else
- -
-raise value_error;
- + +
- -
end if;
- - 310 -
-return l_result;
- -
-end;
- + +
- -
- -
end;
+UT3.UT_DATA_VALUE_OBJECT
84.62 % covered
39 relevant lines. 33 lines covered and 6 lines missed+ +
- +
+ +--listener - after call to executable
- + 505 +
+ +ut_event_manager.trigger_event('after_'||self.executable_type, self);
- +
+ +- + 505 +
+ +l_end_transaction_id := dbms_transaction.local_transaction_id();
- + 505 +
+ +if l_start_transaction_id != l_end_transaction_id or l_end_transaction_id is null then
- + 3 +
+ +a_item.add_transaction_invalidator(self.form_name());
- +
+ +end if;
- +
+ +- + 505 +
+ +return l_completed_without_errors;
- +
+ +- +
+ +end do_execute;
- +
+ +- +
+ +member function get_error_stack_trace return varchar2 is
- +
+ +begin
- + 589 +
+ +return rtrim(self.error_stack||self.error_backtrace, chr(10));
- +
+ +end;
- +
+end;
UT3.UT_EXECUTABLE_TEST
96.15 % lines covered
26 relevant lines. 25 lines covered and 1 lines missed+
- -
+type body ut_data_value_object as
type body ut_executable_test as
+- +
/*
- -
+utPLSQL - Version X.X.X.X
utPLSQL - Version 3
+- -
+Copyright 2016 - 2017 utPLSQL Project
Copyright 2016 - 2019 utPLSQL Project
+- +
- +
Licensed under the Apache License, Version 2.0 (the "License"):
- +
you may not use this file except in compliance with the License.
- +
You may obtain a copy of the License at
- +
- +
http://www.apache.org/licenses/LICENSE-2.0
- +
- +
Unless required by applicable law or agreed to in writing, software
- +
distributed under the License is distributed on an "AS IS" BASIS,
- +
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
See the License for the specific language governing permissions and
- +
limitations under the License.
- +
*/
- +
- -
+constructor function ut_data_value_object(self in out nocopy ut_data_value_object, a_value anydata) return self as result is
constructor function ut_executable_test(
+- +
+ +self in out nocopy ut_executable_test, a_owner varchar2, a_package varchar2,
- +
+ +a_procedure_name varchar2, a_executable_type varchar2
- +
+ +) return self as result is
- -
begin
- - 20 -
-self.data_value := a_value;
- - 20 -
-self.self_type := $$plsql_unit;
- - 20 -
-self.data_type := case when a_value is not null then lower(a_value.gettypename) else 'undefined' end;
- - 20 + +
- + 2468 +
+ +self.self_type := $$plsql_unit;
- + 2468 +
+ +self.executable_type := a_executable_type;
- + 2468 +
+ +self.owner_name := a_owner;
- + 2468 +
+ +self.object_name := a_package;
- + 2468 +
+ +self.procedure_name := a_procedure_name;
- + 2468
-return;
- -
-end;
- -
-- -
-overriding member function is_null return boolean is
- -
-l_is_null boolean;
- -
+l_data_is_null pls_integer;
- -
+l_sql varchar2(32767);
end;
+- -
+l_cursor number;
+
- -
+l_status number;
member procedure do_execute(
+- -
-begin
- - 50 -
-if self.data_value is null then
- -
+l_is_null := true;
self in out nocopy ut_executable_test, a_item in out nocopy ut_suite_item,
+ +- +
+ +a_expected_error_codes in ut_integer_list
- +
+) is
- -
+--check if typename is a schema based object
l_completed_without_errors boolean;
+- -
-else
- -
---XMLTYPE doesn't like the null being passed to ANYDATA so we need to check if anydata holds null Object/collection
- - 50 -
+l_sql := '
begin
+ +- + 337 +
+ +l_completed_without_errors := self.do_execute(a_item, a_expected_error_codes);
- +
+end do_execute;
- -
+declare
+
- -
+l_data '||self.data_value.gettypename()||';
member function do_execute(
+- -
+l_value anydata := :a_value;
self in out nocopy ut_executable_test, a_item in out nocopy ut_suite_item,
+- -
+x integer;
a_expected_error_codes in ut_integer_list
+- -
+begin
) return boolean is
+- -
+x := l_value.getObject(l_data);
l_expected_except_message varchar2(4000);
+- -
+:l_data_is_null := case when l_data is null then 1 else 0 end;
+
- -
-end;';
- - 50 -
-l_cursor := sys.dbms_sql.open_cursor();
- - 50 -
-sys.dbms_sql.parse(l_cursor, l_sql, dbms_sql.native);
- - 50 -
-sys.dbms_sql.bind_variable(l_cursor,'a_value',self.data_value);
- - 50 -
+sys.dbms_sql.bind_variable(l_cursor,'l_data_is_null',l_data_is_null);
function failed_expec_errnum_message(a_expected_error_codes in ut_integer_list) return varchar is
+ +- +
+ +l_actual_error_no integer;
- +
+ +l_expected_error_codes varchar2(4000);
- +
+ +l_fail_message varchar2(4000);
- +
+begin
- -
-begin
- - 50 -
-l_status := sys.dbms_sql.execute(l_cursor);
- - 50 -
-sys.dbms_sql.variable_value(l_cursor,'l_data_is_null',l_data_is_null);
- - 50 -
-sys.dbms_sql.close_cursor(l_cursor);
- -
-exception when others then
- -
-if sys.dbms_sql.is_open(l_cursor) then
- -
-sys.dbms_sql.close_cursor(l_cursor);
- -
-end if;
- -
-raise;
- -
-end;
- - 50 -
+l_is_null := ut_utils.int_to_boolean(l_data_is_null);
--Convert the ut_varchar2_list to string to can construct the message
+ +- + 16 +
+ +l_expected_error_codes := ut_utils.table_to_clob(a_expected_error_codes, ', ');
- +
+ +- + 16 +
+ +if self.error_stack is null then
- + 1 +
+ +l_fail_message := 'Expected one of exceptions ('||l_expected_error_codes||') but nothing was raised.';
- +
+ +else
- + 15 +
+ +l_actual_error_no := regexp_substr(self.error_stack, '^[a-zA-Z]{3}(-[0-9]+)', subexpression=>1);
- + 15 +
+ +if not l_actual_error_no member of a_expected_error_codes then
- + 2 +
+ +l_fail_message := 'Actual: '||l_actual_error_no||' was expected to ';
- + 2 +
+ +if cardinality(a_expected_error_codes) > 1 then
- +
+l_fail_message := l_fail_message || 'be one of: ('||l_expected_error_codes||')';
- -
-end if;
- - 50 -
+return l_is_null;
else
+ +- + 2 +
+l_fail_message := l_fail_message || 'equal: '||l_expected_error_codes;
- -
-end;
- -
+end if;
+ +- + 2 +
+l_fail_message := substr( l_fail_message||chr(10)||self.error_stack||chr(10)||self.error_backtrace, 1, 4000 );
- -
+overriding member function to_string return varchar2 is
end if;
+- -
+l_result varchar2(32767);
end if;
+- -
-l_clob clob;
- +
+ +- + 16 +
+ +return l_fail_message;
- +
+ +end;
- -
begin
- - 11 -
-if self.is_null() then
- - 4 -
+l_result := ut_utils.to_string( to_char(null) );
- -
-else
- - 7 -
-ut_expectation_processor.set_xml_nls_params();
- - 7 -
-select xmlserialize(content xmltype(self.data_value) indent) into l_clob from dual;
- - 7 -
-l_result := ut_utils.to_string( l_clob, null );
- - 7 -
+ut_expectation_processor.reset_nls_params();
--Create a ut_executable object and call do_execute after that get the data to know the test's execution result
+ +- + 337 +
+ +self.do_execute(a_item);
- +
+ +- + 337 +
+ +if a_expected_error_codes is not null and a_expected_error_codes is not empty then
- + 16 +
+l_expected_except_message := failed_expec_errnum_message(a_expected_error_codes);
- -
-end if;
- - 11 -
-return self.format_multi_line( l_result );
- -
-end;
- + +
- + 16 +
+ +if l_expected_except_message is not null then
- + 3 +
+ +ut_expectation_processor.add_expectation_result(
- +
+ut_expectation_result(ut_utils.gc_failure, null, l_expected_except_message, false)
- -
+overriding member function compare_implementation(a_other ut_data_value) return integer is
);
+- -
-l_self_data xmltype;
- -
-l_other_data xmltype;
- -
-l_other ut_data_value_object;
- -
-l_result integer;
- -
-begin
- - 6 -
-if a_other is of (ut_data_value_object) then
- - 6 -
-l_other := treat(a_other as ut_data_value_object);
- -
---needed for 11g xe as it fails on constructing XMLTYPE from null ANYDATA
- - 6 -
-if not self.is_null() and not l_other.is_null() then
- - 6 -
-ut_expectation_processor.set_xml_nls_params();
- - 4 -
-l_self_data := xmltype.createxml(self.data_value);
- - 4 -
-l_other_data := xmltype.createxml(l_other.data_value);
- - 4 -
-ut_expectation_processor.reset_nls_params();
- - 4 -
-if l_self_data is not null and l_other_data is not null then
- - 4 -
-l_result := dbms_lob.compare( l_self_data.getclobval(), l_other_data.getclobval() );
- -
-end if;
- -
end if;
- -
-else
- -
-raise value_error;
- + +
- + 16 +
+ +self.error_stack := null;
- + 16 +
+ +self.error_backtrace := null;
- -
end if;
- - 6 -
-return l_result;
- -
-end;
- + +
- -
- -
-overriding member function is_multi_line return boolean is
- -
-begin
- - 22 -
-return not self.is_null();
- + +
- + 337 +
+ +return (self.error_stack||self.error_backtrace) is null;
- -
end;
- -
-- -
end;
+UT3.UT_DATA_VALUE_REFCURSOR
95 % covered
60 relevant lines. 57 lines covered and 3 lines missed+ +
- +
+end;
+UT3.UT_EXPECTATION_RESULT
93.33 % lines covered
15 relevant lines. 14 lines covered and 1 lines missed+
- -
+type body ut_data_value_refcursor as
type body ut_expectation_result is
+- +
/*
- -
+utPLSQL - Version X.X.X.X
utPLSQL - Version 3
+- -
+Copyright 2016 - 2017 utPLSQL Project
Copyright 2016 - 2019 utPLSQL Project
+- +
- +
Licensed under the Apache License, Version 2.0 (the "License"):
- +
you may not use this file except in compliance with the License.
- +
You may obtain a copy of the License at
- +
- +
http://www.apache.org/licenses/LICENSE-2.0
- +
- +
Unless required by applicable law or agreed to in writing, software
- +
distributed under the License is distributed on an "AS IS" BASIS,
- +
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
See the License for the specific language governing permissions and
- +
limitations under the License.
- +
*/
- +
- -
+constructor function ut_data_value_refcursor(self in out nocopy ut_data_value_refcursor, a_value sys_refcursor) return self as result is
constructor function ut_expectation_result(
+- -
-begin
- - 19 -
-init(a_value);
- - 18 -
+return;
self in out nocopy ut_expectation_result, a_status integer,
+ +- +
+ +a_description varchar2, a_message clob, a_include_caller_info boolean := true
- +
+) return self as result is
- -
-end;
- -
-- -
-constructor function ut_data_value_refcursor(self in out nocopy ut_data_value_refcursor, a_value sys_refcursor, a_exclude varchar2 ) return self as result is
- -
begin
- - 11 -
-if a_exclude is not null then
- - 2 -
-self.exclude_xpath := '//'||replace(a_exclude,',','|//');
- + +
- + 799 +
+ +self.self_type := $$plsql_unit;
- + 799 +
+ +self.status := a_status;
- + 799 +
+ +self.description := a_description;
- + 799 +
+ +self.message := a_message;
- + 800 +
+ +if self.status = ut_utils.gc_failure and a_include_caller_info then
- + 427 +
+ +self.caller_info := ut_expectation_processor.who_called_expectation(dbms_utility.format_call_stack());
- -
end if;
- - 11 -
-init(a_value);
- - 11 + +
- + 799
+return;
- +
end;
- +
- -
+constructor function ut_data_value_refcursor(self in out nocopy ut_data_value_refcursor, a_value sys_refcursor, a_exclude ut_varchar2_list ) return self as result is
member function get_result_clob(self in ut_expectation_result) return clob is
+- -
+i integer;
l_result clob;
+- -
begin
- - 2 -
+ +i := a_exclude.first;
- + 33 +
+if self.description is not null then
- 6 -
-while i is not null loop
- - 4 -
-if a_exclude(i) is not null then
- - 4 -
+self.exclude_xpath := self.exclude_xpath || '//'||a_exclude(i)||'|';
ut_utils.append_to_clob(l_result, '"'||self.description||'"');
+ +- + 6 +
+ +if self.message is not null then
- + 6 +
+ut_utils.append_to_clob(l_result, chr(10));
- -
end if;
- - 4 -
-i := a_exclude.next(i);
- -
-end loop;
- - 2 -
-self.exclude_xpath := rtrim(self.exclude_xpath,',|');
- - 2 -
-init(a_value);
- - 2 -
-return;
- + +
- +
+ +end if;
- + 33 +
+ +ut_utils.append_to_clob(l_result, self.message);
- + 33 +
+ +return l_result;
- -
end;
- + +
- -
- -
+ +member procedure init(self in out nocopy ut_data_value_refcursor, a_value sys_refcursor) is
- +
+ +member function get_result_lines(self in ut_expectation_result) return ut_varchar2_list is
- +
+ +begin
- + 33 +
+return ut_utils.clob_to_table(get_result_clob(), 4000 );
- -
+l_ctx number;
end;
+- -
-l_xml xmltype;
- - 32 -
+c_bulk_rows constant integer := 1000;
+ +
- +
+member function result return integer is
- -
-l_current_date_format varchar2(4000);
- -
-pragma autonomous_transaction;
- -
begin
- - 32 -
-self.is_cursor_null := ut_utils.boolean_to_int(a_value is null);
- - 32 -
-self.self_type := $$plsql_unit;
- - 32 -
-self.data_value := sys_guid();
- - 32 -
-self.data_type := 'refcursor';
- - 32 -
-if a_value is not null and a_value%isopen then
- - 27 -
-self.row_count := 0;
- -
--- We use DBMS_XMLGEN in order to:
- -
--- 1) be able to process data in bulks (set of rows)
- -
--- 2) be able to influence the ROWSET/ROW tags
- -
--- 3) be able to influence the way NULL values are handled (empty TAG)
- -
--- 4) be able to influence the way TIMESTAMP is formatted.
- -
--- Due to Oracle feature/bug, it is not possible to change the DATE formatting of cursor data
- -
--- AFTER the cursor was opened.
- -
--- The only solution for this is to change NLS settings before opening the cursor.
- -
---
- -
--- This would work fine if we could use DBMS_XMLGEN.restartQuery.
- -
--- The restartQuery fails however if PLSQL variables of TIMESTAMP/INTERVAL or CLOB/BLOB are used.
- -
-- - 42 -
-ut_expectation_processor.set_xml_nls_params();
- - 27 -
-l_ctx := dbms_xmlgen.newContext(a_value);
- - 27 -
-dbms_xmlgen.setNullHandling(l_ctx, dbms_xmlgen.empty_tag);
- - 27 -
-dbms_xmlgen.setMaxRows(l_ctx, c_bulk_rows);
- -
-- - 51 -
-loop
- - 51 -
-l_xml := dbms_xmlgen.getxmltype(l_ctx);
- -
-- - 50 -
-insert into ut_cursor_data(cursor_data_guid, row_no, row_data)
- -
-select self.data_value, rownum, value(a) from table( xmlsequence( extract(l_xml,'ROWSET/*') ) ) a;
- + +
- +
+ +return self.status;
- +
+ +end;
- -
- - 50 -
-exit when sql%rowcount = 0;
- + +
- +
+end;
UT3.UT_FILE_MAPPING
100 % lines covered
2 relevant lines. 2 lines covered and 0 lines missed+ +
- +
+ +type body ut_file_mapping as
- +
+ +/*
- +
+ +utPLSQL - Version 3
- +
+ +Copyright 2016 - 2019 utPLSQL Project
- -
- - 24 -
-self.row_count := self.row_count + sql%rowcount;
- -
-end loop;
- + +
- +
+ +Licensed under the Apache License, Version 2.0 (the "License"):
- +
+ +you may not use this file except in compliance with the License.
- +
+ +You may obtain a copy of the License at
- -
- - 26 -
-ut_expectation_processor.reset_nls_params();
- - 26 -
-if a_value%isopen then
- -
-close a_value;
- -
-end if;
- - 26 -
-dbms_xmlgen.closeContext(l_ctx);
- -
-end if;
- - 31 -
-commit;
- -
-exception
- - 1 -
-when others then
- - 1 -
-ut_expectation_processor.reset_nls_params();
- - 1 -
-if a_value%isopen then
- -
-close a_value;
- -
-end if;
- - 1 -
-dbms_xmlgen.closeContext(l_ctx);
- - 1 -
-rollback;
- - 1 -
-raise;
- -
-end;
- + +
- +
+ +http://www.apache.org/licenses/LICENSE-2.0
- -
- -
-overriding member function is_null return boolean is
- + +
- +
+ +Unless required by applicable law or agreed to in writing, software
- +
+ +distributed under the License is distributed on an "AS IS" BASIS,
- +
+ +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
+ +See the License for the specific language governing permissions and
- +
+ +limitations under the License.
- +
+ +*/
- + 48 +
+ +map member function pk return varchar2 is
- -
begin
- - 59 -
-return ut_utils.int_to_boolean(self.is_cursor_null);
- + +
- + 48 +
+ +return object_type||' '||object_owner||'.'||object_name;
- -
end;
- -
-- -
-overriding member function to_string return varchar2 is
- -
-type t_clob_tab is table of clob;
- -
-l_results t_clob_tab;
- - 27 -
-c_max_rows constant integer := 10;
- -
-l_result clob;
- -
-l_result_xml xmltype;
- -
-l_result_string varchar2(32767);
- -
-begin
- - 27 -
-dbms_lob.createtemporary(l_result,true);
- -
---return first 100 rows
- - 27 -
-select xmlserialize( content ucd.row_data no indent)
- -
-bulk collect into l_results
- -
-from ut_cursor_data ucd
- -
-where ucd.cursor_data_guid = self.data_value
- -
-and ucd.row_no <= c_max_rows;
- -
-- - 82 -
-for i in 1 .. l_results.count loop
- - 55 -
-dbms_lob.append(l_result,l_results(i));
- - 55 -
-if i < l_results.count then
- - 31 -
-ut_utils.append_to_clob(l_result,chr(10));
- -
-end if;
- -
-end loop;
- -
-- - 27 -
-l_result_string := ut_utils.to_string(l_result,null);
- - 27 -
-dbms_lob.freetemporary(l_result);
- - 27 -
-return self.format_multi_line( l_result_string );
- -
-end;
- -
-- -
-member function is_empty return boolean is
- -
-begin
- - 56 -
-return self.row_count = 0;
- -
-end;
- -
-- -
-overriding member function compare_implementation(a_other ut_data_value) return integer is
- -
-l_result integer;
- -
-l_other ut_data_value_refcursor;
- -
-begin
- - 11 -
-if a_other is of (ut_data_value_refcursor) then
- - 11 -
-l_other := treat(a_other as ut_data_value_refcursor);
- - 11 -
-select count(1)
- -
-into l_result
- -
-from (select case when coalesce(self.exclude_xpath, l_other.exclude_xpath) is not null then deletexml( ucd.row_data, coalesce(self.exclude_xpath, l_other.exclude_xpath) ) else ucd.row_data end as row_data,
- -
-ucd.row_no
- -
-from ut_cursor_data ucd where ucd.cursor_data_guid = self.data_value) exp
- -
-full outer join (select case when coalesce(self.exclude_xpath, l_other.exclude_xpath) is not null then deletexml( ucd.row_data, coalesce(self.exclude_xpath, l_other.exclude_xpath) ) else ucd.row_data end as row_data,
- -
-ucd.row_no
- -
-from ut_cursor_data ucd where ucd.cursor_data_guid = l_other.data_value) act
- -
-on (exp.row_no = act.row_no)
- -
-where nvl(dbms_lob.compare(xmlserialize( content exp.row_data no indent), xmlserialize( content act.row_data no indent)),1) != 0
- -
-and rownum <= 1;
- -
-else
- -
-raise value_error;
- -
-end if;
- - 11 -
-return l_result;
- -
-end;
- -
-- -
-overriding member function is_multi_line return boolean is
- -
-begin
- - 54 -
-return not self.is_null() and not self.is_empty();
- -
-end;
- -
-- -
end;
+UT3.UT_DATA_VALUE_TIMESTAMP
93.75 % covered
16 relevant lines. 15 lines covered and 1 lines missed+ +
- +
+end;
UT3.UT_LOGICAL_SUITE
100 % lines covered
42 relevant lines. 42 lines covered and 0 lines missed+
- -
+type body ut_data_value_timestamp as
type body ut_logical_suite as
+- +
/*
- -
+utPLSQL - Version X.X.X.X
utPLSQL - Version 3
+- -
+Copyright 2016 - 2017 utPLSQL Project
Copyright 2016 - 2019 utPLSQL Project
+- +
- +
Licensed under the Apache License, Version 2.0 (the "License"):
- +
you may not use this file except in compliance with the License.
- +
You may obtain a copy of the License at
- +
- +
http://www.apache.org/licenses/LICENSE-2.0
- +
- +
Unless required by applicable law or agreed to in writing, software
- +
distributed under the License is distributed on an "AS IS" BASIS,
- +
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
See the License for the specific language governing permissions and
- +
limitations under the License.
- +
*/
- +
- -
+constructor function ut_data_value_timestamp(self in out nocopy ut_data_value_timestamp, a_value timestamp_unconstrained) return self as result is
overriding member procedure mark_as_skipped(self in out nocopy ut_logical_suite) is
+- -
begin
- - 96 -
-self.data_value := a_value;
- - 96 -
-self.self_type := $$plsql_unit;
- - 96 -
-self.data_type := 'timestamp';
- - 96 -
+ +return;
- + 2 +
+ +ut_event_manager.trigger_event(ut_event_manager.gc_before_suite, self);
- + 1 +
+ +self.start_time := current_timestamp;
- + 3 +
+ +for i in 1 .. self.items.count loop
- + 2 +
+self.items(i).mark_as_skipped();
- +
+ +end loop;
- + 1 +
+ +self.end_time := self.start_time;
- + 1 +
+ +ut_event_manager.trigger_event(ut_event_manager.gc_after_suite, self);
- + 1 +
+ +self.calc_execution_result();
- -
end;
- -
-- -
-overriding member function is_null return boolean is
- -
-begin
- - 22 -
+return (self.data_value is null);
- -
-end;
- + +
- +
+overriding member procedure set_rollback_type(self in out nocopy ut_logical_suite, a_rollback_type integer, a_force boolean := false) is
- -
-overriding member function to_string return varchar2 is
- -
begin
- - 90 -
-return ut_utils.to_string(self.data_value);
- -
+ +end;
- + 1419 +
+ +self.rollback_type := case when a_force then a_rollback_type else coalesce(self.rollback_type, a_rollback_type) end;
- + 3289 +
+ +for i in 1 .. self.items.count loop
- + 1870 +
+self.items(i).set_rollback_type(self.rollback_type, a_force);
- -
+end loop;
+- -
+overriding member function compare_implementation(a_other ut_data_value) return integer is
end;
+- -
+l_result integer;
+
- -
+l_other ut_data_value_timestamp;
overriding member function do_execute(self in out nocopy ut_logical_suite) return boolean is
+- +
+ +l_suite_savepoint varchar2(30);
- +
+ +l_item_savepoint varchar2(30);
- +
+ +l_completed_without_errors boolean;
- -
begin
- - 47 -
-if a_other is of (ut_data_value_timestamp) then
- - 47 -
-l_other := treat(a_other as ut_data_value_timestamp);
- - 47 -
-if self.data_value = l_other.data_value then
- - 7 -
-l_result := 0;
- - 40 -
-elsif self.data_value > l_other.data_value then
- - 18 -
-l_result := 1;
- - 22 -
-elsif self.data_value < l_other.data_value then
- - 8 -
-l_result := -1;
- -
+ +end if;
- + 141 +
+ +ut_utils.debug_log('ut_logical_suite.execute');
- +
+ +- + 141 +
+ +ut_event_manager.trigger_event(ut_event_manager.gc_before_suite, self);
- + 141 +
+ +self.start_time := current_timestamp;
- +
+ +- + 285 +
+for i in 1 .. self.items.count loop
- -
-else
- -
+raise value_error;
-- execute the item (test or suite)
+ +- + 144 +
+self.items(i).do_execute();
- -
-end if;
- - 47 -
-return l_result;
- -
-end;
- +
+ +end loop;
- + +
- + 141 +
+ +self.calc_execution_result();
- + 141 +
+self.end_time := current_timestamp;
- -
end;
+UT3.UT_DATA_VALUE_TIMESTAMP_LTZ
93.75 % covered
16 relevant lines. 15 lines covered and 1 lines missed-
- -
-type body ut_data_value_timestamp_ltz as
- -
+/*
+ +
- + 141 +
+ +ut_event_manager.trigger_event(ut_event_manager.gc_after_suite, self);
- +
+ +- + 141 +
+ +return l_completed_without_errors;
- +
+ +end;
- +
+ +- +
+ +overriding member procedure calc_execution_result(self in out nocopy ut_logical_suite) is
- +
+ +l_result integer(1);
- +
+ +begin
- + 347 +
+ +if self.items is not null and self.items.count > 0 then
- + 876 +
+ +for i in 1 .. self.items.count loop
- + 531 +
+ +self.results_count.sum_counter_values( self.items(i).results_count );
- +
+ +end loop;
- + 345 +
+ +l_result := self.results_count.result_status();
- +
+ +else
- +
+ +--if suite is empty then it's successful (no errors)
- + 2 +
+ +l_result := ut_utils.gc_success;
- +
+ +end if;
- +
+ +- + 347 +
+ +self.result := l_result;
- +
+ +end;
- +
+ +- +
+ +overriding member procedure mark_as_errored(self in out nocopy ut_logical_suite, a_error_stack_trace varchar2) is
- +
+ +begin
- + 2 +
+ +ut_utils.debug_log('ut_logical_suite.fail');
- + 2 +
+ +ut_event_manager.trigger_event(ut_event_manager.gc_before_suite, self);
- + 2 +
+ +self.start_time := current_timestamp;
- + 4 +
+ +for i in 1 .. self.items.count loop
- +
+ +-- execute the item (test or suite)
- + 2 +
+ +self.items(i).mark_as_errored(a_error_stack_trace);
- +
+ +end loop;
- + 2 +
+ +self.calc_execution_result();
- + 2 +
+ +self.end_time := self.start_time;
- + 2 +
+ +ut_event_manager.trigger_event(ut_event_manager.gc_after_suite, self);
- +
+ +end;
- +
+ +- +
+ +overriding member function get_error_stack_traces return ut_varchar2_list is
- +
+ +begin
- + 1 +
+ +return ut_varchar2_list();
- +
+ +end;
- +
+ +- +
+ +overriding member function get_serveroutputs return clob is
- +
+ +begin
- + 1 +
+ +return null;
- +
+ +end;
- +
+ +- +
+ +overriding member function get_transaction_invalidators return ut_varchar2_list is
- +
+ +l_result ut_varchar2_list;
- +
+ +l_child_results ut_varchar2_list;
- +
+ +begin
- + 3 +
+ +l_result := self.transaction_invalidators;
- + 5 +
+ +for i in 1 .. self.items.count loop
- + 2 +
+ +l_child_results := self.items(i).get_transaction_invalidators();
- + 4 +
+ +for j in 1 .. l_child_results.count loop
- + 2 +
+ +if l_child_results(j) not member of l_result then
- + 4 +
+ +l_result.extend; l_result(l_result.last) := l_child_results(j);
- +
+ +end if;
- +
+ +end loop;
- +
+ +end loop;
- + 3 +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+end;
UT3.UT_OBJECT_NAME
90 % lines covered
10 relevant lines. 9 lines covered and 1 lines missed+ +
- +
+ +type body ut_object_name as
- +
+/*
- -
+utPLSQL - Version X.X.X.X
utPLSQL - Version 3
+- -
+Copyright 2016 - 2017 utPLSQL Project
Copyright 2016 - 2019 utPLSQL Project
+- +
- +
Licensed under the Apache License, Version 2.0 (the "License"):
- +
you may not use this file except in compliance with the License.
- +
You may obtain a copy of the License at
- +
- +
http://www.apache.org/licenses/LICENSE-2.0
- +
- +
Unless required by applicable law or agreed to in writing, software
- +
distributed under the License is distributed on an "AS IS" BASIS,
- +
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
See the License for the specific language governing permissions and
- +
limitations under the License.
- +
*/
- -
+constructor function ut_object_name(self in out nocopy ut_object_name, owner varchar2, name varchar2) return self as result is
+- -
-constructor function ut_data_value_timestamp_ltz(self in out nocopy ut_data_value_timestamp_ltz, a_value timestamp_ltz_unconstrained) return self as result is
- -
begin
- - 96 -
-self.data_value := a_value;
- - 96 -
-self.self_type := $$plsql_unit;
- - 96 -
-self.data_type := 'timestamp with local time zone';
- - 96 + +
- + 2545 +
+ +self.owner := upper(owner);
- + 2545 +
+ +self.name := upper(name);
- + 2545
-return;
- + +
- -
end;
- + +
- -
- -
-overriding member function is_null return boolean is
- + +
- +
+ +constructor function ut_object_name(self in out nocopy ut_object_name, a_unit_name varchar2) return self as result is
- -
begin
- - 22 -
+ +return (self.data_value is null);
- + 3 +
+ +if instr(a_unit_name,'.') > 0 then
- + 3 +
+ +self.owner := upper(regexp_substr(a_unit_name,'[^\.]+', 1, 1));
- + 3 +
+self.name := upper(regexp_substr(a_unit_name,'[^\.]+', 1, 2));
- -
-end;
- -
+else
+ +- +
+self.name := upper(a_unit_name);
- -
-overriding member function to_string return varchar2 is
- -
-begin
- - 90 -
-return ut_utils.to_string(self.data_value);
- +
+ +end if;
- + 3 +
+ +return;
- + +
end;
- +
+- -
- -
+ +overriding member function compare_implementation(a_other ut_data_value) return integer is
- + 1 +
+map member function identity return varchar2 is
- -
-l_result integer;
- -
-l_other ut_data_value_timestamp_ltz;
- -
begin
- - 47 -
-if a_other is of (ut_data_value_timestamp_ltz) then
- - 47 -
-l_other := treat(a_other as ut_data_value_timestamp_ltz);
- - 47 -
-if self.data_value = l_other.data_value then
- - 7 -
-l_result := 0;
- - 40 -
-elsif self.data_value > l_other.data_value then
- - 18 -
-l_result := 1;
- - 22 -
-elsif self.data_value < l_other.data_value then
- - 8 -
-l_result := -1;
- -
-end if;
- -
-else
- -
-raise value_error;
- -
-end if;
- - 47 -
-return l_result;
- + +
- + 1 +
+ +return owner||'.'||name;
- -
end;
- -
-- -
end;
+UT3.UT_DATA_VALUE_TIMESTAMP_TZ
93.75 % covered
16 relevant lines. 15 lines covered and 1 lines missed+ +
- +
+end;
UT3.UT_OUTPUT_REPORTER_BASE
75 % lines covered
20 relevant lines. 15 lines covered (including 1 lines partially covered ) and 5 lines missed+
- -
+type body ut_data_value_timestamp_tz as
type body ut_output_reporter_base is
+- +
/*
- -
+utPLSQL - Version X.X.X.X
utPLSQL - Version 3
+- -
+Copyright 2016 - 2017 utPLSQL Project
Copyright 2016 - 2019 utPLSQL Project
+- +
- +
Licensed under the Apache License, Version 2.0 (the "License"):
- +
you may not use this file except in compliance with the License.
- +
You may obtain a copy of the License at
- +
- +
http://www.apache.org/licenses/LICENSE-2.0
- +
- +
Unless required by applicable law or agreed to in writing, software
- +
distributed under the License is distributed on an "AS IS" BASIS,
- +
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
See the License for the specific language governing permissions and
- +
limitations under the License.
- +
*/
- +
- -
+constructor function ut_data_value_timestamp_tz(self in out nocopy ut_data_value_timestamp_tz, a_value timestamp_tz_unconstrained) return self as result is
constructor function ut_output_reporter_base(self in out nocopy ut_output_reporter_base) return self as result is
+- -
begin
- - 92 -
-self.data_value := a_value;
- - 92 -
-self.self_type := $$plsql_unit;
- - 92 -
-self.data_type := 'timestamp with time zone';
- - 92 + +
- -
return;
- + +
- -
end;
- + +
- -
- -
-overriding member function is_null return boolean is
- + +
- +
+ +member procedure init(self in out nocopy ut_output_reporter_base, a_self_type varchar2, a_output_buffer ut_output_buffer_base := null) is
- -
begin
- - 22 -
-return (self.data_value is null);
- + +
- + 117 +
+ +(self as ut_reporter_base).init(a_self_type);
- + 117 +
+ +self.output_buffer := coalesce(a_output_buffer, ut_output_table_buffer());
- + 117 +
+ +self.set_reporter_id(self.output_buffer.output_id);
- -
end;
- + +
- + +
- +
+overriding member procedure set_reporter_id(self in out nocopy ut_output_reporter_base, a_reporter_id raw) is
- -
-overriding member function to_string return varchar2 is
- -
begin
- - 90 -
+ +return ut_utils.to_string(self.data_value);
- + 117 +
+ +self.id := a_reporter_id;
- + 117 +
+self.output_buffer.init(a_reporter_id);
- +
end;
- +
- -
-overriding member function compare_implementation(a_other ut_data_value) return integer is
- -
+l_result integer;
member function set_reporter_id(self in ut_output_reporter_base, a_reporter_id raw) return ut_output_reporter_base is
+ +- +
+l_result ut_output_reporter_base := self;
- -
-l_other ut_data_value_timestamp_tz;
- -
begin
- - 47 -
-if a_other is of (ut_data_value_timestamp_tz) then
- - 47 -
-l_other := treat(a_other as ut_data_value_timestamp_tz);
- - 47 -
-if self.data_value = l_other.data_value then
- - 7 -
-l_result := 0;
- - 40 -
-elsif self.data_value > l_other.data_value then
- - 18 -
-l_result := 1;
- - 22 -
-elsif self.data_value < l_other.data_value then
- - 8 -
+ +l_result := -1;
- +
+ +l_result.set_reporter_id(a_reporter_id);
- +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+ +overriding member procedure before_calling_run(self in out nocopy ut_output_reporter_base, a_run in ut_run) is
- +
+ +l_output_table_buffer ut_output_table_buffer;
- +
+ +begin
- + 113 +
+ +(self as ut_reporter_base).before_calling_run(a_run);
- + 113 +
+l_output_table_buffer := treat(self.output_buffer as ut_output_table_buffer);
- -
+end if;
end;
+- -
-else
- -
+raise value_error;
+ +
- +
+member procedure print_text(self in out nocopy ut_output_reporter_base, a_text varchar2, a_item_type varchar2 := null) is
- -
-end if;
- - 47 -
+return l_result;
begin
+ +- + 1691 +
+self.output_buffer.send_line(a_text, a_item_type);
- +
end;
- +
- -
end;
UT3.UT_DATA_VALUE_VARCHAR2
94.12 % covered
17 relevant lines. 16 lines covered and 1 lines missed-
- -
-type body ut_data_value_varchar2 as
- -
-/*
- -
-utPLSQL - Version X.X.X.X
- -
-Copyright 2016 - 2017 utPLSQL Project
- -
-- -
-Licensed under the Apache License, Version 2.0 (the "License"):
- -
-you may not use this file except in compliance with the License.
- -
-You may obtain a copy of the License at
- -
-- -
-http://www.apache.org/licenses/LICENSE-2.0
- -
-- -
-Unless required by applicable law or agreed to in writing, software
- -
-distributed under the License is distributed on an "AS IS" BASIS,
- -
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- -
-See the License for the specific language governing permissions and
- -
-limitations under the License.
- -
-*/
- -
-- -
-constructor function ut_data_value_varchar2(self in out nocopy ut_data_value_varchar2, a_value varchar2) return self as result is
- +
+ +member procedure print_text_lines(self in out nocopy ut_output_reporter_base, a_text_lines ut_varchar2_rows, a_item_type varchar2 := null) is
- -
begin
- - 392 -
-self.data_value := a_value;
- - 392 -
-self.self_type := $$plsql_unit;
- - 392 -
-self.data_type := 'varchar2';
- - 392 -
-return;
- + +
- + 333 +
+ +self.output_buffer.send_lines(a_text_lines, a_item_type);
- -
end;
- + +
- -
- -
-overriding member function is_null return boolean is
- + +
- +
+ +member procedure print_clob(self in out nocopy ut_output_reporter_base, a_clob clob, a_item_type varchar2 := null) is
- -
begin
- - 807 -
-return (self.data_value is null);
- + +
- + 30 +
+ +self.output_buffer.send_clob( a_clob, a_item_type );
- -
end;
- -
-- -
-overriding member function to_string return varchar2 is
- + +
- +
+ +- +
+ +final member function get_lines(a_initial_timeout natural := null, a_timeout_sec natural) return ut_output_data_rows pipelined is
- -
begin
- - 384 -
-return self.format_multi_line( ut_utils.to_string(self.data_value) );
- + +
- + 1/2 + 32 +
+ +for i in (select value(x) val from table(self.output_buffer.get_lines(a_initial_timeout, a_timeout_sec)) x ) loop
- +
+ +pipe row (i.val);
- +
+ +end loop;
- -
end;
- + +
- -
- -
-overriding member function compare_implementation(a_other ut_data_value) return integer is
- -
-l_result integer;
- -
-l_other ut_data_value_varchar2;
- + +
- +
+ +final member function get_lines_cursor(a_initial_timeout natural := null, a_timeout_sec natural) return sys_refcursor is
- -
begin
- - 159 -
-if a_other is of (ut_data_value_varchar2) then
- - 159 -
-l_other := treat(a_other as ut_data_value_varchar2);
- - 159 -
-if self.data_value = l_other.data_value then
- - 134 -
-l_result := 0;
- - 25 -
-elsif self.data_value > l_other.data_value then
- - 8 -
-l_result := 1;
- - 17 -
-elsif self.data_value < l_other.data_value then
- - 3 -
-l_result := -1;
- -
-end if;
- -
-else
- -
-raise value_error;
- -
-end if;
- - 159 -
-return l_result;
- + +
- + 81 +
+ +return self.output_buffer.get_lines_cursor(a_initial_timeout, a_timeout_sec);
- -
end;
- + +
- -
- -
-overriding member function is_multi_line return boolean is
- + +
- +
+ +final member procedure lines_to_dbms_output(self in ut_output_reporter_base, a_initial_timeout natural := null, a_timeout_sec natural) is
- -
begin
- - 768 -
-return not self.is_null() and (length(self.data_value) > 100 or instr(self.data_value,chr(10)) > 0);
- + +
- + 32 +
+ +self.output_buffer.lines_to_dbms_output(a_initial_timeout, a_timeout_sec);
- -
end;
- + +
- -
- -
end;
+UT3.UT_DATA_VALUE_YMINTERVAL
100 % covered
15 relevant lines. 15 lines covered and 0 lines missed+ +
- +
+ +overriding final member procedure on_finalize(self in out nocopy ut_output_reporter_base, a_run in ut_run) is
- +
+ +begin
- + 116 +
+ +self.output_buffer.close();
- +
+ +end;
- +
+ +- +
+ +overriding member procedure on_initialize(self in out nocopy ut_output_reporter_base, a_run in ut_run) is
- +
+ +begin
- + 116 +
+ +self.output_buffer.send_line(null, 'initialize');
- +
+ +end;
- +
+ +- +
+end;
UT3.UT_REPORTER_BASE
94.52 % lines covered
73 relevant lines. 69 lines covered and 4 lines missed+
- -
+type body ut_data_value_yminterval as
type body ut_reporter_base is
+- +
/*
- -
+utPLSQL - Version X.X.X.X
utPLSQL - Version 3
+- -
+Copyright 2016 - 2017 utPLSQL Project
Copyright 2016 - 2019 utPLSQL Project
+- +
- +
Licensed under the Apache License, Version 2.0 (the "License"):
- +
you may not use this file except in compliance with the License.
- +
You may obtain a copy of the License at
- +
- +
http://www.apache.org/licenses/LICENSE-2.0
- +
- +
Unless required by applicable law or agreed to in writing, software
- +
distributed under the License is distributed on an "AS IS" BASIS,
- +
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
See the License for the specific language governing permissions and
- +
limitations under the License.
- +
*/
- +
- -
+constructor function ut_data_value_yminterval(self in out nocopy ut_data_value_yminterval, a_value yminterval_unconstrained) return self as result is
final member procedure init(self in out nocopy ut_reporter_base, a_self_type varchar2) is
+- -
begin
- - 82 -
-self.data_value := a_value;
- - 82 -
-self.self_type := $$plsql_unit;
- - 82 -
-self.data_type := 'interval year to month';
- - 82 + +
- + 117 +
+ +self.self_type := a_self_type;
- + 117 +
+ +self.id := sys_guid();
- + 117
-return;
- + +
- -
end;
- + +
- + +
- +
+member procedure set_reporter_id(self in out nocopy ut_reporter_base, a_reporter_id raw) is
- -
-overriding member function is_null return boolean is
- -
begin
- - 16 -
-return (self.data_value is null);
- + +
- +
+ +self.id := a_reporter_id;
- -
end;
- + +
- + +
- +
+member function get_reporter_id return raw is
- -
-overriding member function to_string return varchar2 is
- -
begin
- - 78 -
-return ut_utils.to_string(self.data_value);
- + +
- +
+ +return self.id;
- -
end;
- + +
- + +
- +
+member function get_description return varchar2 is
- -
-overriding member function compare_implementation(a_other ut_data_value) return integer is
- -
+l_result integer;
begin
+ +- +
+return 'No description available';
- -
+l_other ut_data_value_yminterval;
end;
+- +
+ +- +
+ +-- run hooks
- +
+ +member procedure before_calling_run(self in out nocopy ut_reporter_base, a_run in ut_run) is
- -
begin
- - 43 -
-if a_other is of (ut_data_value_yminterval) then
- - 43 -
-l_other := treat(a_other as ut_data_value_yminterval);
- - 43 -
-if self.data_value = l_other.data_value then
- - 6 -
-l_result := 0;
- - 37 -
-elsif self.data_value > l_other.data_value then
- - 15 -
-l_result := 1;
- - 22 -
-elsif self.data_value < l_other.data_value then
- - 8 -
+ +l_result := -1;
- + 113 +
+ +null;
- +
+ +end;
- +
+ +- +
+ +-- suite hooks
- +
+member procedure before_calling_suite(self in out nocopy ut_reporter_base, a_suite in ut_logical_suite) is
- -
-end if;
- -
-end if;
- - 43 -
-return l_result;
- +
+ +begin
- + 107 +
+ +null;
- -
end;
- -
end;
UT3.UT_BE_BETWEEN
96.43 % covered
28 relevant lines. 27 lines covered and 1 lines missed-
- -
-type body ut_be_between is
- -
-/*
- -
-utPLSQL - Version X.X.X.X
- -
-Copyright 2016 - 2017 utPLSQL Project
- + +
- -
- -
-Licensed under the Apache License, Version 2.0 (the "License"):
- -
-you may not use this file except in compliance with the License.
- -
-You may obtain a copy of the License at
- -
-- -
-http://www.apache.org/licenses/LICENSE-2.0
- -
-- -
-Unless required by applicable law or agreed to in writing, software
- -
-distributed under the License is distributed on an "AS IS" BASIS,
- -
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- -
-See the License for the specific language governing permissions and
- -
-limitations under the License.
- -
-*/
- -
-- -
-member procedure init(self in out nocopy ut_be_between, a_lower_bound ut_data_value, a_upper_bound ut_data_value) is
- -
-begin
- - 70 -
-self.self_type := $$plsql_unit;
- - 70 -
-self.lower_bound := a_lower_bound;
- - 70 -
-self.upper_bound := a_upper_bound;
- -
-end;
- -
-- -
-constructor function ut_be_between(self in out nocopy ut_be_between, a_lower_bound date, a_upper_bound date)
- -
-return self as result is
- -
-begin
- - 8 -
-init(ut_data_value_date(a_lower_bound), ut_data_value_date(a_upper_bound));
- - 8 -
-return;
- -
-end;
- -
-constructor function ut_be_between(self in out nocopy ut_be_between, a_lower_bound number, a_upper_bound number)
- -
-return self as result is
- -
-begin
- - 8 -
-init(ut_data_value_number(a_lower_bound), ut_data_value_number(a_upper_bound));
- - 8 -
-return;
- -
-end;
- -
-constructor function ut_be_between(self in out nocopy ut_be_between, a_lower_bound varchar2, a_upper_bound varchar2)
- -
-return self as result is
- -
-begin
- - 8 -
-init(ut_data_value_varchar2(a_lower_bound), ut_data_value_varchar2(a_upper_bound));
- - 8 -
-return;
- -
-end;
- -
-constructor function ut_be_between(self in out nocopy ut_be_between, a_lower_bound timestamp_unconstrained, a_upper_bound timestamp_unconstrained)
- -
-return self as result is
- -
-begin
- - 10 -
-init(ut_data_value_timestamp(a_lower_bound), ut_data_value_timestamp(a_upper_bound));
- - 10 -
-return;
- -
-end;
- -
-constructor function ut_be_between(self in out nocopy ut_be_between, a_lower_bound timestamp_tz_unconstrained, a_upper_bound timestamp_tz_unconstrained)
- -
-return self as result is
- + +
- +
+ +member procedure before_calling_before_all(self in out nocopy ut_reporter_base, a_executable in ut_executable) is
- -
begin
- - 10 -
-init(ut_data_value_timestamp_tz(a_lower_bound), ut_data_value_timestamp_tz(a_upper_bound));
- - 10 -
-return;
- -
+ +end;
- + 14 +
+null;
- -
+constructor function ut_be_between(self in out nocopy ut_be_between, a_lower_bound timestamp_ltz_unconstrained, a_upper_bound timestamp_ltz_unconstrained)
end;
+- -
+return self as result is
member procedure after_calling_before_all (self in out nocopy ut_reporter_base, a_executable in ut_executable) is
+- -
begin
- - 10 -
-init(ut_data_value_timestamp_ltz(a_lower_bound), ut_data_value_timestamp_ltz(a_upper_bound));
- - 10 -
-return;
- + +
- + 7 +
+ +null;
- -
end;
- + +
- + +
- +
+member procedure before_calling_before_each(self in out nocopy ut_reporter_base, a_executable in ut_executable) is
- -
-constructor function ut_be_between(self in out nocopy ut_be_between, a_lower_bound yminterval_unconstrained, a_upper_bound yminterval_unconstrained)
- -
-return self as result is
- -
begin
- - 8 -
-init(ut_data_value_yminterval(a_lower_bound), ut_data_value_yminterval(a_upper_bound));
- - 8 -
-return;
- + +
- + 24 +
+ +null;
- + +
end;
- +
+ +member procedure after_calling_before_each (self in out nocopy ut_reporter_base, a_executable in ut_executable) is
- +
+ +begin
- + 24 +
+null;
- -
+end;
+- -
+constructor function ut_be_between(self in out nocopy ut_be_between, a_lower_bound dsinterval_unconstrained, a_upper_bound dsinterval_unconstrained)
+
- -
+return self as result is
-- test hooks
+- +
+ +member procedure before_calling_test(self in out nocopy ut_reporter_base, a_test in ut_test) is
- -
begin
- - 8 -
-init(ut_data_value_dsinterval(a_lower_bound), ut_data_value_dsinterval(a_upper_bound));
- - 8 -
+ +return;
- + 301 +
+null;
- +
end;
- +
- -
+overriding member function run_matcher(self in out nocopy ut_be_between, a_actual ut_data_value) return boolean is
member procedure before_calling_before_test(self in out nocopy ut_reporter_base, a_executable in ut_executable) is
+- -
-l_lower_result boolean;
- -
+l_upper_result boolean;
begin
+ +- + 23 +
+null;
- -
+l_result boolean;
end;
+- +
+ +member procedure after_calling_before_test (self in out nocopy ut_reporter_base, a_executable in ut_executable) is
- -
begin
- - 70 -
-if self.lower_bound.data_type = a_actual.data_type then
- - 70 -
-l_lower_result := a_actual >= self.lower_bound;
- - 70 -
-l_upper_result := a_actual <= self.upper_bound;
- - 70 -
-if l_lower_result is not null and l_upper_result is not null then
- - 38 -
-l_result := l_lower_result and l_upper_result;
- -
-end if;
- -
-else
- -
-l_result := (self as ut_matcher).run_matcher(a_actual);
- -
-end if;
- - 70 -
-return l_result;
- + +
- + 23 +
+ +null;
- -
end;
- + +
- -
- -
-overriding member function failure_message(a_actual ut_data_value) return varchar2 is
- + +
- +
+ +member procedure before_calling_test_execute(self in out nocopy ut_reporter_base, a_executable in ut_executable) is
- -
begin
- - 38 -
-return (self as ut_matcher).failure_message(a_actual)
- -
-|| ': '|| self.lower_bound.to_string_report(true,false)
- -
-|| ' and ' || self.upper_bound.to_string_report(a_with_type_name => false);
- + +
- + 291 +
+ +null;
- -
end;
- -
-- -
-overriding member function failure_message_when_negated(a_actual ut_data_value) return varchar2 is
- + +
- +
+ +member procedure after_calling_test_execute (self in out nocopy ut_reporter_base, a_executable in ut_executable) is
- -
begin
- - 32 -
-return (self as ut_matcher).failure_message_when_negated(a_actual)
- -
-|| ': '|| self.lower_bound.to_string_report(true,false)
- -
-|| ' and ' || self.upper_bound.to_string_report(a_with_type_name => false);
- + +
- + 291 +
+ +null;
- -
end;
- -
-- -
end;
UT3.UT_BE_EMPTY
100 % covered
9 relevant lines. 9 lines covered and 0 lines missed-
- -
-type body ut_be_empty as
- -
-/*
- -
-utPLSQL - Version X.X.X.X
- -
-Copyright 2016 - 2017 utPLSQL Project
- -
-- -
-Licensed under the Apache License, Version 2.0 (the "License"):
- -
-you may not use this file except in compliance with the License.
- -
-You may obtain a copy of the License at
- -
-- -
-http://www.apache.org/licenses/LICENSE-2.0
- -
-- -
-Unless required by applicable law or agreed to in writing, software
- -
-distributed under the License is distributed on an "AS IS" BASIS,
- -
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- -
-See the License for the specific language governing permissions and
- -
-limitations under the License.
- -
-*/
- + +
- -
- -
-member procedure init(self in out nocopy ut_be_empty) is
- + +
- +
+ +member procedure before_calling_after_test(self in out nocopy ut_reporter_base, a_executable in ut_executable) is
- -
begin
- + +
- 10 -
-self.self_type := $$plsql_unit;
- +
+ +null;
- -
end;
- -
-- -
-constructor function ut_be_empty(self in out nocopy ut_be_empty) return self as result is
- + +
- +
+ +member procedure after_calling_after_test (self in out nocopy ut_reporter_base, a_executable in ut_executable) is
- -
begin
- - 10 -
-init();
- + +
- 10 -
-return;
- +
+ +null;
- -
end;
- + +
- -
- -
-overriding member function run_matcher(self in out nocopy ut_be_empty, a_actual ut_data_value) return boolean is
- -
-l_result boolean;
- + +
- +
+ +member procedure after_calling_test(self in out nocopy ut_reporter_base, a_test in ut_test) is
- -
begin
- - 10 -
-if a_actual is of(ut_data_value_refcursor) then
- - 4 -
-l_result := treat(a_actual as ut_data_value_refcursor).is_empty;
- - 6 -
-elsif a_actual is of(ut_data_value_collection) then
- - 4 -
-l_result := treat(a_actual as ut_data_value_collection).is_empty;
- -
-else
- - 2 -
-l_result := (self as ut_matcher).run_matcher(a_actual);
- -
-end if;
- - 10 -
-return l_result;
- + +
- + 85 +
+ +null;
- -
end;
- -
-- -
end;
UT3.UT_BE_FALSE
100 % covered
6 relevant lines. 6 lines covered and 0 lines missed-
- -
-type body ut_be_false as
- -
-/*
- -
-utPLSQL - Version X.X.X.X
- -
-Copyright 2016 - 2017 utPLSQL Project
- -
-- -
-Licensed under the Apache License, Version 2.0 (the "License"):
- -
-you may not use this file except in compliance with the License.
- -
-You may obtain a copy of the License at
- -
-- -
-http://www.apache.org/licenses/LICENSE-2.0
- -
-- -
-Unless required by applicable law or agreed to in writing, software
- -
-distributed under the License is distributed on an "AS IS" BASIS,
- -
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- -
-See the License for the specific language governing permissions and
- -
-limitations under the License.
- -
-*/
- + +
- -
- -
-constructor function ut_be_false(self in out nocopy ut_be_false) return self as result is
- + +
- +
+ +--suite hooks continued
- +
+ +member procedure before_calling_after_each(self in out nocopy ut_reporter_base, a_executable in ut_executable) is
- -
begin
- - 8 -
-self.self_type := $$plsql_unit;
- - 8 -
-return;
- + +
- + 31 +
+ +null;
- -
end;
- + +
- +
+ +member procedure after_calling_after_each (self in out nocopy ut_reporter_base, a_executable in ut_executable) is
- +
+ +begin
- + 31 +
+ +null;
- +
+ +end;
- -
- -
-overriding member function run_matcher(self in out nocopy ut_be_false, a_actual ut_data_value) return boolean is
- -
-l_result boolean;
- + +
- +
+ +member procedure before_calling_after_all(self in out nocopy ut_reporter_base, a_executable in ut_executable) is
- -
begin
- - 8 -
-if a_actual is of (ut_data_value_boolean) then
- + +
- + 12 +
+ +null;
- +
+ +end;
- +
+ +member procedure after_calling_after_all (self in out nocopy ut_reporter_base, a_executable in ut_executable) is
- +
+ +begin
- 7 -
-l_result := not ut_utils.int_to_boolean(treat(a_actual as ut_data_value_boolean).data_value);
- -
-else
- - 1 -
-l_result := (self as ut_matcher).run_matcher(a_actual);
- -
-end if;
- - 8 -
-return l_result;
- +
+ +null;
- -
end;
- + +
- -
- -
end;
+UT3.UT_BE_GREATER_OR_EQUAL
95.45 % covered
22 relevant lines. 21 lines covered and 1 lines missed-
- -
-type body ut_be_greater_or_equal AS
- -
-/*
- -
-utPLSQL - Version X.X.X.X
- -
-Copyright 2016 - 2017 utPLSQL Project
- + +
- +
+ +member procedure after_calling_suite(self in out nocopy ut_reporter_base, a_suite in ut_logical_suite) is
- +
+ +begin
- + 107 +
+ +null;
- +
+ +end;
- + +
- +
+ +-- run hooks continued
- +
+ +member procedure after_calling_run (self in out nocopy ut_reporter_base, a_run in ut_run) is
- +
+ +begin
- + 75 +
+ +null;
- +
+ +end;
- +
+ +- +
+ +overriding member function get_supported_events return ut_varchar2_list is
- +
+ +begin
- + 115 +
+ +return ut_varchar2_list(
- +
+ +ut_event_manager.gc_initialize,
- +
+ +ut_event_manager.gc_before_run,
- +
+ +ut_event_manager.gc_before_suite,
- +
+ +ut_event_manager.gc_before_test,
- +
+ +ut_event_manager.gc_before_before_all,
- +
+ +ut_event_manager.gc_before_before_each,
- +
+ +ut_event_manager.gc_before_before_test,
- +
+ +ut_event_manager.gc_before_test_execute,
- +
+ +ut_event_manager.gc_before_after_test,
- +
+ +ut_event_manager.gc_before_after_each,
- +
+ +ut_event_manager.gc_before_after_all,
- +
+ +ut_event_manager.gc_after_run,
- +
+ +ut_event_manager.gc_after_suite,
- +
+ +ut_event_manager.gc_after_test,
- +
+ +ut_event_manager.gc_after_before_all,
- +
+ +ut_event_manager.gc_after_before_each,
- +
+ +ut_event_manager.gc_after_before_test,
- +
+ +ut_event_manager.gc_after_test_execute,
- +
+ +ut_event_manager.gc_after_after_test,
- +
+ +ut_event_manager.gc_after_after_each,
- +
+ +ut_event_manager.gc_after_after_all,
- +
+ +ut_event_manager.gc_finalize
- +
+ +);
- +
+ +end;
- +
+ +- +
+ +overriding member procedure on_event( self in out nocopy ut_reporter_base, a_event_name varchar2, a_event_item ut_event_item) is
- +
+ +begin
- + 2596 +
+ +case a_event_name
- + 2596 +
+ +when ut_event_manager.gc_initialize
- + 115 +
+ +then self.on_initialize(treat(a_event_item as ut_run));
- + 2481 +
+ +when ut_event_manager.gc_before_run
- + 114 +
+ +then self.before_calling_run(treat(a_event_item as ut_run));
- + 2367 +
+ +when ut_event_manager.gc_before_suite
- + 327 +
+ +then self.before_calling_suite(treat(a_event_item as ut_logical_suite));
- + 2040 +
+ +when ut_event_manager.gc_before_before_all
- + 15 +
+ +then self.before_calling_before_all(treat(a_event_item as ut_executable));
- + 2025 +
+ +when ut_event_manager.gc_before_before_each
- + 27 +
+ +then self.before_calling_before_each(treat(a_event_item as ut_executable));
- + 1998 +
+ +when ut_event_manager.gc_before_test
- + 315 +
+ +then self.before_calling_test(treat(a_event_item as ut_test));
- + 1683 +
+ +when ut_event_manager.gc_before_before_test
- + 24 +
+ +then self.before_calling_before_test(treat(a_event_item as ut_executable));
- + 1659 +
+ +when ut_event_manager.gc_before_test_execute
- + 303 +
+ +then self.before_calling_test_execute(treat(a_event_item as ut_executable));
- + 1356 +
+ +when ut_event_manager.gc_before_after_test
- + 11 +
+ +then self.before_calling_after_test(treat(a_event_item as ut_executable));
- + 1345 +
+ +when ut_event_manager.gc_before_after_each
- + 34 +
+ +then self.before_calling_after_each(treat(a_event_item as ut_executable));
- + 1311 +
+ +when ut_event_manager.gc_before_after_all
- + 13 +
+ +then self.before_calling_after_all(treat(a_event_item as ut_executable));
- + 1298 +
+ +when ut_event_manager.gc_after_run
- + 114 +
+ +then self.after_calling_run(treat(a_event_item as ut_run));
- + 1184 +
+ +when ut_event_manager.gc_after_suite
- + 327 +
+ +then self.after_calling_suite(treat(a_event_item as ut_logical_suite));
- + 857 +
+ +when ut_event_manager.gc_after_before_all
- + 15 +
+ +then self.after_calling_before_all(treat(a_event_item as ut_executable));
- + 842 +
+ +when ut_event_manager.gc_after_before_each
- + 27 +
+ +then self.after_calling_before_each(treat(a_event_item as ut_executable));
- + 815 +
+ +when ut_event_manager.gc_after_test
- + 315 +
+ +then self.after_calling_test(treat(a_event_item as ut_test));
- + 500 +
+ +when ut_event_manager.gc_after_before_test
- + 24 +
+ +then self.after_calling_before_test(treat(a_event_item as ut_executable));
- + 476 +
+ +when ut_event_manager.gc_after_test_execute
- + 303 +
+ +then self.after_calling_test_execute(treat(a_event_item as ut_executable));
- + 173 +
+ +when ut_event_manager.gc_after_after_test
- + 11 +
+ +then self.after_calling_after_test(treat(a_event_item as ut_executable));
- + 162 +
+ +when ut_event_manager.gc_after_after_each
- + 34 +
+ +then self.after_calling_after_each(treat(a_event_item as ut_executable));
- + 128 +
+ +when ut_event_manager.gc_after_after_all
- + 13 +
+ +then self.after_calling_after_all(treat(a_event_item as ut_executable));
- + 115 +
+ +when ut_event_manager.gc_finalize
- + 115 +
+ +then self.on_finalize(treat(a_event_item as ut_run));
- +
+ +else null;
- +
+ +end case;
- +
+ +end;
- +
+ +- +
+end;
UT3.UT_RESULTS_COUNTER
100 % lines covered
27 relevant lines. 27 lines covered and 0 lines missed+ +
- +
+ +type body ut_results_counter as
- +
+ +/*
- +
+ +utPLSQL - Version 3
- +
+ +Copyright 2016 - 2019 utPLSQL Project
- +
+- +
Licensed under the Apache License, Version 2.0 (the "License"):
- +
you may not use this file except in compliance with the License.
- +
You may obtain a copy of the License at
- +
- +
http://www.apache.org/licenses/LICENSE-2.0
- +
- +
Unless required by applicable law or agreed to in writing, software
- +
distributed under the License is distributed on an "AS IS" BASIS,
- +
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
See the License for the specific language governing permissions and
- +
limitations under the License.
- +
*/
- -
+constructor function ut_results_counter(self in out nocopy ut_results_counter) return self as result is
+- -
-member procedure init(self in out nocopy ut_be_greater_or_equal, a_expected ut_data_value) is
- -
-begin
- - 28 -
-self.self_type := $$plsql_unit;
- - 28 -
-self.expected := a_expected;
- -
-end;
- -
-- -
-constructor function ut_be_greater_or_equal(self in out nocopy ut_be_greater_or_equal, a_expected date) return self as result is
- -
begin
- - 4 -
-init(ut_data_value_date(a_expected));
- - 4 + +
- + 4201 +
+ +self.disabled_count := 0;
- + 4201 +
+ +self.success_count := 0;
- + 4201 +
+ +self.failure_count := 0;
- + 4201 +
+ +self.errored_count := 0;
- + 4201 +
+ +self.warnings_count := 0;
- + 4201
-return;
- + +
- -
end;
- + +
- -
- -
-constructor function ut_be_greater_or_equal(self in out nocopy ut_be_greater_or_equal, a_expected NUMBER) return self as result is
- + +
- +
+ +member procedure set_counter_values(self in out nocopy ut_results_counter, a_status integer) is
- -
begin
- - 4 -
-init(ut_data_value_number(a_expected));
- - 4 -
-return;
- + +
- + 361 +
+ +self.disabled_count := case when a_status = ut_utils.gc_disabled then 1 else 0 end;
- + 360 +
+ +self.success_count := case when a_status = ut_utils.gc_success then 1 else 0 end;
- + 360 +
+ +self.failure_count := case when a_status = ut_utils.gc_failure then 1 else 0 end;
- + 360 +
+ +self.errored_count := case when a_status = ut_utils.gc_error then 1 else 0 end;
- -
end;
- + +
- + +
- +
+member procedure sum_counter_values(self in out nocopy ut_results_counter, a_item ut_results_counter) is
- -
-constructor function ut_be_greater_or_equal(self in out nocopy ut_be_greater_or_equal, a_expected timestamp_unconstrained) return self as result is
- -
begin
- - 4 -
-init(ut_data_value_timestamp(a_expected));
- - 4 -
-return;
- -
-end;
- -
+ +- + 673 +
+ +self.disabled_count := self.disabled_count + a_item.disabled_count;
- + 673 +
+ +self.success_count := self.success_count + a_item.success_count;
- + 673 +
+ +self.failure_count := self.failure_count + a_item.failure_count;
- + 673 +
+ +self.errored_count := self.errored_count + a_item.errored_count;
- + 673 +
+self.warnings_count := self.warnings_count + a_item.warnings_count;
- -
+constructor function ut_be_greater_or_equal(self in out nocopy ut_be_greater_or_equal, a_expected timestamp_tz_unconstrained) return self as result is
end;
+- +
+ +- +
+ +member procedure increase_warning_count(self in out nocopy ut_results_counter, a_count integer := 1) is
- -
begin
- - 4 -
-init(ut_data_value_timestamp_tz(a_expected));
- - 4 -
-return;
- -
+ +end;
- + 409 +
+self.warnings_count := self.warnings_count + nvl(a_count,0);
- -
+end;
+- -
+constructor function ut_be_greater_or_equal(self in out nocopy ut_be_greater_or_equal, a_expected timestamp_ltz_unconstrained) return self as result is
+
- +
+ +member function total_count return integer is
- -
begin
- - 4 -
-init(ut_data_value_timestamp_ltz(a_expected));
- - 4 -
-return;
- -
+ +end;
- +
+ +--skip warnings here
- + 70 +
+return self.disabled_count + self.success_count + self.failure_count + self.errored_count;
- -
-- -
-constructor function ut_be_greater_or_equal(self in out nocopy ut_be_greater_or_equal, a_expected yminterval_unconstrained) return self as RESULT IS
- -
-begin
- - 4 -
-init(ut_data_value_yminterval(a_expected));
- - 4 -
-return;
- -
end;
- + +
- -
- -
-constructor function ut_be_greater_or_equal(self in out nocopy ut_be_greater_or_equal, a_expected dsinterval_unconstrained) return self as RESULT IS
- + +
- +
+ +member function result_status return integer is
- +
+ +l_result integer;
- -
begin
- - 4 -
-init(ut_data_value_dsinterval(a_expected));
- - 4 -
-return;
- -
-end;
- -
+ +- + 459 +
+ +if self.errored_count > 0 then
- + 208 +
+ +l_result := ut_utils.gc_error;
- + 251 +
+ +elsif self.failure_count > 0 then
- + 46 +
+ +l_result := ut_utils.gc_failure;
- + 205 +
+ +elsif self.success_count > 0 then
- + 200 +
+ +l_result := ut_utils.gc_success;
- + 5 +
+ +elsif self.disabled_count > 0 then
- + 1 +
+l_result := ut_utils.gc_disabled;
- -
-overriding member function run_matcher(self in out nocopy ut_be_greater_or_equal, a_actual ut_data_value) return boolean is
- -
-l_result boolean;
- -
-begin
- - 28 -
-if self.expected.data_type = a_actual.data_type then
- - 28 -
-l_result := a_actual >= self.expected;
- -
else
- -
-l_result := (self as ut_matcher).run_matcher(a_actual);
- + +
- + 4 +
+ +l_result := ut_utils.gc_error;
- -
end if;
- - 28 + +
- + 459
-return l_result;
- -
-end;
- -
-- -
-overriding member function failure_message(a_actual ut_data_value) return varchar2 is
- -
-begin
- - 21 -
-return (self as ut_matcher).failure_message(a_actual) || ': '|| expected.to_string_report();
- -
-end;
- -
-- -
-overriding member function failure_message_when_negated(a_actual ut_data_value) return varchar2 is
- -
-begin
- - 7 -
-return (self as ut_matcher).failure_message_when_negated(a_actual) || ': '|| expected.to_string_report();
- + +
- -
end;
- + +
- -
- -
end;
+UT3.UT_BE_GREATER_THAN
95.45 % covered
22 relevant lines. 21 lines covered and 1 lines missed+ +
- +
+end;
UT3.UT_RUN
93.94 % lines covered
33 relevant lines. 31 lines covered (including 1 lines partially covered ) and 2 lines missed+
- -
+type body ut_be_greater_than AS
type body ut_run as
+- +
/*
- -
+utPLSQL - Version X.X.X.X
utPLSQL - Version 3
+- -
+Copyright 2016 - 2017 utPLSQL Project
Copyright 2016 - 2019 utPLSQL Project
+- +
- +
Licensed under the Apache License, Version 2.0 (the "License"):
- +
you may not use this file except in compliance with the License.
- +
You may obtain a copy of the License at
- +
- +
http://www.apache.org/licenses/LICENSE-2.0
- +
- +
Unless required by applicable law or agreed to in writing, software
- +
distributed under the License is distributed on an "AS IS" BASIS,
- +
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
See the License for the specific language governing permissions and
- +
limitations under the License.
- +
*/
- +
- -
+member procedure init(self in out nocopy ut_be_greater_than, a_expected ut_data_value) is
constructor function ut_run(
+- -
-begin
- - 27 -
-self.self_type := $$plsql_unit;
- - 27 -
+self.expected := a_expected;
self in out nocopy ut_run,
+ +- +
+ +a_items ut_suite_items,
- +
+a_run_paths ut_varchar2_list := null,
- -
+end;
a_schema_names ut_varchar2_rows := null,
+- -
+a_exclude_objects ut_object_names := null,
+- -
+constructor function ut_be_greater_than(self in out nocopy ut_be_greater_than, a_expected date) return self as result is
a_include_objects ut_object_names := null,
+- -
-begin
- - 3 -
-init(ut_data_value_date(a_expected));
- - 3 -
+return;
a_project_file_mappings ut_file_mappings := null,
+ +- +
+ +a_test_file_mappings ut_file_mappings := null,
- +
+a_client_character_set varchar2 := null,
- -
+end;
a_random_test_order_seed positive := null,
+- -
+a_run_tags ut_varchar2_rows := null
+- -
+constructor function ut_be_greater_than(self in out nocopy ut_be_greater_than, a_expected NUMBER) return self as result is
) return self as result is
+- -
begin
- - 9 -
-init(ut_data_value_number(a_expected));
- - 9 -
-return;
- -
-end;
- -
-- -
-constructor function ut_be_greater_than(self in out nocopy ut_be_greater_than, a_expected timestamp_unconstrained) return self as result is
- -
-begin
- - 3 -
-init(ut_data_value_timestamp(a_expected));
- - 3 -
-return;
- -
+ +end;
- + 116 +
+ +self.run_paths := a_run_paths;
- + 116 +
+ +self.run_tags := a_run_tags;
- + 116 +
+ +self.self_type := $$plsql_unit;
- + 116 +
+ +self.items := a_items;
- + 116 +
+ +self.client_character_set := lower(a_client_character_set);
- + 116 +
+ +self.random_test_order_seed := a_random_test_order_seed;
- + 116 +
+ +self.results_count := ut_results_counter();
- + 116 +
+ +self.test_file_mappings := coalesce(a_test_file_mappings, ut_file_mappings());
- + 116 +
+self.coverage_options := ut_coverage_options(
- -
+a_schema_names,
+- -
+constructor function ut_be_greater_than(self in out nocopy ut_be_greater_than, a_expected timestamp_tz_unconstrained) return self as result is
a_exclude_objects,
+- -
-begin
- - 3 -
-init(ut_data_value_timestamp_tz(a_expected));
- - 3 +
+ +a_include_objects,
- +
+ +a_project_file_mappings
- +
+ +);
- + 116
-return;
- -
+end;
- -
+end;
+- -
+constructor function ut_be_greater_than(self in out nocopy ut_be_greater_than, a_expected timestamp_ltz_unconstrained) return self as result is
+
- +
+ +overriding member procedure mark_as_skipped(self in out nocopy ut_run) is
- -
begin
- - 3 -
-init(ut_data_value_timestamp_ltz(a_expected));
- - 3 -
+ +return;
- +
+null;
- +
end;
- +
- -
+constructor function ut_be_greater_than(self in out nocopy ut_be_greater_than, a_expected yminterval_unconstrained) return self as RESULT IS
overriding member function do_execute(self in out nocopy ut_run) return boolean is
+- +
+ +l_completed_without_errors boolean;
- -
begin
- - 3 -
-init(ut_data_value_yminterval(a_expected));
- - 3 -
+ +return;
- + 115 +
+ut_utils.debug_log('ut_run.execute');
- -
-end;
- -
- -
+ +constructor function ut_be_greater_than(self in out nocopy ut_be_greater_than, a_expected dsinterval_unconstrained) return self as RESULT IS
- + 116 +
+ +ut_event_manager.trigger_event(ut_event_manager.gc_before_run, self);
- + 115 +
+self.start_time := current_timestamp;
- -
-begin
- - 3 -
-init(ut_data_value_dsinterval(a_expected));
- - 3 -
+return;
+ +
- +
+ +-- clear anything that might stay in the session's cache
- + 116 +
+ut_expectation_processor.clear_expectations;
- -
-end;
- -
- -
+ +overriding member function run_matcher(self in out nocopy ut_be_greater_than, a_actual ut_data_value) return boolean is
- + 257 +
+ +for i in 1 .. self.items.count loop
- + 142 +
+l_completed_without_errors := self.items(i).do_execute();
- -
+l_result boolean;
end loop;
+- +
+ +- + 115 +
+ +self.calc_execution_result();
- +
+ +- + 115 +
+ +self.end_time := current_timestamp;
- +
+ +- + 115 +
+ +ut_event_manager.trigger_event(ut_event_manager.gc_after_run, self);
- +
+ +- + 115 +
+ +return l_completed_without_errors;
- +
+ +end;
- +
+ +- +
+ +overriding member procedure set_rollback_type(self in out nocopy ut_run, a_rollback_type integer, a_force boolean := false) is
- -
begin
- - 27 -
-if self.expected.data_type = a_actual.data_type then
- - 27 -
-l_result := a_actual > self.expected;
- + +
- + 2/4 + 2 +
+ +self.rollback_type := case when a_force then a_rollback_type else coalesce(self.rollback_type, a_rollback_type) end;
- + 4 +
+ +for i in 1 .. self.items.count loop
- + 2 +
+ +self.items(i).set_rollback_type(self.rollback_type, a_force);
- +
+ +end loop;
- +
+ +end;
- +
+ +- +
+ +overriding member procedure calc_execution_result(self in out nocopy ut_run) is
- +
+ +l_result integer(1);
- +
+ +begin
- + 115 +
+ +if self.items is not null and self.items.count > 0 then
- + 256 +
+ +for i in 1 .. self.items.count loop
- + 142 +
+ +self.results_count.sum_counter_values( self.items(i).results_count );
- +
+ +end loop;
- + 114 +
+ +l_result := self.results_count.result_status();
- -
else
- -
-l_result := (self as ut_matcher).run_matcher(a_actual);
- + +
- +
+ +--if suite is empty then it's successful (no errors)
- + 1 +
+ +l_result := ut_utils.gc_success;
- -
end if;
- - 27 -
-return l_result;
- + +
- +
+ +- + 115 +
+ +self.result := l_result;
- -
end;
- + +
- -
- -
-overriding member function failure_message(a_actual ut_data_value) return varchar2 is
- + +
- +
+ +overriding member procedure mark_as_errored(self in out nocopy ut_run, a_error_stack_trace varchar2) is
- -
begin
- - 20 -
-return (self as ut_matcher).failure_message(a_actual) || ': '|| expected.to_string_report();
- + +
- +
+ +null;
- -
end;
- + +
- -
- -
-overriding member function failure_message_when_negated(a_actual ut_data_value) return varchar2 is
- + +
- +
+ +overriding member function get_error_stack_traces return ut_varchar2_list is
- -
begin
- - 7 -
-return (self as ut_matcher).failure_message_when_negated(a_actual) || ': '|| expected.to_string_report();
- + +
- + 1 +
+ +return ut_varchar2_list();
- -
end;
- + +
- -
- -
end;
+UT3.UT_BE_LESS_OR_EQUAL
95.45 % covered
22 relevant lines. 21 lines covered and 1 lines missed+ +
- +
+ +overriding member function get_serveroutputs return clob is
- +
+ +begin
- + 1 +
+ +return null;
- +
+ +end;
- +
+ +- +
+ +- +
+end;
UT3.UT_RUN_INFO
100 % lines covered
10 relevant lines. 10 lines covered and 0 lines missed+
- -
+type body ut_be_less_or_equal AS
type body ut_run_info as
+- +
/*
- -
+utPLSQL - Version X.X.X.X
utPLSQL - Version 3
+- -
+Copyright 2016 - 2017 utPLSQL Project
Copyright 2016 - 2019 utPLSQL Project
+- +
- +
Licensed under the Apache License, Version 2.0 (the "License"):
- +
you may not use this file except in compliance with the License.
- +
You may obtain a copy of the License at
- +
- +
http://www.apache.org/licenses/LICENSE-2.0
- +
- +
Unless required by applicable law or agreed to in writing, software
- +
distributed under the License is distributed on an "AS IS" BASIS,
- +
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- -
+See the License for the specific language governing permissions and
See the License for the specific language governing permissions andTEST_GET_REPORTERS_LIST
+- +
limitations under the License.
- +
*/
- -
-- -
+member procedure init(self in out nocopy ut_be_less_or_equal, a_expected ut_data_value) is
constructor function ut_run_info(self in out nocopy ut_run_info) return self as result is
+ +- + 116 +
+l_ut_owner varchar2(250) := ut_utils.ut_owner;
- -
begin
- - 28 + +
- + 116
-self.self_type := $$plsql_unit;
- - 28 -
+ +self.expected := a_expected;
- + 116 +
+execute immediate
- -
+end;
'select '||l_ut_owner||'.ut.version() from dual'
+- -
+into self.ut_version;
+- -
-constructor function ut_be_less_or_equal(self in out nocopy ut_be_less_or_equal, a_expected date) return self as result is
- -
-begin
- - 4 -
-init(ut_data_value_date(a_expected));
- - 4 -
-return;
- -
-end;
- + +
- + 116 +
+ +dbms_utility.db_version( self.db_version, self.db_compatibility );
- + 116 +
+ +db_os_type := dbms_utility.port_string();
- +
+ +- + 116 +
+ +execute immediate
- +
+'select '||l_ut_owner||'.ut_key_value_pair(x.product, x.version) from product_component_version x'
- -
+constructor function ut_be_less_or_equal(self in out nocopy ut_be_less_or_equal, a_expected NUMBER) return self as result is
bulk collect into self.db_component_version;
+- -
-begin
- - 4 -
-init(ut_data_value_number(a_expected));
- - 4 -
+return;
+ +
- + 116 +
+ +execute immediate
- +
+'select '||l_ut_owner||'.ut_key_value_pair(x.parameter, x.value)
- -
+end;
from nls_session_parameters x'
+- -
+bulk collect into self.nls_session_params;
+- -
-constructor function ut_be_less_or_equal(self in out nocopy ut_be_less_or_equal, a_expected timestamp_unconstrained) return self as result is
- -
-begin
- - 4 -
-init(ut_data_value_timestamp(a_expected));
- - 4 -
+return;
+ +
- + 116 +
+ +execute immediate
- +
+ +'select '||l_ut_owner||'.ut_key_value_pair(x.parameter, x.value) from nls_instance_parameters x'
- +
+bulk collect into self.nls_instance_params;
- -
-end;
- + +
- + 116 +
+execute immediate
- -
+constructor function ut_be_less_or_equal(self in out nocopy ut_be_less_or_equal, a_expected timestamp_tz_unconstrained) return self as result is
'select '||l_ut_owner||'.ut_key_value_pair(x.parameter, x.value) from nls_database_parameters x'
+- -
-begin
- - 4 -
-init(ut_data_value_timestamp_tz(a_expected));
- - 4 -
-return;
- -
-end;
- -
-- -
-constructor function ut_be_less_or_equal(self in out nocopy ut_be_less_or_equal, a_expected timestamp_ltz_unconstrained) return self as result is
- -
-begin
- - 4 -
-init(ut_data_value_timestamp_ltz(a_expected));
- - 4 -
-return;
- -
-end;
- -
-- -
-constructor function ut_be_less_or_equal(self in out nocopy ut_be_less_or_equal, a_expected yminterval_unconstrained) return self as RESULT IS
- -
-begin
- - 4 -
-init(ut_data_value_yminterval(a_expected));
- - 4 -
-return;
- -
-end;
- -
-- -
-constructor function ut_be_less_or_equal(self in out nocopy ut_be_less_or_equal, a_expected dsinterval_unconstrained) return self as RESULT IS
- -
-begin
- - 4 -
-init(ut_data_value_dsinterval(a_expected));
- - 4 +
+ +bulk collect into self.nls_db_params;
- + 116
-return;
- -
-end;
- -
-- -
-overriding member function run_matcher(self in out nocopy ut_be_less_or_equal, a_actual ut_data_value) return boolean is
- -
-l_result boolean;
- -
-begin
- - 28 -
-if self.expected.data_type = a_actual.data_type then
- - 28 -
-l_result := a_actual <= self.expected;
- -
-else
- -
-l_result := (self as ut_matcher).run_matcher(a_actual);
- -
-end if;
- - 28 -
-return l_result;
- -
-end;
- -
-- -
-overriding member function failure_message(a_actual ut_data_value) return varchar2 is
- -
-begin
- - 21 -
-return (self as ut_matcher).failure_message(a_actual) || ': '|| expected.to_string_report();
- -
-end;
- -
-- -
-overriding member function failure_message_when_negated(a_actual ut_data_value) return varchar2 is
- -
-begin
- - 7 -
-return (self as ut_matcher).failure_message_when_negated(a_actual) || ': '|| expected.to_string_report();
- + +
- -
end;
- -
-- -
end;
+UT3.UT_BE_LESS_THAN
95.45 % covered
22 relevant lines. 21 lines covered and 1 lines missed+ +
- +
+end;
UT3.UT_SUITE
100 % lines covered
44 relevant lines. 44 lines covered and 0 lines missed+
- -
+type body ut_be_less_than as
type body ut_suite as
+- +
/*
- -
+utPLSQL - Version X.X.X.X
utPLSQL - Version 3
+- -
+Copyright 2016 - 2017 utPLSQL Project
Copyright 2016 - 2019 utPLSQL Project
+- +
- +
Licensed under the Apache License, Version 2.0 (the "License"):
- +
you may not use this file except in compliance with the License.
- +
You may obtain a copy of the License at
- +
- +
http://www.apache.org/licenses/LICENSE-2.0
- +
- +
Unless required by applicable law or agreed to in writing, software
- +
distributed under the License is distributed on an "AS IS" BASIS,
- +
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
See the License for the specific language governing permissions and
- +
limitations under the License.
- +
*/
- +
- -
+member procedure init(self in out nocopy ut_be_less_than, a_expected ut_data_value) is
constructor function ut_suite (
+- -
-begin
- - 21 -
-self.self_type := $$plsql_unit;
- - 21 -
+self.expected := a_expected;
self in out nocopy ut_suite, a_object_owner varchar2, a_object_name varchar2, a_line_no integer,
+ +- +
+ +a_tags ut_varchar2_rows := null
- +
+) return self as result is
- -
-end;
- -
-- -
-constructor function ut_be_less_than(self in out nocopy ut_be_less_than, a_expected date) return self as result is
- -
begin
- - 3 -
-init(ut_data_value_date(a_expected));
- - 3 + +
- + 284 +
+ +self.self_type := $$plsql_unit;
- + 284 +
+ +self.init(a_object_owner, a_object_name, a_object_name, a_line_no);
- + 284 +
+ +self.items := ut_suite_items();
- + 284 +
+ +before_all_list := ut_executables();
- + 284 +
+ +after_all_list := ut_executables();
- + 284 +
+ +self.tags := coalesce(a_tags,ut_varchar2_rows());
- + 284
-return;
- -
-end;
- -
+- -
+constructor function ut_be_less_than(self in out nocopy ut_be_less_than, a_expected number) return self as result is
end;
+- -
-begin
- - 3 -
-init(ut_data_value_number(a_expected));
- - 3 -
+return;
+ +
- +
+ +overriding member function do_execute(self in out nocopy ut_suite) return boolean is
- +
+l_suite_savepoint varchar2(30);
- -
+end;
l_no_errors boolean;
+- +
- -
+constructor function ut_be_less_than(self in out nocopy ut_be_less_than, a_expected timestamp_unconstrained)
procedure propagate_error(a_error_stack_trace varchar2) is
+- -
-return self as result is
- -
-begin
- - 3 -
-init(ut_data_value_timestamp(a_expected));
- - 3 -
+return;
begin
+ +- + 4 +
+ +for i in 1..self.items.count loop
- + 2 +
+ +self.items(i).mark_as_errored(a_error_stack_trace);
- +
+end loop;
- -
+end;
end;
+- -
-- -
-constructor function ut_be_less_than(self in out nocopy ut_be_less_than, a_expected timestamp_tz_unconstrained)
- -
-return self as result is
- -
begin
- - 3 -
-init(ut_data_value_timestamp_tz(a_expected));
- - 3 -
-return;
- -
-end;
- + +
- + 204 +
+ +ut_utils.debug_log('ut_suite.execute');
- + +
- + 204 +
+ +if self.get_disabled_flag() then
- + 1 +
+ +self.mark_as_skipped();
- +
+ +else
- + 203 +
+ +self.start_time := current_timestamp;
- + 204 +
+ut_event_manager.trigger_event(ut_event_manager.gc_before_suite, self);
- -
-constructor function ut_be_less_than(self in out nocopy ut_be_less_than, a_expected timestamp_ltz_unconstrained)
- -
+return self as result is
+ +
- + 203 +
+l_suite_savepoint := self.create_savepoint_if_needed();
- -
-begin
- - 3 -
-init(ut_data_value_timestamp_ltz(a_expected));
- - 3 -
-return;
- -
-end;
- -
- -
-constructor function ut_be_less_than(self in out nocopy ut_be_less_than, a_expected yminterval_unconstrained)
- -
-return self as result is
- -
-begin
- - 3 -
-init(ut_data_value_yminterval(a_expected));
- - 3 -
+ +return;
- +
+ +--includes listener calls for before and after actions
- + 203 +
+ +l_no_errors := true;
- + 227 +
+ +for i in 1 .. self.before_all_list.count loop
- + 26 +
+ +l_no_errors := self.before_all_list(i).do_execute(self);
- + 26 +
+ +if not l_no_errors then
- + 2 +
+ +propagate_error(self.before_all_list(i).get_error_stack_trace());
- + 2 +
+ +exit;
- +
+ +end if;
- +
+end loop;
- -
-end;
- -
- -
-constructor function ut_be_less_than(self in out nocopy ut_be_less_than, a_expected dsinterval_unconstrained)
- -
+ +return self as result is
- + 203 +
+ +if l_no_errors then
- + 582 +
+ +for i in 1 .. self.items.count loop
- + 381 +
+self.items(i).do_execute();
- -
-begin
- - 3 -
-init(ut_data_value_dsinterval(a_expected));
- - 3 -
-return;
- -
-end;
- +
+ +end loop;
- +
+ +end if;
- -
- -
-overriding member function run_matcher(self in out nocopy ut_be_less_than, a_actual ut_data_value) return boolean is
- -
+ +l_result boolean;
- + 218 +
+ +for i in 1 .. after_all_list.count loop
- + 15 +
+ +l_no_errors := self.after_all_list(i).do_execute(self);
- + 15 +
+ +if not l_no_errors then
- + 2 +
+self.put_warning(self.after_all_list(i).get_error_stack_trace());
- -
-begin
- - 21 -
-if self.expected.data_type = a_actual.data_type then
- - 21 -
-l_result := a_actual < self.expected;
- -
-else
- -
-l_result := (self as ut_matcher).run_matcher(a_actual);
- -
-end if;
- - 21 -
-return l_result;
- -
-end;
- +
+ +end if;
- +
+ +end loop;
- +
+ +- + 203 +
+ +self.rollback_to_savepoint(l_suite_savepoint);
- + +
- + 203 +
+ +self.calc_execution_result();
- + 203 +
+ +self.end_time := current_timestamp;
- + 203 +
+ +ut_event_manager.trigger_event(ut_event_manager.gc_after_suite, self);
- +
+end if;
- -
-overriding member function failure_message(a_actual ut_data_value) return varchar2 is
- -
-begin
- - 14 -
-return (self as ut_matcher).failure_message(a_actual) || ': '|| expected.to_string_report();
- +
+ +- + 204 +
+ +return l_no_errors;
- -
end;
- + +
- -
- -
+ +overriding member function failure_message_when_negated(a_actual ut_data_value) return varchar2 is
- +
+ +overriding member function get_error_stack_traces(self ut_suite) return ut_varchar2_list is
- + 29 +
+l_stack_traces ut_varchar2_list := ut_varchar2_list();
- -
begin
- - 7 -
-return (self as ut_matcher).failure_message_when_negated(a_actual) || ': '|| expected.to_string_report();
- -
+ +end;
- + 33 +
+ +for i in 1 .. before_all_list.count loop
- + 4 +
+ut_utils.append_to_list(l_stack_traces, self.before_all_list(i).get_error_stack_trace());
- +
+ +end loop;
- + 33 +
+ +for i in 1 .. after_all_list.count loop
- + 4 +
+ +ut_utils.append_to_list(l_stack_traces, self.after_all_list(i).get_error_stack_trace());
- +
+ +end loop;
- + 29 +
+ +return l_stack_traces;
- +
+ +end;
- -
- -
end;
UT3.UT_BE_LIKE
100 % covered
23 relevant lines. 23 lines covered and 0 lines missed-
- -
-type body ut_be_like as
- -
-/*
- -
-utPLSQL - Version X.X.X.X
- -
-Copyright 2016 - 2017 utPLSQL Project
- -
-- -
-Licensed under the Apache License, Version 2.0 (the "License"):
- -
-you may not use this file except in compliance with the License.
- -
-You may obtain a copy of the License at
- -
-- -
-http://www.apache.org/licenses/LICENSE-2.0
- -
-- -
-Unless required by applicable law or agreed to in writing, software
- -
-distributed under the License is distributed on an "AS IS" BASIS,
- -
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- -
-See the License for the specific language governing permissions and
- -
-limitations under the License.
- -
-*/
- -
-- -
-constructor function ut_be_like(self in out nocopy ut_be_like, a_mask in varchar2, a_escape_char in varchar2 := null) return self as result is
- -
-begin
- - 20 -
-self.self_type := $$plsql_unit;
- - 20 -
-self.mask := a_mask;
- - 20 -
-self.escape_char := a_escape_char;
- - 20 -
-return;
- -
-end ut_be_like;
- -
-- -
-overriding member function run_matcher(self in out nocopy ut_be_like, a_actual ut_data_value) return boolean is
- -
-l_value clob;
- -
-l_result boolean;
- -
-begin
- - 20 -
-if a_actual is of (ut_data_value_varchar2, ut_data_value_clob) then
- -
-- - 19 -
-if a_actual is of (ut_data_value_varchar2) then
- - 8 -
-l_value := treat(a_actual as ut_data_value_varchar2).data_value;
- -
-else
- - 11 -
-l_value := treat(a_actual as ut_data_value_clob).data_value;
- -
-end if;
- -
-- - 19 -
-if escape_char is not null then
- - 8 -
-l_result := l_value like mask escape escape_char;
- -
-else
- - 11 -
-l_result := l_value like mask;
- -
-end if;
- -
-else
- - 1 -
-l_result := (self as ut_matcher).run_matcher(a_actual);
- -
-end if;
- - 20 -
-return l_result;
- -
-end run_matcher;
- -
-- -
-overriding member function failure_message(a_actual ut_data_value) return varchar2 is
- -
-l_result varchar2(32767);
- -
-begin
- - 11 -
-l_result := (self as ut_matcher).failure_message(a_actual);
- - 11 -
-if self.escape_char is not null then
- - 4 -
-l_result := l_result || ': '|| ut_data_value_varchar2(self.mask).to_string_report(true, false) || ', escape ''' || self.escape_char ||'''';
- -
-else
- - 7 -
-l_result := l_result || ': '|| ut_data_value_varchar2(self.mask).to_string_report(false, false);
- -
-end if;
- - 11 -
-return l_result;
- -
-end;
- -
-- -
-overriding member function failure_message_when_negated(a_actual ut_data_value) return varchar2 is
- -
-l_result varchar2(32767);
- + +
- +
+ +overriding member function get_serveroutputs return clob is
- +
+ +l_outputs clob;
- -
begin
- - 8 -
-l_result := (self as ut_matcher).failure_message_when_negated(a_actual);
- - 8 -
-if self.escape_char is not null then
- - 4 -
-l_result := l_result || ': '|| ut_data_value_varchar2(self.mask).to_string_report(true, false) || ', escape ''' || self.escape_char ||'''';
- -
-else
- - 4 -
-l_result := l_result || ': '|| ut_data_value_varchar2(self.mask).to_string_report(false, false);
- -
-end if;
- - 8 -
-return l_result;
- + +
- + 35 +
+ +for i in 1 .. before_all_list.count loop
- + 5 +
+ +ut_utils.append_to_clob(l_outputs, self.before_all_list(i).serveroutput);
- +
+ +end loop;
- + 35 +
+ +for i in 1 .. after_all_list.count loop
- + 5 +
+ +ut_utils.append_to_clob(l_outputs, self.after_all_list(i).serveroutput);
- +
+ +end loop;
- + 30 +
+ +return l_outputs;
- -
end;
- + +
- -
- -
end;
+UT3.UT_BE_NOT_NULL
100 % covered
3 relevant lines. 3 lines covered and 0 lines missed+ +
- +
+end;
UT3.UT_SUITE_CONTEXT
100 % lines covered
6 relevant lines. 6 lines covered and 0 lines missed+
- -
+type body ut_be_not_null as
type body ut_suite_context as
+- +
/*
- -
+utPLSQL - Version X.X.X.X
utPLSQL - Version 3
+- -
+Copyright 2016 - 2017 utPLSQL Project
Copyright 2016 - 2019 utPLSQL Project
+- +
- +
Licensed under the Apache License, Version 2.0 (the "License"):
- +
you may not use this file except in compliance with the License.
- +
You may obtain a copy of the License at
- +
- +
http://www.apache.org/licenses/LICENSE-2.0
- +
- +
Unless required by applicable law or agreed to in writing, software
- +
distributed under the License is distributed on an "AS IS" BASIS,
- +
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
See the License for the specific language governing permissions and
- +
limitations under the License.
- +
*/
- +
- -
+constructor function ut_be_not_null(self in out nocopy ut_be_not_null) return self as result is
constructor function ut_suite_context (
+- +
+ +self in out nocopy ut_suite_context, a_object_owner varchar2, a_object_name varchar2, a_context_name varchar2 := null, a_line_no integer
- +
+ +) return self as result is
- -
begin
- - 18 + +
- + 176
-self.self_type := $$plsql_unit;
- - 18 + +
- + 176 +
+ +self.init(a_object_owner, a_object_name, a_context_name, a_line_no);
- + 176 +
+ +self.items := ut_suite_items();
- + 176 +
+ +before_all_list := ut_executables();
- + 176 +
+ +after_all_list := ut_executables();
- + 176
-return;
- -
-end;
- -
-- -
-overriding member function run_matcher(self in out nocopy ut_be_not_null, a_actual ut_data_value) return boolean is
- -
-begin
- - 18 -
-return not a_actual.is_null;
- -
+end;
- -
+end;
+- -
end;
+UT3.UT_BE_NULL
100 % covered
3 relevant lines. 3 lines covered and 0 lines missed+
+ +
- +
+end;
UT3.UT_SUITE_ITEM
100 % lines covered
33 relevant lines. 33 lines covered and 0 lines missed+
- -
+type body ut_be_null as
type body ut_suite_item as
+- +
/*
- -
+utPLSQL - Version X.X.X.X
utPLSQL - Version 3
+- -
+Copyright 2016 - 2017 utPLSQL Project
Copyright 2016 - 2019 utPLSQL Project
+- +
- +
Licensed under the Apache License, Version 2.0 (the "License"):
- +
you may not use this file except in compliance with the License.
- +
You may obtain a copy of the License at
- +
- +
http://www.apache.org/licenses/LICENSE-2.0
- +
- +
Unless required by applicable law or agreed to in writing, software
- +
distributed under the License is distributed on an "AS IS" BASIS,
- +
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
See the License for the specific language governing permissions and
- +
limitations under the License.
- +
*/
- +
- -
+constructor function ut_be_null(self in out nocopy ut_be_null) return self as result is
member procedure init(self in out nocopy ut_suite_item, a_object_owner varchar2, a_object_name varchar2, a_name varchar2, a_line_no integer) is
+- -
begin
- - 57 -
-self.self_type := $$plsql_unit;
- - 57 -
-return;
- -
-end;
- -
-- -
-overriding member function run_matcher(self in out nocopy ut_be_null, a_actual ut_data_value) return boolean is
- -
-begin
- - 57 -
-return a_actual.is_null;
- -
+ +end;
- + 2921 +
+ +self.object_owner := a_object_owner;
- + 2921 +
+ +self.object_name := lower(trim(a_object_name));
- + 2921 +
+ +self.name := lower(trim(a_name));
- + 2921 +
+ +self.results_count := ut_results_counter();
- + 2921 +
+ +self.warnings := ut_varchar2_rows();
- + 2921 +
+ +self.line_no := a_line_no;
- + 2921 +
+ +self.transaction_invalidators := ut_varchar2_list();
- + 2921 +
+self.disabled_flag := ut_utils.boolean_to_int(false);
- -
+end;
+- -
end;
+UT3.UT_BE_TRUE
100 % covered
6 relevant lines. 6 lines covered and 0 lines missed+
+ +
- +
+ +member function get_disabled_flag return boolean is
- +
+ +begin
- + 569 +
+ +return ut_utils.int_to_boolean(self.disabled_flag);
- +
+ +end;
- +
+ +- +
+ +member procedure set_rollback_type(self in out nocopy ut_suite_item, a_rollback_type integer, a_force boolean := false) is
- +
+ +begin
- + 1315 +
+ +self.rollback_type := case when a_force then a_rollback_type else coalesce(self.rollback_type, a_rollback_type) end;
- +
+ +end;
- +
+ +- +
+ +member function get_rollback_type return integer is
- +
+ +begin
- + 1512 +
+ +return nvl(self.rollback_type, ut_utils.gc_rollback_default);
- +
+ +end;
- +
+ +- +
+ +final member procedure do_execute(self in out nocopy ut_suite_item) is
- +
+ +l_completed_without_errors boolean;
- +
+ +begin
- + 674 +
+ +l_completed_without_errors := self.do_execute();
- +
+ +end;
- +
+ +- +
+ +member function create_savepoint_if_needed return varchar2 is
- +
+ +l_savepoint varchar2(30);
- +
+ +begin
- + 548 +
+ +if get_rollback_type() = ut_utils.gc_rollback_auto then
- + 321 +
+ +l_savepoint := ut_utils.gen_savepoint_name();
- + 321 +
+ +execute immediate 'savepoint ' || l_savepoint;
- +
+ +end if;
- + 548 +
+ +return l_savepoint;
- +
+ +end;
- +
+ +- +
+ +member procedure rollback_to_savepoint(self in out nocopy ut_suite_item, a_savepoint varchar2) is
- +
+ +ex_savepoint_not_exists exception;
- +
+ +l_transaction_invalidators clob;
- +
+ +pragma exception_init(ex_savepoint_not_exists, -1086);
- +
+ +l_savepoint varchar2(250);
- +
+ +begin
- + 549 +
+ +if get_rollback_type() = ut_utils.gc_rollback_auto and a_savepoint is not null then
- + 322 +
+ +l_savepoint := sys.dbms_assert.qualified_sql_name(a_savepoint);
- + 322 +
+ +execute immediate 'rollback to ' || l_savepoint;
- +
+ +end if;
- +
+ +exception
- + 12 +
+ +when ex_savepoint_not_exists then
- + 6 +
+ +l_transaction_invalidators :=
- +
+ +lower( ut_utils.indent_lines( ut_utils.table_to_clob( self.get_transaction_invalidators() ), 2, true ) );
- + 6 +
+ +if length(l_transaction_invalidators) > 3000 then
- + 1 +
+ +l_transaction_invalidators := substr(l_transaction_invalidators,1,3000)||'...';
- +
+ +end if;
- + 6 +
+ +put_warning(
- +
+ +'Unable to perform automatic rollback after test'
- + 1 +
+ +|| case when self_type like '%SUITE' then ' suite' when self_type like '%CONTEXT' then ' context' end || '. '
- +
+ +||'An implicit or explicit commit/rollback occurred in procedures:'||chr(10)
- +
+ +||l_transaction_invalidators||chr(10)
- +
+ +||'Use the "--%rollback(manual)" annotation or remove commit/rollback/ddl statements that are causing the issue.'
- +
+ +);
- +
+ +end;
- +
+ +- +
+ +member function execution_time return number is
- +
+ +begin
- + 424 +
+ +return ut_utils.time_diff(start_time, end_time);
- +
+ +end;
- +
+ +- +
+ +member procedure put_warning(self in out nocopy ut_suite_item, a_message varchar2) is
- +
+ +begin
- + 62 +
+ +self.warnings.extend;
- + 62 +
+ +self.warnings(self.warnings.last) := a_message;
- + 62 +
+ +self.results_count.increase_warning_count;
- +
+ +end;
- +
+ +- +
+ +member function get_transaction_invalidators return ut_varchar2_list is
- +
+ +begin
- + 5 +
+ +return transaction_invalidators;
- +
+ +end;
- +
+ +- +
+ +member procedure add_transaction_invalidator(self in out nocopy ut_suite_item, a_object_name varchar2) is
- +
+ +begin
- + 103 +
+ +if a_object_name not member of transaction_invalidators then
- + 103 +
+ +transaction_invalidators.extend();
- + 103 +
+ +transaction_invalidators(transaction_invalidators.last) := a_object_name;
- +
+ +end if;
- +
+ +end;
- +
+ +- +
+end;
UT3.UT_TEST
100 % lines covered
87 relevant lines. 87 lines covered and 0 lines missed+
- -
+type body ut_be_true as
type body ut_test as
+- +
/*
- -
+utPLSQL - Version X.X.X.X
utPLSQL - Version 3
+- -
+Copyright 2016 - 2017 utPLSQL Project
Copyright 2016 - 2019 utPLSQL Project
+- +
- +
Licensed under the Apache License, Version 2.0 (the "License"):
- +
you may not use this file except in compliance with the License.
- +
You may obtain a copy of the License at
- +
- +
http://www.apache.org/licenses/LICENSE-2.0
- +
- +
Unless required by applicable law or agreed to in writing, software
- +
distributed under the License is distributed on an "AS IS" BASIS,
- +
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
See the License for the specific language governing permissions and
- +
limitations under the License.
- +
*/
- +
- -
-constructor function ut_be_true(self in out nocopy ut_be_true) return self as result is
- -
-begin
- - 51 -
-self.self_type := $$plsql_unit;
- - 51 -
-return;
- -
-end;
- -
-- -
-overriding member function run_matcher(self in out nocopy ut_be_true, a_actual ut_data_value) return boolean is
- -
-l_result boolean;
- -
-begin
- - 51 -
-if a_actual is of (ut_data_value_boolean) then
- - 50 -
-l_result := ut_utils.int_to_boolean( treat(a_actual as ut_data_value_boolean).data_value);
- -
-else
- - 1 -
-l_result := (self as ut_matcher).run_matcher(a_actual);
- -
-end if;
- - 51 -
-return l_result;
- -
-end;
- -
-- -
end;
UT3.UT_COMPARISON_MATCHER
100 % covered
3 relevant lines. 3 lines covered and 0 lines missed-
- -
-type body ut_comparison_matcher as
- -
-/*
- -
-utPLSQL - Version X.X.X.X
- -
-Copyright 2016 - 2017 utPLSQL Project
- -
-- -
-Licensed under the Apache License, Version 2.0 (the "License"):
- -
-you may not use this file except in compliance with the License.
- -
-You may obtain a copy of the License at
- -
-- -
-http://www.apache.org/licenses/LICENSE-2.0
- -
-- -
-Unless required by applicable law or agreed to in writing, software
- -
-distributed under the License is distributed on an "AS IS" BASIS,
- -
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- -
-See the License for the specific language governing permissions and
- -
-limitations under the License.
- -
-*/
- -
-- -
+overriding member function error_message(a_actual ut_data_value) return varchar2 is
constructor function ut_test(
+- -
+l_result varchar2(32767);
self in out nocopy ut_test, a_object_owner varchar2 := null, a_object_name varchar2, a_name varchar2,
+- +
+ +a_line_no integer, a_expected_error_codes ut_integer_list := null, a_tags ut_varchar2_rows := null
- +
+ +) return self as result is
- -
begin
- - 691 -
-if ut_utils.int_to_boolean(self.is_errored) then
- - 35 -
-l_result := 'Actual ('||a_actual.data_type||') cannot be compared to Expected ('||expected.data_type||') using matcher '''||self.name()||'''.';
- -
-end if;
- - 691 -
-return l_result;
- -
-end;
- -
-- -
end;
UT3.UT_EQUAL
100 % covered
39 relevant lines. 39 lines covered and 0 lines missed-
- -
-type body ut_equal as
- -
-/*
- -
-utPLSQL - Version X.X.X.X
- -
-Copyright 2016 - 2017 utPLSQL Project
- -
-- -
-Licensed under the Apache License, Version 2.0 (the "License"):
- -
-you may not use this file except in compliance with the License.
- -
-You may obtain a copy of the License at
- -
-- -
-http://www.apache.org/licenses/LICENSE-2.0
- -
-- -
-Unless required by applicable law or agreed to in writing, software
- -
-distributed under the License is distributed on an "AS IS" BASIS,
- -
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- -
-See the License for the specific language governing permissions and
- -
-limitations under the License.
- -
-*/
- -
-- -
-member procedure init(self in out nocopy ut_equal, a_expected ut_data_value, a_nulls_are_equal boolean) is
- -
-begin
- - 587 -
-self.nulls_are_equal_flag := ut_utils.boolean_to_int( coalesce(a_nulls_are_equal, ut_expectation_processor.nulls_are_equal()) );
- - 587 + +
- + 2461
-self.self_type := $$plsql_unit;
- - 587 -
-self.expected := a_expected;
- -
-end;
- -
-- -
-member function equal_with_nulls(a_assert_result boolean, a_actual ut_data_value) return boolean is
- -
-begin
- - 552 -
-ut_utils.debug_log('ut_equal.equal_with_nulls :' || ut_utils.to_test_result(a_assert_result) || ':');
- - 552 -
-return ( a_assert_result or ( self.expected.is_null() and a_actual.is_null() and ut_utils.int_to_boolean( nulls_are_equal_flag ) ) );
- -
-end;
- -
-- -
-constructor function ut_equal(self in out nocopy ut_equal, a_expected anydata, a_nulls_are_equal boolean := null) return self as result is
- -
-begin
- - 14 -
-init(ut_data_value_anydata.get_instance(a_expected), a_nulls_are_equal);
- - 14 + +
- + 2461 +
+ +self.init(a_object_owner, a_object_name, a_name, a_line_no);
- + 2461 +
+ +self.item := ut_executable_test(a_object_owner, a_object_name, a_name, ut_utils.gc_test_execute);
- + 2461 +
+ +self.before_each_list := ut_executables();
- + 2461 +
+ +self.before_test_list := ut_executables();
- + 2461 +
+ +self.after_test_list := ut_executables();
- + 2461 +
+ +self.after_each_list := ut_executables();
- + 2461 +
+ +self.all_expectations := ut_expectation_results();
- + 2461 +
+ +self.failed_expectations := ut_expectation_results();
- + 2461 +
+ +self.expected_error_codes := a_expected_error_codes;
- + 2461 +
+ +self.tags := coalesce(a_tags,ut_varchar2_rows());
- + 2461
+return;
- +
end;
- +
- -
+constructor function ut_equal(self in out nocopy ut_equal, a_expected blob, a_nulls_are_equal boolean := null) return self as result is
overriding member procedure mark_as_skipped(self in out nocopy ut_test) is
+- -
begin
- - 15 -
-init(ut_data_value_blob(a_expected), a_nulls_are_equal);
- - 15 -
-return;
- + +
- + 13 +
+ +ut_event_manager.trigger_event(ut_event_manager.gc_before_test, self);
- + 13 +
+ +self.start_time := current_timestamp;
- + 13 +
+ +self.result := ut_utils.gc_disabled;
- + 13 +
+ +ut_utils.debug_log('ut_test.execute - disabled');
- + 13 +
+ +self.results_count.set_counter_values(self.result);
- + 13 +
+ +self.end_time := self.start_time;
- + 13 +
+ +ut_event_manager.trigger_event(ut_event_manager.gc_after_test, self);
- -
end;
- -
-- -
-constructor function ut_equal(self in out nocopy ut_equal, a_expected boolean, a_nulls_are_equal boolean := null) return self as result is
- -
-begin
- - 15 -
-init(ut_data_value_boolean(a_expected), a_nulls_are_equal);
- - 15 -
+return;
- -
-end;
- + +
- +
+overriding member function do_execute(self in out nocopy ut_test) return boolean is
- -
+constructor function ut_equal(self in out nocopy ut_equal, a_expected clob, a_nulls_are_equal boolean := null) return self as result is
l_no_errors boolean;
+- +
+ +l_savepoint varchar2(30);
- -
begin
- - 15 -
-init(ut_data_value_clob(a_expected), a_nulls_are_equal);
- - 15 -
-return;
- -
+ +end;
- +
+ +- + 356 +
+ut_utils.debug_log('ut_test.execute');
- -
- -
-constructor function ut_equal(self in out nocopy ut_equal, a_expected date, a_nulls_are_equal boolean := null) return self as result is
- -
-begin
- - 15 -
-init(ut_data_value_date(a_expected), a_nulls_are_equal);
- - 15 -
-return;
- -
+ +end;
- + 356 +
+ +if self.get_disabled_flag() then
- + 11 +
+ +mark_as_skipped();
- +
+ +else
- + 345 +
+ +self.start_time := current_timestamp;
- + 346 +
+ut_event_manager.trigger_event(ut_event_manager.gc_before_test, self);
- -
- -
+ +constructor function ut_equal(self in out nocopy ut_equal, a_expected number, a_nulls_are_equal boolean := null) return self as result is
- + 345 +
+l_savepoint := self.create_savepoint_if_needed();
- -
-begin
- - 276 -
-init(ut_data_value_number(a_expected), a_nulls_are_equal);
- - 276 -
-return;
- -
-end;
- -
- -
+ +constructor function ut_equal(self in out nocopy ut_equal, a_expected sys_refcursor, a_exclude varchar2 := null, a_nulls_are_equal boolean := null) return self as result is
- +
+ +--includes listener calls for before and after actions
- + 345 +
+ +l_no_errors := true;
- + 345 +
+ +for i in 1 .. self.before_each_list.count loop
- + 35 +
+ +l_no_errors := self.before_each_list(i).do_execute(self);
- + 35 +
+exit when not l_no_errors;
- -
-begin
- - 11 -
-init(ut_data_value_refcursor(a_expected, a_exclude), a_nulls_are_equal);
- - 11 -
-return;
- -
-end;
- +
+ +end loop;
- -
- -
+ +constructor function ut_equal(self in out nocopy ut_equal, a_expected sys_refcursor, a_exclude ut_varchar2_list, a_nulls_are_equal boolean := null) return self as result is
- + 345 +
+ +if l_no_errors then
- + 342 +
+ +for i in 1 .. self.before_test_list.count loop
- + 30 +
+ +l_no_errors := self.before_test_list(i).do_execute(self);
- + 30 +
+exit when not l_no_errors;
- -
-begin
- - 2 -
-init(ut_data_value_refcursor(a_expected, a_exclude), a_nulls_are_equal);
- - 2 -
-return;
- -
-end;
- +
+ +end loop;
- + +
- + 342 +
+ +if l_no_errors then
- +
+ +-- execute the test
- + 337 +
+self.item.do_execute(self, self.expected_error_codes);
- -
+constructor function ut_equal(self in out nocopy ut_equal, a_expected timestamp_unconstrained, a_nulls_are_equal boolean := null) return self as result is
+
- -
-begin
- - 17 -
-init(ut_data_value_timestamp(a_expected), a_nulls_are_equal);
- +
+ +end if;
- +
+ +-- perform cleanup regardless of the test or setup failure
- + 359 +
+ +for i in 1 .. self.after_test_list.count loop
- 17 -
-return;
- -
+end;
self.after_test_list(i).do_execute(self);
+- -
+end loop;
+- -
+constructor function ut_equal(self in out nocopy ut_equal, a_expected timestamp_tz_unconstrained, a_nulls_are_equal boolean := null) return self as result is
end if;
+- -
-begin
- - 15 -
-init(ut_data_value_timestamp_tz(a_expected), a_nulls_are_equal);
- - 15 -
-return;
- -
-end;
- + +
- + 387 +
+ +for i in 1 .. self.after_each_list.count loop
- + 42 +
+ +self.after_each_list(i).do_execute(self);
- +
+ +end loop;
- + 345 +
+self.rollback_to_savepoint(l_savepoint);
- -
-constructor function ut_equal(self in out nocopy ut_equal, a_expected timestamp_ltz_unconstrained, a_nulls_are_equal boolean := null) return self as result is
- -
-begin
- - 15 -
-init(ut_data_value_timestamp_ltz(a_expected), a_nulls_are_equal);
- - 15 -
-return;
- -
-end;
- + +
- + 345 +
+ +self.calc_execution_result();
- + 345 +
+ +self.end_time := current_timestamp;
- + 345 +
+ +ut_event_manager.trigger_event(ut_event_manager.gc_after_test, self);
- +
+ +end if;
- + 356 +
+return l_no_errors;
- -
-constructor function ut_equal(self in out nocopy ut_equal, a_expected varchar2, a_nulls_are_equal boolean := null) return self as result is
- -
-begin
- - 147 -
-init(ut_data_value_varchar2(a_expected), a_nulls_are_equal);
- - 147 -
-return;
- -
end;
- + +
- -
- -
-constructor function ut_equal(self in out nocopy ut_equal, a_expected yminterval_unconstrained, a_nulls_are_equal boolean := null) return self as result is
- + +
- +
+ +overriding member procedure calc_execution_result(self in out nocopy ut_test) is
- +
+ +l_warnings ut_varchar2_rows;
- -
begin
- - 15 -
-init(ut_data_value_yminterval(a_expected), a_nulls_are_equal);
- - 15 -
+ +return;
- + 347 +
+ +if self.get_error_stack_traces().count = 0 then
- + 261 +
+ +self.result := ut_expectation_processor.get_status();
- +
+ +else
- + 86 +
+ +self.result := ut_utils.gc_error;
- +
+end if;
- -
-end;
- -
-- -
-constructor function ut_equal(self in out nocopy ut_equal, a_expected dsinterval_unconstrained, a_nulls_are_equal boolean := null) return self as result is
- -
-begin
- - 15 -
-init(ut_data_value_dsinterval(a_expected), a_nulls_are_equal);
- - 15 -
-return;
- -
-end;
- -
+--expectation results need to be part of test results
+ +- + 347 +
+ +self.all_expectations := ut_expectation_processor.get_all_expectations();
- + 347 +
+ +self.failed_expectations := ut_expectation_processor.get_failed_expectations();
- + 347 +
+ +l_warnings := coalesce( ut_expectation_processor.get_warnings(), ut_varchar2_rows() );
- + 347 +
+ +self.warnings := self.warnings multiset union all l_warnings;
- + 347 +
+ +self.results_count.increase_warning_count( cardinality(l_warnings) );
- + 347 +
+ +self.results_count.set_counter_values(self.result);
- + 347 +
+ut_expectation_processor.clear_expectations();
- -
+overriding member function run_matcher(self in out nocopy ut_equal, a_actual ut_data_value) return boolean is
end;
+- -
+l_result boolean;
+
- +
+ +overriding member procedure mark_as_errored(self in out nocopy ut_test, a_error_stack_trace varchar2) is
- -
begin
- - 587 -
-if self.expected.data_type = a_actual.data_type then
- - 552 -
-l_result := equal_with_nulls((self.expected = a_actual), a_actual);
- -
-else
- - 35 -
-l_result := (self as ut_matcher).run_matcher(a_actual);
- -
-end if;
- - 587 -
-return l_result;
- -
-end;
- -
+ +- + 2 +
+ +ut_utils.debug_log('ut_test.fail');
- + 2 +
+ +ut_event_manager.trigger_event(ut_event_manager.gc_before_test, self);
- + 2 +
+ +self.start_time := current_timestamp;
- + 2 +
+ +self.parent_error_stack_trace := a_error_stack_trace;
- + 2 +
+ +self.calc_execution_result();
- + 2 +
+ +self.end_time := self.start_time;
- + 2 +
+ut_event_manager.trigger_event(ut_event_manager.gc_after_test, self);
- -
+overriding member function failure_message(a_actual ut_data_value) return varchar2 is
end;
+- -
+l_result varchar2(32767);
+
- -
-begin
- - 529 -
+return (self as ut_matcher).failure_message(a_actual) || ': '|| expected.to_string_report();
overriding member function get_error_stack_traces(self ut_test) return ut_varchar2_list is
+ +- + 424 +
+l_stack_traces ut_varchar2_list := ut_varchar2_list();
- -
-end;
- -
-- -
-overriding member function failure_message_when_negated(a_actual ut_data_value) return varchar2 is
- -
+l_result varchar2(32767);
begin
+ +- + 424 +
+ +ut_utils.append_to_list(l_stack_traces, self.parent_error_stack_trace);
- + 466 +
+ +for i in 1 .. before_each_list.count loop
- + 42 +
+ut_utils.append_to_list(l_stack_traces, self.before_each_list(i).get_error_stack_trace());
- +
+ +end loop;
- + 464 +
+ +for i in 1 .. before_test_list.count loop
- + 40 +
+ +ut_utils.append_to_list(l_stack_traces, self.before_test_list(i).get_error_stack_trace());
- +
+ +end loop;
- + 424 +
+ +ut_utils.append_to_list(l_stack_traces, self.item.get_error_stack_trace());
- + 441 +
+ +for i in 1 .. after_test_list.count loop
- + 17 +
+ +ut_utils.append_to_list(l_stack_traces, self.after_test_list(i).get_error_stack_trace());
- +
+ +end loop;
- + 475 +
+ +for i in 1 .. after_each_list.count loop
- + 51 +
+ +ut_utils.append_to_list(l_stack_traces, self.after_each_list(i).get_error_stack_trace());
- +
+ +end loop;
- + 424 +
+ +return l_stack_traces;
- +
+ +end;
- +
+ +overriding member function get_serveroutputs return clob is
- +
+ +l_outputs clob;
- -
begin
- - 23 -
-return (self as ut_matcher).failure_message_when_negated(a_actual) || ': '|| expected.to_string_report();
- + +
- + 278 +
+ +for i in 1 .. before_each_list.count loop
- + 24 +
+ +ut_utils.append_to_clob(l_outputs, self.before_each_list(i).serveroutput);
- +
+ +end loop;
- + 278 +
+ +for i in 1 .. before_test_list.count loop
- + 24 +
+ +ut_utils.append_to_clob(l_outputs, self.before_test_list(i).serveroutput);
- +
+ +end loop;
- + 254 +
+ +ut_utils.append_to_clob(l_outputs, self.item.serveroutput );
- + 263 +
+ +for i in 1 .. after_test_list.count loop
- + 9 +
+ +ut_utils.append_to_clob(l_outputs, self.after_test_list(i).serveroutput);
- +
+ +end loop;
- + 285 +
+ +for i in 1 .. after_each_list.count loop
- + 31 +
+ +ut_utils.append_to_clob(l_outputs, self.after_each_list(i).serveroutput);
- +
+ +end loop;
- + 254 +
+ +return l_outputs;
- -
end;
- + +
- -
- -
end;
+UT3.UT_MATCH
100 % covered
20 relevant lines. 20 lines covered and 0 lines missed+ +
- +
+ +member function get_failed_expectation_lines return ut_varchar2_rows is
- +
+ +l_results ut_varchar2_rows;
- +
+ +begin
- + 34 +
+ +for i in 1 .. failed_expectations.count loop
- + 17 +
+ +ut_utils.append_to_list( l_results, ut_utils.convert_collection( failed_expectations(i).get_result_lines() ) );
- + 17 +
+ +ut_utils.append_to_list( l_results, failed_expectations(i).caller_info );
- +
+ +end loop;
- + 17 +
+ +return l_results;
- +
+ +end;
- +
+end;
UT3.UT_EXPECTATION_PROCESSOR
100 % lines covered
71 relevant lines. 71 lines covered and 0 lines missed+
- -
+type body ut_match as
package body ut_expectation_processor as
+- +
/*
- -
+utPLSQL - Version X.X.X.X
utPLSQL - Version 3
+- -
+Copyright 2016 - 2017 utPLSQL Project
Copyright 2016 - 2019 utPLSQL Project
+- +
- +
Licensed under the Apache License, Version 2.0 (the "License"):
- +
you may not use this file except in compliance with the License.
- +
You may obtain a copy of the License at
- +
- +
http://www.apache.org/licenses/LICENSE-2.0
- +
- +
Unless required by applicable law or agreed to in writing, software
- +
distributed under the License is distributed on an "AS IS" BASIS,
- +
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
See the License for the specific language governing permissions and
- +
limitations under the License.
- +
*/
- +
- -
+constructor function ut_match(self in out nocopy ut_match, a_pattern in varchar2, a_modifiers in varchar2 default null) return self as result is
type tt_nls_params is table of nls_session_parameters%rowtype;
+- -
-begin
- - 17 -
-self.self_type := $$plsql_unit;
- - 17 -
-self.pattern := a_pattern;
- - 17 -
-self.modifiers := a_modifiers;
- - 17 -
-return;
- -
+end;
+ +
- +
+ +g_session_params tt_nls_params;
- +
+ +- + 1 +
+ +g_expectations_called ut_expectation_results := ut_expectation_results();
- +
+ +- + 1 +
+g_warnings ut_varchar2_rows := ut_varchar2_rows();
- -
- -
+ +overriding member function run_matcher(self in out nocopy ut_match, a_actual ut_data_value) return boolean is
- + 1 +
+g_nulls_are_equal boolean_not_null := gc_default_nulls_are_equal;
- -
-l_result boolean;
- +
+ +- + 1 +
+ +g_package_invalidated boolean := false;
- +
+ +- +
+ +function nulls_are_equal return boolean is
- -
begin
- - 17 -
-if a_actual is of (ut_data_value_varchar2) then
- - 8 -
-l_result := regexp_like(treat(a_actual as ut_data_value_varchar2).data_value, pattern, modifiers);
- - 9 -
-elsif a_actual is of (ut_data_value_clob) then
- - 8 -
+ +l_result := regexp_like(treat(a_actual as ut_data_value_clob).data_value, pattern, modifiers);
- + 373 +
+return g_nulls_are_equal;
- -
-else
- - 1 -
-l_result := (self as ut_matcher).run_matcher(a_actual);
- -
-end if;
- - 17 -
-return l_result;
- -
end;
- + +
- -
- -
-overriding member function failure_message(a_actual ut_data_value) return varchar2 is
- -
-l_result varchar2(32767);
- + +
- +
+ +procedure nulls_are_equal(a_setting boolean_not_null) is
- -
begin
- - 8 -
-l_result := (self as ut_matcher).failure_message(a_actual);
- - 8 -
-if self.modifiers is not null then
- - 4 -
-l_result := l_result || ': '|| ut_data_value_varchar2(self.pattern).to_string_report(true, false) || ', modifiers ''' || self.modifiers ||'''';
- -
-else
- + +
- 4 -
-l_result := l_result || ': '|| ut_data_value_varchar2(self.pattern).to_string_report(false, false);
- -
-end if;
- - 8 -
-return l_result;
- +
+ +g_nulls_are_equal := a_setting;
- -
end;
- + +
- -
- -
-overriding member function failure_message_when_negated(a_actual ut_data_value) return varchar2 is
- -
-l_result varchar2(32767);
- + +
- +
+ +function get_status return integer is
- + 261 +
+ +l_result integer := ut_utils.gc_success;
- -
begin
- - 8 -
-l_result := (self as ut_matcher).failure_message_when_negated(a_actual);
- - 8 -
-if self.modifiers is not null then
- - 4 -
-l_result := l_result || ': '|| ut_data_value_varchar2(self.pattern).to_string_report(true, false) || ', modifiers ''' || self.modifiers ||'''';
- -
-else
- - 4 -
-l_result := l_result || ': '|| ut_data_value_varchar2(self.pattern).to_string_report(false, false);
- -
-end if;
- - 8 -
-return l_result;
- -
-end;
- -
-- -
end;
UT3.UT_MATCHER
100 % covered
12 relevant lines. 12 lines covered and 0 lines missed-
- -
-type body ut_matcher as
- -
-/*
- -
-utPLSQL - Version X.X.X.X
- -
-Copyright 2016 - 2017 utPLSQL Project
- -
-- -
-Licensed under the Apache License, Version 2.0 (the "License"):
- -
-you may not use this file except in compliance with the License.
- -
-You may obtain a copy of the License at
- -
-- -
-http://www.apache.org/licenses/LICENSE-2.0
- -
-- -
-Unless required by applicable law or agreed to in writing, software
- -
-distributed under the License is distributed on an "AS IS" BASIS,
- -
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- -
-See the License for the specific language governing permissions and
- -
-limitations under the License.
- -
-*/
- -
-- -
-member function run_matcher(self in out nocopy ut_matcher, a_actual ut_data_value) return boolean is
- -
-begin
- - 41 -
-ut_utils.debug_log('Failure - ut_matcher.run_matcher'||'(a_actual '||a_actual.data_type||')');
- - 41 -
-self.is_errored := ut_utils.boolean_to_int(true);
- -
--- self.error_message := 'The matcher '''||name()||''' cannot be used';
- -
--- if self.expected is not null then
- -
--- self.error_message := self.error_message ||' for comparison of data type ('||self.expected.data_type||')';
- -
--- end if;
- -
--- self.error_message := self.error_message ||' with data type ('||a_actual.data_type||').';
- - 41 -
-return null;
- -
-end;
- -
-- -
-member function run_matcher_negated(self in out nocopy ut_matcher, a_actual ut_data_value) return boolean is
- -
-begin
- - 138 -
-return not run_matcher(a_actual);
- -
-end;
- -
-- -
-member function name return varchar2 is
- -
-begin
- - 942 -
-return replace(ltrim(lower(self.self_type),'ut_'),'_',' ');
- -
-end;
- -
-- -
-member function description return varchar2 is
- -
-begin
- - 780 -
-return 'was expected to '||name();
- -
+ +end;
- + 261 +
+ut_utils.debug_log('ut_expectation_processor.get_status');
- -
- -
-member function description_when_negated return varchar2 is
- -
-begin
- - 121 -
+ +return 'was expected not to '||name();
- + 261 +
+ +for i in 1 .. g_expectations_called.count loop
- + 82 +
+ +l_result := greatest(l_result, g_expectations_called(i).status);
- + 82 +
+exit when l_result = ut_utils.gc_error;
- -
-end;
- -
+end loop;
+ +- + 261 +
+return l_result;
- -
+member function error_message(a_actual ut_data_value) return varchar2 is
end get_status;
+- -
+l_result varchar2(32767);
+
- +
+ +procedure clear_expectations is
- -
begin
- - 251 -
-if ut_utils.int_to_boolean(self.is_errored) then
- - 6 -
-l_result := 'The matcher '''||name()||''' cannot be used with data type ('||a_actual.data_type||').';
- -
-end if;
- - 251 -
+ +return l_result;
- + 1188 +
+ +ut_utils.debug_log('ut_expectation_processor.clear_expectations');
- + 1188 +
+ +g_expectations_called.delete;
- + 1188 +
+g_warnings.delete;
- +
end;
- +
- -
+member function failure_message(a_actual ut_data_value) return varchar2 is
function get_all_expectations return ut_expectation_results is
+- -
begin
- - 780 -
-return 'Actual: ' || a_actual.to_string_report(true) || description();
- -
+ +end;
- + 347 +
+ +ut_utils.debug_log('ut_expectation_processor.get_all_expectations: g_expectations_called.count='||g_expectations_called.count);
- + 347 +
+return g_expectations_called;
- -
+end get_all_expectations;
+- -
+member function failure_message_when_negated(a_actual ut_data_value) return varchar2 is
+
- -
-begin
- - 121 -
+return 'Actual: ' || a_actual.to_string_report(true) || description_when_negated();
function get_failed_expectations return ut_expectation_results is
+ +- + 1039 +
+l_expectations_results ut_expectation_results := ut_expectation_results();
- -
-end;
- -
-- -
end;
UT3.UT_EXPECTATION
94.74 % covered
76 relevant lines. 72 lines covered and 4 lines missed-
- -
-type body ut_expectation as
- -
-/*
- -
-utPLSQL - Version X.X.X.X
- -
-Copyright 2016 - 2017 utPLSQL Project
- -
-- -
-Licensed under the Apache License, Version 2.0 (the "License"):
- -
-you may not use this file except in compliance with the License.
- -
-You may obtain a copy of the License at
- -
-- -
-http://www.apache.org/licenses/LICENSE-2.0
- -
-- -
-Unless required by applicable law or agreed to in writing, software
- -
-distributed under the License is distributed on an "AS IS" BASIS,
- -
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- -
-See the License for the specific language governing permissions and
- -
-limitations under the License.
- -
-*/
- -
-member procedure to_equal(self in ut_expectation, a_expected anydata, a_nulls_are_equal boolean := null) is
- -
begin
- - 2 -
-ut_utils.debug_log('ut_expectation.to_equal(self in ut_expectation, a_expected anydata, a_nulls_are_equal boolean := null)');
- - 2 -
-self.to_( ut_equal(a_expected, a_nulls_are_equal) );
- -
-end;
- + +
- + 1039 +
+ +ut_utils.debug_log('ut_expectation_processor.get_failed_expectations: g_expectations_called.count='||g_expectations_called.count);
- + 1813 +
+ +for i in 1 .. g_expectations_called.count loop
- + 774 +
+ +if g_expectations_called(i).status > ut_utils.gc_success then
- + 423 +
+ +l_expectations_results.extend;
- + 423 +
+ +l_expectations_results(l_expectations_results.last) := g_expectations_called(i);
- +
+ +end if;
- +
+ +end loop;
- + 1039 +
+ +ut_utils.debug_log('ut_expectation_processor.get_failed_expectations: l_expectations_results.count='||l_expectations_results.count);
- + 1039 +
+ +return l_expectations_results;
- +
+ +end get_failed_expectations;
- -
- -
-member procedure to_equal(self in ut_expectation, a_expected blob, a_nulls_are_equal boolean := null) is
- + +
- +
+ +procedure add_expectation_result(a_expectation_result ut_expectation_result) is
- +
+ +l_results ut_varchar2_list;
- -
begin
- - 1 -
-ut_utils.debug_log('ut_expectation.to_equal(self in ut_expectation, a_expected blob, a_nulls_are_equal boolean := null)');
- - 1 -
-self.to_( ut_equal(a_expected, a_nulls_are_equal) );
- -
-end;
- -
-- -
-member procedure to_equal(self in ut_expectation, a_expected boolean, a_nulls_are_equal boolean := null) is
- -
-begin
- - 1 -
-ut_utils.debug_log('ut_expectation.to_equal(self in ut_expectation, a_expected boolean, a_nulls_are_equal boolean := null)');
- - 1 -
-self.to_( ut_equal(a_expected, a_nulls_are_equal) );
- -
-end;
- -
-- -
-member procedure to_equal(self in ut_expectation, a_expected clob, a_nulls_are_equal boolean := null) is
- -
-begin
- - 1 -
-ut_utils.debug_log('ut_expectation.to_equal(self in ut_expectation, a_expected clob, a_nulls_are_equal boolean := null)');
- - 1 -
-self.to_( ut_equal(a_expected, a_nulls_are_equal) );
- -
-end;
- -
-- -
-member procedure to_equal(self in ut_expectation, a_expected date, a_nulls_are_equal boolean := null) is
- -
-begin
- - 1 -
-ut_utils.debug_log('ut_expectation.to_equal(self in ut_expectation, a_expected date, a_nulls_are_equal boolean := null)');
- - 1 -
-self.to_( ut_equal(a_expected, a_nulls_are_equal) );
- -
-end;
- -
-- -
-member procedure to_equal(self in ut_expectation, a_expected number, a_nulls_are_equal boolean := null) is
- -
-begin
- - 1 -
-ut_utils.debug_log('ut_expectation.to_equal(self in ut_expectation, a_expected number, a_nulls_are_equal boolean := null)');
- - 1 -
-self.to_( ut_equal(a_expected, a_nulls_are_equal) );
- -
-end;
- -
-- -
-member procedure to_equal(self in ut_expectation, a_expected sys_refcursor, a_exclude varchar2 := null, a_nulls_are_equal boolean := null) is
- -
-begin
- - 1 -
-ut_utils.debug_log('ut_expectation.to_equal(self in ut_expectation, a_expected sys_refcursor, a_exclude varchar2 := null, a_nulls_are_equal boolean := null)');
- - 1 -
-self.to_( ut_equal(a_expected, a_exclude, a_nulls_are_equal) );
- -
-end;
- -
-- -
-member procedure to_equal(self in ut_expectation, a_expected sys_refcursor, a_exclude ut_varchar2_list, a_nulls_are_equal boolean := null) is
- -
-begin
- - 2 -
-ut_utils.debug_log('ut_expectation.to_equal(self in ut_expectation, a_expected sys_refcursor, a_exclude ut_varchar2_list, a_nulls_are_equal boolean := null)');
- - 2 -
-self.to_( ut_equal(a_expected, a_exclude, a_nulls_are_equal) );
- -
-end;
- -
-- -
-member procedure to_equal(self in ut_expectation, a_expected timestamp_unconstrained, a_nulls_are_equal boolean := null) is
- -
-begin
- - 2 -
-ut_utils.debug_log('ut_expectation.to_equal(self in ut_expectation, a_expected timestamp_unconstrained, a_nulls_are_equal boolean := null)');
- - 2 -
-self.to_( ut_equal(a_expected, a_nulls_are_equal) );
- -
-end;
- -
-- -
-member procedure to_equal(self in ut_expectation, a_expected timestamp_ltz_unconstrained, a_nulls_are_equal boolean := null) is
- -
-begin
- - 1 -
-ut_utils.debug_log('ut_expectation.to_equal(self in ut_expectation, a_expected timestamp_ltz_unconstrained, a_nulls_are_equal boolean := null)');
- - 1 -
-self.to_( ut_equal(a_expected, a_nulls_are_equal) );
- -
-end;
- -
-- -
-member procedure to_equal(self in ut_expectation, a_expected timestamp_tz_unconstrained, a_nulls_are_equal boolean := null) is
- -
-begin
- - 1 -
-ut_utils.debug_log('ut_expectation.to_equal(self in ut_expectation, a_expected timestamp_tz_unconstrained, a_nulls_are_equal boolean := null)');
- - 1 -
-self.to_( ut_equal(a_expected, a_nulls_are_equal) );
- -
-end;
- -
-- -
-member procedure to_equal(self in ut_expectation, a_expected varchar2, a_nulls_are_equal boolean := null) is
- -
-begin
- - 2 -
-ut_utils.debug_log('ut_expectation.to_equal(self in ut_expectation, a_expected varchar2, a_nulls_are_equal boolean := null)');
- + +
- + 799 +
+ +if ut_session_context.is_ut_run then
- + 794 +
+ +ut_event_manager.trigger_event(ut_event_manager.gc_debug, a_expectation_result);
- + 793 +
+ +g_expectations_called.extend;
- + 793 +
+ +g_expectations_called(g_expectations_called.last) := a_expectation_result;
- +
+ +else
- + 6 +
+ +l_results := a_expectation_result.get_result_lines();
- + 6 +
+ +dbms_output.put_line( upper( ut_utils.test_result_to_char( a_expectation_result.status ) ) || '');
- + 12 +
+ +for i in 1 .. l_results.count loop
- + 6 +
+ +dbms_output.put_line( ' ' || l_results(i) );
- +
+ +end loop;
- + 6 +
+ +if a_expectation_result.caller_info is not null then
- 2 -
-self.to_( ut_equal(a_expected, a_nulls_are_equal) );
- -
-end;
- -
-- -
-member procedure to_equal(self in ut_expectation, a_expected yminterval_unconstrained, a_nulls_are_equal boolean := null) is
- -
-begin
- - 1 -
-ut_utils.debug_log('ut_expectation.to_equal(self in ut_expectation, a_expected yminterval_unconstrained, a_nulls_are_equal boolean := null)');
- - 1 -
-self.to_( ut_equal(a_expected, a_nulls_are_equal) );
- -
+end;
dbms_output.put_line( ut_utils.indent_lines( a_expectation_result.caller_info, 2, true) );
+- -
+end if;
+- -
+member procedure to_equal(self in ut_expectation, a_expected dsinterval_unconstrained, a_nulls_are_equal boolean := null) is
end if;
+- -
-begin
- - 1 -
-ut_utils.debug_log('ut_expectation.to_equal(self in ut_expectation, a_expected dsinterval_unconstrained, a_nulls_are_equal boolean := null)');
- - 1 -
-self.to_( ut_equal(a_expected, a_nulls_are_equal) );
- -
end;
- + +
- + +
- +
+ +procedure report_failure(a_message in varchar2) is
- +
+ +begin
- + 1 +
+add_expectation_result(ut_expectation_result(ut_utils.gc_failure, null, a_message));
- -
+final member procedure to_(self in ut_expectation, a_matcher ut_matcher) is
end;
+- -
-l_expectation_result boolean;
- - 804 -
+l_matcher ut_matcher := a_matcher;
+ +
- +
+function get_session_parameters return tt_nls_params is
- -
+l_message varchar2(32767);
l_session_params tt_nls_params;
+- -
begin
- - 804 -
+ +ut_utils.debug_log('ut_expectation.to_(self in ut_expectation, a_matcher ut_matcher)');
- + 397 +
+select nsp.parameter, nsp.value
- -
-- - 804 -
-l_expectation_result := l_matcher.run_matcher( self.actual_data );
- - 804 -
-l_expectation_result := coalesce(l_expectation_result,false);
- - 804 -
-l_message := coalesce( l_matcher.error_message( self.actual_data ), l_matcher.failure_message( self.actual_data ) );
- - 804 -
+ut_expectation_processor.add_expectation_result( ut_expectation_result( ut_utils.to_test_result( l_expectation_result ), self.description, l_message ) );
bulk collect into l_session_params
+ +- +
+ +from nls_session_parameters nsp
- +
+ +where parameter
- +
+ +in ( 'NLS_DATE_FORMAT', 'NLS_TIMESTAMP_FORMAT', 'NLS_TIMESTAMP_TZ_FORMAT')
- +
+order by 1;
- -
-end;
- + +
- + 397 +
+return l_session_params;
- -
+final member procedure not_to(self in ut_expectation, a_matcher ut_matcher) is
end;
+- -
-l_expectation_result boolean;
- - 138 -
+l_matcher ut_matcher := a_matcher;
+ +
- +
+procedure set_xml_nls_params is
- -
+l_message varchar2(32767);
insuf_privs exception;
+- +
+ +pragma exception_init(insuf_privs, -1031);
- -
begin
- - 138 -
-ut_utils.debug_log('ut_expectation.not_to(self in ut_expectation, a_matcher ut_matcher)');
- -
-- - 138 -
-l_expectation_result := l_matcher.run_matcher_negated( self.actual_data );
- - 138 -
-l_expectation_result := coalesce(l_expectation_result,false);
- - 138 -
-l_message := coalesce( l_matcher.error_message( self.actual_data ), l_matcher.failure_message_when_negated( self.actual_data ) );
- - 138 -
-ut_expectation_processor.add_expectation_result( ut_expectation_result( ut_utils.to_test_result( l_expectation_result ), self.description, l_message ) );
- -
-end;
- + +
- + 397 +
+ +g_session_params := get_session_parameters();
- -
- -
-final member procedure to_be_null(self in ut_expectation) is
- -
-begin
- - 39 -
-ut_utils.debug_log('ut_expectation.to_be_null');
- - 39 -
-self.to_( ut_be_null() );
- + +
- +
+ +begin
- + 397 +
+ +execute immediate q'[alter session set events '19119 trace name context forever, level 0x8']';
- +
+ +exception
- + 1191 +
+ +when insuf_privs then NULL;
- +
+ +end;
- +
+ +- + 397 +
+ +execute immediate 'alter session set nls_timestamp_format = '''||ut_utils.gc_timestamp_format||'''';
- + 397 +
+ +execute immediate 'alter session set nls_timestamp_tz_format = '''||ut_utils.gc_timestamp_tz_format||'''';
- -
end;
- + +
- + +
- +
+procedure reset_nls_params is
- -
+final member procedure to_be_not_null(self in ut_expectation) is
insuf_privs exception;
+- +
+ +pragma exception_init(insuf_privs, -1031);
- -
begin
- - 18 -
-ut_utils.debug_log('ut_expectation.to_be_not_null');
- - 18 -
-self.to_( ut_be_not_null() );
- -
+ +end;
- +
+ +begin
- + 397 +
+execute immediate q'[alter session set events '19119 trace name context off']';
- -
-- -
+final member procedure not_to_be_null(self in ut_expectation) is
exception
+ +- + 1191 +
+when insuf_privs then NULL;
- -
-begin
- - 18 -
-ut_utils.debug_log('ut_expectation.to_be_null');
- - 18 -
-self.not_to( ut_be_null() );
- -
-end;
- +
+ +end;
- + +
- + 397 +
+ +if g_session_params is not null then
- + 1588 +
+ +for i in 1 .. g_session_params.count loop
- + 1191 +
+execute immediate 'alter session set '||g_session_params(i).parameter||' = '''||g_session_params(i).value||'''';
- -
+final member procedure not_to_be_not_null(self in ut_expectation) is
end loop;
+- -
-begin
- -
-ut_utils.debug_log('ut_expectation.to_be_not_null');
- -
-self.not_to( ut_be_not_null() );
- +
+ +end if;
- +
+ +- -
end;
- + +
- + +
- +
+function who_called_expectation(a_call_stack varchar2) return varchar2 is
- -
+member procedure not_to_equal(self in ut_expectation, a_expected anydata, a_nulls_are_equal boolean := null) is
l_caller_stack_line varchar2(4000);
+- -
-begin
- - 2 -
-ut_utils.debug_log('ut_expectation.not_to_equal(self in ut_expectation, a_expected anydata, a_nulls_are_equal boolean := null)');
- - 2 -
+self.not_to( ut_equal(a_expected, a_nulls_are_equal) );
l_call_stack varchar2(4000);
+ +- +
+ +l_line_no integer;
- +
+l_owner varchar2(1000);
- -
+end;
l_object_name varchar2(1000);
+- -
+l_result varchar2(4000);
+- -
+member procedure not_to_equal(self in ut_expectation, a_expected blob, a_nulls_are_equal boolean := null) is
-- in 12.2 format_call_stack reportes not only package name, but also the procedure name
+- -
-begin
- - 1 -
-ut_utils.debug_log('ut_expectation.not_to_equal(self in ut_expectation, a_expected blob, a_nulls_are_equal boolean := null)');
- - 1 -
-self.not_to( ut_equal(a_expected, a_nulls_are_equal) );
- -
+end;
-- when 11g and 12c reports only package name
+ +- +
+ +function cut_header_and_expectations( a_stack varchar2 ) return varchar2 is
- +
+ +begin
- + 450 +
+return regexp_substr( a_stack, '(.*\.(UT_EXPECTATION[A-Z0-9#_$]*|UT|UTASSERT2?)(\.[A-Z0-9#_$]+)?\s+)+((.|\s)*)', 1, 1, 'm', 4);
- -
+end;
+- -
+member procedure not_to_equal(self in ut_expectation, a_expected boolean, a_nulls_are_equal boolean := null) is
function cut_address_columns( a_stack varchar2 ) return varchar2 is
+- -
-begin
- - 1 -
-ut_utils.debug_log('ut_expectation.not_to_equal(self in ut_expectation, a_expected boolean, a_nulls_are_equal boolean := null)');
- - 1 -
+self.not_to( ut_equal(a_expected, a_nulls_are_equal) );
begin
+ +- + 450 +
+ +return regexp_replace( a_stack, '^(0x)?[0-9a-f]+\s+', '', 1, 0, 'm' );
- +
+end;
- -
+end;
function cut_framework_stack( a_stack varchar2 ) return varchar2 is
+- -
-- -
+member procedure not_to_equal(self in ut_expectation, a_expected clob, a_nulls_are_equal boolean := null) is
begin
+ +- + 450 +
+return regexp_replace(
- -
-begin
- - 1 -
-ut_utils.debug_log('ut_expectation.not_to_equal(self in ut_expectation, a_expected clob, a_nulls_are_equal boolean := null)');
- - 1 -
+self.not_to( ut_equal(a_expected, a_nulls_are_equal) );
a_stack,
+ +- +
+ +'[0-9]+\s+anonymous\s+block\s+[0-9]+\s+package\s+body\s+sys\.dbms_sql(\.execute)?\s+[0-9]+\s+[0-9_$#a-z ]+\.ut_executable.*',
- +
+'',
- -
+end;
1, 1, 'mni'
+- -
+);
+- -
+member procedure not_to_equal(self in ut_expectation, a_expected date, a_nulls_are_equal boolean := null) is
end;
+- -
-begin
- - 1 -
-ut_utils.debug_log('ut_expectation.not_to_equal(self in ut_expectation, a_expected date, a_nulls_are_equal boolean := null)');
- - 1 -
+self.not_to( ut_equal(a_expected, a_nulls_are_equal) );
function format_stack( a_stack varchar2 ) return varchar2 is
+ +- +
+ +begin
- + 450 +
+return regexp_replace(
- -
+end;
a_stack,
+- -
+'([0-9]+)\s+(.* )?((anonymous block)|(([0-9_$#a-z]+\.[0-9_$#a-z]+(\.([0-9_$#a-z])+)?)))',
+- -
+member procedure not_to_equal(self in ut_expectation, a_expected number, a_nulls_are_equal boolean := null) is
'at "\3", line \1', 1, 0, 'i'
+- +
+ +);
- +
+ +end;
- -
begin
- - 1 -
-ut_utils.debug_log('ut_expectation.not_to_equal(self in ut_expectation, a_expected number, a_nulls_are_equal boolean := null)');
- - 1 -
-self.not_to( ut_equal(a_expected, a_nulls_are_equal) );
- -
-end;
- -
-- -
-member procedure not_to_equal(self in ut_expectation, a_expected sys_refcursor, a_exclude varchar2 := null, a_nulls_are_equal boolean := null) is
- -
-begin
- - 1 -
-ut_utils.debug_log('ut_expectation.not_to_equal(self in ut_expectation, a_expected sys_refcursor, a_exclude varchar2 := null, a_nulls_are_equal boolean := null)');
- - 1 -
-self.not_to( ut_equal(a_expected, a_exclude, a_nulls_are_equal) );
- -
-end;
- -
-- -
-member procedure not_to_equal(self in ut_expectation, a_expected sys_refcursor, a_exclude ut_varchar2_list, a_nulls_are_equal boolean := null) is
- -
-begin
- -
-ut_utils.debug_log('ut_expectation.not_to_equal(self in ut_expectation, a_expected sys_refcursor, a_exclude ut_varchar2_list, a_nulls_are_equal boolean := null)');
- -
+ +self.not_to( ut_equal(a_expected, a_exclude, a_nulls_are_equal) );
- + 450 +
+ +l_call_stack := cut_header_and_expectations( a_call_stack );
- + 450 +
+ +l_call_stack := cut_address_columns( l_call_stack );
- + 450 +
+ +l_call_stack := cut_framework_stack( l_call_stack );
- + 450 +
+ +l_call_stack := format_stack( l_call_stack );
- + 450 +
+ +l_caller_stack_line := regexp_substr(l_call_stack,'^(.*)');
- + 450 +
+ +if l_caller_stack_line like '%.%' then
- + 195 +
+ +l_line_no := to_number( regexp_substr( l_caller_stack_line, ', line (\d+)', subexpression => 1 ) );
- + 195 +
+ +l_owner := regexp_substr( l_caller_stack_line, 'at "([A-Za-z0-9$#_]+)\.(([A-Za-z0-9$#_]+)(\.([A-Za-z0-9$#_]+))?)", line (\d+)', subexpression => 1 );
- + 195 +
+ +l_object_name := regexp_substr( l_caller_stack_line, 'at "([A-Za-z0-9$#_]+)\.(([A-Za-z0-9$#_]+)(\.([A-Za-z0-9$#_]+))?)", line (\d+)', subexpression => 3 );
- + 195 +
+ +l_result :=
- +
+ +l_caller_stack_line || ' ' || rtrim(ut_metadata.get_source_definition_line(l_owner, l_object_name, l_line_no),chr(10))
- +
+|| replace( l_call_stack, l_caller_stack_line );
- +
+ +else
- + 255 +
+ +l_result := l_call_stack;
- +
+ +end if;
- + 450 +
+ +return rtrim(l_result,chr(10));
- -
end;
- + +
- -
- -
-member procedure not_to_equal(self in ut_expectation, a_expected timestamp_unconstrained, a_nulls_are_equal boolean := null) is
- -
-begin
- - 2 -
-ut_utils.debug_log('ut_expectation.not_to_equal(self in ut_expectation, a_expected timestamp_unconstrained, a_nulls_are_equal boolean := null)');
- - 2 -
+self.not_to( ut_equal(a_expected, a_nulls_are_equal) );
- -
+end;
procedure add_warning(a_messsage varchar2) is
+- -
-- -
-member procedure not_to_equal(self in ut_expectation, a_expected timestamp_ltz_unconstrained, a_nulls_are_equal boolean := null) is
- -
begin
- - 1 -
-ut_utils.debug_log('ut_expectation.not_to_equal(self in ut_expectation, a_expected timestamp_ltz_unconstrained, a_nulls_are_equal boolean := null)');
- - 1 -
-self.not_to( ut_equal(a_expected, a_nulls_are_equal) );
- + +
- + 23 +
+ +g_warnings.extend;
- + 23 +
+ +g_warnings(g_warnings.last) := a_messsage;
- -
end;
- + +
- -
- -
-member procedure not_to_equal(self in ut_expectation, a_expected timestamp_tz_unconstrained, a_nulls_are_equal boolean := null) is
- + +
- +
+ +procedure add_depreciation_warning(a_deprecated_syntax varchar2, a_new_syntax varchar2) is
- -
begin
- - 1 -
-ut_utils.debug_log('ut_expectation.not_to_equal(self in ut_expectation, a_expected timestamp_tz_unconstrained, a_nulls_are_equal boolean := null)');
- - 1 -
+ +self.not_to( ut_equal(a_expected, a_nulls_are_equal) );
- + 17 +
+ +add_warning(
- +
+ +ut_utils.build_depreciation_warning( a_deprecated_syntax, a_new_syntax ) || chr(10)
- +
+ +|| ut_expectation_processor.who_called_expectation(dbms_utility.format_call_stack())
- +
+);
- +
end;
- +
- -
+member procedure not_to_equal(self in ut_expectation, a_expected varchar2, a_nulls_are_equal boolean := null) is
function get_warnings return ut_varchar2_rows is
+- -
begin
- - 2 -
-ut_utils.debug_log('ut_expectation.not_to_equal(self in ut_expectation, a_expected varchar2, a_nulls_are_equal boolean := null)');
- - 2 -
-self.not_to( ut_equal(a_expected, a_nulls_are_equal) );
- + +
- + 371 +
+ +return g_warnings;
- -
end;
- + +
- + +
- +
+function invalidation_exception_found return boolean is
- -
-member procedure not_to_equal(self in ut_expectation, a_expected yminterval_unconstrained, a_nulls_are_equal boolean := null) is
- -
begin
- - 1 -
-ut_utils.debug_log('ut_expectation.not_to_equal(self in ut_expectation, a_expected yminterval_unconstrained, a_nulls_are_equal boolean := null)');
- - 1 -
-self.not_to( ut_equal(a_expected, a_nulls_are_equal) );
- + +
- + 113 +
+ +return g_package_invalidated;
- -
end;
- + +
- -
- -
-member procedure not_to_equal(self in ut_expectation, a_expected dsinterval_unconstrained, a_nulls_are_equal boolean := null) is
- + +
- +
+ +procedure set_invalidation_exception is
- -
begin
- - 1 -
-ut_utils.debug_log('ut_expectation.not_to_equal(self in ut_expectation, a_expected dsinterval_unconstrained, a_nulls_are_equal boolean := null)');
- + +
- 1 -
-self.not_to( ut_equal(a_expected, a_nulls_are_equal) );
- +
+ +g_package_invalidated := true;
- -
end;
- + +
- + +
- +
+ +procedure reset_invalidation_exception is
- +
+ +begin
- + 117 +
+g_package_invalidated := false;
- -
end;
+UT3.UT_EXPECTATION_ANYDATA
75 % covered
8 relevant lines. 6 lines covered and 2 lines missed+
end;
+ +- +
+ +- +
+end;
UT3.UT_FILE_MAPPER
100 % lines covered
27 relevant lines. 27 lines covered and 0 lines missed+
- -
+type body ut_expectation_anydata as
package body ut_file_mapper is
+- +
/*
- -
+utPLSQL - Version X.X.X.X
utPLSQL - Version 3
+- -
+Copyright 2016 - 2017 utPLSQL Project
Copyright 2016 - 2019 utPLSQL Project
+- +
- +
Licensed under the Apache License, Version 2.0 (the "License"):
- +
you may not use this file except in compliance with the License.
- +
You may obtain a copy of the License at
- +
- +
http://www.apache.org/licenses/LICENSE-2.0
- +
- +
Unless required by applicable law or agreed to in writing, software
- +
distributed under the License is distributed on an "AS IS" BASIS,
- +
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
See the License for the specific language governing permissions and
- +
limitations under the License.
- +
*/
- -
+overriding member procedure to_equal(self in ut_expectation_anydata, a_expected anydata, a_nulls_are_equal boolean := null) is
+
- -
-begin
- - 10 -
-ut_utils.debug_log('ut_expectation_anydata.to_equal(self in ut_expectation_anydata, a_expected anydata, a_nulls_are_equal boolean := null)');
- - 10 -
+self.to_( ut_equal(a_expected, a_nulls_are_equal) );
type tt_key_values is table of varchar2(4000) index by varchar2(4000);
+ +- +
+ +- +
+/**
- -
+end;
* Private functions
+- -
+*/
+- -
+member procedure to_be_empty(self in ut_expectation_anydata) is
+
- +
+ +function to_hash_table(a_key_value_tab ut_key_value_pairs) return tt_key_values is
- +
+ +l_result tt_key_values;
- -
begin
- - 3 -
-ut_utils.debug_log('ut_expectation_anydata.to_be_empty(self in ut_expectation_anydata)');
- - 3 -
-self.to_( ut_be_empty() );
- -
-end;
- -
-- -
+ +overriding member procedure not_to_equal(self in ut_expectation_anydata, a_expected anydata, a_nulls_are_equal boolean := null) is
- + 31 +
+ +if a_key_value_tab is not null then
- + 217 +
+ +for i in 1 .. a_key_value_tab.count loop
- + 186 +
+l_result(upper(a_key_value_tab(i).key)) := a_key_value_tab(i).value;
- -
-begin
- -
-ut_utils.debug_log('ut_expectation_anydata.not_to_equal(self in ut_expectation_anydata, a_expected anydata, a_nulls_are_equal boolean := null)');
- -
+self.not_to( ut_equal(a_expected, a_nulls_are_equal) );
end loop;
+ +- +
+ +end if;
- + 31 +
+return l_result;
- +
end;
- +
- -
+member procedure not_to_be_empty(self in ut_expectation_anydata) is
/**
+- -
-begin
- - 3 -
-ut_utils.debug_log('ut_expectation_anydata.not_to_be_empty(self in ut_expectation_anydata)');
- - 3 -
+self.not_to( ut_be_empty() );
* Public functions
+ +- +
+ +*/
- +
+function default_file_to_obj_type_map return ut_key_value_pairs is
- -
-end;
- -
+begin
+ +- + 31 +
+return ut_key_value_pairs(
- -
+ut_key_value_pair('fnc', 'FUNCTION'),
+- -
end;
UT3.UT_EXPECTATION_BLOB
100 % covered
4 relevant lines. 4 lines covered and 0 lines missed-
- -
-type body ut_expectation_blob as
- -
-/*
- -
-utPLSQL - Version X.X.X.X
- -
-Copyright 2016 - 2017 utPLSQL Project
- -
-- -
-Licensed under the Apache License, Version 2.0 (the "License"):
- -
-you may not use this file except in compliance with the License.
- -
-You may obtain a copy of the License at
- -
-- -
-http://www.apache.org/licenses/LICENSE-2.0
- +
+ +ut_key_value_pair('prc', 'PROCEDURE'),
- +
+ +ut_key_value_pair('tpb', 'TYPE BODY'),
- +
+ +ut_key_value_pair('pkb', 'PACKAGE BODY'),
- +
+ +ut_key_value_pair('bdy', 'PACKAGE BODY'),
- +
+ +ut_key_value_pair('trg', 'TRIGGER')
- +
+ +);
- +
+ +end;
- -
- -
-Unless required by applicable law or agreed to in writing, software
- -
-distributed under the License is distributed on an "AS IS" BASIS,
- -
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- -
-See the License for the specific language governing permissions and
- -
-limitations under the License.
- -
-*/
- -
-overriding member procedure to_equal(self in ut_expectation_blob, a_expected blob, a_nulls_are_equal boolean := null) is
- -
-begin
- - 11 -
-ut_utils.debug_log('ut_expectation_blob.to_equal(self in ut_expectation, a_expected blob)');
- - 11 -
-self.to_( ut_equal(a_expected, a_nulls_are_equal) );
- + +
- +
+ +function build_file_mappings(
- +
+ +a_file_paths ut_varchar2_list,
- +
+ +a_file_to_object_type_mapping ut_key_value_pairs := null,
- +
+ +a_regex_pattern varchar2 := null,
- +
+ +a_object_owner_subexpression positive := null,
- +
+ +a_object_name_subexpression positive := null,
- +
+ +a_object_type_subexpression positive := null
- +
+ +) return ut_file_mappings is
- +
+ +begin
- + 29 +
+ +return build_file_mappings(
- +
+ +null, a_file_paths, a_file_to_object_type_mapping, a_regex_pattern,
- +
+ +a_object_owner_subexpression, a_object_name_subexpression, a_object_type_subexpression
- +
+ +);
- -
end;
- + +
- -
- -
-overriding member procedure not_to_equal(self in ut_expectation_blob, a_expected blob, a_nulls_are_equal boolean := null) is
- + +
- +
+ +function build_file_mappings(
- +
+ +a_object_owner varchar2,
- +
+ +a_file_paths ut_varchar2_list,
- +
+ +a_file_to_object_type_mapping ut_key_value_pairs := null,
- +
+ +a_regex_pattern varchar2 := null,
- +
+ +a_object_owner_subexpression positive := null,
- +
+ +a_object_name_subexpression positive := null,
- +
+ +a_object_type_subexpression positive := null
- +
+ +) return ut_file_mappings is
- + 31 +
+ +l_file_to_object_type_mapping ut_key_value_pairs := coalesce(a_file_to_object_type_mapping, default_file_to_obj_type_map());
- + 31 +
+ +l_regex_pattern varchar2(4000) := coalesce(a_regex_pattern, gc_file_mapping_regex);
- + 31 +
+ +l_object_owner_subexpression positive := coalesce(a_object_owner_subexpression, gc_regex_owner_subexpression);
- + 31 +
+ +l_object_name_subexpression positive := coalesce(a_object_name_subexpression, gc_regex_name_subexpression);
- + 31 +
+ +l_object_type_subexpression positive := coalesce(a_object_type_subexpression, gc_regex_type_subexpression);
- +
+ +- +
+ +l_key_values tt_key_values;
- +
+ +l_mappings ut_file_mappings;
- +
+ +l_mapping ut_file_mapping;
- +
+ +l_object_type_key varchar2(4000);
- +
+ +l_object_type varchar2(4000);
- +
+ +l_object_owner varchar2(4000);
- +
+ +l_file_path varchar2(32767);
- -
begin
- - 2 -
-ut_utils.debug_log('ut_expectation_blob.not_to_equal(self in ut_expectation, a_expected blob)');
- + +
- + 31 +
+ +if a_file_paths is not null then
- + 31 +
+ +l_key_values := to_hash_table(l_file_to_object_type_mapping);
- + 31 +
+ +l_mappings := ut_file_mappings();
- +
+ +- + 67 +
+ +for i in 1 .. a_file_paths.count loop
- + 36 +
+ +l_file_path := replace(a_file_paths(i),'\','/');
- + 36 +
+ +l_object_type_key := upper(regexp_substr(l_file_path, l_regex_pattern, 1, 1, 'i', l_object_type_subexpression));
- + 36 +
+ +if l_key_values.exists(l_object_type_key) then
- + 34 +
+ +l_object_type := upper(l_key_values(l_object_type_key));
- +
+ +else
- 2 -
-self.not_to( ut_equal(a_expected, a_nulls_are_equal) );
- +
+ +l_object_type := null;
- +
+ +end if;
- +
+ +- + 36 +
+ +l_object_owner := coalesce(
- + 1 +
+ +upper(a_object_owner),
- + 1 +
+ +upper(regexp_substr(l_file_path, l_regex_pattern, 1, 1, 'i', l_object_owner_subexpression)),
- +
+ +sys_context('USERENV', 'CURRENT_SCHEMA'));
- +
+ +- + 36 +
+ +l_mapping := ut_file_mapping(
- +
+ +file_name => a_file_paths(i),
- +
+ +object_owner => l_object_owner,
- +
+ +object_name => upper(regexp_substr(l_file_path, l_regex_pattern, 1, 1, 'i', l_object_name_subexpression)),
- +
+ +object_type => l_object_type
- +
+ +);
- + 36 +
+ +l_mappings.extend();
- + 36 +
+ +l_mappings(l_mappings.last) := l_mapping;
- +
+ +end loop;
- +
+ +end if;
- +
+ +- + 31 +
+ +return l_mappings;
- -
end;
- + +
- -
- -
end;
+UT3.UT_EXPECTATION_BOOLEAN
66.67 % covered
12 relevant lines. 8 lines covered and 4 lines missed+ +
- +
+end;
UT3.UT_METADATA
91.76 % lines covered
85 relevant lines. 78 lines covered and 7 lines missed+
- -
+type body ut_expectation_boolean as
package body ut_metadata as
+- +
/*
- -
+utPLSQL - Version X.X.X.X
utPLSQL - Version 3
+- -
+Copyright 2016 - 2017 utPLSQL Project
Copyright 2016 - 2019 utPLSQL Project
+- +
- +
Licensed under the Apache License, Version 2.0 (the "License"):
- +
you may not use this file except in compliance with the License.
- +
You may obtain a copy of the License at
- +
- +
http://www.apache.org/licenses/LICENSE-2.0
- +
- +
Unless required by applicable law or agreed to in writing, software
- +
distributed under the License is distributed on an "AS IS" BASIS,
- +
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
See the License for the specific language governing permissions and
- +
limitations under the License.
- +
*/
- -
+overriding member procedure to_equal(self in ut_expectation_boolean, a_expected boolean, a_nulls_are_equal boolean := null) is
+
- -
-begin
- - 11 -
-ut_utils.debug_log('ut_expectation_boolean.to_equal(self in ut_expectation_boolean, a_expected boolean, a_nulls_are_equal boolean := null)');
- - 11 -
+self.to_( ut_equal(a_expected, a_nulls_are_equal) );
type t_cache is table of all_source.text%type;
+ +- +
+ +g_source_cache t_cache;
- +
+g_cached_object varchar2(500);
- -
+end;
------------------------------
+- -
+--public definitions
+- -
+member procedure to_be_true(self in ut_expectation_boolean) is
function form_name(a_owner_name varchar2, a_object varchar2, a_subprogram varchar2 default null) return varchar2 is
+- +
+ +l_name varchar2(200);
- -
begin
- - 50 -
-ut_utils.debug_log('ut_expectation_boolean.to_be_true(self in ut_expectation_boolean)');
- - 50 -
-self.to_( ut_be_true() );
- -
-end;
- -
+ +- + 563 +
+ +l_name := trim(a_object);
- + 563 +
+ +if trim(a_owner_name) is not null then
- + 176 +
+l_name := trim(a_owner_name) || '.' || l_name;
- -
-member procedure to_be_false(self in ut_expectation_boolean) is
- -
-begin
- - 7 -
-ut_utils.debug_log('ut_expectation_boolean.to_be_false(self in ut_expectation_boolean)');
- - 7 -
-self.to_( ut_be_false() );
- -
+end;
end if;
+ +- + 563 +
+ +if trim(a_subprogram) is not null then
- + 561 +
+ +l_name := l_name || '.' || trim(a_subprogram);
- +
+ +end if;
- + 563 +
+return l_name;
- -
+end form_name;
+- -
+overriding member procedure not_to_equal(self in ut_expectation_boolean, a_expected boolean, a_nulls_are_equal boolean := null) is
+
- -
-begin
- - 2 -
-ut_utils.debug_log('ut_expectation_boolean.not_to_equal(self in ut_expectation_boolean, a_expected boolean, a_nulls_are_equal boolean := null)');
- - 2 -
+self.not_to( ut_equal(a_expected, a_nulls_are_equal) );
function package_valid(a_owner_name varchar2, a_package_name in varchar2) return boolean as
+ +- +
+ +l_cnt number;
- + 12 +
+l_view_name varchar2(200) := get_objects_view_name;
- -
+end;
begin
+- -
- -
+ +member procedure not_to_be_true(self in ut_expectation_boolean) is
- + 12 +
+execute immediate q'[select count(*)
- -
-begin
- -
-ut_utils.debug_log('ut_expectation_boolean.not_to_be_true(self in ut_expectation_boolean)');
- -
+self.not_to( ut_be_true() );
from ]'||l_view_name||q'[
+ +- +
+ +where owner = :a_owner_name
- +
+and object_name = :a_package_name
- -
+end;
and object_type = 'PACKAGE'
+- -
+and status = 'VALID']'
+- -
-member procedure not_to_be_false(self in ut_expectation_boolean) is
- -
-begin
- -
+ut_utils.debug_log('ut_expectation_boolean.not_to_be_false(self in ut_expectation_boolean)');
into l_cnt using upper(a_owner_name), upper(a_package_name);
+ +- + 12 +
+ +return l_cnt = 1;
- +
+exception
- -
-self.not_to( ut_be_false() );
- -
+end;
when others then
+ +- +
+return false;
- -
+end;
+- -
end;
UT3.UT_EXPECTATION_CLOB
100 % covered
12 relevant lines. 12 lines covered and 0 lines missed-
- -
-type body ut_expectation_clob as
- -
-/*
- -
-utPLSQL - Version X.X.X.X
- -
-Copyright 2016 - 2017 utPLSQL Project
- -
- -
-Licensed under the Apache License, Version 2.0 (the "License"):
- -
-you may not use this file except in compliance with the License.
- -
-You may obtain a copy of the License at
- + +
- +
+ +function procedure_exists(a_owner_name varchar2, a_package_name in varchar2, a_procedure_name in varchar2)
- +
+ +return boolean as
- +
+ +l_cnt number;
- + 6 +
+ +l_view_name varchar2(200) := get_dba_view('dba_procedures');
- +
+ +begin
- + 6 +
+ +execute immediate
- +
+ +'select count(*) from '||l_view_name
- +
+ +||' where owner = :l_schema and object_name = :l_package_name and procedure_name = :l_procedure_name and rownum = 1'
- +
+ +into l_cnt using a_owner_name, a_package_name, a_procedure_name;
- -
- -
-http://www.apache.org/licenses/LICENSE-2.0
- + +
- +
+ +--expect one method only for the package with that name.
- + 6 +
+ +return l_cnt = 1;
- +
+ +exception
- +
+ +when others then
- +
+ +return false;
- +
+ +end;
- -
- -
-Unless required by applicable law or agreed to in writing, software
- -
-distributed under the License is distributed on an "AS IS" BASIS,
- -
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- -
-See the License for the specific language governing permissions and
- -
-limitations under the License.
- -
-*/
- -
-overriding member procedure to_equal(self in ut_expectation_clob, a_expected clob, a_nulls_are_equal boolean := null) is
- + +
- +
+ +function get_source_definition_line(a_owner varchar2, a_object_name varchar2, a_line_no integer) return varchar2 is
- + 195 +
+ +l_view_name varchar2(128) := get_source_view_name();
- +
+ +l_line all_source.text%type;
- + 195 +
+ +c_key constant varchar2(500) := a_owner || '.' || a_object_name;
- -
begin
- - 11 -
-ut_utils.debug_log('ut_expectation_clob.to_equal(self in ut_expectation, a_expected clob)');
- - 11 -
-self.to_( ut_equal(a_expected, a_nulls_are_equal) );
- + +
- + 195 +
+ +if not nvl(c_key = g_cached_object, false) then
- + 50 +
+ +g_cached_object := c_key;
- + 50 +
+ +execute immediate
- +
+ +'select trim(text) text
- +
+ +from '||l_view_name||q'[ s
- +
+ +where s.owner = :a_owner
- +
+ +and s.name = :a_object_name
- +
+ +/*skip the declarations, consider only definitions*/
- +
+ +and s.type not in ('PACKAGE', 'TYPE')
- +
+ +order by line]'
- +
+ +bulk collect into g_source_cache
- +
+ +using a_owner, a_object_name;
- +
+ +end if;
- +
+ +- + 195 +
+ +if g_source_cache.exists(a_line_no) then
- + 190 +
+ +l_line := g_source_cache(a_line_no);
- +
+ +end if;
- + 195 +
+ +return l_line;
- -
end;
- + +
- -
- -
-member procedure to_be_like(self in ut_expectation_clob, a_mask in varchar2, a_escape_char in varchar2 := null) is
- + +
- +
+ +procedure reset_source_definition_cache is
- -
begin
- - 7 -
-ut_utils.debug_log('ut_expectation_clob.to_be_like(self in ut_expectation, a_mask in varchar2, a_escape_char in varchar2 default null)');
- - 7 -
-self.to_( ut_be_like(a_mask, a_escape_char) );
- + +
- + 116 +
+ +g_source_cache := null;
- + 116 +
+ +g_cached_object := null;
- -
end;
- + +
- -
- -
-member procedure to_match(self in ut_expectation_clob, a_pattern in varchar2, a_modifiers in varchar2 default null) is
- + +
- +
+ +function get_dba_view(a_dba_view_name varchar2) return varchar2 is
- + 903 +
+ +l_result varchar2(128) := lower(a_dba_view_name);
- -
begin
- - 4 -
-ut_utils.debug_log('ut_expectation_clob.to_match(self in ut_expectation, a_pattern in varchar2, a_modifiers in varchar2 default null)');
- - 4 -
-self.to_( ut_match(a_pattern, a_modifiers) );
- + +
- + 903 +
+ +if not is_object_visible(a_dba_view_name) then
- + 761 +
+ +l_result := replace(l_result,'dba_','all_');
- +
+ +end if;
- + 903 +
+ +return l_result;
- -
end;
- + +
- -
- -
-overriding member procedure not_to_equal(self in ut_expectation_clob, a_expected clob, a_nulls_are_equal boolean := null) is
- + +
- +
+ +function get_source_view_name return varchar2 is
- -
begin
- - 2 -
-ut_utils.debug_log('ut_expectation_clob.not_to_equal(self in ut_expectation, a_expected clob)');
- - 2 -
-self.not_to( ut_equal(a_expected, a_nulls_are_equal) );
- + +
- + 293 +
+ +return get_dba_view('dba_source');
- -
end;
- + +
- -
- -
-member procedure not_to_be_like(self in ut_expectation_clob, a_mask in varchar2, a_escape_char in varchar2 := null) is
- -
-begin
- - 4 -
-ut_utils.debug_log('ut_expectation_clob.not_to_be_like(self in ut_expectation, a_mask in varchar2, a_escape_char in varchar2 default null)');
- - 4 -
-self.not_to( ut_be_like(a_mask, a_escape_char) );
- -
-end;
- + +
- -
- -
-member procedure not_to_match(self in ut_expectation_clob, a_pattern in varchar2, a_modifiers in varchar2 default null) is
- + +
- +
+ +function get_objects_view_name return varchar2 is
- -
begin
- - 4 -
-ut_utils.debug_log('ut_expectation_clob.not_to_match(self in ut_expectation, a_pattern in varchar2, a_modifiers in varchar2 default null)');
- - 4 -
-self.not_to( ut_match(a_pattern, a_modifiers) );
- + +
- + 604 +
+ +return get_dba_view('dba_objects');
- -
end;
- -
-- -
end;
UT3.UT_EXPECTATION_DATE
100 % covered
24 relevant lines. 24 lines covered and 0 lines missed-
- -
-type body ut_expectation_date as
- -
-/*
- -
-utPLSQL - Version X.X.X.X
- -
-Copyright 2016 - 2017 utPLSQL Project
- -
-- -
-Licensed under the Apache License, Version 2.0 (the "License"):
- -
-you may not use this file except in compliance with the License.
- -
-You may obtain a copy of the License at
- -
-- -
-http://www.apache.org/licenses/LICENSE-2.0
- + +
- -
- -
-Unless required by applicable law or agreed to in writing, software
- -
-distributed under the License is distributed on an "AS IS" BASIS,
- -
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- -
-See the License for the specific language governing permissions and
- -
-limitations under the License.
- -
-*/
- -
-overriding member procedure to_equal(self in ut_expectation_date, a_expected date, a_nulls_are_equal boolean := null) is
- + +
- +
+ +function user_has_execute_any_proc return boolean is
- + 169 +
+ +l_ut_owner varchar2(250) := ut_utils.ut_owner;
- -
begin
- - 11 -
-ut_utils.debug_log('ut_expectation_date.to_equal(self in ut_expectation, a_expected date, a_nulls_are_equal boolean := null)');
- - 11 -
-self.to_( ut_equal(a_expected, a_nulls_are_equal) );
- + +
- + 169 +
+ +return is_object_visible(l_ut_owner||'.ut_utils');
- -
end;
- + +
- -
- -
-member procedure to_be_between(self in ut_expectation_date, a_lower_bound date, a_upper_bound date) is
- + +
- +
+ +function is_object_visible(a_object_name varchar2) return boolean is
- +
+ +l_invalid_object_name exception;
- +
+ +pragma exception_init(l_invalid_object_name,-44002);
- -
begin
- - 4 -
-ut_utils.debug_log('ut_expectation_date.to_be_between(self in ut_expectation_date, a_lower_bound date, a_upper_bound date)');
- - 4 -
-self.to_( ut_be_between(a_lower_bound,a_upper_bound) );
- + +
- + 1377 +
+ +return dbms_assert.sql_object_name(a_object_name) is not null;
- +
+ +exception
- + 1972 +
+ +when l_invalid_object_name then
- + 986 +
+ +return false;
- -
end;
- + +
- -
- -
-member procedure to_be_greater_or_equal(self in ut_expectation_date, a_expected date) is
- + +
- +
+ +function package_exists_in_cur_schema(a_object_name varchar2) return boolean is
- +
+ +l_cnt number;
- + 135 +
+ +c_current_schema constant all_tables.owner%type := sys_context('USERENV','CURRENT_SCHEMA');
- -
begin
- - 3 -
-ut_utils.debug_log('ut_expectation_date.to_be_greater_or_equal(self in ut_expectation_date, a_expected date)');
- - 3 -
-self.to_( ut_be_greater_or_equal (a_expected) );
- + +
- + 135 +
+ +select count(*)
- +
+ +into l_cnt
- +
+ +from all_objects t
- +
+ +where t.object_name = a_object_name
- +
+ +and t.object_type = 'PACKAGE'
- +
+ +and t.owner = c_current_schema;
- + 135 +
+ +return l_cnt > 0;
- -
end;
- + +
- -
- -
-member procedure to_be_greater_than(self in ut_expectation_date, a_expected date) is
- + +
- +
+ +function is_collection (a_anytype_code in integer) return boolean is
- -
begin
- - 2 -
-ut_utils.debug_log('ut_expectation_date.to_be_greater_than(self in ut_expectation_date, a_expected date)');
- - 2 -
-self.to_( ut_be_greater_than (a_expected) );
- + +
- + 1062 +
+ +return coalesce(a_anytype_code in (dbms_types.typecode_varray,dbms_types.typecode_table,dbms_types.typecode_namedcollection),false);
- -
end;
- + +
- -
- -
-member procedure to_be_less_or_equal(self in ut_expectation_date, a_expected date) is
- + +
- +
+ +function is_collection (a_owner varchar2, a_type_name varchar2) return boolean is
- -
begin
- - 3 -
-ut_utils.debug_log('ut_expectation_date.to_be_less_or_equal(self in ut_expectation_date, a_expected date)');
- - 3 -
-self.to_( ut_be_less_or_equal (a_expected) );
- + +
- + 845 +
+ +return is_collection(
- +
+ +get_anytype_members_info(
- +
+ +get_user_defined_type(a_owner, a_type_name)
- +
+ +).type_code
- +
+ +);
- -
end;
- + +
- -
- -
-member procedure to_be_less_than(self in ut_expectation_date, a_expected date) is
- + +
- +
+ +function get_attr_elem_info( a_anytype anytype, a_pos pls_integer := null )
- +
+ +return t_anytype_elem_info_rec is
- +
+ +l_result t_anytype_elem_info_rec;
- -
begin
- - 2 -
-ut_utils.debug_log('ut_expectation_date.to_be_less_than(self in ut_expectation_date, a_expected date');
- - 2 -
-self.to_( ut_be_less_than (a_expected) );
- + +
- + 525 +
+ +if a_anytype is not null then
- + 525 +
+ +l_result.type_code := a_anytype.getattreleminfo(
- +
+ +pos => a_pos,
- +
+ +prec => l_result.precision,
- +
+ +scale => l_result.scale,
- +
+ +len => l_result.length,
- +
+ +csid => l_result.char_set_id,
- +
+ +csfrm => l_result.char_set_frm,
- +
+ +attr_elt_type => l_result.attr_elt_type,
- +
+ +aname => l_result.attribute_name
- +
+ +);
- +
+ +end if;
- + 525 +
+ +return l_result;
- -
end;
- + +
- -
- -
-overriding member procedure not_to_equal(self in ut_expectation_date, a_expected date, a_nulls_are_equal boolean := null) is
- + +
- +
+ +function get_anytype_members_info( a_anytype anytype )
- +
+ +return t_anytype_members_rec is
- +
+ +l_result t_anytype_members_rec;
- -
begin
- - 2 -
-ut_utils.debug_log('ut_expectation_date.not_to_equal(self in ut_expectation, a_expected date, a_nulls_are_equal boolean := null)');
- - 2 -
-self.not_to( ut_equal(a_expected, a_nulls_are_equal) );
- -
-end;
- -
-- -
-member procedure not_to_be_between(self in ut_expectation_date, a_lower_bound date, a_upper_bound date) is
- -
-begin
- - 4 -
-ut_utils.debug_log('ut_expectation_date.not_to_be_between(self in ut_expectation_date, a_lower_bound date, a_upper_bound date)');
- - 4 -
-self.not_to( ut_be_between(a_lower_bound,a_upper_bound) );
- -
-end;
- -
-- -
-member procedure not_to_be_greater_or_equal(self in ut_expectation_date, a_expected date) is
- -
-begin
- - 1 -
-ut_utils.debug_log('ut_expectation_date.not_to_be_greater_or_equal(self in ut_expectation_date, a_expected date)');
- - 1 -
-self.not_to( ut_be_greater_or_equal (a_expected) );
- + +
- + 1062 +
+ +if a_anytype is not null then
- + 336 +
+ +l_result.type_code := a_anytype.getinfo(
- +
+ +prec => l_result.precision,
- +
+ +scale => l_result.scale,
- +
+ +len => l_result.length,
- +
+ +csid => l_result.char_set_id,
- +
+ +csfrm => l_result.char_set_frm,
- +
+ +schema_name => l_result.schema_name,
- +
+ +type_name => l_result.type_name,
- +
+ +version => l_result.version,
- +
+ +numelems => l_result.elements_count
- +
+ +);
- +
+ +end if;
- + 1062 +
+ +return l_result;
- -
end;
- + +
- -
- -
-member procedure not_to_be_greater_than(self in ut_expectation_date, a_expected date) is
- + +
- +
+ +function get_user_defined_type(a_owner varchar2, a_type_name varchar2) return anytype is
- +
+ +l_anytype anytype;
- +
+ +not_found exception;
- +
+ +pragma exception_init(not_found,-22303);
- -
begin
- - 1 -
-ut_utils.debug_log('ut_expectation_date.not_to_be_greater_than(self in ut_expectation_date, a_expected date)');
- - 1 -
-self.not_to( ut_be_greater_than (a_expected) );
- + +
- + 964 +
+ +if a_type_name is not null then
- +
+ +begin
- + 238 +
+ +if ut_metadata.is_object_visible('GETANYTYPEFROMPERSISTENT') then
- + 238 +
+ +execute immediate 'begin :l_anytype := getanytypefrompersistent( :a_owner, :a_type_name ); end;'
- +
+ +using out l_anytype, in nvl(a_owner,sys_context('userenv','current_schema')), in a_type_name;
- +
+ +else
- +
+ +execute immediate 'begin :l_anytype := anytype.getpersistent( :a_owner, :a_type_name ); end;'
- +
+ +using out l_anytype, in nvl(a_owner,sys_context('userenv','current_schema')), in a_type_name;
- +
+ +end if;
- +
+ +exception
- +
+ +when not_found then
- +
+ +null;
- +
+ +end;
- +
+ +end if;
- + 964 +
+ +return l_anytype;
- -
end;
- + +
- -
- -
-member procedure not_to_be_less_or_equal(self in ut_expectation_date, a_expected date) is
- + +
- +
+ +function get_collection_element(a_anydata in anydata) return varchar2
- +
+ +is
- +
+ +l_anytype anytype;
- +
+ +l_nested_type t_anytype_members_rec;
- +
+ +l_elements_rec t_anytype_elem_info_rec;
- +
+ +l_type_code integer;
- -
begin
- - 1 -
-ut_utils.debug_log('ut_expectation_date.not_to_be_less_or_equal(self in ut_expectation_date, a_expected date)');
- - 1 -
-self.not_to( ut_be_less_or_equal (a_expected) );
- + +
- + 72 +
+ +l_type_code := a_anydata.gettype(l_anytype);
- + 72 +
+ +if is_collection(l_type_code) then
- + 72 +
+ +l_elements_rec := get_attr_elem_info(l_anytype);
- + 72 +
+ +if l_elements_rec.attr_elt_type is null then
- + 38 +
+ +l_nested_type := get_anytype_members_info(l_anytype);
- +
+ +else
- + 34 +
+ +l_nested_type := get_anytype_members_info(l_elements_rec.attr_elt_type);
- +
+ +end if;
- +
+ +end if;
- + 72 +
+ +return l_nested_type.schema_name || '.' ||l_nested_type.type_name;
- -
end;
- + +
- -
- -
-member procedure not_to_be_less_than(self in ut_expectation_date, a_expected date) is
- + +
- +
+ +function has_collection_members (a_anydata in anydata) return boolean is
- +
+ +l_anytype anytype;
- +
+ +l_elements_rec t_anytype_elem_info_rec;
- +
+ +l_type_code integer;
- -
begin
- - 1 -
-ut_utils.debug_log('ut_expectation_date.not_to_be_less_than(self in ut_expectation_date, a_expected date');
- - 1 -
-self.not_to( ut_be_less_than (a_expected) );
- + +
- + 72 +
+ +l_type_code := a_anydata.gettype(l_anytype);
- + 72 +
+ +l_elements_rec := get_attr_elem_info(l_anytype);
- + 72 +
+ +return l_elements_rec.attr_elt_type is not null;
- -
end;
- -
-- -
end;
UT3.UT_EXPECTATION_DSINTERVAL
100 % covered
24 relevant lines. 24 lines covered and 0 lines missed-
- -
-type body ut_expectation_dsinterval as
- -
-/*
- -
-utPLSQL - Version X.X.X.X
- -
-Copyright 2016 - 2017 utPLSQL Project
- -
-- -
-Licensed under the Apache License, Version 2.0 (the "License"):
- -
-you may not use this file except in compliance with the License.
- -
-You may obtain a copy of the License at
- -
-- -
-http://www.apache.org/licenses/LICENSE-2.0
- + +
- -
- -
-Unless required by applicable law or agreed to in writing, software
- -
-distributed under the License is distributed on an "AS IS" BASIS,
- -
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- -
-See the License for the specific language governing permissions and
- -
-limitations under the License.
- -
-*/
- -
-overriding member procedure to_equal(self in ut_expectation_dsinterval, a_expected dsinterval_unconstrained, a_nulls_are_equal boolean := null) is
- + +
- +
+ +function get_anydata_typename(a_data_value anydata) return varchar2
- +
+ +is
- -
begin
- - 11 -
-ut_utils.debug_log('ut_expectation_dsinterval.to_equal(self in ut_expectation, a_expected dsinterval_unconstrained)');
- - 11 -
-self.to_( ut_equal(a_expected, a_nulls_are_equal) );
- + +
- + 335 +
+ +return case when a_data_value is not null then lower(a_data_value.gettypename()) else 'undefined' end;
- -
end;
- + +
- -
- -
-member procedure to_be_between(self in ut_expectation_dsinterval, a_lower_bound dsinterval_unconstrained, a_upper_bound dsinterval_unconstrained) is
- + +
- +
+ +function is_anytype_null(a_value in anydata, a_compound_type in varchar2) return number is
- + 173 +
+ +l_result integer := 0;
- +
+ +l_anydata_sql varchar2(4000);
- +
+ +l_compound_type varchar2(250);
- -
begin
- - 4 -
-ut_utils.debug_log('ut_expectation_dsinterval.to_be_between(self in ut_expectation_dsinterval, a_lower_bound dsinterval_unconstrained, a_upper_bound dsinterval_unconstrained)');
- - 4 -
-self.to_( ut_be_between(a_lower_bound,a_upper_bound) );
- -
-end;
- -
-- -
-member procedure to_be_greater_or_equal(self in ut_expectation_dsinterval, a_expected dsinterval_unconstrained) is
- -
-begin
- - 3 -
-ut_utils.debug_log('ut_expectation_dsinterval.to_be_greater_or_equal(self in ut_expectation_dsinterval, a_expected dsinterval_unconstrained)');
- - 3 -
-self.to_( ut_be_greater_or_equal (a_expected) );
- -
-end;
- -
-member procedure to_be_greater_than(self in ut_expectation_dsinterval, a_expected dsinterval_unconstrained) is
- -
-begin
- - 2 -
-ut_utils.debug_log('ut_expectation_dsinterval.to_be_greater_than(self in ut_expectation_dsinterval, a_expected dsinterval_unconstrained)');
- - 2 -
-self.to_( ut_be_greater_than (a_expected) );
- -
-end;
- -
-member procedure to_be_less_or_equal(self in ut_expectation_dsinterval, a_expected dsinterval_unconstrained) is
- -
-begin
- - 3 -
-ut_utils.debug_log('ut_expectation_dsinterval.to_be_less_or_equal(self in ut_expectation_dsinterval, a_expected dsinterval_unconstrained)');
- - 3 -
-self.to_( ut_be_less_or_equal (a_expected) );
- -
-end;
- -
-member procedure to_be_less_than(self in ut_expectation_dsinterval, a_expected dsinterval_unconstrained) is
- -
-begin
- - 2 -
-ut_utils.debug_log('ut_expectation_dsinterval.to_be_less_than(self in ut_expectation_dsinterval, a_expected dsinterval_unconstrained)');
- - 2 -
-self.to_( ut_be_less_than (a_expected) );
- -
-end;
- -
-- -
-overriding member procedure not_to_equal(self in ut_expectation_dsinterval, a_expected dsinterval_unconstrained, a_nulls_are_equal boolean := null) is
- -
-begin
- - 2 -
-ut_utils.debug_log('ut_expectation_dsinterval.not_to_equal(self in ut_expectation, a_expected dsinterval_unconstrained)');
- - 2 -
-self.not_to( ut_equal(a_expected, a_nulls_are_equal) );
- + +
- + 173 +
+ +if a_value is not null then
- + 162 +
+ +l_compound_type := sys.dbms_assert.qualified_sql_name(a_compound_type);
- + 162 +
+ +l_anydata_sql := '
- +
+ +declare
- +
+ +l_data '||get_anydata_typename(a_value)||';
- +
+ +l_value anydata := :a_value;
- +
+ +l_status integer;
- +
+ +begin
- +
+ +l_status := l_value.get'||l_compound_type||'(l_data);
- +
+ +:l_data_is_null := case when l_data is null then 1 else 0 end;
- +
+ +end;';
- + 162 +
+ +execute immediate l_anydata_sql using in a_value, out l_result;
- +
+ +else
- + 11 +
+ +l_result := 1;
- +
+ +end if;
- + 173 +
+ +return l_result;
- -
end;
- + +
- -
- -
-member procedure not_to_be_between(self in ut_expectation_dsinterval, a_lower_bound dsinterval_unconstrained, a_upper_bound dsinterval_unconstrained) is
- + +
- +
+ +function get_object_name(a_full_object_name in varchar2) return varchar2 is
- +
+ +l_result varchar2(250);
- -
begin
- - 4 -
-ut_utils.debug_log('ut_expectation_dsinterval.not_to_be_between(self in ut_expectation_dsinterval, a_lower_bound dsinterval_unconstrained, a_upper_bound dsinterval_unconstrained)');
- - 4 -
-self.not_to( ut_be_between(a_lower_bound,a_upper_bound) );
- + +
- + 127 +
+ +l_result := regexp_substr(
- +
+ +a_full_object_name,
- +
+ +'^([A-Za-z0-9$#_]+|".*?")\.([A-Za-z0-9$#_]+|".*?")', subexpression => 2
- +
+ +);
- + 127 +
+ +if not l_result like '"%"' then
- + 127 +
+ +l_result := upper(l_result);
- +
+ +end if;
- + 127 +
+ +return ut_utils.qualified_sql_name(l_result);
- -
end;
- + +
- -
- -
-member procedure not_to_be_greater_or_equal(self in ut_expectation_dsinterval, a_expected dsinterval_unconstrained) is
- -
-begin
- - 1 -
-ut_utils.debug_log('ut_expectation_dsinterval.not_to_be_greater_or_equal(self in ut_expectation_dsinterval, a_expected dsinterval_unconstrained)');
- - 1 -
-self.not_to( ut_be_greater_or_equal (a_expected) );
- -
-end;
- -
-member procedure not_to_be_greater_than(self in ut_expectation_dsinterval, a_expected dsinterval_unconstrained) is
- -
-begin
- - 1 -
-ut_utils.debug_log('ut_expectation_dsinterval.not_to_be_greater_than(self in ut_expectation_dsinterval, a_expected dsinterval_unconstrained)');
- - 1 -
-self.not_to( ut_be_greater_than (a_expected) );
- -
-end;
- -
-member procedure not_to_be_less_or_equal(self in ut_expectation_dsinterval, a_expected dsinterval_unconstrained) is
- -
-begin
- - 1 -
-ut_utils.debug_log('ut_expectation_dsinterval.not_to_be_less_or_equal(self in ut_expectation_dsinterval, a_expected dsinterval_unconstrained)');
- - 1 -
-self.not_to( ut_be_less_or_equal (a_expected) );
- -
-end;
- -
-member procedure not_to_be_less_than(self in ut_expectation_dsinterval, a_expected dsinterval_unconstrained) is
- + +
- +
+ +function get_anydata_compound_type(a_data_value anydata) return varchar2 is
- +
+ +l_result varchar2(30);
- +
+ +l_type anytype;
- +
+ +l_type_code integer;
- -
begin
- - 1 -
-ut_utils.debug_log('ut_expectation_dsinterval.not_to_be_less_than(self in ut_expectation_dsinterval, a_expected dsinterval_unconstrained)');
- + +
- + 173 +
+ +if a_data_value is not null then
- + 162 +
+ +l_type_code := a_data_value.gettype(l_type);
- + 162 +
+ +if l_type_code in (dbms_types.typecode_table, dbms_types.typecode_varray, dbms_types.typecode_namedcollection,
- 1 -
-self.not_to( ut_be_less_than (a_expected) );
- +
+ +dbms_types.typecode_object) then
- + 162 +
+ +if l_type_code = dbms_types.typecode_object then
- + 67 +
+ +l_result := 'object';
- +
+ +else
- + 95 +
+ +l_result := 'collection';
- +
+ +end if;
- +
+ +end if;
- +
+ +end if;
- + 173 +
+ +return l_result;
- -
end;
- + +
- -
- -
end;
+UT3.UT_EXPECTATION_NUMBER
100 % covered
24 relevant lines. 24 lines covered and 0 lines missed+ +
- +
+end;
UT3.UT_SUITE_BUILDER
98.76 % lines covered
322 relevant lines. 318 lines covered and 4 lines missed+
- -
+type body ut_expectation_number as
package body ut_suite_builder is
+- +
/*
- -
+utPLSQL - Version X.X.X.X
utPLSQL - Version 3
+- -
+Copyright 2016 - 2017 utPLSQL Project
Copyright 2016 - 2019 utPLSQL Project
+- +
- +
Licensed under the Apache License, Version 2.0 (the "License"):
- +
you may not use this file except in compliance with the License.
- +
You may obtain a copy of the License at
- +
- +
http://www.apache.org/licenses/LICENSE-2.0
- +
- +
Unless required by applicable law or agreed to in writing, software
- +
distributed under the License is distributed on an "AS IS" BASIS,
- +
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
See the License for the specific language governing permissions and
- +
limitations under the License.
- +
*/
- -
+overriding member procedure to_equal(self in ut_expectation_number, a_expected number, a_nulls_are_equal boolean := null) is
+
- -
-begin
- - 272 -
-ut_utils.debug_log('ut_expectation_number.to_equal(self in ut_expectation, a_expected number, a_nulls_are_equal boolean := null)');
- - 272 -
+self.to_( ut_equal(a_expected, a_nulls_are_equal) );
subtype t_annotation_text is varchar2(4000);
+ +- +
+ +subtype t_annotation_name is varchar2(4000);
- +
+subtype t_object_name is varchar2(500);
- -
+end;
subtype t_annotation_position is binary_integer;
+- -
- -
-member procedure to_be_between(self in ut_expectation_number, a_lower_bound number, a_upper_bound number) is
- -
-begin
- - 4 -
-ut_utils.debug_log('ut_expectation_number.to_be_between(self in ut_expectation_date, a_lower_bound number, a_upper_bound number)');
- - 4 -
-self.to_( ut_be_between(a_lower_bound,a_upper_bound) );
- -
-end;
- -
-- -
-member procedure to_be_greater_or_equal(self in ut_expectation_number, a_expected number) is
- -
-begin
- - 3 -
-ut_utils.debug_log('ut_expectation_number.to_be_greater_or_equal(self in ut_expectation_number, a_expected number)');
- - 3 -
-self.to_( ut_be_greater_or_equal (a_expected) );
- -
-end;
- -
-- -
-member procedure to_be_greater_than(self in ut_expectation_number, a_expected number) is
- -
-begin
- - 2 -
-ut_utils.debug_log('ut_expectation_number.to_be_greater_than(self in ut_expectation_number, a_expected number)');
- - 2 -
+ +self.to_( ut_be_greater_than (a_expected) );
- + 1 +
+ +gc_suite constant t_annotation_name := 'suite';
- + 1 +
+ +gc_suitepath constant t_annotation_name := 'suitepath';
- + 1 +
+ +gc_tags constant t_annotation_name := 'tags';
- + 1 +
+ +gc_test constant t_annotation_name := ut_utils.gc_test_execute;
- + 1 +
+ +gc_disabled constant t_annotation_name := 'disabled';
- + 1 +
+ +gc_displayname constant t_annotation_name := 'displayname';
- + 1 +
+ +gc_beforeall constant t_annotation_name := ut_utils.gc_before_all;
- + 1 +
+ +gc_beforeeach constant t_annotation_name := ut_utils.gc_before_each;
- + 1 +
+ +gc_beforetest constant t_annotation_name := ut_utils.gc_before_test;
- + 1 +
+ +gc_afterall constant t_annotation_name := ut_utils.gc_after_all;
- + 1 +
+ +gc_aftereach constant t_annotation_name := ut_utils.gc_after_each;
- + 1 +
+ +gc_aftertest constant t_annotation_name := ut_utils.gc_after_test;
- + 1 +
+ +gc_throws constant t_annotation_name := 'throws';
- + 1 +
+ +gc_rollback constant t_annotation_name := 'rollback';
- + 1 +
+ +gc_context constant t_annotation_name := 'context';
- + 1 +
+gc_endcontext constant t_annotation_name := 'endcontext';
- -
-end;
- + +
- +
+type tt_annotations is table of t_annotation_name;
- -
-member procedure to_be_less_or_equal(self in ut_expectation_number, a_expected number) is
- -
-begin
- - 3 -
-ut_utils.debug_log('ut_expectation_number.to_be_less_or_equal(self in ut_expectation_number, a_expected number)');
- - 3 -
+self.to_( ut_be_less_or_equal (a_expected) );
+ +
- + 1 +
+ +gc_supported_annotations constant tt_annotations
- +
+ +:= tt_annotations(
- +
+gc_suite,
- -
+end;
gc_suitepath,
+- -
+gc_tags,
+- -
+member procedure to_be_less_than(self in ut_expectation_number, a_expected number) is
gc_test,
+- -
-begin
- - 2 -
-ut_utils.debug_log('ut_expectation_number.to_be_less_than(self in ut_expectation_number, a_expected number');
- - 2 -
+self.to_( ut_be_less_than (a_expected) );
gc_disabled,
+ +- +
+ +gc_displayname,
- +
+gc_beforeall,
- -
+end;
gc_beforeeach,
+- -
+gc_beforetest,
+- -
+overriding member procedure not_to_equal(self in ut_expectation_number, a_expected number, a_nulls_are_equal boolean := null) is
gc_afterall,
+- -
-begin
- - 2 -
-ut_utils.debug_log('ut_expectation_number.not_to_equal(self in ut_expectation, a_expected number, a_nulls_are_equal boolean := null)');
- - 2 -
+self.not_to( ut_equal(a_expected, a_nulls_are_equal) );
gc_aftereach,
+ +- +
+ +gc_aftertest,
- +
+gc_throws,
- -
+end;
gc_rollback,
+- -
+gc_context,
+- -
+member procedure not_to_be_between(self in ut_expectation_number, a_lower_bound number, a_upper_bound number) is
gc_endcontext
+- -
-begin
- - 4 -
-ut_utils.debug_log('ut_expectation_number.not_to_be_between(self in ut_expectation_date, a_lower_bound number, a_upper_bound number)');
- - 4 -
-self.not_to( ut_be_between(a_lower_bound,a_upper_bound) );
- -
+end;
);
+ +- +
+ +- + 1 +
+ +gc_integer_exception constant varchar2(1) := 'I';
- + 1 +
+gc_named_exception constant varchar2(1) := 'N';
- +
- -
+member procedure not_to_be_greater_or_equal(self in ut_expectation_number, a_expected number) is
type tt_executables is table of ut_executables index by t_annotation_position;
+- -
-begin
- - 1 -
-ut_utils.debug_log('ut_expectation_number.not_to_be_greater_or_equal(self in ut_expectation_number, a_expected number)');
- - 1 -
+self.not_to( ut_be_greater_or_equal (a_expected) );
+ +
- +
+ +type t_annotation is record(
- +
+name t_annotation_name,
- -
+end;
text t_annotation_text,
+- -
+procedure_name t_object_name
+- -
+member procedure not_to_be_greater_than(self in ut_expectation_number, a_expected number) is
);
+- -
-begin
- - 1 -
-ut_utils.debug_log('ut_expectation_number.not_to_be_greater_than(self in ut_expectation_number, a_expected number)');
- - 1 -
+self.not_to( ut_be_greater_than (a_expected) );
+ +
- +
+ +type tt_annotations_by_line is table of t_annotation index by t_annotation_position;
- +
+- -
+end;
--list of annotation texts for a given annotation indexed by annotation position:
+- -
+--This would hold: ('some', 'other') for a single annotation name recurring in a single procedure example
+- -
+member procedure not_to_be_less_or_equal(self in ut_expectation_number, a_expected number) is
-- --%beforetest(some)
+- -
-begin
- - 1 -
-ut_utils.debug_log('ut_expectation_number.not_to_be_less_or_equal(self in ut_expectation_number, a_expected number)');
- - 1 -
+self.not_to( ut_be_less_or_equal (a_expected) );
-- --%beforetest(other)
+ +- +
+ +-- --%test(some test with two before test procedures)
- +
+-- procedure some_test ...
- -
+end;
-- when you'd like to have two beforetest procedures executed in a single test
+- -
+type tt_annotation_texts is table of t_annotation_text index by t_annotation_position;
+- -
+member procedure not_to_be_less_than(self in ut_expectation_number, a_expected number) is
+
- -
-begin
- - 1 -
-ut_utils.debug_log('ut_expectation_number.not_to_be_less_than(self in ut_expectation_number, a_expected number');
- - 1 -
+self.not_to( ut_be_less_than (a_expected) );
type tt_annotations_by_name is table of tt_annotation_texts index by t_annotation_name;
+ +- +
+ +- +
+type tt_annotations_by_proc is table of tt_annotations_by_name index by t_object_name;
- -
-end;
- + +
- +
+type t_annotations_info is record (
- -
end;
UT3.UT_EXPECTATION_REFCURSOR
100 % covered
8 relevant lines. 8 lines covered and 0 lines missed-
- -
-type body ut_expectation_refcursor as
- -
-/*
- -
-utPLSQL - Version X.X.X.X
- -
-Copyright 2016 - 2017 utPLSQL Project
- -
-- -
-Licensed under the Apache License, Version 2.0 (the "License"):
- -
-you may not use this file except in compliance with the License.
- -
-You may obtain a copy of the License at
- -
-- -
-http://www.apache.org/licenses/LICENSE-2.0
- +
+ +owner t_object_name,
- +
+ +name t_object_name,
- +
+ +parse_time timestamp,
- +
+ +by_line tt_annotations_by_line,
- +
+ +by_proc tt_annotations_by_proc,
- +
+ +by_name tt_annotations_by_name
- +
+ +);
- -
- -
-Unless required by applicable law or agreed to in writing, software
- -
-distributed under the License is distributed on an "AS IS" BASIS,
- -
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- -
-See the License for the specific language governing permissions and
- -
-limitations under the License.
- -
-*/
- -
-overriding member procedure to_equal(self in ut_expectation_refcursor, a_expected sys_refcursor, a_exclude varchar2 := null, a_nulls_are_equal boolean := null) is
- + +
- +
+ +function get_qualified_object_name(
- +
+ +a_suite ut_suite_item, a_procedure_name t_object_name
- +
+ +) return varchar2 is
- +
+ +l_result varchar2(1000);
- -
begin
- - 8 -
-ut_utils.debug_log('ut_expectation_refcursor.to_equal(self in ut_expectation_refcursor, a_expected sys_refcursor, a_nulls_are_equal boolean := null)');
- - 8 -
-self.to_( ut_equal(a_expected, a_exclude, a_nulls_are_equal) );
- -
-end;
- -
-- -
-member procedure to_be_empty(self in ut_expectation_refcursor) is
- -
-begin
- - 2 -
-ut_utils.debug_log('ut_expectation_refcursor.to_be_empty(self in ut_expectation_refcursor)');
- - 2 -
-self.to_( ut_be_empty() );
- + +
- + 54 +
+ +if a_suite is not null then
- + 54 +
+ +l_result := upper( a_suite.object_owner || '.' || a_suite.object_name );
- + 54 +
+ +if a_procedure_name is not null then
- + 32 +
+ +l_result := l_result || upper( '.' || a_procedure_name );
- +
+ +end if;
- +
+ +end if;
- + 54 +
+ +return l_result;
- -
end;
- + +
- -
- -
-overriding member procedure not_to_equal(self in ut_expectation_refcursor, a_expected sys_refcursor, a_exclude varchar2 := null, a_nulls_are_equal boolean := null) is
- + +
- +
+ +function get_object_reference(
- +
+ +a_suite ut_suite_item, a_procedure_name t_object_name, a_line_no binary_integer
- +
+ +) return varchar2 is
- -
begin
- - 1 -
-ut_utils.debug_log('ut_expectation_refcursor.not_to_equal(self in ut_expectation_refcursor, a_expected sys_refcursor, a_nulls_are_equal boolean := null)');
- - 1 -
-self.not_to( ut_equal(a_expected, a_exclude, a_nulls_are_equal) );
- + +
- + 54 +
+ +return chr( 10 ) || 'at package "' || get_qualified_object_name(a_suite, a_procedure_name) || '", line ' || a_line_no;
- -
end;
- + +
- -
- -
-member procedure not_to_be_empty(self in ut_expectation_refcursor) is
- + +
- +
+ +procedure delete_annotations_range(
- +
+ +a_annotations in out nocopy t_annotations_info,
- +
+ +a_start_pos t_annotation_position,
- +
+ +a_end_pos t_annotation_position
- +
+ +) is
- + 177 +
+ +l_pos t_annotation_position := a_start_pos;
- +
+ +l_annotation t_annotation;
- -
begin
- - 2 -
-ut_utils.debug_log('ut_expectation_refcursor.not_to_be_empty(self in ut_expectation_refcursor)');
- - 2 -
-self.not_to( ut_be_empty() );
- + +
- + 2037 +
+ +while l_pos is not null and l_pos <= a_end_pos loop
- + 1860 +
+ +l_annotation := a_annotations.by_line(l_pos);
- + 1860 +
+ +if l_annotation.procedure_name is not null and a_annotations.by_proc.exists(l_annotation.procedure_name) then
- + 1163 +
+ +a_annotations.by_proc.delete(l_annotation.procedure_name);
- + 697 +
+ +elsif a_annotations.by_name.exists(l_annotation.name) then
- + 530 +
+ +a_annotations.by_name(l_annotation.name).delete(l_pos);
- + 530 +
+ +if a_annotations.by_name(l_annotation.name).count = 0 then
- + 169 +
+ +a_annotations.by_name.delete(l_annotation.name);
- +
+ +end if;
- +
+ +end if;
- + 1860 +
+ +l_pos := a_annotations.by_line.next( l_pos );
- +
+ +end loop;
- + 177 +
+ +a_annotations.by_line.delete(a_start_pos, a_end_pos);
- -
end;
- -
end;
UT3.UT_EXPECTATION_TIMESTAMP
100 % covered
24 relevant lines. 24 lines covered and 0 lines missed-
- -
-type body ut_expectation_timestamp as
- -
-/*
- -
-utPLSQL - Version X.X.X.X
- -
-Copyright 2016 - 2017 utPLSQL Project
- -
-- -
-Licensed under the Apache License, Version 2.0 (the "License"):
- -
-you may not use this file except in compliance with the License.
- -
-You may obtain a copy of the License at
- + +
- -
- -
-http://www.apache.org/licenses/LICENSE-2.0
- + +
- -
- -
-Unless required by applicable law or agreed to in writing, software
- -
-distributed under the License is distributed on an "AS IS" BASIS,
- -
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- -
-See the License for the specific language governing permissions and
- -
-limitations under the License.
- -
-*/
- -
-overriding member procedure to_equal(self in ut_expectation_timestamp, a_expected timestamp_unconstrained, a_nulls_are_equal boolean := null) is
- + +
- +
+ +procedure add_items_to_list(a_list in out nocopy ut_suite_items, a_items ut_suite_items) is
- -
begin
- - 11 -
-ut_utils.debug_log('ut_expectation_timestamp.to_equal(self in ut_expectation, a_expected timestamp_unconstrained, a_nulls_are_equal boolean := null)');
- - 11 -
-self.to_( ut_equal(a_expected, a_nulls_are_equal) );
- + +
- + 1286 +
+ +for i in 1 .. a_items.count loop
- + 1110 +
+ +a_list.extend();
- + 1110 +
+ +a_list(a_list.last) := a_items(i);
- +
+ +end loop;
- -
end;
- + +
- -
- -
-member procedure to_be_between(self in ut_expectation_timestamp, a_lower_bound timestamp_unconstrained, a_upper_bound timestamp_unconstrained) is
- -
-begin
- - 6 -
-ut_utils.debug_log('ut_expectation_timestamp.to_be_between(self in ut_expectation_timestamp, a_lower_bound timestamp_unconstrained, a_upper_bound timestamp_unconstrained)');
- - 6 -
-self.to_( ut_be_between(a_lower_bound, a_upper_bound) );
- -
-end;
- + +
- +
+ +-----------------------------------------------
- +
+ +-- Processing annotations
- +
+ +-----------------------------------------------
- -
- -
-member procedure to_be_greater_or_equal(self in ut_expectation_timestamp, a_expected timestamp_unconstrained) is
- + +
- +
+ +procedure add_annotation_ignored_warning(
- +
+ +a_suite in out nocopy ut_suite_item,
- +
+ +a_annotation t_annotation_name,
- +
+ +a_message varchar2,
- +
+ +a_line_no binary_integer,
- +
+ +a_procedure_name t_object_name := null
- +
+ +) is
- -
begin
- - 3 -
-ut_utils.debug_log('ut_expectation_timestamp.to_be_greater_or_equal(self in ut_expectation_timestamp, a_expected timestamp_unconstrained)');
- - 3 -
-self.to_( ut_be_greater_or_equal (a_expected) );
- + +
- + 30 +
+ +a_suite.put_warning(
- +
+ +replace(a_message,'%%%','"--%'||a_annotation||'"')
- +
+ +|| ' Annotation ignored.' || get_object_reference( a_suite, a_procedure_name, a_line_no )
- +
+ +);
- -
end;
- + +
- -
- -
-member procedure to_be_greater_than(self in ut_expectation_timestamp, a_expected timestamp_unconstrained) is
- + +
- +
+ +function get_rollback_type(a_rollback_type_name varchar2) return ut_utils.t_rollback_type is
- +
+ +l_rollback_type ut_utils.t_rollback_type;
- -
begin
- - 2 -
-ut_utils.debug_log('ut_expectation_timestamp.to_be_greater_than(self in ut_expectation_timestamp, a_expected timestamp_unconstrained)');
- - 2 -
-self.to_( ut_be_greater_than (a_expected) );
- + +
- + 22 +
+ +l_rollback_type :=
- + 1 +
+ +case lower(a_rollback_type_name)
- + 1 +
+ +when 'manual' then ut_utils.gc_rollback_manual
- + 1 +
+ +when 'auto' then ut_utils.gc_rollback_auto
- +
+ +end;
- + 22 +
+ +return l_rollback_type;
- -
end;
- + +
- -
- -
-member procedure to_be_less_or_equal(self in ut_expectation_timestamp, a_expected timestamp_unconstrained) is
- -
-begin
- - 3 -
-ut_utils.debug_log('ut_expectation_timestamp.to_be_less_or_equal(self in ut_expectation_timestamp, a_expected timestamp_unconstrained)');
- - 3 -
-self.to_( ut_be_less_or_equal (a_expected) );
- -
-end;
- -
-- -
-member procedure to_be_less_than(self in ut_expectation_timestamp, a_expected timestamp_unconstrained) is
- -
-begin
- - 2 -
-ut_utils.debug_log('ut_expectation_timestamp.to_be_less_than(self in ut_expectation_timestamp, a_expected timestamp_unconstrained)');
- - 2 -
-self.to_( ut_be_less_than (a_expected) );
- -
-end;
- + +
- +
+ +procedure add_to_throws_numbers_list(
- +
+ +a_suite in out nocopy ut_suite,
- +
+ +a_list in out nocopy ut_integer_list,
- +
+ +a_procedure_name t_object_name,
- +
+ +a_throws_ann_text tt_annotation_texts
- +
+ +) is
- +
+ +l_annotation_pos binary_integer;
- -
- -
-overriding member procedure not_to_equal(self in ut_expectation_timestamp, a_expected timestamp_unconstrained, a_nulls_are_equal boolean := null) is
- -
-begin
- - 2 -
-ut_utils.debug_log('ut_expectation_timestamp.not_to_equal(self in ut_expectation, a_expected timestamp_unconstrained, a_nulls_are_equal boolean := null)');
- - 2 -
-self.not_to( ut_equal(a_expected, a_nulls_are_equal) );
- -
-end;
- + +
- +
+ +function is_valid_qualified_name (a_name varchar2) return boolean is
- +
+ +l_name varchar2(500);
- +
+ +begin
- + 51 +
+ +l_name := dbms_assert.qualified_sql_name(a_name);
- + 19 +
+ +return true;
- + 64 +
+ +exception when others then
- + 32 +
+ +return false;
- +
+ +end;
- -
- -
-member procedure not_to_be_between(self in ut_expectation_timestamp, a_lower_bound timestamp_unconstrained, a_upper_bound timestamp_unconstrained) is
- -
-begin
- - 4 -
-ut_utils.debug_log('ut_expectation_timestamp.not_to_be_between(self in ut_expectation_timestamp, a_lower_bound timestamp_unconstrained, a_upper_bound timestamp_unconstrained)');
- - 4 -
-self.not_to( ut_be_between(a_lower_bound, a_upper_bound) );
- -
-end;
- + +
- +
+ +function check_exception_type(a_exception_name in varchar2) return varchar2 is
- +
+ +l_exception_type varchar2(50);
- +
+ +begin
- +
+ +--check if it is a predefined exception
- +
+ +begin
- + 19 +
+ +execute immediate 'begin null; exception when '||a_exception_name||' then null; end;';
- + 3 +
+ +l_exception_type := gc_named_exception;
- +
+ +exception
- + 32 +
+ +when others then
- + 16 +
+ +if dbms_utility.format_error_stack() like '%PLS-00485%' then
- +
+ +begin
- + 7 +
+ +execute immediate 'declare x positiven := -('||a_exception_name||'); begin null; end;';
- + 7 +
+ +l_exception_type := gc_integer_exception;
- +
+ +exception
- +
+ +when others then
- +
+ +--invalid exception number (positive)
- +
+ +--TODO add warning for this value
- +
+ +null;
- +
+ +end;
- +
+ +end if;
- +
+ +end;
- + 19 +
+ +return l_exception_type;
- +
+ +end;
- -
- -
-member procedure not_to_be_greater_or_equal(self in ut_expectation_timestamp, a_expected timestamp_unconstrained) is
- -
-begin
- - 1 -
-ut_utils.debug_log('ut_expectation_timestamp.not_to_be_greater_or_equal(self in ut_expectation_timestamp, a_expected timestamp_unconstrained)');
- - 1 -
-self.not_to( ut_be_greater_or_equal (a_expected) );
- -
-end;
- + +
- +
+ +function get_exception_number (a_exception_var in varchar2) return integer is
- +
+ +l_exc_no integer;
- +
+ +l_exc_type varchar2(50);
- +
+ +function remap_no_data_found (a_number integer) return integer is
- +
+ +begin
- + 19 +
+ +return case a_number when 100 then -1403 else a_number end;
- +
+ +end;
- +
+ +begin
- + 19 +
+ +l_exc_type := check_exception_type(a_exception_var);
- -
- -
-member procedure not_to_be_greater_than(self in ut_expectation_timestamp, a_expected timestamp_unconstrained) is
- -
-begin
- - 1 -
-ut_utils.debug_log('ut_expectation_timestamp.not_to_be_greater_than(self in ut_expectation_timestamp, a_expected timestamp_unconstrained)');
- - 1 -
-self.not_to( ut_be_greater_than (a_expected) );
- -
-end;
- + +
- + 19 +
+ +if l_exc_type is not null then
- -
- -
-member procedure not_to_be_less_or_equal(self in ut_expectation_timestamp, a_expected timestamp_unconstrained) is
- -
-begin
- - 1 -
-ut_utils.debug_log('ut_expectation_timestamp.not_to_be_less_or_equal(self in ut_expectation_timestamp, a_expected timestamp_unconstrained)');
- + +
- + 10 +
+ +execute immediate
- 1 -
-self.not_to( ut_be_less_or_equal (a_expected) );
- -
-end;
- -
-- -
-member procedure not_to_be_less_than(self in ut_expectation_timestamp, a_expected timestamp_unconstrained) is
- -
-begin
- +
+ +case l_exc_type
- 1 -
-ut_utils.debug_log('ut_expectation_timestamp.not_to_be_less_than(self in ut_expectation_timestamp, a_expected timestamp_unconstrained)');
- +
+ +when gc_integer_exception then
- +
+ +'declare
- +
+ +l_exception number;
- +
+ +begin
- +
+ +:l_exception := '||a_exception_var||'; '
- 1 -
-self.not_to( ut_be_less_than (a_expected) );
- -
-end;
- +
+ +when gc_named_exception then
- +
+ +'begin
- +
+ +raise '||a_exception_var||';
- +
+ +exception
- +
+ +when others then
- +
+ +:l_exception := sqlcode; '
- +
+ +end ||
- +
+ +'end;'
- +
+ +using out l_exc_no;
- -
- -
end;
UT3.UT_EXPECTATION_TIMESTAMP_LTZ
100 % covered
24 relevant lines. 24 lines covered and 0 lines missed-
- -
-type body ut_expectation_timestamp_ltz as
- -
-/*
- -
-utPLSQL - Version X.X.X.X
- -
-Copyright 2016 - 2017 utPLSQL Project
- + +
- +
+ +end if;
- + 19 +
+ +return remap_no_data_found(l_exc_no);
- +
+ +end;
- -
- -
-Licensed under the Apache License, Version 2.0 (the "License"):
- -
-you may not use this file except in compliance with the License.
- -
-You may obtain a copy of the License at
- + +
- +
+ +function build_exception_numbers_list(
- +
+ +a_suite in out nocopy ut_suite,
- +
+ +a_procedure_name t_object_name,
- +
+ +a_line_no integer,
- +
+ +a_annotation_text in varchar2
- +
+ +) return ut_integer_list is
- +
+ +l_throws_list ut_varchar2_list;
- +
+ +l_exception_number integer;
- + 29 +
+ +l_exception_number_list ut_integer_list := ut_integer_list();
- + 29 +
+ +c_regexp_for_exception_no constant varchar2(30) := '^-?[[:digit:]]{1,5}$';
- +
+ +begin
- +
+ +--the a_expected_error_codes is converted to a ut_varchar2_list after that is trimmed and filtered to left only valid exception numbers
- + 29 +
+ +l_throws_list := ut_utils.trim_list_elements(ut_utils.string_to_table(a_annotation_text, ',', 'Y'));
- -
- -
-http://www.apache.org/licenses/LICENSE-2.0
- + +
- + 80 +
+ +for i in 1 .. l_throws_list.count
- +
+ +loop
- +
+ +/**
- +
+ +* Check if its a valid qualified name and if so try to resolve name to an exception number
- +
+ +*/
- + 51 +
+ +if is_valid_qualified_name(l_throws_list(i)) then
- + 19 +
+ +l_exception_number := get_exception_number(l_throws_list(i));
- + 32 +
+ +elsif regexp_like(l_throws_list(i), c_regexp_for_exception_no) then
- + 24 +
+ +l_exception_number := l_throws_list(i);
- +
+ +end if;
- -
- -
-Unless required by applicable law or agreed to in writing, software
- -
-distributed under the License is distributed on an "AS IS" BASIS,
- -
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- -
-See the License for the specific language governing permissions and
- -
-limitations under the License.
- -
-*/
- -
-overriding member procedure to_equal(self in ut_expectation_timestamp_ltz, a_expected timestamp_ltz_unconstrained, a_nulls_are_equal boolean := null) is
- -
-begin
- - 11 -
-ut_utils.debug_log('ut_expectation_timestamp_ltz.to_equal(self in ut_expectation, a_expected timestamp_ltz_unconstrained, a_nulls_are_equal boolean := null)');
- - 11 -
-self.to_( ut_equal(a_expected, a_nulls_are_equal) );
- -
-end;
- + +
- + 51 +
+ +if l_exception_number is null then
- + 17 +
+ +a_suite.put_warning(
- +
+ +'Invalid parameter value "'||l_throws_list(i)
- +
+ +||'" for "--%throws" annotation. Parameter ignored.'||get_object_reference( a_suite, a_procedure_name, a_line_no )
- +
+ +);
- +
+ +else
- + 34 +
+ +l_exception_number_list.extend;
- + 34 +
+ +l_exception_number_list(l_exception_number_list.last) := l_exception_number;
- +
+ +end if;
- + 51 +
+ +l_exception_number := null;
- +
+ +end loop;
- -
- -
-member procedure to_be_between(self in ut_expectation_timestamp_ltz, a_lower_bound timestamp_ltz_unconstrained, a_upper_bound timestamp_ltz_unconstrained) is
- + +
- + 29 +
+ +return l_exception_number_list;
- +
+ +end;
- +
+ +- -
begin
- - 6 -
-ut_utils.debug_log('ut_expectation_timestamp_ltz.to_be_between(self in ut_expectation_timestamp_ltz, a_lower_bound timestamp_ltz_unconstrained, a_upper_bound timestamp_ltz_unconstrained)');
- - 6 -
-self.to_( ut_be_between(a_lower_bound, a_upper_bound) );
- + +
- + 33 +
+ +a_list := ut_integer_list();
- + 33 +
+ +l_annotation_pos := a_throws_ann_text.first;
- + 66 +
+ +while l_annotation_pos is not null loop
- + 33 +
+ +if a_throws_ann_text(l_annotation_pos) is null then
- + 4 +
+ +a_suite.put_warning(
- +
+ +'"--%throws" annotation requires a parameter. Annotation ignored.'
- +
+ +|| get_object_reference( a_suite, a_procedure_name, l_annotation_pos )
- +
+ +);
- +
+ +else
- + 29 +
+ +a_list :=
- +
+ +a_list multiset union
- +
+ +build_exception_numbers_list(
- +
+ +a_suite,
- +
+ +a_procedure_name,
- +
+ +l_annotation_pos,
- +
+ +a_throws_ann_text(l_annotation_pos)
- +
+ +);
- +
+ +end if;
- + 33 +
+ +l_annotation_pos := a_throws_ann_text.next(l_annotation_pos);
- +
+ +end loop;
- -
end;
- + +
- -
- -
-member procedure to_be_greater_or_equal(self in ut_expectation_timestamp_ltz, a_expected timestamp_ltz_unconstrained) is
- + +
- +
+ +procedure add_tags_to_suite_item(
- +
+ +a_suite in out nocopy ut_suite,
- +
+ +a_tags_ann_text tt_annotation_texts,
- +
+ +a_list in out nocopy ut_varchar2_rows,
- +
+ +a_procedure_name t_object_name := null
- +
+ +) is
- +
+ +l_annotation_pos binary_integer;
- + 55 +
+ +l_tag_list ut_varchar2_list := ut_varchar2_list();
- -
begin
- - 3 -
-ut_utils.debug_log('ut_expectation_timestamp_ltz.to_be_greater_or_equal(self in ut_expectation_timestamp_ltz, a_expected timestamp_ltz_unconstrained)');
- + +
- + 55 +
+ +l_annotation_pos := a_tags_ann_text.first;
- + 114 +
+ +while l_annotation_pos is not null loop
- + 59 +
+ +if a_tags_ann_text(l_annotation_pos) is null then
- 3 -
-self.to_( ut_be_greater_or_equal (a_expected) );
- +
+ +a_suite.put_warning(
- +
+ +'"--%tags" annotation requires a tag value populated. Annotation ignored.'
- +
+ +|| get_object_reference( a_suite, a_procedure_name, l_annotation_pos )
- +
+ +);
- +
+ +else
- + 56 +
+ +l_tag_list := l_tag_list multiset union distinct ut_utils.trim_list_elements(
- +
+ +ut_utils.string_to_table(a_tags_ann_text(l_annotation_pos),',')
- +
+ +);
- +
+ +end if;
- + 59 +
+ +l_annotation_pos := a_tags_ann_text.next(l_annotation_pos);
- +
+ +end loop;
- +
+ +--remove empty strings from table list e.g. tag1,,tag2 and conver to rows
- + 55 +
+ +a_list := ut_utils.convert_collection( ut_utils.filter_list(l_tag_list,ut_utils.gc_word_no_space) );
- -
end;
- -
-member procedure to_be_greater_than(self in ut_expectation_timestamp_ltz, a_expected timestamp_ltz_unconstrained) is
- + +
- +
+ +- +
+ +procedure set_seq_no(
- +
+ +a_list in out nocopy ut_executables
- +
+ +) is
- -
begin
- - 2 -
-ut_utils.debug_log('ut_expectation_timestamp_ltz.to_be_greater_than(self in ut_expectation_timestamp_ltz, a_expected timestamp_ltz_unconstrained)');
- - 2 -
-self.to_( ut_be_greater_than (a_expected) );
- + +
- + 8368 +
+ +if a_list is not null then
- + 10116 +
+ +for i in 1 .. a_list.count loop
- + 1748 +
+ +a_list(i).seq_no := i;
- +
+ +end loop;
- +
+ +end if;
- -
end;
- -
-member procedure to_be_less_or_equal(self in ut_expectation_timestamp_ltz, a_expected timestamp_ltz_unconstrained) is
- -
-begin
- - 3 -
-ut_utils.debug_log('ut_expectation_timestamp_ltz.to_be_less_or_equal(self in ut_expectation_timestamp_ltz, a_expected timestamp_ltz_unconstrained)');
- - 3 -
-self.to_( ut_be_less_or_equal (a_expected) );
- -
-end;
- -
-member procedure to_be_less_than(self in ut_expectation_timestamp_ltz, a_expected timestamp_ltz_unconstrained) is
- -
-begin
- - 2 -
-ut_utils.debug_log('ut_expectation_timestamp_ltz.to_be_less_than(self in ut_expectation_timestamp_ltz, a_expected timestamp_ltz_unconstrained)');
- - 2 -
-self.to_( ut_be_less_than (a_expected) );
- -
-end;
- + +
- -
- -
-overriding member procedure not_to_equal(self in ut_expectation_timestamp_ltz, a_expected timestamp_ltz_unconstrained, a_nulls_are_equal boolean := null) is
- + +
- +
+ +function convert_list(
- +
+ +a_list tt_executables
- +
+ +) return ut_executables is
- + 8368 +
+ +l_result ut_executables := ut_executables();
- + 8368 +
+ +l_pos t_annotation_position := a_list.first;
- -
begin
- - 2 -
-ut_utils.debug_log('ut_expectation_timestamp_ltz.not_to_equal(self in ut_expectation, a_expected timestamp_ltz_unconstrained, a_nulls_are_equal boolean := null)');
- - 2 -
-self.not_to( ut_equal(a_expected, a_nulls_are_equal) );
- + +
- + 10004 +
+ +while l_pos is not null loop
- + 3308 +
+ +for i in 1 .. a_list(l_pos).count loop
- + 1672 +
+ +l_result.extend;
- + 1672 +
+ +l_result(l_result.last) := a_list(l_pos)(i);
- +
+ +end loop;
- + 1636 +
+ +l_pos := a_list.next(l_pos);
- +
+ +end loop;
- + 8368 +
+ +return l_result;
- -
end;
- + +
- -
- -
-member procedure not_to_be_between(self in ut_expectation_timestamp_ltz, a_lower_bound timestamp_ltz_unconstrained, a_upper_bound timestamp_ltz_unconstrained) is
- + +
- +
+ +function add_executables(
- +
+ +a_owner t_object_name,
- +
+ +a_package_name t_object_name,
- +
+ +a_annotation_texts tt_annotation_texts,
- +
+ +a_event_name ut_event_manager.t_event_name
- +
+ +) return tt_executables is
- +
+ +l_executables ut_executables;
- +
+ +l_result tt_executables;
- +
+ +l_annotation_pos binary_integer;
- +
+ +l_procedures_list ut_varchar2_list;
- +
+ +l_procedures_pos binary_integer;
- +
+ +l_components_list ut_varchar2_list;
- -
begin
- - 4 -
-ut_utils.debug_log('ut_expectation_timestamp_ltz.not_to_be_between(self in ut_expectation_timestamp_ltz, a_lower_bound timestamp_ltz_unconstrained, a_upper_bound timestamp_ltz_unconstrained)');
- - 4 -
-self.not_to( ut_be_between(a_lower_bound, a_upper_bound) );
- -
-end;
- + +
- + 543 +
+ +l_annotation_pos := a_annotation_texts.first;
- + 1103 +
+ +while l_annotation_pos is not null loop
- + 560 +
+ +l_procedures_list :=
- +
+ +ut_utils.filter_list(
- +
+ +ut_utils.trim_list_elements(
- +
+ +ut_utils.string_to_table(a_annotation_texts(l_annotation_pos), ',')
- +
+ +)
- +
+ +, '[[:alpha:]]+'
- +
+ +);
- -
- -
-member procedure not_to_be_greater_or_equal(self in ut_expectation_timestamp_ltz, a_expected timestamp_ltz_unconstrained) is
- -
-begin
- + +
- + 560 +
+ +l_procedures_pos := l_procedures_list.first;
- + 560 +
+ +l_executables := ut_executables();
- + 1144 +
+ +while l_procedures_pos is not null loop
- + 584 +
+ +l_components_list := ut_utils.string_to_table(l_procedures_list(l_procedures_pos), '.');
- +
+ +- + 584 +
+ +l_executables.extend;
- + 584 +
+ +l_executables(l_executables.last) :=
- 1 -
-ut_utils.debug_log('ut_expectation_timestamp_ltz.not_to_be_greater_or_equal(self in ut_expectation_timestamp_ltz, a_expected timestamp_ltz_unconstrained)');
- +
+ +case(l_components_list.count())
- 1 -
-self.not_to( ut_be_greater_or_equal (a_expected) );
- -
-end;
- -
-member procedure not_to_be_greater_than(self in ut_expectation_timestamp_ltz, a_expected timestamp_ltz_unconstrained) is
- -
-begin
- +
+ +when 1 then
- +
+ +ut_executable(a_owner, a_package_name, l_components_list(1), a_event_name)
- 1 -
-ut_utils.debug_log('ut_expectation_timestamp_ltz.not_to_be_greater_than(self in ut_expectation_timestamp_ltz, a_expected timestamp_ltz_unconstrained)');
- +
+ +when 2 then
- +
+ +ut_executable(a_owner,l_components_list(1), l_components_list(2), a_event_name)
- 1 -
-self.not_to( ut_be_greater_than (a_expected) );
- +
+ +when 3 then
- +
+ +ut_executable(l_components_list(1), l_components_list(2), l_components_list(3), a_event_name)
- +
+ +else
- +
+ +null
- +
+ +end;
- + 584 +
+ +l_procedures_pos := l_procedures_list.next(l_procedures_pos);
- +
+ +end loop;
- + 560 +
+ +l_result(l_annotation_pos) := l_executables;
- + 560 +
+ +l_annotation_pos := a_annotation_texts.next(l_annotation_pos);
- +
+ +end loop;
- + 543 +
+ +return l_result;
- -
end;
- -
-member procedure not_to_be_less_or_equal(self in ut_expectation_timestamp_ltz, a_expected timestamp_ltz_unconstrained) is
- + +
- +
+ +- +
+ +procedure warning_on_duplicate_annot(
- +
+ +a_suite in out nocopy ut_suite_item,
- +
+ +a_annotations tt_annotations_by_name,
- +
+ +a_for_annotation varchar2,
- +
+ +a_procedure_name t_object_name := null
- +
+ +) is
- +
+ +l_line_no binary_integer;
- -
begin
- - 1 -
-ut_utils.debug_log('ut_expectation_timestamp_ltz.not_to_be_less_or_equal(self in ut_expectation_timestamp_ltz, a_expected timestamp_ltz_unconstrained)');
- - 1 -
-self.not_to( ut_be_less_or_equal (a_expected) );
- + +
- + 8204 +
+ +if a_annotations.exists(a_for_annotation) and a_annotations(a_for_annotation).count > 1 then
- +
+ +--start from second occurrence of annotation
- + 14 +
+ +l_line_no := a_annotations(a_for_annotation).next( a_annotations(a_for_annotation).first );
- + 28 +
+ +while l_line_no is not null loop
- + 14 +
+ +add_annotation_ignored_warning( a_suite, a_for_annotation, 'Duplicate annotation %%%.', l_line_no, a_procedure_name );
- + 14 +
+ +l_line_no := a_annotations(a_for_annotation).next( l_line_no );
- +
+ +end loop;
- +
+ +end if;
- -
end;
- -
-member procedure not_to_be_less_than(self in ut_expectation_timestamp_ltz, a_expected timestamp_ltz_unconstrained) is
- + +
- +
+ +- +
+ +procedure warning_bad_annot_combination(
- +
+ +a_suite in out nocopy ut_suite_item,
- +
+ +a_procedure_name t_object_name,
- +
+ +a_proc_annotations tt_annotations_by_name,
- +
+ +a_for_annotation varchar2,
- +
+ +a_invalid_annotations ut_varchar2_list
- +
+ +) is
- +
+ +l_annotation_name t_annotation_name;
- +
+ +l_line_no binary_integer;
- -
begin
- - 1 -
-ut_utils.debug_log('ut_expectation_timestamp_ltz.not_to_be_less_than(self in ut_expectation_timestamp_ltz, a_expected timestamp_ltz_unconstrained)');
- - 1 -
-self.not_to( ut_be_less_than (a_expected) );
- + +
- + 2417 +
+ +if a_proc_annotations.exists(a_for_annotation) then
- + 2417 +
+ +l_annotation_name := a_proc_annotations.first;
- + 5359 +
+ +while l_annotation_name is not null loop
- + 2942 +
+ +if l_annotation_name member of a_invalid_annotations then
- + 4 +
+ +l_line_no := a_proc_annotations(l_annotation_name).first;
- + 8 +
+ +while l_line_no is not null loop
- + 4 +
+ +add_annotation_ignored_warning(
- +
+ +a_suite, l_annotation_name, 'Annotation %%% cannot be used with "--%'|| a_for_annotation || '".',
- +
+ +l_line_no, a_procedure_name
- +
+ +);
- + 4 +
+ +l_line_no := a_proc_annotations(l_annotation_name).next(l_line_no);
- +
+ +end loop;
- +
+ +end if;
- + 2942 +
+ +l_annotation_name := a_proc_annotations.next(l_annotation_name);
- +
+ +end loop;
- +
+ +end if;
- -
end;
- + +
- -
- -
end;
UT3.UT_EXPECTATION_TIMESTAMP_TZ
100 % covered
24 relevant lines. 24 lines covered and 0 lines missed-
- -
-type body ut_expectation_timestamp_tz as
- -
-/*
- -
-utPLSQL - Version X.X.X.X
- -
-Copyright 2016 - 2017 utPLSQL Project
- -
-- -
-Licensed under the Apache License, Version 2.0 (the "License"):
- -
-you may not use this file except in compliance with the License.
- -
-You may obtain a copy of the License at
- -
-- -
-http://www.apache.org/licenses/LICENSE-2.0
- -
-- -
-Unless required by applicable law or agreed to in writing, software
- -
-distributed under the License is distributed on an "AS IS" BASIS,
- -
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- -
-See the License for the specific language governing permissions and
- -
-limitations under the License.
- -
-*/
- -
-overriding member procedure to_equal(self in ut_expectation_timestamp_tz, a_expected timestamp_tz_unconstrained, a_nulls_are_equal boolean := null) is
- -
-begin
- - 11 -
-ut_utils.debug_log('ut_expectation_timestamp_tz.to_equal(self in ut_expectation, a_expected timestamp_tz_unconstrained, a_nulls_are_equal boolean := null)');
- - 11 -
-self.to_( ut_equal(a_expected, a_nulls_are_equal) );
- -
-end;
- -
-- -
-member procedure to_be_between(self in ut_expectation_timestamp_tz, a_lower_bound timestamp_tz_unconstrained, a_upper_bound timestamp_tz_unconstrained) is
- -
-begin
- - 6 -
-ut_utils.debug_log('ut_expectation_timestamp_tz.to_be_between(self in ut_expectation_timestamp_tz, a_lower_bound timestamp_tz_unconstrained, a_upper_bound timestamp_tz_unconstrained)');
- - 6 -
-self.to_( ut_be_between(a_lower_bound, a_upper_bound) );
- -
-end;
- -
-- -
-member procedure to_be_greater_or_equal(self in ut_expectation_timestamp_tz, a_expected timestamp_tz_unconstrained) is
- -
-begin
- - 3 -
-ut_utils.debug_log('ut_expectation_timestamp_tz.to_be_greater_or_equal(self in ut_expectation_timestamp_tz, a_expected timestamp_tz_unconstrained)');
- - 3 -
-self.to_( ut_be_greater_or_equal (a_expected) );
- -
-end;
- -
-member procedure to_be_greater_than(self in ut_expectation_timestamp_tz, a_expected timestamp_tz_unconstrained) is
- -
-begin
- - 2 -
-ut_utils.debug_log('ut_expectation_timestamp_tz.to_be_greater_than(self in ut_expectation_timestamp_tz, a_expected timestamp_tz_unconstrained)');
- - 2 -
-self.to_( ut_be_greater_than (a_expected) );
- -
-end;
- -
-member procedure to_be_less_or_equal(self in ut_expectation_timestamp_tz, a_expected timestamp_tz_unconstrained) is
- -
-begin
- - 3 -
-ut_utils.debug_log('ut_expectation_timestamp_tz.to_be_less_or_equal(self in ut_expectation_timestamp_tz, a_expected timestamp_tz_unconstrained)');
- - 3 -
-self.to_( ut_be_less_or_equal (a_expected) );
- -
-end;
- -
-member procedure to_be_less_than(self in ut_expectation_timestamp_tz, a_expected timestamp_tz_unconstrained) is
- + +
- +
+ +procedure add_test(
- +
+ +a_suite in out nocopy ut_suite,
- +
+ +a_suite_items in out nocopy ut_suite_items,
- +
+ +a_procedure_name t_object_name,
- +
+ +a_annotations t_annotations_info
- +
+ +) is
- +
+ +l_test ut_test;
- +
+ +l_annotation_texts tt_annotation_texts;
- + 2646 +
+ +l_proc_annotations tt_annotations_by_name := a_annotations.by_proc(a_procedure_name);
- -
begin
- - 2 -
-ut_utils.debug_log('ut_expectation_timestamp_tz.to_be_less_than(self in ut_expectation_timestamp_tz, a_expected timestamp_tz_unconstrained)');
- - 2 -
-self.to_( ut_be_less_than (a_expected) );
- -
-end;
- + +
- + 2646 +
+ +if not l_proc_annotations.exists(gc_test) then
- + 229 +
+ +return;
- +
+ +end if;
- + 2417 +
+ +warning_on_duplicate_annot( a_suite, l_proc_annotations, gc_test, a_procedure_name);
- + 2417 +
+ +warning_on_duplicate_annot( a_suite, l_proc_annotations, gc_displayname, a_procedure_name);
- + 2417 +
+ +warning_on_duplicate_annot( a_suite, l_proc_annotations, gc_rollback, a_procedure_name);
- + 2417 +
+ +warning_bad_annot_combination(
- +
+ +a_suite, a_procedure_name, l_proc_annotations, gc_test,
- +
+ +ut_varchar2_list(gc_beforeeach, gc_aftereach, gc_beforeall, gc_afterall)
- +
+ +);
- -
- -
-overriding member procedure not_to_equal(self in ut_expectation_timestamp_tz, a_expected timestamp_tz_unconstrained, a_nulls_are_equal boolean := null) is
- -
-begin
- - 2 -
-ut_utils.debug_log('ut_expectation_timestamp_tz.not_to_equal(self in ut_expectation, a_expected timestamp_tz_unconstrained, a_nulls_are_equal boolean := null)');
- - 2 -
-self.not_to( ut_equal(a_expected, a_nulls_are_equal) );
- -
-end;
- + +
- + 2417 +
+ +l_test := ut_test(a_suite.object_owner, a_suite.object_name, a_procedure_name, l_proc_annotations( gc_test).first);
- + 2417 +
+ +l_test.parse_time := a_annotations.parse_time;
- -
- -
-member procedure not_to_be_between(self in ut_expectation_timestamp_tz, a_lower_bound timestamp_tz_unconstrained, a_upper_bound timestamp_tz_unconstrained) is
- -
-begin
- - 4 -
-ut_utils.debug_log('ut_expectation_timestamp_tz.not_to_be_between(self in ut_expectation_timestamp_tz, a_lower_bound timestamp_tz_unconstrained, a_upper_bound timestamp_tz_unconstrained)');
- - 4 -
-self.not_to( ut_be_between(a_lower_bound, a_upper_bound) );
- -
-end;
- + +
- + 2417 +
+ +if l_proc_annotations.exists( gc_displayname) then
- + 5 +
+ +l_annotation_texts := l_proc_annotations( gc_displayname);
- +
+ +--take the last definition if more than one was provided
- + 5 +
+ +l_test.description := l_annotation_texts(l_annotation_texts.first);
- +
+ +--TODO if more than one - warning
- +
+ +else
- + 2412 +
+ +l_test.description := l_proc_annotations(gc_test)(l_proc_annotations(gc_test).first);
- +
+ +end if;
- + 2417 +
+ +l_test.path := a_suite.path ||'.'||a_procedure_name;
- -
- -
-member procedure not_to_be_greater_or_equal(self in ut_expectation_timestamp_tz, a_expected timestamp_tz_unconstrained) is
- -
-begin
- - 1 -
-ut_utils.debug_log('ut_expectation_timestamp_tz.not_to_be_greater_or_equal(self in ut_expectation_timestamp_tz, a_expected timestamp_tz_unconstrained)');
- - 1 -
-self.not_to( ut_be_greater_or_equal (a_expected) );
- -
-end;
- -
-member procedure not_to_be_greater_than(self in ut_expectation_timestamp_tz, a_expected timestamp_tz_unconstrained) is
- -
-begin
- - 1 -
-ut_utils.debug_log('ut_expectation_timestamp_tz.not_to_be_greater_than(self in ut_expectation_timestamp_tz, a_expected timestamp_tz_unconstrained)');
- - 1 -
-self.not_to( ut_be_greater_than (a_expected) );
- -
-end;
- -
-member procedure not_to_be_less_or_equal(self in ut_expectation_timestamp_tz, a_expected timestamp_tz_unconstrained) is
- -
-begin
- - 1 -
-ut_utils.debug_log('ut_expectation_timestamp_tz.not_to_be_less_or_equal(self in ut_expectation_timestamp_tz, a_expected timestamp_tz_unconstrained)');
- + +
- + 2417 +
+ +if l_proc_annotations.exists(gc_rollback) then
- 1 -
-self.not_to( ut_be_less_or_equal (a_expected) );
- -
-end;
- -
-member procedure not_to_be_less_than(self in ut_expectation_timestamp_tz, a_expected timestamp_tz_unconstrained) is
- -
-begin
- +
+ +l_annotation_texts := l_proc_annotations(gc_rollback);
- 1 -
-ut_utils.debug_log('ut_expectation_timestamp_tz.not_to_be_less_than(self in ut_expectation_timestamp_tz, a_expected timestamp_tz_unconstrained)');
- +
+ +l_test.rollback_type := get_rollback_type(l_annotation_texts(l_annotation_texts.first));
- 1 -
-self.not_to( ut_be_less_than (a_expected) );
- -
-end;
- +
+ +if l_test.rollback_type is null then
- +
+ +add_annotation_ignored_warning(
- +
+ +a_suite, gc_rollback, 'Annotation %%% must be provided with one of values: "auto" or "manual".',
- +
+ +l_annotation_texts.first, a_procedure_name
- +
+ +);
- +
+ +end if;
- +
+ +end if;
- -
- -
end;
UT3.UT_EXPECTATION_VARCHAR2
100 % covered
16 relevant lines. 16 lines covered and 0 lines missed-
- -
-type body ut_expectation_varchar2 as
- -
-/*
- -
-utPLSQL - Version X.X.X.X
- -
-Copyright 2016 - 2017 utPLSQL Project
- + +
- + 2417 +
+ +if l_proc_annotations.exists( gc_beforetest) then
- + 215 +
+ +l_test.before_test_list := convert_list(
- +
+ +add_executables( l_test.object_owner, l_test.object_name, l_proc_annotations( gc_beforetest ), gc_beforetest )
- +
+ +);
- + 215 +
+ +set_seq_no(l_test.before_test_list);
- +
+ +end if;
- + 2417 +
+ +if l_proc_annotations.exists( gc_aftertest) then
- + 213 +
+ +l_test.after_test_list := convert_list(
- +
+ +add_executables( l_test.object_owner, l_test.object_name, l_proc_annotations( gc_aftertest ), gc_aftertest )
- +
+ +);
- + 213 +
+ +set_seq_no(l_test.after_test_list);
- +
+ +end if;
- -
- -
-Licensed under the Apache License, Version 2.0 (the "License"):
- -
-you may not use this file except in compliance with the License.
- -
-You may obtain a copy of the License at
- + +
- + 2417 +
+ +if l_proc_annotations.exists( gc_tags) then
- + 33 +
+ +add_tags_to_suite_item(a_suite, l_proc_annotations( gc_tags), l_test.tags, a_procedure_name);
- +
+ +end if;
- -
- -
-http://www.apache.org/licenses/LICENSE-2.0
- + +
- + 2417 +
+ +if l_proc_annotations.exists( gc_throws) then
- + 33 +
+ +add_to_throws_numbers_list(a_suite, l_test.expected_error_codes, a_procedure_name, l_proc_annotations( gc_throws));
- +
+ +end if;
- + 2417 +
+ +l_test.disabled_flag := ut_utils.boolean_to_int( l_proc_annotations.exists( gc_disabled));
- -
- -
-Unless required by applicable law or agreed to in writing, software
- -
-distributed under the License is distributed on an "AS IS" BASIS,
- -
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- -
-See the License for the specific language governing permissions and
- -
-limitations under the License.
- -
-*/
- -
-overriding member procedure to_equal(self in ut_expectation_varchar2, a_expected varchar2, a_nulls_are_equal boolean := null) is
- -
-begin
- - 141 -
-ut_utils.debug_log('ut_expectation_varchar2.to_equal(self in ut_expectation, a_expected varchar2)');
- - 141 -
-self.to_( ut_equal(a_expected, a_nulls_are_equal) );
- -
-end;
- + +
- + 2417 +
+ +a_suite_items.extend;
- + 2417 +
+ +a_suite_items( a_suite_items.last ) := l_test;
- -
- -
-member procedure to_be_between(self in ut_expectation_varchar2, a_lower_bound varchar2, a_upper_bound varchar2) is
- -
-begin
- - 4 -
-ut_utils.debug_log('ut_expectation_varchar2.to_be_between(self in ut_expectation_varchar2, a_lower_bound varchar2, a_upper_bound varchar2)');
- - 4 -
-self.to_( ut_be_between(a_lower_bound,a_upper_bound) );
- + +
- -
end;
- + +
- -
- -
-member procedure to_be_like(self in ut_expectation_varchar2, a_mask in varchar2, a_escape_char in varchar2 := null) is
- -
-begin
- - 4 -
-ut_utils.debug_log('ut_expectation_varchar2.to_be_like(self in ut_expectation, a_mask in varchar2, a_escape_char in varchar2 default null)');
- - 4 -
-self.to_( ut_be_like(a_mask, a_escape_char) );
- -
-end;
- + +
- +
+ +procedure propagate_before_after_each(
- +
+ +a_suite_items in out nocopy ut_suite_items,
- +
+ +a_before_each_list tt_executables,
- +
+ +a_after_each_list tt_executables
- +
+ +) is
- +
+ +l_test ut_test;
- +
+ +l_context ut_logical_suite;
- +
+ +begin
- + 619 +
+ +if a_suite_items is not null then
- + 4322 +
+ +for i in 1 .. a_suite_items.count loop
- + 3703 +
+ +if a_suite_items(i) is of (ut_test) then
- + 3527 +
+ +l_test := treat( a_suite_items(i) as ut_test);
- + 3527 +
+ +l_test.before_each_list := convert_list(a_before_each_list) multiset union all l_test.before_each_list;
- + 3527 +
+ +set_seq_no(l_test.before_each_list);
- + 3527 +
+ +l_test.after_each_list := l_test.after_each_list multiset union all convert_list(a_after_each_list);
- + 3527 +
+ +set_seq_no(l_test.after_each_list);
- + 3527 +
+ +a_suite_items(i) := l_test;
- + 176 +
+ +elsif a_suite_items(i) is of (ut_logical_suite) then
- + 176 +
+ +l_context := treat(a_suite_items(i) as ut_logical_suite);
- + 176 +
+ +propagate_before_after_each( l_context.items, a_before_each_list, a_after_each_list);
- + 176 +
+ +a_suite_items(i) := l_context;
- +
+ +end if;
- +
+ +end loop;
- +
+ +end if;
- +
+ +end;
- -
- -
-member procedure to_match(self in ut_expectation_varchar2, a_pattern in varchar2, a_modifiers in varchar2 default null) is
- + +
- +
+ +procedure process_before_after_annot(
- +
+ +a_list in out nocopy tt_executables,
- +
+ +a_annotation_name t_annotation_name,
- +
+ +a_procedure_name t_object_name,
- +
+ +a_proc_annotations tt_annotations_by_name,
- +
+ +a_suite in out nocopy ut_suite
- +
+ +) is
- -
begin
- - 4 -
-ut_utils.debug_log('ut_expectation_varchar2.to_match(self in ut_expectation, a_pattern in varchar2, a_modifiers in varchar2 default null)');
- - 4 -
-self.to_( ut_match(a_pattern, a_modifiers) );
- + +
- + 10584 +
+ +if a_proc_annotations.exists(a_annotation_name) and not a_proc_annotations.exists(gc_test) then
- + 231 +
+ +a_list( a_proc_annotations(a_annotation_name).first ) := ut_executables(ut_executable(a_suite.object_owner, a_suite.object_name, a_procedure_name, a_annotation_name));
- + 231 +
+ +warning_on_duplicate_annot(a_suite, a_proc_annotations, a_annotation_name, a_procedure_name);
- +
+ +--TODO add warning if annotation has text - text ignored
- +
+ +end if;
- -
end;
- + +
- -
- -
-overriding member procedure not_to_equal(self in ut_expectation_varchar2, a_expected varchar2, a_nulls_are_equal boolean := null) is
- + +
- +
+ +procedure get_annotated_procedures(
- +
+ +a_proc_annotations t_annotations_info,
- +
+ +a_suite in out nocopy ut_suite,
- +
+ +a_suite_items in out nocopy ut_suite_items,
- +
+ +a_before_each_list in out nocopy tt_executables,
- +
+ +a_after_each_list in out nocopy tt_executables,
- +
+ +a_before_all_list in out nocopy tt_executables,
- +
+ +a_after_all_list in out nocopy tt_executables
- +
+ +) is
- +
+ +l_procedure_name t_object_name;
- -
begin
- - 2 -
-ut_utils.debug_log('ut_expectation_varchar2.not_to_equal(self in ut_expectation, a_expected varchar2)');
- - 2 -
-self.not_to( ut_equal(a_expected, a_nulls_are_equal) );
- + +
- + 443 +
+ +l_procedure_name := a_proc_annotations.by_proc.first;
- + 3089 +
+ +while l_procedure_name is not null loop
- + 2646 +
+ +add_test( a_suite, a_suite_items, l_procedure_name, a_proc_annotations );
- + 2646 +
+ +process_before_after_annot(a_before_each_list, gc_beforeeach, l_procedure_name, a_proc_annotations.by_proc(l_procedure_name), a_suite);
- + 2646 +
+ +process_before_after_annot(a_after_each_list, gc_aftereach, l_procedure_name, a_proc_annotations.by_proc(l_procedure_name), a_suite);
- + 2646 +
+ +process_before_after_annot(a_before_all_list, gc_beforeall, l_procedure_name, a_proc_annotations.by_proc(l_procedure_name), a_suite);
- + 2646 +
+ +process_before_after_annot(a_after_all_list, gc_afterall, l_procedure_name, a_proc_annotations.by_proc(l_procedure_name), a_suite);
- + 2646 +
+ +l_procedure_name := a_proc_annotations.by_proc.next( l_procedure_name );
- +
+ +end loop;
- -
end;
- + +
- -
- -
-member procedure not_to_be_between(self in ut_expectation_varchar2, a_lower_bound varchar2, a_upper_bound varchar2) is
- + +
- +
+ +procedure build_suitepath(
- +
+ +a_suite in out nocopy ut_suite,
- +
+ +a_annotations t_annotations_info
- +
+ +) is
- +
+ +l_annotation_text t_annotation_text;
- -
begin
- - 4 -
-ut_utils.debug_log('ut_expectation_varchar2.not_to_be_between(self in ut_expectation_varchar2, a_lower_bound varchar2, a_upper_bound varchar2)');
- - 4 -
-self.not_to( ut_be_between(a_lower_bound,a_upper_bound) );
- + +
- + 269 +
+ +if a_annotations.by_name.exists(gc_suitepath) then
- + 169 +
+ +l_annotation_text := trim(a_annotations.by_name(gc_suitepath)(a_annotations.by_name(gc_suitepath).first));
- + 169 +
+ +if l_annotation_text is not null then
- + 167 +
+ +if regexp_like(l_annotation_text,'^((\w|[$#])+\.)*(\w|[$#])+$') then
- + 166 +
+ +a_suite.path := l_annotation_text||'.'||a_suite.object_name;
- +
+ +else
- + 1 +
+ +add_annotation_ignored_warning(
- +
+ +a_suite, gc_suitepath||'('||l_annotation_text||')',
- +
+ +'Invalid path value in annotation %%%.', a_annotations.by_name(gc_suitepath).first
- +
+ +);
- +
+ +end if;
- +
+ +else
- + 2 +
+ +add_annotation_ignored_warning(
- +
+ +a_suite, gc_suitepath, '%%% annotation requires a non-empty parameter value.',
- +
+ +a_annotations.by_name(gc_suitepath).first
- +
+ +);
- +
+ +end if;
- + 167 +
+ +warning_on_duplicate_annot(a_suite, a_annotations.by_name, gc_suitepath);
- +
+ +end if;
- + 267 +
+ +a_suite.path := lower(coalesce(a_suite.path, a_suite.object_name));
- -
end;
- + +
- -
- -
-member procedure not_to_be_like(self in ut_expectation_varchar2, a_mask in varchar2, a_escape_char in varchar2 := null) is
- + +
- +
+ +procedure add_suite_tests(
- +
+ +a_suite in out nocopy ut_suite,
- +
+ +a_annotations t_annotations_info,
- +
+ +a_suite_items in out nocopy ut_suite_items
- +
+ +) is
- +
+ +l_before_each_list tt_executables;
- +
+ +l_after_each_list tt_executables;
- +
+ +l_before_all_list tt_executables;
- +
+ +l_after_all_list tt_executables;
- +
+ +l_rollback_type ut_utils.t_rollback_type;
- +
+ +l_annotation_text t_annotation_text;
- -
begin
- - 4 -
-ut_utils.debug_log('ut_expectation_varchar2.not_to_be_like(self in ut_expectation, a_mask in varchar2, a_escape_char in varchar2 default null)');
- - 4 -
-self.not_to( ut_be_like(a_mask, a_escape_char) );
- -
-end;
- + +
- + 443 +
+ +if a_annotations.by_name.exists(gc_displayname) then
- + 89 +
+ +l_annotation_text := trim(a_annotations.by_name(gc_displayname)(a_annotations.by_name(gc_displayname).first));
- + 89 +
+ +if l_annotation_text is not null then
- + 88 +
+ +a_suite.description := l_annotation_text;
- +
+ +else
- + 1 +
+ +add_annotation_ignored_warning(
- +
+ +a_suite, gc_displayname, '%%% annotation requires a non-empty parameter value.',
- +
+ +a_annotations.by_name(gc_displayname).first
- +
+ +);
- +
+ +end if;
- + 89 +
+ +warning_on_duplicate_annot(a_suite, a_annotations.by_name, gc_displayname);
- +
+ +end if;
- -
- -
-member procedure not_to_match(self in ut_expectation_varchar2, a_pattern in varchar2, a_modifiers in varchar2 default null) is
- -
-begin
- - 4 -
-ut_utils.debug_log('ut_expectation_varchar2.not_to_match(self in ut_expectation, a_pattern in varchar2, a_modifiers in varchar2 default null)');
- - 4 -
-self.not_to( ut_match(a_pattern, a_modifiers) );
- -
-end;
- + +
- + 443 +
+ +if a_annotations.by_name.exists(gc_rollback) then
- + 21 +
+ +l_rollback_type := get_rollback_type(a_annotations.by_name(gc_rollback)(a_annotations.by_name(gc_rollback).first));
- + 21 +
+ +if l_rollback_type is null then
- + 2 +
+ +add_annotation_ignored_warning(
- +
+ +a_suite, gc_rollback, '%%% annotation requires one of values as parameter: "auto" or "manual".',
- +
+ +a_annotations.by_name(gc_rollback).first
- +
+ +);
- +
+ +end if;
- + 21 +
+ +warning_on_duplicate_annot(a_suite, a_annotations.by_name, gc_rollback);
- +
+ +end if;
- + 443 +
+ +if a_annotations.by_name.exists(gc_beforeall) then
- + 52 +
+ +l_before_all_list := add_executables( a_suite.object_owner, a_suite.object_name, a_annotations.by_name(gc_beforeall), gc_beforeall );
- +
+ +end if;
- + 443 +
+ +if a_annotations.by_name.exists(gc_afterall) then
- + 52 +
+ +l_after_all_list := add_executables( a_suite.object_owner, a_suite.object_name, a_annotations.by_name(gc_afterall), gc_afterall );
- +
+ +end if;
- -
- -
end;
UT3.UT_EXPECTATION_YMINTERVAL
100 % covered
24 relevant lines. 24 lines covered and 0 lines missed-
- -
-type body ut_expectation_yminterval as
- -
-/*
- -
-utPLSQL - Version X.X.X.X
- -
-Copyright 2016 - 2017 utPLSQL Project
- + +
- + 443 +
+ +if a_annotations.by_name.exists(gc_beforeeach) then
- + 4 +
+ +l_before_each_list := add_executables( a_suite.object_owner, a_suite.object_name, a_annotations.by_name(gc_beforeeach), gc_beforeeach );
- +
+ +end if;
- + 443 +
+ +if a_annotations.by_name.exists(gc_aftereach) then
- + 7 +
+ +l_after_each_list := add_executables( a_suite.object_owner, a_suite.object_name, a_annotations.by_name(gc_aftereach), gc_aftereach );
- +
+ +end if;
- -
- -
-Licensed under the Apache License, Version 2.0 (the "License"):
- -
-you may not use this file except in compliance with the License.
- -
-You may obtain a copy of the License at
- + +
- + 443 +
+ +if a_annotations.by_name.exists(gc_tags) then
- + 22 +
+ +add_tags_to_suite_item(a_suite, a_annotations.by_name(gc_tags),a_suite.tags);
- +
+ +end if;
- + 443 +
+ +a_suite.disabled_flag := ut_utils.boolean_to_int(a_annotations.by_name.exists(gc_disabled));
- -
- -
-http://www.apache.org/licenses/LICENSE-2.0
- + +
- +
+ +--process procedure annotations for suite
- + 443 +
+ +get_annotated_procedures(a_annotations, a_suite, a_suite_items, l_before_each_list, l_after_each_list, l_before_all_list, l_after_all_list);
- -
- -
-Unless required by applicable law or agreed to in writing, software
- -
-distributed under the License is distributed on an "AS IS" BASIS,
- -
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- -
-See the License for the specific language governing permissions and
- -
-limitations under the License.
- -
-*/
- -
-overriding member procedure to_equal(self in ut_expectation_yminterval, a_expected yminterval_unconstrained, a_nulls_are_equal boolean := null) is
- -
-begin
- - 11 -
-ut_utils.debug_log('ut_expectation_yminterval.to_equal(self in ut_expectation, a_expected yminterval_unconstrained)');
- - 11 -
-self.to_( ut_equal(a_expected, a_nulls_are_equal) );
- + +
- + 443 +
+ +a_suite.set_rollback_type(l_rollback_type);
- + 443 +
+ +propagate_before_after_each( a_suite_items, l_before_each_list, l_after_each_list);
- + 443 +
+ +a_suite.before_all_list := convert_list(l_before_all_list);
- + 443 +
+ +set_seq_no(a_suite.before_all_list);
- + 443 +
+ +a_suite.after_all_list := convert_list(l_after_all_list);
- + 443 +
+ +set_seq_no(a_suite.after_all_list);
- -
end;
- + +
- -
- -
-member procedure to_be_between(self in ut_expectation_yminterval, a_lower_bound yminterval_unconstrained, a_upper_bound yminterval_unconstrained) is
- + +
- +
+ +function get_endcontext_position(
- +
+ +a_context_ann_pos t_annotation_position,
- +
+ +a_package_annotations in out nocopy tt_annotations_by_name
- +
+ +) return t_annotation_position is
- +
+ +l_result t_annotation_position;
- -
begin
- - 4 -
-ut_utils.debug_log('ut_expectation_yminterval.to_be_between(self in ut_expectation_yminterval, a_lower_bound dsinterval_unconstrained, a_upper_bound dsinterval_unconstrained)');
- - 4 -
-self.to_( ut_be_between(a_lower_bound,a_upper_bound) );
- + +
- + 179 +
+ +if a_package_annotations.exists(gc_endcontext) then
- + 177 +
+ +l_result := a_package_annotations(gc_endcontext).first;
- + 177 +
+ +while l_result <= a_context_ann_pos loop
- +
+ +l_result := a_package_annotations(gc_endcontext).next(l_result);
- +
+ +end loop;
- +
+ +end if;
- + 179 +
+ +return l_result;
- -
end;
- + +
- -
- -
-member procedure to_be_greater_or_equal(self in ut_expectation_yminterval, a_expected yminterval_unconstrained) is
- -
-begin
- - 3 -
-ut_utils.debug_log('ut_expectation_yminterval.to_be_greater_or_equal(self in ut_expectation_yminterval, a_expected yminterval_unconstrained)');
- - 3 -
-self.to_( ut_be_greater_or_equal (a_expected) );
- -
-end;
- -
-member procedure to_be_greater_than(self in ut_expectation_yminterval, a_expected yminterval_unconstrained) is
- -
-begin
- - 2 -
-ut_utils.debug_log('ut_expectation_yminterval.to_be_greater_than(self in ut_expectation_yminterval, a_expected yminterval_unconstrained)');
- - 2 -
-self.to_( ut_be_greater_than (a_expected) );
- -
-end;
- -
-member procedure to_be_less_or_equal(self in ut_expectation_yminterval, a_expected yminterval_unconstrained) is
- -
-begin
- - 3 -
-ut_utils.debug_log('ut_expectation_yminterval.to_be_less_or_equal(self in ut_expectation_yminterval, a_expected yminterval_unconstrained)');
- - 3 -
-self.to_( ut_be_less_or_equal (a_expected) );
- -
-end;
- -
-member procedure to_be_less_than(self in ut_expectation_yminterval, a_expected yminterval_unconstrained) is
- + +
- +
+ +function get_annotations_in_context(
- +
+ +a_annotations t_annotations_info,
- +
+ +a_context_pos t_annotation_position,
- +
+ +a_end_context_pos t_annotation_position
- +
+ +) return t_annotations_info is
- +
+ +l_result t_annotations_info;
- +
+ +l_position t_annotation_position;
- +
+ +l_procedure_name t_object_name;
- +
+ +l_annotation_name t_annotation_name;
- +
+ +l_annotation_text t_annotation_text;
- -
begin
- - 2 -
-ut_utils.debug_log('ut_expectation_yminterval.to_be_less_than(self in ut_expectation_yminterval, a_expected yminterval_unconstrained)');
- - 2 -
-self.to_( ut_be_less_than (a_expected) );
- + +
- + 177 +
+ +l_position := a_context_pos;
- + 177 +
+ +l_result.owner := a_annotations.owner;
- + 177 +
+ +l_result.name := a_annotations.name;
- + 177 +
+ +l_result.parse_time := a_annotations.parse_time;
- + 2037 +
+ +while l_position is not null and l_position <= a_end_context_pos loop
- + 1860 +
+ +l_result.by_line(l_position) := a_annotations.by_line(l_position);
- + 1860 +
+ +l_procedure_name := l_result.by_line(l_position).procedure_name;
- + 1860 +
+ +l_annotation_name := l_result.by_line(l_position).name;
- + 1860 +
+ +l_annotation_text := l_result.by_line(l_position).text;
- + 1860 +
+ +if l_procedure_name is not null then
- + 1330 +
+ +l_result.by_proc(l_procedure_name)(l_annotation_name)(l_position) := l_annotation_text;
- +
+ +else
- + 530 +
+ +l_result.by_name(l_annotation_name)(l_position) := l_annotation_text;
- +
+ +end if;
- + 1860 +
+ +l_position := a_annotations.by_line.next(l_position);
- +
+ +end loop;
- + 177 +
+ +return l_result;
- -
end;
- + +
- -
- -
-overriding member procedure not_to_equal(self in ut_expectation_yminterval, a_expected yminterval_unconstrained, a_nulls_are_equal boolean := null) is
- + +
- +
+ +procedure get_suite_contexts_items(
- +
+ +a_suite in out nocopy ut_suite,
- +
+ +a_annotations in out nocopy t_annotations_info,
- +
+ +a_suite_items out nocopy ut_suite_items
- +
+ +) is
- +
+ +l_context_pos t_annotation_position;
- +
+ +l_end_context_pos t_annotation_position;
- +
+ +l_context_name t_object_name;
- +
+ +l_ctx_annotations t_annotations_info;
- +
+ +l_context ut_suite_context;
- + 267 +
+ +l_context_no binary_integer := 1;
- +
+ +l_context_items ut_suite_items;
- +
+ +type tt_context_names is table of boolean index by t_object_name;
- +
+ +l_context_names tt_context_names;
- -
begin
- - 2 -
-ut_utils.debug_log('ut_expectation_yminterval.not_to_equal(self in ut_expectation, a_expected yminterval_unconstrained)');
- - 2 -
-self.not_to( ut_equal(a_expected, a_nulls_are_equal) );
- -
-end;
- + +
- + 267 +
+ +a_suite_items := ut_suite_items();
- + 267 +
+ +if not a_annotations.by_name.exists(gc_context) then
- + 204 +
+ +return;
- +
+ +end if;
- -
- -
-member procedure not_to_be_between(self in ut_expectation_yminterval, a_lower_bound yminterval_unconstrained, a_upper_bound yminterval_unconstrained) is
- -
-begin
- - 4 -
-ut_utils.debug_log('ut_expectation_yminterval.not_to_be_between(self in ut_expectation_yminterval, a_lower_bound dsinterval_unconstrained, a_upper_bound dsinterval_unconstrained)');
- - 4 -
-self.not_to( ut_be_between(a_lower_bound,a_upper_bound) );
- -
-end;
- + +
- + 63 +
+ +l_context_pos := a_annotations.by_name( gc_context).first;
- -
- -
-member procedure not_to_be_greater_or_equal(self in ut_expectation_yminterval, a_expected yminterval_unconstrained) is
- -
-begin
- - 1 -
-ut_utils.debug_log('ut_expectation_yminterval.not_to_be_greater_or_equal(self in ut_expectation_yminterval, a_expected yminterval_unconstrained)');
- - 1 -
-self.not_to( ut_be_greater_or_equal (a_expected) );
- -
-end;
- -
-member procedure not_to_be_greater_than(self in ut_expectation_yminterval, a_expected yminterval_unconstrained) is
- -
-begin
- - 1 -
-ut_utils.debug_log('ut_expectation_yminterval.not_to_be_greater_than(self in ut_expectation_yminterval, a_expected yminterval_unconstrained)');
- + +
- + 179 +
+ +while l_context_pos is not null loop
- + 179 +
+ +l_end_context_pos := get_endcontext_position(l_context_pos, a_annotations.by_name );
- +
+ +- + 179 +
+ +exit when l_end_context_pos is null;
- +
+ +- + 177 +
+ +l_context_items := ut_suite_items();
- +
+ +--create a sub-set of annotations to process as sub-suite (context)
- + 177 +
+ +l_ctx_annotations := get_annotations_in_context( a_annotations, l_context_pos, l_end_context_pos);
- +
+ +- + 177 +
+ +l_context_name := coalesce(
- 1 -
-self.not_to( ut_be_greater_than (a_expected) );
- +
+ +l_ctx_annotations.by_line( l_context_pos ).text
- +
+ +, gc_context||'_'||l_context_no
- +
+ +);
- + 177 +
+ +if l_context_names.exists(l_context_name) then
- + 1 +
+ +add_annotation_ignored_warning( a_suite, 'context', 'Context name must be unique in a suite. Context and all of it''s content ignored.', l_context_pos );
- +
+ +else
- + 176 +
+ +l_context_names(l_context_name) := true;
- +
+ +- + 176 +
+ +l_context := ut_suite_context(a_suite.object_owner, a_suite.object_name, l_context_name, l_context_pos );
- +
+ +- + 176 +
+ +l_context.path := a_suite.path||'.'||l_context_name;
- + 176 +
+ +l_context.description := l_ctx_annotations.by_line( l_context_pos ).text;
- + 176 +
+ +l_context.parse_time := a_annotations.parse_time;
- +
+ +- + 176 +
+ +warning_on_duplicate_annot( l_context, l_ctx_annotations.by_name, gc_context );
- +
+ +- + 176 +
+ +add_suite_tests( l_context, l_ctx_annotations, l_context_items );
- + 176 +
+ +add_items_to_list(a_suite_items, l_context_items);
- + 176 +
+ +a_suite_items.extend;
- + 176 +
+ +a_suite_items(a_suite_items.last) := l_context;
- +
+ +end if;
- +
+ +-- remove annotations within context after processing them
- + 177 +
+ +delete_annotations_range(a_annotations, l_context_pos, l_end_context_pos);
- +
+ +- + 177 +
+ +exit when not a_annotations.by_name.exists( gc_context);
- +
+ +- + 116 +
+ +l_context_pos := a_annotations.by_name( gc_context).next( l_context_pos);
- + 116 +
+ +l_context_no := l_context_no + 1;
- +
+ +end loop;
- -
end;
- -
-member procedure not_to_be_less_or_equal(self in ut_expectation_yminterval, a_expected yminterval_unconstrained) is
- + +
- +
+ +- +
+ +procedure warning_on_incomplete_context(
- +
+ +a_suite in out nocopy ut_suite,
- +
+ +a_package_ann_index tt_annotations_by_name
- +
+ +) is
- +
+ +l_annotation_pos t_annotation_position;
- -
begin
- + +
- + 267 +
+ +if a_package_ann_index.exists(gc_context) then
- + 2 +
+ +l_annotation_pos := a_package_ann_index(gc_context).first;
- + 4 +
+ +while l_annotation_pos is not null loop
- + 2 +
+ +add_annotation_ignored_warning(
- +
+ +a_suite, gc_context, 'Invalid annotation %%%. Cannot find following "--%endcontext".',
- +
+ +l_annotation_pos
- +
+ +);
- + 2 +
+ +l_annotation_pos := a_package_ann_index(gc_context).next(l_annotation_pos);
- +
+ +end loop;
- +
+ +end if;
- + 267 +
+ +if a_package_ann_index.exists(gc_endcontext) then
- 1 -
-ut_utils.debug_log('ut_expectation_yminterval.not_to_be_less_or_equal(self in ut_expectation_yminterval, a_expected yminterval_unconstrained)');
- +
+ +l_annotation_pos := a_package_ann_index(gc_endcontext).first;
- + 2 +
+ +while l_annotation_pos is not null loop
- 1 -
-self.not_to( ut_be_less_or_equal (a_expected) );
- +
+ +add_annotation_ignored_warning(
- +
+ +a_suite, gc_endcontext, 'Invalid annotation %%%. Cannot find preceding "--%context".',
- +
+ +l_annotation_pos
- +
+ +);
- + 1 +
+ +l_annotation_pos := a_package_ann_index(gc_endcontext).next(l_annotation_pos);
- +
+ +end loop;
- +
+ +end if;
- -
end;
- -
-member procedure not_to_be_less_than(self in ut_expectation_yminterval, a_expected yminterval_unconstrained) is
- + +
- +
+ +- +
+ +procedure warning_on_unknown_annotations(
- +
+ +a_suite in out nocopy ut_suite_item,
- +
+ +a_annotations tt_annotations_by_line
- +
+ +) is
- + 269 +
+ +l_line_no t_annotation_position := a_annotations.first;
- -
begin
- - 1 -
-ut_utils.debug_log('ut_expectation_yminterval.not_to_be_less_than(self in ut_expectation_yminterval, a_expected yminterval_unconstrained)');
- - 1 -
-self.not_to( ut_be_less_than (a_expected) );
- + +
- + 4525 +
+ +while l_line_no is not null loop
- + 4256 +
+ +if a_annotations(l_line_no).name not member of (gc_supported_annotations) then
- + 2 +
+ +add_annotation_ignored_warning(
- +
+ +a_suite,
- +
+ +a_annotations(l_line_no).name,
- +
+ +'Unsupported annotation %%%.',
- +
+ +l_line_no,
- +
+ +a_annotations(l_line_no).procedure_name
- +
+ +);
- +
+ +end if;
- + 4256 +
+ +l_line_no := a_annotations.next(l_line_no);
- +
+ +end loop;
- -
end;
- + +
- -
- -
end;
+UT3.UT_ANSICONSOLE_HELPER
83.33 % covered
18 relevant lines. 15 lines covered and 3 lines missed+ +
- +
+ +function convert_package_annotations(a_object ut_annotated_object) return t_annotations_info is
- +
+ +l_result t_annotations_info;
- +
+ +l_annotation t_annotation;
- +
+ +l_annotation_no binary_integer;
- +
+ +l_annotation_pos binary_integer;
- +
+ +begin
- + 274 +
+ +l_result.owner := a_object.object_owner;
- + 274 +
+ +l_result.name := lower(trim(a_object.object_name));
- + 274 +
+ +l_result.parse_time := a_object.parse_time;
- + 274 +
+ +l_annotation_no := a_object.annotations.first;
- + 4542 +
+ +while l_annotation_no is not null loop
- + 4268 +
+ +l_annotation_pos := a_object.annotations(l_annotation_no).position;
- + 4268 +
+ +l_annotation.name := a_object.annotations(l_annotation_no).name;
- + 4268 +
+ +l_annotation.text := a_object.annotations(l_annotation_no).text;
- + 4268 +
+ +l_annotation.procedure_name := lower(trim(a_object.annotations(l_annotation_no).subobject_name));
- + 4268 +
+ +l_result.by_line( l_annotation_pos) := l_annotation;
- + 4268 +
+ +if l_annotation.procedure_name is null then
- + 1063 +
+ +l_result.by_name( l_annotation.name)( l_annotation_pos) := l_annotation.text;
- +
+ +else
- + 3205 +
+ +l_result.by_proc(l_annotation.procedure_name)(l_annotation.name)(l_annotation_pos) := l_annotation.text;
- +
+ +end if;
- + 4268 +
+ +l_annotation_no := a_object.annotations.next(l_annotation_no);
- +
+ +end loop;
- + 274 +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+ +procedure create_suite_item_list( a_annotated_object ut_annotated_object, a_suite_items out nocopy ut_suite_items ) is
- +
+ +l_annotations t_annotations_info;
- +
+ +l_annotation_pos t_annotation_position;
- +
+ +l_suite ut_suite;
- +
+ +begin
- + 274 +
+ +l_annotations := convert_package_annotations( a_annotated_object );
- +
+ +- + 274 +
+ +if l_annotations.by_name.exists(gc_suite) then
- + 269 +
+ +l_annotation_pos := l_annotations.by_name(gc_suite).first;
- + 269 +
+ +l_suite := ut_suite(l_annotations.owner, l_annotations.name, l_annotation_pos);
- + 269 +
+ +l_suite.description := l_annotations.by_name( gc_suite)( l_annotation_pos);
- + 269 +
+ +l_suite.parse_time := l_annotations.parse_time;
- + 269 +
+ +warning_on_unknown_annotations(l_suite, l_annotations.by_line);
- +
+ +- + 269 +
+ +warning_on_duplicate_annot( l_suite, l_annotations.by_name, gc_suite );
- +
+ +- + 269 +
+ +build_suitepath( l_suite, l_annotations );
- + 267 +
+ +get_suite_contexts_items( l_suite, l_annotations, a_suite_items );
- +
+ +--create suite tests and add
- + 267 +
+ +add_suite_tests( l_suite, l_annotations, a_suite_items );
- +
+ +- +
+ +--by this time all contexts were consumed and l_annotations should not have any context/endcontext annotation in it.
- + 267 +
+ +warning_on_incomplete_context( l_suite, l_annotations.by_name );
- +
+ +- + 267 +
+ +a_suite_items.extend;
- + 267 +
+ +a_suite_items( a_suite_items.last) := l_suite;
- +
+ +end if;
- +
+ +end;
- +
+ +- +
+end ut_suite_builder;
UT3.UT_SUITE_CACHE_MANAGER
96.92 % lines covered
65 relevant lines. 63 lines covered and 2 lines missed+
- -
+package body ut_ansiconsole_helper as
package body ut_suite_cache_manager is
+- +
/*
- -
+utPLSQL - Version X.X.X.X
utPLSQL - Version 3
+- -
+Copyright 2016 - 2017 utPLSQL Project
Copyright 2016 - 2019 utPLSQL Project
+- +
- +
Licensed under the Apache License, Version 2.0 (the "License"):
- +
you may not use this file except in compliance with the License.
- +
You may obtain a copy of the License at
- +
- +
http://www.apache.org/licenses/LICENSE-2.0
- +
- +
Unless required by applicable law or agreed to in writing, software
- +
distributed under the License is distributed on an "AS IS" BASIS,
- +
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
See the License for the specific language governing permissions and
- +
limitations under the License.
- -
*/
- - 1 -
-c_red constant varchar2(7) := chr(27) || '[31m';
- - 1 -
-c_green constant varchar2(7) := chr(27) || '[32m';
- - 1 -
-c_yellow constant varchar2(7) := chr(27) || '[33m';
- - 1 -
-c_blue constant varchar2(7) := chr(27) || '[34m';
- - 1 -
-c_magenta constant varchar2(7) := chr(27) || '[35m';
- - 1 -
-c_cyan constant varchar2(7) := chr(27) || '[36m';
- - 1 -
-c_reset constant varchar2(7) := chr(27) || '[0m';
- - 1 -
-g_enabled boolean := false;
- + +
- -
- -
+ +procedure color_enabled(a_enabled boolean) is
- +
+ +/*
- +
+ +* Private code
- +
+ +*/
- +
+ +- + 1 +
+ +gc_get_cache_suite_sql constant varchar2(32767) :=
- +
+ +q'[with
- +
+ +suite_items as (
- +
+ +select /*+ cardinality(c 500) */ value(c) as obj
- +
+from ut_suite_cache c
- -
-begin
- - 48 -
+g_enabled := a_enabled;
where 1 = 1
+ +- +
+and c.object_owner = :l_object_owner
- -
+end;
and ( {:path:}
+- -
+and {:object_name:}
+- -
+function add_color(a_text varchar2, a_color varchar2 := c_reset) return varchar2 is
and {:procedure_name:}
+- -
-begin
- - 185 -
-if g_enabled and a_text is not null then
- -
+return a_color||a_text||c_reset;
)
+ +- +
+ +)
- +
+),
- -
-else
- - 185 -
+return a_text;
{:tags:}
+ +- +
+suitepaths as (
- -
+end if;
select distinct substr(c.obj.path,1,instr(c.obj.path,'.',-1)-1) as suitepath,
+- -
+end;
c.obj.path as path,
+- -
+c.obj.object_owner as object_owner
+- -
+function red(a_text varchar2) return varchar2 is
from {:suite_item_name:} c
+- -
-begin
- - 95 -
+return add_color(a_text, c_red);
where c.obj.self_type = 'UT_SUITE'
+ +- +
+),
- -
+end;
gen as (
+- -
+select rownum as pos
+- -
+function green(a_text varchar2) return varchar2 is
from xmltable('1 to 20')
+- -
-begin
- - 64 -
+return add_color(a_text, c_green);
),
+ +- +
+suitepath_part AS (
- -
+end;
select distinct
+- -
+substr(b.suitepath, 1, instr(b.suitepath || '.', '.', 1, g.pos) -1) as path,
+- -
+function yellow(a_text varchar2) return varchar2 is
object_owner
+- -
-begin
- - 13 -
+return add_color(a_text, c_yellow);
from suitepaths b
+ +- +
+join gen g
- -
+end;
on g.pos <= regexp_count(b.suitepath, '\w+')
+- -
+),
+- -
+function blue(a_text varchar2) return varchar2 is
logical_suite_data as (
+- -
-begin
- -
+return add_color(a_text, c_blue);
select 'UT_LOGICAL_SUITE' as self_type, p.path, p.object_owner,
+ +- +
+upper( substr(p.path, instr( p.path, '.', -1 ) + 1 ) ) as object_name,
- -
+end;
cast(null as ut_executables) as x,
+- -
+cast(null as ut_integer_list) as y,
+- -
+function magenta(a_text varchar2) return varchar2 is
cast(null as ut_executable_test) as z
+- -
-begin
- -
+return add_color(a_text, c_magenta);
from suitepath_part p
+ +- +
+where p.path
- -
+end;
not in (select s.path from suitepaths s)
+- -
+),
+- -
+function cyan(a_text varchar2) return varchar2 is
logical_suites as (
+- -
-begin
- - 13 -
+return add_color(a_text, c_cyan);
select ut_suite_cache_row(
+ +- +
+null,
- -
+end;
s.self_type, s.path, s.object_owner, s.object_name,
+- -
+s.object_name, null, null, null, null, 0,
+- -
end;
UT3.UT_COVERAGE_HTML_REPORTER
100 % covered
9 relevant lines. 9 lines covered and 0 lines missed-
- -
-type body ut_coverage_html_reporter is
- -
-/*
- -
-utPLSQL - Version X.X.X.X
- -
-Copyright 2016 - 2017 utPLSQL Project
- +
+ +ut_varchar2_rows(),
- +
+ +s.x, s.x, s.x, s.x, s.x, s.x,
- +
+ +s.y, null, s.z
- +
+ +) as obj
- +
+ +from logical_suite_data s
- +
+ +),
- +
+ +items as (
- +
+ +select obj from {:suite_item_name:}
- +
+ +union all
- +
+ +select obj from logical_suites
- +
+ +)
- +
+ +select c.obj
- +
+ +from items c
- +
+ +order by c.obj.object_owner,{:random_seed:}]';
- -
- -
-Licensed under the Apache License, Version 2.0 (the "License"):
- -
-you may not use this file except in compliance with the License.
- -
-You may obtain a copy of the License at
- + +
- +
+ +function get_missing_cache_objects(a_object_owner varchar2) return ut_varchar2_rows is
- +
+ +l_result ut_varchar2_rows;
- +
+ +l_data ut_annotation_objs_cache_info;
- +
+ +begin
- + 301 +
+ +l_data := ut_annotation_cache_manager.get_cached_objects_list(a_object_owner, 'PACKAGE');
- -
- -
-http://www.apache.org/licenses/LICENSE-2.0
- + +
- + 301 +
+ +select i.object_name
- +
+ +bulk collect into l_result
- +
+ +from ut_suite_cache_package i
- +
+ +where not exists (
- +
+ +select 1 from table(l_data) o
- +
+ +where o.object_owner = i.object_owner
- +
+ +and o.object_name = i.object_name
- +
+ +and o.object_type = 'PACKAGE'
- +
+ +)
- +
+ +and i.object_owner = a_object_owner;
- + 301 +
+ +return l_result;
- +
+ +end;
- -
- -
-Unless required by applicable law or agreed to in writing, software
- -
-distributed under the License is distributed on an "AS IS" BASIS,
- -
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- -
-See the License for the specific language governing permissions and
- -
-limitations under the License.
- -
-*/
- + +
- -
- -
-constructor function ut_coverage_html_reporter(
- -
-self in out nocopy ut_coverage_html_reporter,
- -
-a_project_name varchar2 := null,
- -
-a_html_report_assets_path varchar2 := null
- -
-) return self as result is
- + +
- +
+ +function get_path_sql(a_path in varchar2) return varchar2 is
- -
begin
- - 3 -
-self.init($$plsql_unit);
- - 3 -
-self.project_name := a_project_name;
- - 3 -
-assets_path := nvl(a_html_report_assets_path, ut_coverage_report_html_helper.get_default_html_assets_path());
- - 3 -
-return;
- + +
- + 215 +
+ +return case when a_path is not null then q'[
- +
+ +:l_path||'.' like c.path || '.%' /*all children and self*/
- +
+ +or ( c.path||'.' like :l_path || '.%' --all parents
- +
+ +]'
- +
+ +else ' :l_path is null and ( :l_path is null ' end;
- -
end;
- + +
- -
- -
-overriding member procedure after_calling_run(self in out nocopy ut_coverage_html_reporter, a_run in ut_run) as
- -
-l_report_lines ut_varchar2_list;
- - 3 -
-l_coverage_data ut_coverage.t_coverage;
- + +
- +
+ +function get_object_name_sql(a_object_name in varchar2) return varchar2 is
- -
begin
- - 5 -
-ut_coverage.coverage_stop();
- -
-- - 3 -
-l_coverage_data := ut_coverage.get_coverage_data(a_run.coverage_options);
- -
-- - 3 -
-self.print_clob( ut_coverage_report_html_helper.get_index( l_coverage_data, self.assets_path, self.project_name ) );
- -
-- - 3 -
-(self as ut_reporter_base).after_calling_run(a_run);
- + +
- + 215 +
+ +return case when a_object_name is not null
- +
+ +then ' c.object_name = :a_object_name '
- +
+ +else ' :a_object_name is null' end;
- -
end;
- -
-- -
end;
UT3.UT_COVERAGE_REPORT_HTML_HELPER
88.64 % covered
88 relevant lines. 78 lines covered and 10 lines missed-
- -
-package body ut_coverage_report_html_helper is
- -
-/*
- -
-utPLSQL - Version X.X.X.X
- -
-Copyright 2016 - 2017 utPLSQL Project
- -
-- -
-Licensed under the Apache License, Version 2.0 (the "License"):
- -
-you may not use this file except in compliance with the License.
- -
-You may obtain a copy of the License at
- -
-- -
-http://www.apache.org/licenses/LICENSE-2.0
- -
-- -
-Unless required by applicable law or agreed to in writing, software
- -
-distributed under the License is distributed on an "AS IS" BASIS,
- -
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- -
-See the License for the specific language governing permissions and
- -
-limitations under the License.
- -
-*/
- -
-- - 1 -
-gc_green_coverage_pct constant integer := 90;
- - 1 -
-gc_yellow_coverage_pct constant integer := 80;
- -
-- - 1 -
-gc_green_css constant varchar2(10) := 'green';
- - 1 -
-gc_yellow_css constant varchar2(10) := 'yellow';
- - 1 -
-gc_red_css constant varchar2(10) := 'red';
- -
-- - 1 -
-gc_missed constant varchar2(7) := 'missed';
- - 1 -
-gc_skipped constant varchar2(7) := 'skipped';
- - 1 -
-gc_disabled constant varchar2(7) := 'never';
- - 1 -
-gc_covered constant varchar2(7) := 'covered';
- -
-- + +
- -
- -
-function get_default_html_assets_path return varchar2 deterministic is
- - 3 -
-c_assets_path constant varchar2(200) := 'https://utplsql.github.io/utPLSQL-coverage-html/assets/';
- + +
- +
+ +function get_procedure_name_sql(a_procedure_name in varchar2) return varchar2 is
- -
begin
- - 3 -
-return c_assets_path;
- + +
- + 215 +
+ +return case when a_procedure_name is not null
- +
+ +then ' c.name = :a_procedure_name'
- +
+ +else ' :a_procedure_name is null' end;
- -
end;
- + +
- -
- -
-function coverage_css_class(a_covered_pct number) return varchar2 is
- -
-l_result varchar2(10);
- + +
- +
+ +function get_tags_sql(a_tags_count in integer) return varchar2 is
- -
begin
- - 347 -
-if a_covered_pct > gc_green_coverage_pct then
- -
-l_result := gc_green_css;
- - 347 -
-elsif a_covered_pct > gc_yellow_coverage_pct then
- -
-l_result := gc_yellow_css;
- -
-else
- - 347 -
-l_result := gc_red_css;
- -
-end if;
- - 347 -
-return l_result;
- + +
- + 215 +
+ +return case when a_tags_count > 0 then
- +
+ +q'[filter_tags as (
- +
+ +select c.obj.path as path
- +
+ +from suite_items c
- +
+ +where c.obj.tags multiset intersect :a_tag_list is not empty
- +
+ +),
- +
+ +suite_items_tags as (
- +
+ +select c.*
- +
+ +from suite_items c
- +
+ +where exists (
- +
+ +select 1 from filter_tags t
- +
+ +where t.path||'.' like c.obj.path || '.%' /*all children and self*/
- +
+ +or c.obj.path||'.' like t.path || '.%' --all parents
- +
+ +)
- +
+ +),]'
- +
+ +else
- +
+ +q'[dummy as (select 'x' from dual where :a_tag_list is null ),]'
- +
+ +end;
- -
end;
- + +
- -
- -
-function line_status(a_executions binary_integer) return varchar2 is
- -
-l_result varchar2(10);
- + +
- +
+ +function get_random_seed_sql(a_random_seed positive) return varchar2 is
- -
begin
- - 17764 -
-if a_executions > 0 then
- -
-l_result := gc_covered;
- - 17764 -
-elsif a_executions = 0 then
- -
-l_result := gc_missed;
- -
-else
- - 17764 -
-l_result := gc_disabled;
- -
-end if;
- - 17764 -
-return l_result;
- + +
- + 215 +
+ +return case
- + 1 +
+ +when a_random_seed is null then q'[
- +
+ +replace(
- +
+ +case
- +
+ +when c.obj.self_type in ( 'UT_TEST' )
- +
+ +then substr(c.obj.path, 1, instr(c.obj.path, '.', -1) )
- +
+ +else c.obj.path
- +
+ +end, '.', chr(0)
- +
+ +) desc nulls last,
- +
+ +c.obj.object_name desc,
- +
+ +c.obj.line_no,
- +
+ +:a_random_seed]'
- +
+ +else
- +
+ +' ut_runner.hash_suite_path(
- +
+ +c.obj.path, :a_random_seed
- +
+ +) desc nulls last'
- +
+ +end;
- -
end;
- + +
- -
- -
-function executions_per_line(a_executions number, a_lines integer) return integer is
- -
-begin
- - 175 -
-return nvl(a_executions/nullif(a_lines,0),0);
- -
-end;
- + +
- -
- -
-function line_hits_css_class(a_line_hist number) return varchar2 is
- -
-l_result varchar2(10);
- -
-begin
- - 3 -
-if a_line_hist > 1 then
- -
-l_result := gc_green_css;
- - 3 -
-elsif a_line_hist = 1 then
- -
-l_result := gc_yellow_css;
- -
-else
- - 3 -
-l_result := gc_red_css;
- -
-end if;
- - 3 -
-return l_result;
- -
-end;
- -
-- -
-function coverage_pct(a_covered_lines integer, a_uncovered_lines integer) return number is
- -
-begin
- - 344 -
-return round(nvl(a_covered_lines/nullif(a_covered_lines+a_uncovered_lines,0),0)*100,2);
- -
-end;
- -
-- -
-function object_id(a_object_full_name varchar2) return varchar2 is
- -
-begin
- - 341 -
-return rawtohex( utl_raw.CAST_TO_RAW(dbms_obfuscation_toolkit.md5(input_string=>a_object_full_name)) );
- -
-end;
- -
-- -
-function link_to_source_file(a_object_full_name varchar2) return varchar2 is
- -
-begin
- - 169 -
-return '<a href="#'||object_id(a_object_full_name)||'" class="src_link" title="'||a_object_full_name||'">'||a_object_full_name||'</a>';
- -
-end;
- -
-- -
-function get_details_file_content(a_object_id varchar2, a_unit ut_object_name, a_unit_coverage ut_coverage.t_unit_coverage) return clob is
- -
-type tt_source_data is table of varchar2(32767);
- -
-l_source_code tt_source_data;
- -
-l_result clob;
- -
-- -
-function build_details_file_content(a_object_id varchar2, a_object_full_name varchar2, a_source_code tt_source_data, a_coverage_unit ut_coverage.t_unit_coverage ) return clob is
- -
-l_file_part varchar2(32767);
- -
-l_result clob;
- -
-l_coverage_pct number(5,2);
- -
-begin
- - 169 -
-dbms_lob.createtemporary(l_result, true);
- - 169 -
-l_coverage_pct := coverage_pct(a_coverage_unit.covered_lines, a_coverage_unit.uncovered_lines);
- - 169 -
-l_file_part :=
- -
-'<div class="source_table" id="'||a_object_id||'"><div class="header"> <h3>'||a_object_full_name||'</h3>' ||
- -
-'<h4><span class="'||coverage_css_class(l_coverage_pct)||'">'||l_coverage_pct||' %</span> covered</h4>' ||
- -
-'<div> <b>'||(a_coverage_unit.covered_lines+a_coverage_unit.uncovered_lines)||'</b> relevant lines. ' ||
- -
-'<span class="green"><b>'||a_coverage_unit.covered_lines||'</b> lines covered</span> and ' ||
- -
-'<span class="red"><b>'||a_coverage_unit.uncovered_lines||'</b> lines missed</span></div></div>' ||
- -
-'<pre><ol>';
- - 169 -
-ut_utils.append_to_clob(l_result, l_file_part);
- -
-- - 17933 -
-for line_no in 1 .. a_source_code.count loop
- - 17764 -
-if not a_coverage_unit.lines.exists(line_no) then
- - 17764 -
-l_file_part :='
- -
-<li class="'||line_status(null)||'" data-hits="" data-linenumber="'||line_no||'">
- -
-<code class="sql">' || (dbms_xmlgen.convert(a_source_code(line_no))) || '</code></li>';
- -
-else
- -
-l_file_part :='
- -
-<li class="'||line_status(a_coverage_unit.lines(line_no))||'" data-hits="'||(a_coverage_unit.lines(line_no))||'" data-linenumber="'||(line_no)||'">';
- -
-if a_coverage_unit.lines(line_no) > 0 then
- -
-l_file_part := l_file_part || '
- -
-<span class="hits">'||(a_coverage_unit.lines(line_no))||'</span>';
- -
-end if;
- -
-l_file_part := l_file_part || '
- -
-<code class="sql">' || (dbms_xmlgen.convert(a_source_code(line_no))) || '</code></li>';
- -
-end if;
- - 17764 -
-ut_utils.append_to_clob(l_result, l_file_part);
- -
-end loop;
- -
-- - 169 -
-l_file_part := '</ol></pre></div>';
- - 169 -
-ut_utils.append_to_clob(l_result, l_file_part);
- - 169 -
-return l_result;
- -
-end;
- -
-begin
- - 169 -
-select rtrim(s.text,chr(10)) text
- -
-bulk collect into l_source_code
- -
-from ut_coverage_sources_tmp s
- -
-where s.owner = a_unit.owner
- -
-and s.name = a_unit.name
- -
-order by s.line;
- - 169 -
-dbms_lob.createtemporary(l_result,true);
- - 169 -
-l_result := build_details_file_content(a_object_id, a_unit.identity, l_source_code, a_unit_coverage);
- - 169 -
-return l_result;
- -
-end;
- -
-- -
-function file_list(a_title varchar2, a_coverage ut_coverage.t_coverage) return clob is
- -
-l_file_part varchar2(32767);
- - 3 -
-l_title varchar2(100) := 'All files';
- -
-l_coverage_pct number(5,2);
- -
-l_result clob;
- - 3 -
-l_id varchar2(50) := object_id(a_title);
- - 3 -
-l_unit_coverage ut_coverage.t_unit_coverage;
- -
-l_unit ut_coverage.t_object_name;
- -
-begin
- - 3 -
-dbms_lob.createtemporary(l_result,true);
- - 3 -
-l_coverage_pct := coverage_pct(a_coverage.covered_lines, a_coverage.uncovered_lines);
- - 3 -
-l_file_part :=
- -
-'<div class="file_list_container" id="'||l_id||'">' ||
- -
-'<h2><span class="group_name">'||l_title||'</span>' ||
- -
-' (<span class="covered_percent"><span class="'||coverage_css_class(l_coverage_pct)||'">'||l_coverage_pct||'%</span></span>' ||
- -
-' covered at <span class="covered_strength">' ||
- -
-'<span class="'||line_hits_css_class(executions_per_line(a_coverage.executions, a_coverage.uncovered_lines + a_coverage.covered_lines))||'">'||
- -
-executions_per_line(a_coverage.executions, a_coverage.uncovered_lines + a_coverage.covered_lines)||'</span></span> hits/line)</h2>' ||
- -
-'<a name="'||l_id||'"></a>' ||
- -
-'<div><b>'||a_coverage.objects.count||'</b> files in total. ' ||
- -
+'<b>'||(a_coverage.uncovered_lines + a_coverage.covered_lines)||'</b> relevant lines. ' ||
- -
+'<span class="green"><b>'||a_coverage.covered_lines||'</b> lines covered</span> and ' ||
+
- -
+'<span class="red"><b>'||a_coverage.uncovered_lines||'</b> lines missed </span></div>' ||
/*
+- -
+'<table class="file_list"><thead>' ||
* Public code
+- -
+'<tr>' ||
*/
+- -
+'<th>File</th><th>% covered</th><th>Lines</th><th>Relevant Lines</th><th>Lines covered</th><th>Lines missed</th><th>Avg. Hits / Line</th>' ||
function get_cached_suite_rows(
+- -
-'</tr></thead><tbody>';
- - 3 -
-ut_utils.append_to_clob(l_result, l_file_part);
- - 3 -
-l_unit := a_coverage.objects.first;
- - 172 -
-loop
- - 172 -
-exit when l_unit is null;
- - 169 -
-l_unit_coverage := a_coverage.objects(l_unit);
- - 169 -
-l_coverage_pct := coverage_pct(l_unit_coverage.covered_lines, l_unit_coverage.uncovered_lines);
- - 169 -
-l_file_part :=
- -
+chr(10)||
a_object_owner varchar2,
+ +- +
+ +a_path varchar2 := null,
- +
+ +a_object_name varchar2 := null,
- +
+ +a_procedure_name varchar2 := null,
- +
+ +a_random_seed positive := null,
- +
+ +a_tags ut_varchar2_rows := null
- +
+ +) return ut_suite_cache_rows is
- +
+ +l_path varchar2(4000);
- + 215 +
+l_results ut_suite_cache_rows := ut_suite_cache_rows();
- -
+'<tr>' ||
l_sql varchar2(32767);
+- -
-'<td class="strong">'||link_to_source_file(l_unit)||'</td>' ||
- -
-'<td class="'||coverage_css_class(l_coverage_pct)||' strong">'||l_coverage_pct||' %</td>' ||
- -
-'<td>'||l_unit_coverage.total_lines||'</td>' ||
- -
-'<td>'||(l_unit_coverage.covered_lines+l_unit_coverage.uncovered_lines)||'</td>' ||
- -
+'<td>'||l_unit_coverage.covered_lines||'</td>' ||
l_suite_item_name varchar2(20);
+ +- + 215 +
+ +l_tags ut_varchar2_rows := coalesce(a_tags,ut_varchar2_rows());
- + 215 +
+ +l_object_owner varchar2(250) := ut_utils.qualified_sql_name(a_object_owner);
- + 215 +
+ +l_object_name varchar2(250) := ut_utils.qualified_sql_name(a_object_name);
- + 215 +
+l_procedure_name varchar2(250) := ut_utils.qualified_sql_name(a_procedure_name);
- -
-'<td>'||l_unit_coverage.uncovered_lines||'</td>' ||
- -
-'<td>'||executions_per_line(l_unit_coverage.executions, l_unit_coverage.uncovered_lines + l_unit_coverage.covered_lines)||'</td>' ||
- -
-'</tr>';
- - 169 -
-ut_utils.append_to_clob(l_result, l_file_part);
- - 169 -
+l_unit := a_coverage.objects.next(l_unit);
begin
+ +- + 215 +
+ +if a_path is null and a_object_name is not null then
- + 165 +
+ +select min(c.path)
- +
+ +into l_path
- +
+from ut_suite_cache c
- -
-end loop;
- - 3 -
-l_file_part := '</tbody></table></div>';
- - 3 -
-ut_utils.append_to_clob(l_result, l_file_part);
- - 3 -
-return l_result;
- -
+end;
where c.object_owner = upper(l_object_owner)
+ +- +
+ +and c.object_name = upper(l_object_name)
- +
+ +and c.name = nvl(upper(l_procedure_name), c.name);
- +
+ +else
- + 50 +
+l_path := lower(ut_utils.qualified_sql_name(a_path));
- -
-- -
+/*
end if;
+ +- + 215 +
+l_suite_item_name := case when l_tags.count > 0 then 'suite_items_tags' else 'suite_items' end;
- -
-* public definitions
- -
-*/
- -
-function get_index(a_coverage_data ut_coverage.t_coverage, a_assets_path varchar2, a_project_name varchar2 := null, a_command_line varchar2 := null) return clob is
- -
- -
-l_file_part varchar2(32767);
- -
-l_result clob;
- -
-l_title varchar2(250);
- -
-l_coverage_pct number(5,2);
- -
+ +l_time_str varchar2(50);
- + 215 +
+ +l_sql := gc_get_cache_suite_sql;
- + 215 +
+ +l_sql := replace(l_sql,'{:suite_item_name:}',l_suite_item_name);
- + 215 +
+ +l_sql := replace(l_sql,'{:object_owner:}',upper(l_object_owner));
- + 215 +
+ +l_sql := replace(l_sql,'{:path:}',get_path_sql(l_path));
- + 215 +
+ +l_sql := replace(l_sql,'{:object_name:}',get_object_name_sql(l_object_name));
- + 215 +
+ +l_sql := replace(l_sql,'{:procedure_name:}',get_procedure_name_sql(l_procedure_name));
- + 215 +
+ +l_sql := replace(l_sql,'{:tags:}',get_tags_sql(l_tags.count));
- + 215 +
+l_sql := replace(l_sql,'{:random_seed:}',get_random_seed_sql(a_random_seed));
- -
-l_using varchar2(1000);
- -
-l_unit ut_coverage.t_full_name;
- -
-begin
- - 3 -
-l_coverage_pct := coverage_pct(a_coverage_data.covered_lines, a_coverage_data.uncovered_lines);
- - 3 -
-l_time_str := ut_utils.to_string(sysdate);
- - 3 -
-l_using := case when a_command_line is not null then '<br/>using '||dbms_xmlgen.convert(a_command_line) end;
- - 3 -
+dbms_lob.createtemporary(l_result,true);
+ +
- + 215 +
+ +ut_event_manager.trigger_event(ut_event_manager.gc_debug, ut_key_anyvalues().put('l_sql',l_sql) );
- +
+ +- + 215 +
+ +execute immediate l_sql
- +
+ +bulk collect into l_results
- +
+ +using upper(l_object_owner), l_path, l_path, upper(a_object_name), upper(a_procedure_name), l_tags, a_random_seed;
- + 215 +
+return l_results;
- +
+ +end;
- -
- - 3 -
+l_title := case when a_project_name is null then 'Code coverage' else dbms_xmlgen.convert(a_project_name) ||' code coverage' end;
- -
---TODO - build main file containing total run data and per schema data
- - 3 -
+l_file_part :=
function get_schema_parse_time(a_schema_name varchar2) return timestamp result_cache is
+ +- +
+l_cache_parse_time timestamp;
- -
-'<!DOCTYPE html><html xmlns=''http://www.w3.org/1999/xhtml''><head>' ||
- -
+'<title>'||l_title||'</title>' ||
begin
+ +- + 302 +
+select min(t.parse_time)
- -
+'<meta http-equiv="content-type" content="text/html; charset=utf-8" />' ||
into l_cache_parse_time
+- -
+'<script src='''||a_assets_path||'application.js'' type=''text/javascript''></script>' ||
from ut_suite_cache_schema t
+- -
-'<link href='''||a_assets_path||'application.css'' media=''screen, projection, print'' rel=''stylesheet'' type=''text/css''>' ||
- -
+'<link rel="shortcut icon" type="image/png" href="'||a_assets_path||'favicon_'||coverage_css_class(l_coverage_pct)||'.png" />' ||
where object_owner = upper(a_schema_name);
+ +- + 302 +
+return l_cache_parse_time;
- -
+'<link rel="icon" type="image/png" href="'||a_assets_path||'favicon_'||coverage_css_class(l_coverage_pct)||'.png" />' ||
end;
+- -
+'</head>' ||
+
- -
+'<body><div id="loading"><img src="'||a_assets_path||'loading.gif" alt="loading"/></div>' ||
procedure save_object_cache(
+- -
+'<div id="wrapper" style="display:none;">' ||
a_object_owner varchar2,
+- -
+'<div class="timestamp">Generated <abbr class="timeago" title="'||l_time_str||'">'||l_time_str||'</abbr></div>' ||
a_object_name varchar2,
+- -
+'<ul class="group_tabs"></ul>' ||
a_parse_time timestamp,
+- -
-'<div id="content">';
- - 3 -
+ut_utils.append_to_clob(l_result, l_file_part);
a_suite_items ut_suite_items
+ +- +
+) is
- -
-- - 3 -
-dbms_lob.append(l_result, file_list('All files', a_coverage_data));
- -
-- - 3 -
+l_file_part :=
pragma autonomous_transaction;
+ +- +
+ +l_cached_parse_time timestamp;
- + 274 +
+ +l_object_owner varchar2(250) := upper(a_object_owner);
- + 274 +
+l_object_name varchar2(250) := upper(a_object_name);
- -
-chr(10)||
- -
+'</div><div id="footer">' ||
begin
+ +- + 274 +
+if a_suite_items is not null and a_suite_items.count = 0 then
- -
-'Generated by <a href="http://github.com/utPLSQL/utPLSQL">'||ut_utils.gc_version||'</a><br/>' ||
- -
+'Based on <a href="http://github.com/colszowka/simplecov-html">simplecov-html</a> v0.10.0 '||l_using||'' ||
+ +
- +
+delete from ut_suite_cache t
- -
-'</div><div class="source_files">';
- - 3 -
+ut_utils.append_to_clob(l_result, l_file_part);
where t.object_owner = l_object_owner
+ +- +
+and t.object_name = l_object_name;
- -
- - 3 -
-l_unit := a_coverage_data.objects.first;
- - 172 -
-loop
- - 172 -
-exit when l_unit is null;
- - 169 -
-dbms_lob.append(l_result, get_details_file_content(object_id(l_unit), ut_object_name(a_coverage_data.objects(l_unit).owner, a_coverage_data.objects(l_unit).name), a_coverage_data.objects(l_unit)));
- - 169 -
+ +l_unit := a_coverage_data.objects.next(l_unit);
- +
+ +delete from ut_suite_cache_package t
- +
+ +where t.object_owner = l_object_owner
- +
+ +and t.object_name = l_object_name;
- +
+ +- +
+else
- -
-end loop;
- -
- - 3 -
+ +l_file_part := '</div></div></body></html>
- + 274 +
+ +select min(parse_time)
- +
+into l_cached_parse_time
- -
+';
from ut_suite_cache_package t
+- +
+ +where t.object_name = l_object_name
- +
+ +and t.object_owner = l_object_owner;
- -
- - 3 -
-ut_utils.append_to_clob(l_result, l_file_part);
- - 3 -
-return l_result;
- -
+ +end;
- + 274 +
+if a_parse_time > l_cached_parse_time or l_cached_parse_time is null then
- -
- -
end;
UT3.UT_COVERAGE_SONAR_REPORTER
82.35 % covered
34 relevant lines. 28 lines covered and 6 lines missed-
- -
-type body ut_coverage_sonar_reporter is
- -
-/*
- -
-utPLSQL - Version X.X.X.X
- -
-Copyright 2016 - 2017 utPLSQL Project
- -
-- -
-Licensed under the Apache License, Version 2.0 (the "License"):
- -
-you may not use this file except in compliance with the License.
- -
-You may obtain a copy of the License at
- + +
- + 274 +
+ +update ut_suite_cache_schema t
- +
+ +set t.parse_time = a_parse_time
- +
+ +where object_owner = l_object_owner;
- -
- -
-http://www.apache.org/licenses/LICENSE-2.0
- + +
- + 274 +
+ +if sql%rowcount = 0 then
- + 4 +
+ +insert into ut_suite_cache_schema
- +
+ +(object_owner, parse_time)
- +
+ +values (l_object_owner, a_parse_time);
- +
+ +end if;
- -
- -
-Unless required by applicable law or agreed to in writing, software
- -
-distributed under the License is distributed on an "AS IS" BASIS,
- -
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- -
-See the License for the specific language governing permissions and
- -
-limitations under the License.
- -
-*/
- + +
- + 274 +
+ +update ut_suite_cache_package t
- +
+ +set t.parse_time = a_parse_time
- +
+ +where t.object_owner = l_object_owner
- +
+ +and t.object_name = l_object_name;
- -
- -
-constructor function ut_coverage_sonar_reporter(
- -
-self in out nocopy ut_coverage_sonar_reporter
- -
-) return self as result is
- -
-begin
- - 3 -
-self.init($$plsql_unit);
- - 3 -
-return;
- -
-end;
- + +
- + 274 +
+ +if sql%rowcount = 0 then
- + 111 +
+ +insert into ut_suite_cache_package
- +
+ +(object_owner, object_name, parse_time)
- +
+ +values (l_object_owner, l_object_name, a_parse_time );
- +
+ +end if;
- -
- + +
- + 274 +
+ +delete from ut_suite_cache t
- +
+ +where t.object_owner = l_object_owner
- +
+ +and t.object_name = l_object_name;
- -
- -
-overriding member procedure after_calling_run(self in out nocopy ut_coverage_sonar_reporter, a_run in ut_run) as
- -
-l_report_lines ut_varchar2_list;
- - 3 -
-l_coverage_data ut_coverage.t_coverage;
- -
-function get_lines_xml(a_unit_coverage ut_coverage.t_unit_coverage) return clob is
- -
-l_file_part varchar2(32767);
- -
-l_result clob;
- -
-l_line_no binary_integer;
- -
-begin
- - 79 -
-dbms_lob.createtemporary(l_result, true);
- - 79 -
-l_line_no := a_unit_coverage.lines.first;
- - 79 -
-if l_line_no is null then
- - 8643 -
-for i in 1 .. a_unit_coverage.total_lines loop
- - 8564 -
-l_file_part := '<lineToCover lineNumber="'||i||'" covered="false"/>'||chr(10);
- - 8564 -
-ut_utils.append_to_clob(l_result, l_file_part);
- -
-end loop;
- -
-else
- -
-while l_line_no is not null loop
- -
-l_file_part :=
- -
-case a_unit_coverage.lines(l_line_no)
- -
-when 0 then
- -
-'<lineToCover lineNumber="'||l_line_no||'" covered="false"/>'||chr(10)
- -
-else
- -
-'<lineToCover lineNumber="'||l_line_no||'" covered="true"/>'||chr(10)
- -
-end;
- -
-ut_utils.append_to_clob(l_result, l_file_part);
- -
-l_line_no := a_unit_coverage.lines.next(l_line_no);
- -
-end loop;
- -
-end if;
- - 79 -
-return l_result;
- -
-end;
- -
-function get_coverage_xml(
- -
-a_coverage_data ut_coverage.t_coverage
- -
-) return clob is
- -
-l_file_part varchar2(32767);
- -
-l_result clob;
- -
-l_unit ut_coverage.t_full_name;
- - 3 -
-c_coverage_header constant varchar2(30) := '<coverage version="1">'||chr(10);
- - 3 -
-c_file_footer constant varchar2(30) := '</file>'||chr(10);
- - 3 -
-c_coverage_footer constant varchar2(30) := '</coverage>';
- -
-begin
- - 3 -
-dbms_lob.createtemporary(l_result,true);
- -
-- - 3 -
-ut_utils.append_to_clob(l_result, c_coverage_header);
- - 3 -
-l_unit := a_coverage_data.objects.first;
- - 82 -
-while l_unit is not null loop
- - 79 -
-l_file_part := '<file path="'||l_unit||'">'||chr(10);
- - 79 -
-ut_utils.append_to_clob(l_result, l_file_part);
- + +
- + 274 +
+ +insert into ut_suite_cache t
- +
+ +(
- +
+ +id, self_type, path, object_owner, object_name, name,
- +
+ +line_no, parse_time, description,
- +
+ +rollback_type, disabled_flag, warnings,
- +
+ +before_all_list, after_all_list,
- +
+ +before_each_list, after_each_list,
- +
+ +before_test_list, after_test_list,
- +
+ +expected_error_codes, tags,
- +
+ +item
- +
+ +)
- +
+ +with suites as (
- +
+ +select treat(value(x) as ut_suite) i
- +
+ +from table(a_suite_items) x
- +
+ +where x.self_type in( 'UT_SUITE', 'UT_SUITE_CONTEXT' ) )
- +
+ +select ut_suite_cache_seq.nextval, s.i.self_type as self_type, s.i.path as path,
- +
+ +upper(s.i.object_owner) as object_owner, upper(s.i.object_name) as object_name, upper(s.i.name) as name,
- +
+ +s.i.line_no as line_no, s.i.parse_time as parse_time, s.i.description as description,
- +
+ +s.i.rollback_type as rollback_type, s.i.disabled_flag as disabled_flag, s.i.warnings as warnings,
- +
+ +s.i.before_all_list as before_all_list, s.i.after_all_list as after_all_list,
- +
+ +null before_each_list, null after_each_list,
- +
+ +null before_test_list, null after_test_list,
- +
+ +null expected_error_codes, s.i.tags tags,
- +
+ +null item
- +
+ +from suites s;
- -
- - 79 -
-dbms_lob.append(l_result,get_lines_xml(a_coverage_data.objects(l_unit)));
- + +
- + 274 +
+ +insert into ut_suite_cache t
- +
+ +(
- +
+ +id, self_type, path, object_owner, object_name, name,
- +
+ +line_no, parse_time, description,
- +
+ +rollback_type, disabled_flag, warnings,
- +
+ +before_all_list, after_all_list,
- +
+ +before_each_list, after_each_list,
- +
+ +before_test_list, after_test_list,
- +
+ +expected_error_codes, tags,
- +
+ +item
- +
+ +)
- +
+ +with tests as (
- +
+ +select treat(value(x) as ut_test) t
- +
+ +from table ( a_suite_items ) x
- +
+ +where x.self_type in ( 'UT_TEST' ) )
- +
+ +select ut_suite_cache_seq.nextval, s.t.self_type as self_type, s.t.path as path,
- +
+ +upper(s.t.object_owner) as object_owner, upper(s.t.object_name) as object_name, upper(s.t.name) as name,
- +
+ +s.t.line_no as line_no, s.t.parse_time as parse_time, s.t.description as description,
- +
+ +s.t.rollback_type as rollback_type, s.t.disabled_flag as disabled_flag, s.t.warnings as warnings,
- +
+ +null before_all_list, null after_all_list,
- +
+ +s.t.before_each_list as before_each_list, s.t.after_each_list as after_each_list,
- +
+ +s.t.before_test_list as before_test_list, s.t.after_test_list as after_test_list,
- +
+ +s.t.expected_error_codes as expected_error_codes, s.t.tags as test_tags,
- +
+ +s.t.item as item
- +
+ +from tests s;
- -
- - 79 -
-ut_utils.append_to_clob(l_result, c_file_footer);
- + +
- +
+ +end if;
- +
+ +end if;
- + 274 +
+ +commit;
- +
+ +end;
- -
- - 79 -
-l_unit := a_coverage_data.objects.next(l_unit);
- -
-end loop;
- - 3 -
-ut_utils.append_to_clob(l_result, c_coverage_footer);
- - 3 -
-return l_result;
- -
-end;
- + +
- +
+ +procedure remove_missing_objs_from_cache(a_schema_name varchar2) is
- +
+ +l_objects ut_varchar2_rows;
- +
+ +pragma autonomous_transaction;
- -
begin
- - 5 -
-ut_coverage.coverage_stop();
- + +
- + 301 +
+ +l_objects := get_missing_cache_objects(a_schema_name);
- -
- - 3 -
-l_coverage_data := ut_coverage.get_coverage_data(a_run.coverage_options);
- + +
- + 301 +
+ +if l_objects is not empty then
- + 36 +
+ +delete from ut_suite_cache i
- +
+ +where i.object_owner = a_schema_name
- +
+ +and i.object_name in ( select column_value from table (l_objects) );
- +
+ +- + 36 +
+ +delete from ut_suite_cache_package i
- +
+ +where i.object_owner = a_schema_name
- +
+ +and i.object_name in ( select column_value from table (l_objects) );
- +
+ +end if;
- +
+ +- + 301 +
+ +commit;
- +
+ +end;
- -
- + +
- +
+ +function get_cached_suite_info(
- +
+ +a_object_owner varchar2,
- +
+ +a_object_name varchar2
- +
+ +) return ut_suite_items_info is
- +
+ +l_cache_rows ut_suite_cache_rows;
- +
+ +l_results ut_suite_items_info;
- +
+ +begin
- 3 -
-self.print_clob( get_coverage_xml( l_coverage_data ) );
- +
+ +l_cache_rows := get_cached_suite_rows( a_object_owner => a_object_owner, a_object_name =>a_object_name );
- + 2 +
+ +select ut_suite_item_info(
- +
+ +c.object_owner, c.object_name, c.name,
- +
+ +c.description, c.self_type, c.line_no,
- +
+ +c.path, c.disabled_flag, c.tags
- +
+ +)
- +
+ +bulk collect into l_results
- +
+ +from table(l_cache_rows) c;
- -
- + +
- 3 -
-(self as ut_reporter_base).after_calling_run(a_run);
- +
+ +return l_results;
- -
end;
- -
-- -
end;
+UT3.UT_COVERALLS_REPORTER
82.93 % covered
41 relevant lines. 34 lines covered and 7 lines missed-
- -
-type body ut_coveralls_reporter is
- -
-/*
- -
-utPLSQL - Version X.X.X.X
- -
-Copyright 2016 - 2017 utPLSQL Project
- + +
- -
- -
-Licensed under the Apache License, Version 2.0 (the "License"):
- + +
- +
+ +function get_cached_packages(
- +
+ +a_schema_names ut_varchar2_rows
- +
+ +) return ut_object_names is
- +
+ +l_results ut_object_names;
- +
+ +begin
- + 116 +
+ +select ut_object_name( c.object_owner, c.object_name )
- +
+ +bulk collect into l_results
- +
+ +from ut_suite_cache_package c
- +
+ +join table ( a_schema_names ) s
- +
+ +on c.object_owner = upper(s.column_value);
- + 117 +
+ +return l_results;
- +
+ +end;
- +
+ +- +
+ +function suite_item_exists(
- +
+ +a_owner_name varchar2,
- +
+ +a_package_name varchar2,
- +
+ +a_procedure_name varchar2
- +
+ +) return boolean is
- +
+ +l_count integer;
- +
+ +begin
- + 12 +
+ +if a_procedure_name is not null then
- + 4 +
+ +select count( 1 ) into l_count from dual
- +
+ +where exists(
- +
+ +select 1
- +
+ +from ut_suite_cache c
- +
+ +where c.object_owner = a_owner_name
- +
+ +and c.object_name = a_package_name
- +
+ +and c.name = a_procedure_name
- +
+ +);
- + 8 +
+ +elsif a_package_name is not null then
- + 4 +
+ +select count( 1 ) into l_count from dual
- +
+ +where exists(
- +
+ +select 1
- +
+ +from ut_suite_cache c
- +
+ +where c.object_owner = a_owner_name
- +
+ +and c.object_name = a_package_name
- +
+ +);
- +
+ +else
- + 4 +
+ +select count( 1 ) into l_count from dual
- +
+ +where exists(
- +
+ +select 1
- +
+ +from ut_suite_cache c
- +
+ +where c.object_owner = a_owner_name
- +
+ +);
- +
+ +end if;
- +
+ +- + 12 +
+ +return l_count > 0;
- +
+ +end;
- +
+ +- +
+end;
+UT3.UT_SUITE_MANAGER
94.68 % lines covered
188 relevant lines. 178 lines covered (including 3 lines partially covered ) and 10 lines missed+ +
- +
+ +package body ut_suite_manager is
- +
+ +/*
- +
+ +utPLSQL - Version 3
- +
+ +Copyright 2016 - 2019 utPLSQL Project
- +
+ +- +
+ +Licensed under the Apache License, Version 2.0 (the "License"):
- +
you may not use this file except in compliance with the License.
- +
You may obtain a copy of the License at
- +
- +
http://www.apache.org/licenses/LICENSE-2.0
- +
- +
Unless required by applicable law or agreed to in writing, software
- +
distributed under the License is distributed on an "AS IS" BASIS,
- +
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
See the License for the specific language governing permissions and
- +
limitations under the License.
- +
*/
- -
- -
+ +constructor function ut_coveralls_reporter(
- + 1 +
+gc_suitpath_error_message constant varchar2(100) := 'Suitepath exceeds 1000 CHAR on: ';
- -
+self in out nocopy ut_coveralls_reporter
+
- -
+) return self as result is
type t_path_item is record (
+- -
-begin
- - 1 -
-self.init($$plsql_unit);
- - 1 -
+return;
object_name varchar2(250),
+ +- +
+ +procedure_name varchar2(250),
- +
+suite_path varchar2(4000)
- -
+end;
);
+- -
+type t_path_items is table of t_path_item;
+- -
+overriding member procedure after_calling_run(self in out nocopy ut_coveralls_reporter, a_run in ut_run) as
type t_schema_paths is table of t_path_items index by varchar2(250 char);
+- -
-l_report_lines ut_varchar2_list;
- - 1 -
-l_coverage_data ut_coverage.t_coverage;
- + +
- +
+ +cursor c_cached_suites_cursor is select * from table(ut_suite_cache_rows());
- +
+type tt_cached_suites is table of c_cached_suites_cursor%rowtype;
- -
+function get_lines_json(a_unit_coverage ut_coverage.t_unit_coverage) return clob is
type t_cached_suites_cursor is ref cursor return c_cached_suites_cursor%rowtype;
+- -
+l_file_part varchar2(32767);
+
- -
+l_result clob;
type t_item_levels is table of ut_suite_items index by binary_integer;
+- -
-l_last_line_no binary_integer;
- - 78 -
-c_coverage_header constant varchar2(30) := '"coverage": [';
- - 78 -
-c_null constant varchar2(4) := 'null';
- -
-begin
- - 78 -
-dbms_lob.createtemporary(l_result, true);
- - 78 -
-ut_utils.append_to_clob(l_result, c_coverage_header);
- +
+ +------------------
- -
- - 78 -
-l_last_line_no := a_unit_coverage.lines.last;
- - 78 -
-if l_last_line_no is null then
- - 78 -
-l_last_line_no := a_unit_coverage.total_lines - 1;
- - 8499 -
-for i in 1 .. l_last_line_no loop
- - 8421 -
+ +ut_utils.append_to_clob(l_result, '0,');
- +
+ +procedure validate_paths(a_paths in ut_varchar2_list) is
- +
+ +l_path varchar2(32767);
- +
+ +begin
- + 263 +
+ +if a_paths is null or a_paths.count = 0 then
- +
+ +raise_application_error(ut_utils.gc_path_list_is_empty, 'Path list is empty');
- +
+ +else
- + 548 +
+ +for i in 1 .. a_paths.count loop
- + 285 +
+ +l_path := a_paths(i);
- + 285 +
+ +if l_path is null or not (regexp_like(l_path, '^[A-Za-z0-9$#_]+(\.[A-Za-z0-9$#_]+){0,2}$') or regexp_like(l_path, '^([A-Za-z0-9$#_]+)?:[A-Za-z0-9$#_]+(\.[A-Za-z0-9$#_]+)*$')) then
- +
+raise_application_error(ut_utils.gc_invalid_path_format, 'Invalid path format: ' || nvl(l_path, 'NULL'));
- -
-end loop;
- - 78 -
+ut_utils.append_to_clob(l_result, '0');
end if;
+ +- +
+end loop;
- -
-else
- -
-for line_no in 1 .. l_last_line_no loop
- -
-if a_unit_coverage.lines.exists(line_no) then
- -
-l_file_part := to_char(a_unit_coverage.lines(line_no));
- -
-else
- -
-l_file_part := c_null;
- -
-end if;
- -
-if line_no < l_last_line_no then
- -
+l_file_part := l_file_part ||',';
end if;
+ +- +
+ +end;
- +
+ +- +
+ +function trim_and_lower_paths( a_paths ut_varchar2_list) return ut_varchar2_list is
- + 263 +
+ +l_paths_temp ut_varchar2_list := ut_varchar2_list();
- +
+ +begin
- + 263 +
+ +l_paths_temp.extend(a_paths.count);
- + 548 +
+ +for i in 1 .. a_paths.count loop
- + 285 +
+l_paths_temp(i) := trim(lower(a_paths(i)));
- -
-end if;
- -
+ut_utils.append_to_clob(l_result, l_file_part);
end loop;
+ +- + 263 +
+return l_paths_temp;
- -
+end loop;
end;
+- -
-end if;
- - 78 -
-ut_utils.append_to_clob(l_result, ']');
- - 78 -
+return l_result;
+ +
- +
+ +function resolve_schema_names(a_paths in out nocopy ut_varchar2_list) return ut_varchar2_rows is
- +
+l_schema varchar2(4000);
- -
-end;
- +
+ +l_object varchar2(4000);
- + 263 +
+ +l_schema_names ut_varchar2_rows := ut_varchar2_rows();
- + 263 +
+ +c_current_schema constant all_tables.owner%type := sys_context('USERENV','CURRENT_SCHEMA');
- +
+ +begin
- + 263 +
+ +a_paths := set( trim_and_lower_paths( a_paths) );
- +
+ +- + 263 +
+ +validate_paths(a_paths);
- +
+ +- + 547 +
+ +for i in 1 .. a_paths.count loop
- +
+ +--if path is suite-path
- + 285 +
+ +if regexp_like(a_paths(i), '^([A-Za-z0-9$#_]+)?:') then
- +
+ +--get schema name / path
- + 34 +
+ +l_schema := regexp_substr(a_paths(i), '^([A-Za-z0-9$#_]+)?:',subexpression => 1);
- +
+ +-- transform ":path1[.path2]" to "schema:path1[.path2]"
- + 34 +
+ +if l_schema is not null then
- + 6 +
+ +l_schema := sys.dbms_assert.schema_name(upper(l_schema));
- +
+ +else
- + 28 +
+ +a_paths(i) := c_current_schema || a_paths(i);
- + 28 +
+ +l_schema := c_current_schema;
- +
+ +end if;
- +
+ +else
- +
+ +-- get schema name / object.[procedure] name
- +
+ +-- When path is one of: schema or schema.package[.object] or package[.object]
- +
+ +-- transform it back to schema[.package[.object]]
- +
+ +begin
- + 251 +
+ +l_object := regexp_substr(a_paths(i), '^[A-Za-z0-9$#_]+');
- + 251 +
+ +l_schema := sys.dbms_assert.schema_name(upper(l_object));
- +
+ +exception
- + 270 +
+ +when sys.dbms_assert.invalid_schema_name then
- + 135 +
+ +if ut_metadata.package_exists_in_cur_schema(upper(l_object)) then
- + 134 +
+ +a_paths(i) := c_current_schema || '.' || a_paths(i);
- + 134 +
+ +l_schema := c_current_schema;
- +
+ +else
- + 1 +
+ +raise;
- +
+ +end if;
- +
+ +end;
- +
+ +end if;
- + 284 +
+ +l_schema_names.extend;
- + 284 +
+ +l_schema_names(l_schema_names.last) := l_schema;
- +
+ +end loop;
- +
+ +- + 262 +
+ +return l_schema_names;
- +
+ +end;
- +
+ +- +
+ +procedure resolve_schema_names(a_paths in out nocopy ut_varchar2_list) is
- +
+ +l_schema_names ut_varchar2_rows;
- +
+ +begin
- + 148 +
+ +l_schema_names := resolve_schema_names(a_paths);
- +
+ +end;
- +
+ +- +
+ +function group_paths_by_schema(a_paths ut_varchar2_list) return t_schema_paths is
- + 147 +
+ +c_package_path_regex constant varchar2(100) := '^([A-Za-z0-9$#_]+)(\.([A-Za-z0-9$#_]+))?(\.([A-Za-z0-9$#_]+))?$';
- +
+ +l_schema varchar2(4000);
- +
+ +l_empty_result t_path_item;
- +
+ +l_result t_path_item;
- +
+ +l_results t_schema_paths;
- +
+ +begin
- + 305 +
+ +for i in 1 .. a_paths.count loop
- + 158 +
+ +l_result := l_empty_result;
- + 158 +
+ +if a_paths(i) like '%:%' then
- + 23 +
+ +l_schema := upper(regexp_substr(a_paths(i),'^[^.:]+'));
- + 23 +
+ +l_result.suite_path := ltrim(regexp_substr(a_paths(i),'[.:].*$'),':');
- +
+ +else
- + 135 +
+ +l_schema := regexp_substr(a_paths(i), c_package_path_regex, subexpression => 1);
- + 135 +
+ +l_result.object_name := regexp_substr(a_paths(i), c_package_path_regex, subexpression => 3);
- + 135 +
+ +l_result.procedure_name := regexp_substr(a_paths(i), c_package_path_regex, subexpression => 5);
- +
+ +end if;
- + 158 +
+ +if l_results.exists(l_schema) then
- + 11 +
+ +l_results(l_schema).extend;
- + 11 +
+ +l_results(l_schema)(l_results(l_schema).last) := l_result;
- +
+ +else
- + 147 +
+ +l_results(l_schema) := t_path_items(l_result);
- +
+ +end if;
- +
+ +end loop;
- + 147 +
+ +return l_results;
- +
+ +end;
- +
+ +- +
+ +- +
+ +function sort_by_seq_no(
- +
+ +a_list ut_executables
- +
+ +) return ut_executables is
- + 3302 +
+ +l_results ut_executables := ut_executables();
- +
+ +begin
- + 3302 +
+ +if a_list is not null then
- + 3302 +
+ +l_results.extend(a_list.count);
- + 3856 +
+ +for i in 1 .. a_list.count loop
- + 554 +
+ +l_results(a_list(i).seq_no) := a_list(i);
- +
+ +end loop;
- +
+ +end if;
- + 3302 +
+ +return l_results;
- +
+ +end;
- +
+ +- +
+ +procedure reverse_list_order(
- +
+ +a_list in out nocopy ut_suite_items
- +
+ +) is
- +
+ +l_start_idx pls_integer;
- +
+ +l_end_idx pls_integer;
- +
+ +l_item ut_suite_item;
- +
+ +begin
- + 212 +
+ +l_start_idx := a_list.first;
- + 212 +
+ +l_end_idx := a_list.last;
- + 242 +
+ +while l_start_idx < l_end_idx loop
- + 30 +
+ +l_item := a_list(l_start_idx);
- + 30 +
+ +a_list(l_start_idx) := a_list(l_end_idx);
- + 30 +
+ +a_list(l_end_idx) := l_item;
- + 30 +
+ +l_end_idx := a_list.prior(l_end_idx);
- + 30 +
+ +l_start_idx := a_list.next(l_start_idx);
- +
+ +end loop;
- +
+ +end;
- +
+ +- +
+ +function get_logical_suite(
- +
+ +a_rows tt_cached_suites,
- +
+ +a_idx pls_integer,
- +
+ +a_level pls_integer,
- +
+ +a_prev_level pls_integer,
- +
+ +a_items_at_level t_item_levels
- +
+ +) return ut_suite_item is
- +
+ +l_result ut_suite_item;
- +
+ +begin
- + 1164 +
+ +case a_rows( a_idx ).self_type
- + 1164 +
+ +when 'UT_SUITE' then
- + 290 +
+ +l_result :=
- + 1/2 + 1 +
+ +case when a_prev_level > a_level then
- +
+ +ut_suite(
- +
+ +self_type => a_rows( a_idx ).self_type,
- +
+ +object_owner => a_rows( a_idx ).object_owner, object_name => lower( a_rows( a_idx ).object_name),
- +
+ +name => lower( a_rows( a_idx ).name), description => a_rows( a_idx ).description, path => a_rows( a_idx ).path,
- +
+ +rollback_type => a_rows( a_idx ).rollback_type, disabled_flag => a_rows( a_idx ).disabled_flag,
- +
+ +line_no => a_rows( a_idx ).line_no, parse_time => a_rows( a_idx ).parse_time,
- +
+ +start_time => null, end_time => null, result => null, warnings => a_rows( a_idx ).warnings,
- +
+ +results_count => ut_results_counter(), transaction_invalidators => ut_varchar2_list(),
- +
+ +items => a_items_at_level(a_prev_level),
- +
+ +before_all_list => sort_by_seq_no( a_rows( a_idx ).before_all_list), after_all_list => sort_by_seq_no(
- +
+ +a_rows( a_idx ).after_all_list), tags => a_rows(a_idx).tags
- +
+ +)
- +
+ +else
- +
+ +ut_suite(
- +
+ +self_type => a_rows( a_idx ).self_type,
- +
+ +object_owner => a_rows( a_idx ).object_owner, object_name => lower( a_rows( a_idx ).object_name),
- +
+ +name => lower( a_rows( a_idx ).name), description => a_rows( a_idx ).description, path => a_rows( a_idx ).path,
- +
+ +rollback_type => a_rows( a_idx ).rollback_type, disabled_flag => a_rows( a_idx ).disabled_flag,
- +
+ +line_no => a_rows( a_idx ).line_no, parse_time => a_rows( a_idx ).parse_time,
- +
+ +start_time => null, end_time => null, result => null, warnings => a_rows( a_idx ).warnings,
- +
+ +results_count => ut_results_counter(), transaction_invalidators => ut_varchar2_list(),
- +
+ +items => ut_suite_items(),
- +
+ +before_all_list => sort_by_seq_no( a_rows( a_idx ).before_all_list), after_all_list => sort_by_seq_no(
- +
+ +a_rows( a_idx ).after_all_list), tags => a_rows(a_idx).tags
- +
+ +)
- +
+ +end;
- + 874 +
+ +when 'UT_SUITE_CONTEXT' then
- + 41 +
+ +l_result :=
- + 1/2 + 1 +
+ +case when a_prev_level > a_level then
- +
+ +ut_suite_context(
- +
+ +self_type => a_rows( a_idx ).self_type,
- +
+ +object_owner => a_rows( a_idx ).object_owner, object_name => lower( a_rows( a_idx ).object_name),
- +
+ +name => lower( a_rows( a_idx ).name), description => a_rows( a_idx ).description, path => a_rows( a_idx ).path,
- +
+ +rollback_type => a_rows( a_idx ).rollback_type, disabled_flag => a_rows( a_idx ).disabled_flag,
- +
+ +line_no => a_rows( a_idx ).line_no, parse_time => a_rows( a_idx ).parse_time,
- +
+ +start_time => null, end_time => null, result => null, warnings => a_rows( a_idx ).warnings,
- +
+ +results_count => ut_results_counter(), transaction_invalidators => ut_varchar2_list(),
- +
+ +items => a_items_at_level(a_prev_level),
- +
+ +before_all_list => sort_by_seq_no( a_rows( a_idx ).before_all_list), after_all_list => sort_by_seq_no(
- +
+ +a_rows( a_idx ).after_all_list), tags => a_rows(a_idx).tags
- +
+ +)
- +
+ +else
- +
+ +ut_suite_context(
- +
+ +self_type => a_rows( a_idx ).self_type,
- +
+ +object_owner => a_rows( a_idx ).object_owner, object_name => lower( a_rows( a_idx ).object_name),
- +
+ +name => lower( a_rows( a_idx ).name), description => a_rows( a_idx ).description, path => a_rows( a_idx ).path,
- +
+ +rollback_type => a_rows( a_idx ).rollback_type, disabled_flag => a_rows( a_idx ).disabled_flag,
- +
+ +line_no => a_rows( a_idx ).line_no, parse_time => a_rows( a_idx ).parse_time,
- +
+ +start_time => null, end_time => null, result => null, warnings => a_rows( a_idx ).warnings,
- +
+ +results_count => ut_results_counter(), transaction_invalidators => ut_varchar2_list(),
- +
+ +items => ut_suite_items(),
- +
+ +before_all_list => sort_by_seq_no( a_rows( a_idx ).before_all_list), after_all_list => sort_by_seq_no(
- +
+ +a_rows( a_idx ).after_all_list), tags => a_rows(a_idx).tags
- +
+ +)
- +
+ +end;
- + 833 +
+ +when 'UT_LOGICAL_SUITE' then
- + 173 +
+ +l_result :=
- + 1/2 + 1 +
+ +case when a_prev_level > a_level then
- +
+ +ut_logical_suite(
- +
+ +self_type => a_rows( a_idx ).self_type,
- +
+ +object_owner => a_rows( a_idx ).object_owner, object_name => lower( a_rows( a_idx ).object_name),
- +
+ +name => lower( a_rows( a_idx ).name), description => a_rows( a_idx ).description, path => a_rows( a_idx ).path,
- +
+ +rollback_type => a_rows( a_idx ).rollback_type, disabled_flag => a_rows( a_idx ).disabled_flag,
- +
+ +line_no => a_rows( a_idx ).line_no, parse_time => a_rows( a_idx ).parse_time,
- +
+ +start_time => null, end_time => null, result => null, warnings => a_rows( a_idx ).warnings,
- +
+ +results_count => ut_results_counter(), transaction_invalidators => ut_varchar2_list(),
- +
+ +items => a_items_at_level(a_prev_level), tags => null
- +
+ +)
- +
+ +else
- +
+ +ut_logical_suite(
- +
+ +self_type => a_rows( a_idx ).self_type,
- +
+ +object_owner => a_rows( a_idx ).object_owner, object_name => lower( a_rows( a_idx ).object_name),
- +
+ +name => lower( a_rows( a_idx ).name), description => a_rows( a_idx ).description, path => a_rows( a_idx ).path,
- +
+ +rollback_type => a_rows( a_idx ).rollback_type, disabled_flag => a_rows( a_idx ).disabled_flag,
- +
+ +line_no => a_rows( a_idx ).line_no, parse_time => a_rows( a_idx ).parse_time,
- +
+ +start_time => null, end_time => null, result => null, warnings => a_rows( a_idx ).warnings,
- +
+ +results_count => ut_results_counter(), transaction_invalidators => ut_varchar2_list(),
- +
+ +items => ut_suite_items(), tags => null
- +
+ +)
- +
+ +end;
- + 660 +
+ +when 'UT_TEST' then
- + 660 +
+ +l_result :=
- +
+ +ut_test(
- +
+ +self_type => a_rows(a_idx).self_type,
- +
+ +object_owner => a_rows(a_idx).object_owner, object_name => lower(a_rows(a_idx).object_name),
- +
+ +name => lower(a_rows(a_idx).name), description => a_rows(a_idx).description, path => a_rows(a_idx).path,
- +
+ +rollback_type => a_rows(a_idx).rollback_type, disabled_flag => a_rows(a_idx).disabled_flag,
- +
+ +line_no => a_rows(a_idx).line_no, parse_time => a_rows(a_idx).parse_time,
- +
+ +start_time => null, end_time => null, result => null, warnings => a_rows(a_idx).warnings,
- +
+ +results_count => ut_results_counter(), transaction_invalidators => ut_varchar2_list(),
- +
+ +before_each_list => sort_by_seq_no(a_rows(a_idx).before_each_list), before_test_list => sort_by_seq_no(a_rows(a_idx).before_test_list),
- +
+ +item => a_rows(a_idx).item,
- +
+ +after_test_list => sort_by_seq_no(a_rows(a_idx).after_test_list), after_each_list => sort_by_seq_no(a_rows(a_idx).after_each_list),
- +
+ +all_expectations => ut_expectation_results(), failed_expectations => ut_expectation_results(),
- +
+ +parent_error_stack_trace => null, expected_error_codes => a_rows(a_idx).expected_error_codes,
- +
+ +tags => a_rows(a_idx).tags
- +
+ +);
- +
+ +end case;
- + 1164 +
+ +l_result.results_count.warnings_count := l_result.warnings.count;
- + 1164 +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+ +procedure reconstruct_from_cache(
- +
+ +a_suites in out nocopy ut_suite_items,
- +
+ +a_suite_data_cursor sys_refcursor
- +
+ +) is
- + 212 +
+ +c_bulk_limit constant pls_integer := 1000;
- +
+ +l_items_at_level t_item_levels;
- +
+ +l_rows tt_cached_suites;
- +
+ +l_level pls_integer;
- +
+ +l_prev_level pls_integer;
- +
+ +l_idx integer;
- +
+ +begin
- + 212 +
+ +loop
- + 212 +
+ +fetch a_suite_data_cursor bulk collect into l_rows limit c_bulk_limit;
- +
+ +- + 212 +
+ +l_idx := l_rows.first;
- + 1376 +
+ +while l_idx is not null loop
- + 1164 +
+ +l_level := length(l_rows(l_idx).path) - length( replace(l_rows(l_idx).path, '.') ) + 1;
- + 1164 +
+ +if l_level > 1 then
- + 935 +
+ +if not l_items_at_level.exists(l_level) then
- + 399 +
+ +l_items_at_level(l_level) := ut_suite_items();
- +
+ +end if;
- + 935 +
+ +l_items_at_level(l_level).extend;
- + 935 +
+ +pragma inline(get_logical_suite, 'YES');
- + 935 +
+ +l_items_at_level(l_level)(l_items_at_level(l_level).last) := get_logical_suite(l_rows, l_idx, l_level,l_prev_level, l_items_at_level );
- +
+ +else
- + 229 +
+ +a_suites.extend;
- + 229 +
+ +pragma inline(get_logical_suite, 'YES');
- + 229 +
+ +a_suites(a_suites.last) := get_logical_suite(l_rows, l_idx, l_level,l_prev_level, l_items_at_level );
- +
+ +end if;
- + 1164 +
+ +if l_prev_level > l_level then
- + 477 +
+ +l_items_at_level(l_prev_level).delete;
- +
+ +end if;
- + 1164 +
+ +l_prev_level := l_level;
- + 1164 +
+ +l_idx := l_rows.next(l_idx);
- +
+ +end loop;
- + 212 +
+ +exit when a_suite_data_cursor%NOTFOUND;
- +
+ +end loop;
- +
+ +- + 212 +
+ +reverse_list_order( a_suites );
- +
+ +- + 452 +
+ +for i in 1 .. a_suites.count loop
- + 240 +
+ +a_suites( i ).set_rollback_type( a_suites( i ).get_rollback_type );
- +
+ +end loop;
- + 212 +
+ +close a_suite_data_cursor;
- +
+ +end reconstruct_from_cache;
- +
+ +- +
+ +function get_cached_suite_data(
- +
+ +a_object_owner varchar2,
- +
+ +a_path varchar2 := null,
- +
+ +a_object_name varchar2 := null,
- +
+ +a_procedure_name varchar2 := null,
- +
+ +a_skip_all_objects boolean := false,
- +
+ +a_random_seed positive,
- +
+ +a_tags ut_varchar2_rows := null
- +
+ +) return t_cached_suites_cursor is
- +
+ +l_unfiltered_rows ut_suite_cache_rows;
- +
+ +l_result t_cached_suites_cursor;
- +
+ +begin
- + 212 +
+ +l_unfiltered_rows := ut_suite_cache_manager.get_cached_suite_rows(
- +
+ +a_object_owner,
- +
+ +a_path,
- +
+ +a_object_name,
- +
+ +a_procedure_name,
- +
+ +a_random_seed,
- +
+ +a_tags
- +
+ +);
- + 212 +
+ +if a_skip_all_objects then
- + 212 +
+ +open l_result for
- + 1 +
+ +select c.* from table(l_unfiltered_rows) c;
- +
+ +else
- +
+ +open l_result for
- +
+ +select c.* from table(l_unfiltered_rows) c
- +
+ +where exists
- +
+ +( select 1
- +
+ +from all_objects a
- +
+ +where a.object_name = c.object_name
- +
+ +and a.owner = c.object_owner
- +
+ +and a.object_type = 'PACKAGE'
- +
+ +);
- +
+ +end if;
- +
+ +- + 212 +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+ +function can_skip_all_objects_scan(
- +
+ +a_owner_name varchar2
- +
+ +) return boolean is
- +
+ +begin
- + 474 +
+ +return sys_context( 'userenv', 'current_schema' ) = a_owner_name or ut_metadata.user_has_execute_any_proc() or ut_trigger_check.is_alive();
- +
+ +end;
- +
+ +- +
+ +procedure build_and_cache_suites(
- +
+ +a_owner_name varchar2,
- +
+ +a_annotated_objects sys_refcursor
- +
+ +) is
- +
+ +l_annotated_objects ut_annotated_objects;
- +
+ +l_suite_items ut_suite_items;
- +
+ +- + 356 +
+ +l_bad_suitepath_obj ut_varchar2_list := ut_varchar2_list();
- +
+ +ex_string_too_small exception;
- +
+ +pragma exception_init (ex_string_too_small,-06502);
- +
+ +begin
- + 356 +
+ +ut_event_manager.trigger_event('build_and_cache_suites - start');
- + 366 +
+ +loop
- + 366 +
+ +fetch a_annotated_objects bulk collect into l_annotated_objects limit 10;
- +
+ +- + 640 +
+ +for i in 1 .. l_annotated_objects.count loop
- +
+ +begin
- + 274 +
+ +ut_suite_builder.create_suite_item_list( l_annotated_objects( i ), l_suite_items );
- +
+ +exception
- + 4 +
+ +when ex_string_too_small then
- + 2 +
+ +ut_utils.append_to_list(l_bad_suitepath_obj,a_owner_name||'.'||l_annotated_objects( i ).object_name);
- +
+ +end;
- + 274 +
+ +ut_suite_cache_manager.save_object_cache(
- +
+ +a_owner_name,
- +
+ +l_annotated_objects( i ).object_name,
- +
+ +l_annotated_objects( i ).parse_time,
- +
+ +l_suite_items
- +
+ +);
- +
+ +end loop;
- + 366 +
+ +exit when a_annotated_objects%notfound;
- +
+ +end loop;
- + 356 +
+ +close a_annotated_objects;
- +
+ +- +
+ +--Check for any invalid suitepath objects
- + 356 +
+ +if l_bad_suitepath_obj.count > 0 then
- + 1 +
+ +raise_application_error(
- +
+ +ut_utils.gc_value_too_large,
- +
+ +ut_utils.to_string(gc_suitpath_error_message||ut_utils.table_to_clob(l_bad_suitepath_obj,','))
- +
+ +);
- +
+ +end if;
- + 355 +
+ +ut_event_manager.trigger_event('build_and_cache_suites - end');
- +
+ +end;
- +
+ +- +
+ +procedure refresh_cache(
- +
+ +a_owner_name varchar2
- +
+ +) is
- +
+ +l_annotations_cursor sys_refcursor;
- +
+ +l_suite_cache_time timestamp;
- +
+ +begin
- + 302 +
+ +ut_event_manager.trigger_event('refresh_cache - start');
- + 302 +
+ +l_suite_cache_time := ut_suite_cache_manager.get_schema_parse_time(a_owner_name);
- + 302 +
+ +l_annotations_cursor := ut_annotation_manager.get_annotated_objects(
- +
+ +a_owner_name, 'PACKAGE', l_suite_cache_time
- +
+ +);
- +
+ +- + 302 +
+ +build_and_cache_suites(a_owner_name, l_annotations_cursor);
- +
+ +- + 301 +
+ +if can_skip_all_objects_scan(a_owner_name) or ut_metadata.is_object_visible( 'dba_objects') then
- + 301 +
+ +ut_suite_cache_manager.remove_missing_objs_from_cache( a_owner_name );
- +
+ +end if;
- +
+ +- + 301 +
+ +ut_event_manager.trigger_event('refresh_cache - end');
- +
+ +end;
- +
+ +- +
+ +procedure add_suites_for_path(
- +
+ +a_owner_name varchar2,
- +
+ +a_path varchar2 := null,
- +
+ +a_object_name varchar2 := null,
- +
+ +a_procedure_name varchar2 := null,
- +
+ +a_suites in out nocopy ut_suite_items,
- +
+ +a_random_seed positive,
- +
+ +a_tags ut_varchar2_rows := null
- +
+ +) is
- +
+ +begin
- + 158 +
+ +refresh_cache(a_owner_name);
- +
+ +- + 158 +
+ +reconstruct_from_cache(
- +
+ +a_suites,
- +
+ +get_cached_suite_data(
- +
+ +a_owner_name,
- +
+ +a_path,
- +
+ +a_object_name,
- +
+ +a_procedure_name,
- +
+ +can_skip_all_objects_scan(a_owner_name),
- +
+ +a_random_seed,
- +
+ +a_tags
- +
+ +)
- +
+ +);
- +
+ +- +
+ +end;
- +
+ +- +
+ +-----------------------------------------------
- +
+ +-----------------------------------------------
- +
+ +------------- Public definitions -------------
- +
+ +- +
+ +function build_suites_from_annotations(
- +
+ +a_owner_name varchar2,
- +
+ +a_annotated_objects sys_refcursor,
- +
+ +a_path varchar2 := null,
- +
+ +a_object_name varchar2 := null,
- +
+ +a_procedure_name varchar2 := null,
- +
+ +a_skip_all_objects boolean := false
- +
+ +) return ut_suite_items is
- + 54 +
+ +l_suites ut_suite_items := ut_suite_items();
- +
+ +begin
- + 54 +
+ +build_and_cache_suites(a_owner_name, a_annotated_objects);
- +
+ +- + 54 +
+ +reconstruct_from_cache(
- +
+ +l_suites,
- +
+ +get_cached_suite_data(
- +
+ +a_owner_name,
- +
+ +a_path,
- +
+ +a_object_name,
- +
+ +a_procedure_name,
- +
+ +a_skip_all_objects,
- +
+ +null,
- +
+ +null
- +
+ +)
- +
+ +);
- + 54 +
+ +return l_suites;
- +
+ +end;
- +
+ +- +
+ +function get_schema_ut_packages(a_schema_names ut_varchar2_rows) return ut_object_names is
- +
+ +begin
- + 246 +
+ +for i in 1 .. a_schema_names.count loop
- + 129 +
+ +refresh_cache(a_schema_names(i));
- +
+ +end loop;
- +
+ +- + 117 +
+ +return ut_suite_cache_manager.get_cached_packages( a_schema_names );
- +
+ +end;
- +
+ +- +
+ +function get_schema_names(a_paths ut_varchar2_list) return ut_varchar2_rows is
- +
+ +l_paths ut_varchar2_list;
- +
+ +begin
- + 115 +
+ +l_paths := a_paths;
- + 115 +
+ +return resolve_schema_names(l_paths);
- +
+ +end;
- +
+ +- +
+ +function configure_execution_by_path(a_paths ut_varchar2_list, a_random_seed positive := null) return ut_suite_items is
- + 32 +
+ +l_suites ut_suite_items := ut_suite_items();
- +
+ +begin
- + 32 +
+ +configure_execution_by_path(a_paths, l_suites );
- + 30 +
+ +return l_suites;
- +
+ +end;
- +
+ +- +
+ +procedure configure_execution_by_path(
- +
+ +a_paths ut_varchar2_list,
- +
+ +a_suites out nocopy ut_suite_items,
- +
+ +a_random_seed positive := null,
- +
+ +a_tags ut_varchar2_rows := ut_varchar2_rows()
- +
+ +) is
- + 148 +
+ +l_paths ut_varchar2_list := a_paths;
- +
+ +l_path_items t_path_items;
- +
+ +l_path_item t_path_item;
- +
+ +l_schema varchar2(4000);
- + 148 +
+ +l_suites_count pls_integer := 0;
- +
+ +l_index varchar2(4000 char);
- +
+ +l_schema_paths t_schema_paths;
- +
+ +begin
- + 148 +
+ +ut_event_manager.trigger_event('configure_execution_by_path - start');
- + 148 +
+ +a_suites := ut_suite_items();
- +
+ +--resolve schema names from paths and group paths by schema name
- + 148 +
+ +resolve_schema_names(l_paths);
- +
+ +- + 147 +
+ +l_schema_paths := group_paths_by_schema(l_paths);
- +
+ +- + 147 +
+ +l_schema := l_schema_paths.first;
- + 292 +
+ +while l_schema is not null loop
- + 147 +
+ +l_path_items := l_schema_paths(l_schema);
- + 303 +
+ +for i in 1 .. l_path_items.count loop
- + 158 +
+ +l_path_item := l_path_items(i);
- + 158 +
+ +add_suites_for_path(
- +
+ +upper(l_schema),
- +
+ +l_path_item.suite_path,
- +
+ +l_path_item.object_name,
- +
+ +l_path_item.procedure_name,
- +
+ +a_suites,
- +
+ +a_random_seed,
- +
+ +a_tags
- +
+ +);
- + 158 +
+ +if a_suites.count = l_suites_count then
- + 3 +
+ +if l_path_item.suite_path is not null then
- +
+ +raise_application_error(ut_utils.gc_suite_package_not_found,'No suite packages found for path '||l_schema||':'||l_path_item.suite_path|| '.');
- + 3 +
+ +elsif l_path_item.procedure_name is not null then
- +
+ +raise_application_error(ut_utils.gc_suite_package_not_found,'Suite test '||l_schema||'.'||l_path_item.object_name|| '.'||l_path_item.procedure_name||' does not exist');
- + 3 +
+ +elsif l_path_item.object_name is not null then
- + 2 +
+ +raise_application_error(ut_utils.gc_suite_package_not_found,'Suite package '||l_schema||'.'||l_path_item.object_name|| ' does not exist');
- +
+ +end if;
- +
+ +end if;
- + 156 +
+ +l_index := a_suites.first;
- + 156 +
+ +l_suites_count := a_suites.count;
- +
+ +end loop;
- + 145 +
+ +l_schema := l_schema_paths.next(l_schema);
- +
+ +end loop;
- +
+ +- +
+ +--propagate rollback type to suite items after organizing suites into hierarchy
- + 320 +
+ +for i in 1 .. a_suites.count loop
- + 175 +
+ +a_suites(i).set_rollback_type( a_suites(i).get_rollback_type() );
- +
+ +end loop;
- +
+ +- + 145 +
+ +ut_event_manager.trigger_event('configure_execution_by_path - start');
- +
+ +end configure_execution_by_path;
- +
+ +- +
+ +function get_suites_info(
- +
+ +a_owner_name varchar2,
- +
+ +a_package_name varchar2 := null
- +
+ +) return sys_refcursor is
- +
+ +l_result sys_refcursor;
- +
+ +l_all_suite_info ut_suite_items_info;
- + 3 +
+ +l_owner_name varchar2(250) := ut_utils.qualified_sql_name(a_owner_name);
- + 3 +
+ +l_package_name varchar2(250) := ut_utils.qualified_sql_name(a_package_name);
- +
+ +begin
- +
+ +- + 3 +
+ +refresh_cache(l_owner_name);
- +
+ +- + 3 +
+ +l_all_suite_info := ut_suite_cache_manager.get_cached_suite_info( l_owner_name, l_package_name );
- + 3 +
+ +if can_skip_all_objects_scan( l_owner_name ) then
- + 3 +
+ +open l_result for
- + 1 +
+ +select value(c)
- +
+ +from table(l_all_suite_info) c
- +
+ +order by c.object_owner, c.object_name, c.item_line_no;
- +
+ +else
- +
+ +open l_result for
- +
+ +select value(c)
- +
+ +from table(l_all_suite_info) c
- +
+ +where exists
- +
+ +( select 1
- +
+ +from all_objects a
- +
+ +where a.object_name = c.object_name
- +
+ +and a.owner = c.object_owner
- +
+ +and a.object_type = 'PACKAGE'
- +
+ +)
- +
+ +order by c.object_owner, c.object_name, c.item_line_no;
- +
+ +end if;
- + 3 +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+ +function suite_item_exists(
- +
+ +a_owner_name varchar2,
- +
+ +a_package_name varchar2 := null,
- +
+ +a_procedure_name varchar2 := null
- +
+ +) return boolean is
- + 12 +
+ +l_count integer := 1;
- +
+ +l_item_exists boolean;
- + 12 +
+ +l_owner_name varchar2(250) := upper(a_owner_name);
- + 12 +
+ +l_package_name varchar2(250) := upper(a_package_name);
- + 12 +
+ +l_procedure_name varchar2(250) := upper(a_procedure_name);
- +
+ +begin
- +
+ +- + 12 +
+ +refresh_cache(l_owner_name);
- + 12 +
+ +l_item_exists := ut_suite_cache_manager.suite_item_exists( l_owner_name, l_package_name, l_procedure_name );
- + 12 +
+ +if not can_skip_all_objects_scan( l_owner_name ) then
- +
+ +select count(1)
- +
+ +into l_count
- +
+ +from dual c
- +
+ +where exists
- +
+ +( select 1
- +
+ +from all_objects a
- +
+ +where a.object_name = l_package_name
- +
+ +and a.owner = l_owner_name
- +
+ +and a.object_type = 'PACKAGE'
- +
+ +);
- +
+ +end if;
- +
+ +- + 12 +
+ +return l_count > 0 and l_item_exists;
- +
+ +end;
- +
+ +- +
+end ut_suite_manager;
+UT3.UT_UTILS
94.29 % lines covered
350 relevant lines. 330 lines covered (including 4 lines partially covered ) and 20 lines missed+ +
- +
+ +package body ut_utils is
- +
+ +/*
- +
+ +utPLSQL - Version 3
- +
+ +Copyright 2016 - 2019 utPLSQL Project
- +
+ +- +
+ +Licensed under the Apache License, Version 2.0 (the "License"):
- +
+ +you may not use this file except in compliance with the License.
- +
+ +You may obtain a copy of the License at
- +
+ +- +
+ +http://www.apache.org/licenses/LICENSE-2.0
- +
+ +- +
+ +Unless required by applicable law or agreed to in writing, software
- +
+ +distributed under the License is distributed on an "AS IS" BASIS,
- +
+ +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
+ +See the License for the specific language governing permissions and
- +
+ +limitations under the License.
- +
+ +*/
- +
+ +- +
+ +/**
- +
+ +* Constants regex used to validate XML name
- +
+ +*/
- + 1 +
+ +gc_invalid_first_xml_char constant varchar2(50) := '[^_a-zA-Z]';
- + 1 +
+ +gc_invalid_xml_char constant varchar2(50) := '[^_a-zA-Z0-9\.-]';
- + 1 +
+ +gc_full_valid_xml_name constant varchar2(50) := '^([_a-zA-Z])([_a-zA-Z0-9\.-])*$';
- +
+ +- +
+ +function surround_with(a_value varchar2, a_quote_char varchar2) return varchar2 is
- +
+ +begin
- + 1516 +
+ +return case when a_quote_char is not null then a_quote_char||a_value||a_quote_char else a_value end;
- +
+ +end;
- +
+ +- +
+ +function test_result_to_char(a_test_result integer) return varchar2 as
- +
+ +l_result varchar2(20);
- +
+ +begin
- + 21 +
+ +if a_test_result = gc_success then
- + 5 +
+ +l_result := gc_success_char;
- + 16 +
+ +elsif a_test_result = gc_failure then
- + 10 +
+ +l_result := gc_failure_char;
- + 6 +
+ +elsif a_test_result = gc_error then
- + 2 +
+ +l_result := gc_error_char;
- + 4 +
+ +elsif a_test_result = gc_disabled then
- + 2 +
+ +l_result := gc_disabled_char;
- +
+ +else
- + 2 +
+ +l_result := 'Unknown(' || coalesce(to_char(a_test_result),'NULL') || ')';
- +
+ +end if ;
- + 21 +
+ +return l_result;
- +
+ +end test_result_to_char;
- +
+ +- +
+ +- +
+ +function to_test_result(a_test boolean) return integer is
- +
+ +l_result integer;
- +
+ +begin
- + 1306 +
+ +if a_test then
- + 621 +
+ +l_result := gc_success;
- +
+ +else
- + 685 +
+ +l_result := gc_failure;
- +
+ +end if;
- + 1306 +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+ +function gen_savepoint_name return varchar2 is
- +
+ +begin
- + 321 +
+ +return 's'||trim(to_char(ut_savepoint_seq.nextval,'0000000000000000000000000000'));
- +
+ +end;
- +
+ +- +
+ +procedure debug_log(a_message varchar2) is
- +
+ +begin
- +
+ +$if $$ut_trace $then
- +
+ +dbms_output.put_line(a_message);
- +
+ +$else
- + 5779 +
+ +null;
- +
+ +$end
- +
+ +end;
- +
+ +- +
+ +procedure debug_log(a_message clob) is
- +
+ +l_varchars ut_varchar2_list;
- +
+ +begin
- +
+ +$if $$ut_trace $then
- +
+ +l_varchars := clob_to_table(a_message);
- +
+ +for i in 1..l_varchars.count loop
- +
+ +dbms_output.put_line(l_varchars(i));
- +
+ +end loop;
- +
+ +$else
- + 429 +
+ +null;
- +
+ +$end
- +
+ +end;
- +
+ +- +
+ +function to_string(
- +
+ +a_value varchar2,
- +
+ +a_quote_char varchar2 := '''',
- +
+ +a_max_output_len in number := gc_max_output_string_length
- +
+ +) return varchar2 is
- +
+ +l_result varchar2(32767);
- + 1189 +
+ +c_length constant integer := coalesce( length( a_value ), 0 );
- + 1189 +
+ +c_max_input_string_length constant integer := a_max_output_len - coalesce( length( a_quote_char ) * 2, 0 );
- + 1189 +
+ +c_overflow_substr_len constant integer := c_max_input_string_length - gc_more_data_string_len;
- +
+ +begin
- + 1189 +
+ +if c_length = 0 then
- + 18 +
+ +l_result := gc_null_string;
- + 1171 +
+ +elsif c_length <= c_max_input_string_length then
- + 1166 +
+ +l_result := surround_with(a_value, a_quote_char);
- +
+ +else
- + 5 +
+ +l_result := surround_with(substr(a_value, 1, c_overflow_substr_len ), a_quote_char) || gc_more_data_string;
- +
+ +end if ;
- + 1189 +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+ +function to_string(
- +
+ +a_value clob,
- +
+ +a_quote_char varchar2 := '''',
- +
+ +a_max_output_len in number := gc_max_output_string_length
- +
+ +) return varchar2 is
- +
+ +l_result varchar2(32767);
- + 355 +
+ +c_length constant integer := coalesce(dbms_lob.getlength(a_value), 0);
- + 355 +
+ +c_max_input_string_length constant integer := a_max_output_len - coalesce( length( a_quote_char ) * 2, 0 );
- + 355 +
+ +c_overflow_substr_len constant integer := c_max_input_string_length - gc_more_data_string_len;
- +
+ +begin
- + 355 +
+ +if a_value is null then
- + 16 +
+ +l_result := gc_null_string;
- + 339 +
+ +elsif c_length = 0 then
- + 6 +
+ +l_result := gc_empty_string;
- + 333 +
+ +elsif c_length <= c_max_input_string_length then
- + 315 +
+ +l_result := surround_with(a_value,a_quote_char);
- +
+ +else
- + 18 +
+ +l_result := surround_with(dbms_lob.substr(a_value, c_overflow_substr_len), a_quote_char) || gc_more_data_string;
- +
+ +end if;
- + 355 +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+ +function to_string(
- +
+ +a_value blob,
- +
+ +a_quote_char varchar2 := '''',
- +
+ +a_max_output_len in number := gc_max_output_string_length
- +
+ +) return varchar2 is
- +
+ +l_result varchar2(32767);
- + 34 +
+ +c_length constant integer := coalesce(dbms_lob.getlength(a_value), 0);
- + 34 +
+ +c_max_input_string_length constant integer := a_max_output_len - coalesce( length( a_quote_char ) * 2, 0 );
- + 34 +
+ +c_overflow_substr_len constant integer := c_max_input_string_length - gc_more_data_string_len;
- +
+ +begin
- + 34 +
+ +if a_value is null then
- + 14 +
+ +l_result := gc_null_string;
- + 20 +
+ +elsif c_length = 0 then
- + 6 +
+ +l_result := gc_empty_string;
- + 14 +
+ +elsif c_length <= c_max_input_string_length then
- + 12 +
+ +l_result := surround_with(rawtohex(a_value),a_quote_char);
- +
+ +else
- + 2 +
+ +l_result := to_string( rawtohex(dbms_lob.substr(a_value, c_overflow_substr_len)) );
- +
+ +end if ;
- + 34 +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+ +function to_string(a_value boolean) return varchar2 is
- +
+ +begin
- + 86 +
+ +return case a_value when true then 'TRUE' when false then 'FALSE' else gc_null_string end;
- +
+ +end;
- +
+ +- +
+ +function to_string(a_value number) return varchar2 is
- +
+ +begin
- + 493 +
+ +return coalesce(to_char(a_value,gc_number_format), gc_null_string);
- +
+ +end;
- +
+ +- +
+ +function to_string(a_value date) return varchar2 is
- +
+ +begin
- + 80 +
+ +return coalesce(to_char(a_value,gc_date_format), gc_null_string);
- +
+ +end;
- +
+ +- +
+ +function to_string(a_value timestamp_unconstrained) return varchar2 is
- +
+ +begin
- + 479 +
+ +return coalesce(to_char(a_value,gc_timestamp_format), gc_null_string);
- +
+ +end;
- +
+ +- +
+ +function to_string(a_value timestamp_tz_unconstrained) return varchar2 is
- +
+ +begin
- + 748 +
+ +return coalesce(to_char(a_value,gc_timestamp_tz_format), gc_null_string);
- +
+ +end;
- +
+ +- +
+ +function to_string(a_value timestamp_ltz_unconstrained) return varchar2 is
- +
+ +begin
- + 86 +
+ +return coalesce(to_char(a_value,gc_timestamp_format), gc_null_string);
- +
+ +end;
- +
+ +- +
+ +function to_string(a_value yminterval_unconstrained) return varchar2 IS
- +
+ +begin
- + 72 +
+ +return coalesce(to_char(a_value), gc_null_string);
- +
+ +end;
- +
+ +- +
+ +function to_string(a_value dsinterval_unconstrained) return varchar2 IS
- +
+ +begin
- + 72 +
+ +return coalesce(to_char(a_value), gc_null_string);
- +
+ +end;
- +
+ +- +
+ +- +
+ +function boolean_to_int(a_value boolean) return integer is
- +
+ +begin
- + 9853 +
+ +return case a_value when true then 1 when false then 0 end;
- +
+ +end;
- +
+ +- +
+ +function int_to_boolean(a_value integer) return boolean is
- +
+ +begin
- + 4412 +
+ +return case a_value when 1 then true when 0 then false end;
- +
+ +end;
- +
+ +- +
+ +function string_to_table(a_string varchar2, a_delimiter varchar2:= chr(10), a_skip_leading_delimiter varchar2 := 'N') return ut_varchar2_list is
- + 20813 +
+ +l_offset integer := 1;
- +
+ +l_delimiter_position integer;
- + 20813 +
+ +l_skip_leading_delimiter boolean := coalesce(a_skip_leading_delimiter = 'Y',false);
- + 20813 +
+ +l_result ut_varchar2_list := ut_varchar2_list();
- +
+ +begin
- + 20813 +
+ +if a_string is null then
- +
+ +return l_result;
- +
+ +end if;
- + 20813 +
+ +if a_delimiter is null then
- + 2 +
+ +return ut_varchar2_list(a_string);
- +
+ +end if;
- +
+ +- + 27082 +
+ +loop
- + 27082 +
+ +l_delimiter_position := instr(a_string, a_delimiter, l_offset);
- + 27082 +
+ +if not (l_delimiter_position = 1 and l_skip_leading_delimiter) then
- + 27081 +
+ +l_result.extend;
- + 27081 +
+ +if l_delimiter_position > 0 then
- + 6270 +
+ +l_result(l_result.last) := substr(a_string, l_offset, l_delimiter_position - l_offset);
- +
+ +else
- + 20811 +
+ +l_result(l_result.last) := substr(a_string, l_offset);
- +
+ +end if;
- +
+ +end if;
- + 27082 +
+ +exit when l_delimiter_position = 0;
- + 6271 +
+ +l_offset := l_delimiter_position + 1;
- +
+ +end loop;
- + 20811 +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+ +function clob_to_table(a_clob clob, a_max_amount integer := 8191, a_delimiter varchar2:= chr(10)) return ut_varchar2_list is
- + 18302 +
+ +l_offset integer := 1;
- + 18302 +
+ +l_length integer := dbms_lob.getlength(a_clob);
- +
+ +l_amount integer;
- +
+ +l_buffer varchar2(32767);
- +
+ +l_last_line varchar2(32767);
- +
+ +l_string_results ut_varchar2_list;
- + 18302 +
+ +l_results ut_varchar2_list := ut_varchar2_list();
- +
+ +l_has_last_line boolean;
- + 18302 +
+ +l_skip_leading_delimiter varchar2(1) := 'N';
- +
+ +begin
- + 36615 +
+ +while l_offset <= l_length loop
- + 18313 +
+ +l_amount := a_max_amount - coalesce( length(l_last_line), 0 );
- +
+ +-- dbms_lob.read(a_clob, l_amount, l_offset, l_buffer);
- + 18313 +
+ +l_buffer := substr(a_clob, l_offset, l_amount);
- + 18313 +
+ +l_amount := length(l_buffer);
- + 18313 +
+ +l_offset := l_offset + l_amount;
- +
+ +- + 18313 +
+ +l_string_results := string_to_table( l_last_line || l_buffer, a_delimiter, l_skip_leading_delimiter );
- + 42495 +
+ +for i in 1 .. l_string_results.count loop
- +
+ +--if a split of lines was not done or not at the last line
- + 24182 +
+ +if l_string_results.count = 1 or i < l_string_results.count then
- + 23630 +
+ +l_results.extend;
- + 23630 +
+ +l_results(l_results.last) := l_string_results(i);
- +
+ +end if;
- +
+ +end loop;
- +
+ +- +
+ +--check if we need to append the last line to the next element
- + 18313 +
+ +if l_string_results.count = 1 then
- + 17761 +
+ +l_has_last_line := false;
- + 17761 +
+ +l_last_line := null;
- + 552 +
+ +elsif l_string_results.count > 1 then
- + 552 +
+ +l_has_last_line := true;
- + 552 +
+ +l_last_line := l_string_results(l_string_results.count);
- +
+ +end if;
- +
+ +- + 18313 +
+ +l_skip_leading_delimiter := 'Y';
- +
+ +end loop;
- + 18302 +
+ +if l_has_last_line then
- + 545 +
+ +l_results.extend;
- + 545 +
+ +l_results(l_results.last) := l_last_line;
- +
+ +end if;
- + 18302 +
+ +return l_results;
- +
+ +end;
- +
+ +- +
+ +function table_to_clob(a_text_table ut_varchar2_list, a_delimiter varchar2:= chr(10)) return clob is
- +
+ +l_result clob;
- + 1018 +
+ +l_table_rows integer := coalesce(cardinality(a_text_table),0);
- +
+ +begin
- + 22014 +
+ +for i in 1 .. l_table_rows loop
- + 20996 +
+ +if i < l_table_rows then
- + 20013 +
+ +append_to_clob(l_result, a_text_table(i)||a_delimiter);
- +
+ +else
- + 983 +
+ +append_to_clob(l_result, a_text_table(i));
- +
+ +end if;
- +
+ +end loop;
- + 1018 +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+ +function table_to_clob(a_text_table ut_varchar2_rows, a_delimiter varchar2:= chr(10)) return clob is
- +
+ +l_result clob;
- + 18 +
+ +l_table_rows integer := coalesce(cardinality(a_text_table),0);
- +
+ +begin
- + 28 +
+ +for i in 1 .. l_table_rows loop
- + 10 +
+ +if i < l_table_rows then
- + 3 +
+ +append_to_clob(l_result, a_text_table(i)||a_delimiter);
- +
+ +else
- + 7 +
+ +append_to_clob(l_result, a_text_table(i));
- +
+ +end if;
- +
+ +end loop;
- + 18 +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+ +function table_to_clob(a_integer_table ut_integer_list, a_delimiter varchar2:= chr(10)) return clob is
- +
+ +l_result clob;
- + 16 +
+ +l_table_rows integer := coalesce(cardinality(a_integer_table),0);
- +
+ +begin
- + 39 +
+ +for i in 1 .. l_table_rows loop
- + 23 +
+ +if i < l_table_rows then
- + 7 +
+ +append_to_clob(l_result, a_integer_table(i)||a_delimiter);
- +
+ +else
- + 16 +
+ +append_to_clob(l_result, a_integer_table(i));
- +
+ +end if;
- +
+ +end loop;
- + 16 +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+ +function time_diff(a_start_time timestamp with time zone, a_end_time timestamp with time zone) return number is
- +
+ +begin
- + 424 +
+ +return
- +
+ +extract(day from(a_end_time - a_start_time)) * 24 * 60 * 60 +
- +
+ +extract(hour from(a_end_time - a_start_time)) * 60 * 60 +
- +
+ +extract(minute from(a_end_time - a_start_time)) * 60 +
- +
+ +extract(second from(a_end_time - a_start_time));
- +
+ +end;
- +
+ +- +
+ +function indent_lines(a_text varchar2, a_indent_size integer := 4, a_include_first_line boolean := false) return varchar2 is
- +
+ +begin
- + 82 +
+ +if a_include_first_line then
- + 82 +
+ +return rtrim(lpad( ' ', a_indent_size ) || replace( a_text, chr(10), chr(10) || lpad( ' ', a_indent_size ) ));
- +
+ +else
- +
+ +return rtrim(replace( a_text, chr(10), chr(10) || lpad( ' ', a_indent_size ) ));
- +
+ +end if;
- +
+ +end;
- +
+ +- +
+ +function get_utplsql_objects_list return ut_object_names is
- +
+ +l_result ut_object_names;
- +
+ +begin
- +
+ +select distinct ut_object_name(sys_context('userenv','current_user'), o.object_name)
- +
+ +bulk collect into l_result
- +
+ +from user_objects o
- +
+ +where o.object_name = 'UT' or object_name like 'UT\_%' escape '\'
- +
+ +and o.object_type <> 'SYNONYM';
- +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+ +procedure append_to_list(a_list in out nocopy ut_varchar2_list, a_item varchar2) is
- +
+ +begin
- + 1028 +
+ +if a_item is not null then
- + 169 +
+ +if a_list is null then
- + 6 +
+ +a_list := ut_varchar2_list();
- +
+ +end if;
- + 169 +
+ +a_list.extend;
- + 169 +
+ +a_list(a_list.last) := a_item;
- +
+ +end if;
- +
+ +end append_to_list;
- +
+ +- +
+ +procedure append_to_list(a_list in out nocopy ut_varchar2_rows, a_items ut_varchar2_rows) is
- +
+ +begin
- + 570 +
+ +if a_items is not null then
- + 570 +
+ +if a_list is null then
- + 17 +
+ +a_list := ut_varchar2_rows();
- +
+ +end if;
- + 13651 +
+ +for i in 1 .. a_items.count loop
- + 13081 +
+ +a_list.extend;
- + 13081 +
+ +a_list(a_list.last) := a_items(i);
- +
+ +end loop;
- +
+ +end if;
- +
+ +end;
- +
+ +- +
+ +procedure append_to_list(a_list in out nocopy ut_varchar2_rows, a_item clob) is
- +
+ +begin
- + 479 +
+ +append_to_list(
- +
+ +a_list,
- +
+ +convert_collection(
- +
+ +clob_to_table( a_item, ut_utils.gc_max_storage_varchar2_len )
- +
+ +)
- +
+ +);
- +
+ +end;
- +
+ +- +
+ +procedure append_to_list(a_list in out nocopy ut_varchar2_rows, a_item varchar2) is
- +
+ +begin
- + 13264 +
+ +if a_item is not null then
- + 13264 +
+ +if a_list is null then
- + 30 +
+ +a_list := ut_varchar2_rows();
- +
+ +end if;
- + 13264 +
+ +if length(a_item) > gc_max_storage_varchar2_len then
- +
+ +append_to_list(
- +
+ +a_list,
- +
+ +ut_utils.convert_collection(
- +
+ +ut_utils.clob_to_table( a_item, gc_max_storage_varchar2_len )
- +
+ +)
- +
+ +);
- +
+ +else
- + 13264 +
+ +a_list.extend;
- + 13264 +
+ +a_list(a_list.last) := a_item;
- +
+ +end if;
- +
+ +end if;
- +
+ +end append_to_list;
- +
+ +- +
+ +procedure append_to_clob(a_src_clob in out nocopy clob, a_clob_table t_clob_tab, a_delimiter varchar2:= chr(10)) is
- +
+ +begin
- + 127 +
+ +if a_clob_table is not null and cardinality(a_clob_table) > 0 then
- + 104 +
+ +if a_src_clob is null then
- +
+ +dbms_lob.createtemporary(a_src_clob, true);
- +
+ +end if;
- + 433 +
+ +for i in 1 .. a_clob_table.count loop
- + 329 +
+ +dbms_lob.append(a_src_clob,a_clob_table(i));
- + 329 +
+ +if i < a_clob_table.count then
- + 225 +
+ +append_to_clob(a_src_clob,a_delimiter);
- +
+ +end if;
- +
+ +end loop;
- +
+ +end if;
- +
+ +end;
- +
+ +- +
+ +procedure append_to_clob(a_src_clob in out nocopy clob, a_new_data clob) is
- +
+ +begin
- + 1421 +
+ +if a_new_data is not null and dbms_lob.getlength(a_new_data) > 0 then
- + 1300 +
+ +if a_src_clob is null then
- + 1018 +
+ +dbms_lob.createtemporary(a_src_clob, true);
- +
+ +end if;
- + 1300 +
+ +dbms_lob.append(a_src_clob, a_new_data);
- +
+ +end if;
- +
+ +end;
- +
+ +- +
+ +procedure append_to_clob(a_src_clob in out nocopy clob, a_new_data varchar2) is
- +
+ +begin
- + 40854 +
+ +if a_new_data is not null then
- + 40852 +
+ +if a_src_clob is null then
- + 1673 +
+ +dbms_lob.createtemporary(a_src_clob, true);
- +
+ +end if;
- + 40852 +
+ +dbms_lob.writeappend(a_src_clob, dbms_lob.getlength(a_new_data), a_new_data);
- +
+ +end if;
- +
+ +end;
- +
+ +- +
+ +function convert_collection(a_collection ut_varchar2_list) return ut_varchar2_rows is
- +
+ +l_result ut_varchar2_rows;
- +
+ +begin
- + 1064 +
+ +if a_collection is not null then
- + 1064 +
+ +l_result := ut_varchar2_rows();
- + 5588 +
+ +for i in 1 .. a_collection.count loop
- + 4524 +
+ +l_result.extend();
- + 4524 +
+ +l_result(i) := substr(a_collection(i),1,gc_max_storage_varchar2_len);
- +
+ +end loop;
- +
+ +end if;
- + 1064 +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+ +function to_xpath(a_list varchar2, a_ancestors varchar2 := '/*/') return varchar2 is
- +
+ +l_xpath varchar2(32767) := a_list;
- +
+ +begin
- +
+ +l_xpath := to_xpath( clob_to_table(a_clob=>a_list, a_delimiter=>','), a_ancestors);
- +
+ +return l_xpath;
- +
+ +end;
- +
+ +- +
+ +function to_xpath(a_list ut_varchar2_list, a_ancestors varchar2 := '/*/') return varchar2 is
- +
+ +l_xpath varchar2(32767);
- +
+ +l_item varchar2(32767);
- +
+ +l_iter integer;
- +
+ +begin
- + 165 +
+ +if a_list is not null then
- + 165 +
+ +l_iter := a_list.first;
- + 464 +
+ +while l_iter is not null loop
- + 299 +
+ +l_item := trim(a_list(l_iter));
- + 299 +
+ +if l_item is not null then
- + 299 +
+ +if l_item like '%,%' then
- +
+ +l_xpath := l_xpath || to_xpath( l_item, a_ancestors ) || '|';
- + 299 +
+ +elsif l_item like '/%' then
- +
+ +l_xpath := l_xpath || l_item || '|';
- +
+ +else
- + 299 +
+ +l_xpath := l_xpath || a_ancestors || l_item || '|';
- +
+ +end if;
- +
+ +end if;
- + 299 +
+ +l_iter := a_list.next(l_iter);
- +
+ +end loop;
- + 165 +
+ +l_xpath := rtrim(l_xpath,',|');
- +
+ +end if;
- + 165 +
+ +return l_xpath;
- +
+ +end;
- +
+ +- +
+ +procedure cleanup_session_temp_tables is
- +
+ +begin
- + 114 +
+ +execute immediate 'truncate table dbmspcc_blocks';
- + 114 +
+ +execute immediate 'truncate table dbmspcc_units';
- + 114 +
+ +execute immediate 'truncate table dbmspcc_runs';
- +
+ +end;
- +
+ +- +
+ +function to_version(a_version_no varchar2) return t_version is
- +
+ +l_result t_version;
- + 32 +
+ +c_version_part_regex constant varchar2(20) := '[0-9]+';
- +
+ +begin
- +
+ +- + 32 +
+ +if regexp_like(a_version_no,'v?([0-9]+(\.|$)){1,4}') then
- + 30 +
+ +l_result.major := regexp_substr(a_version_no, c_version_part_regex, 1, 1);
- + 30 +
+ +l_result.minor := regexp_substr(a_version_no, c_version_part_regex, 1, 2);
- + 30 +
+ +l_result.bugfix := regexp_substr(a_version_no, c_version_part_regex, 1, 3);
- + 30 +
+ +l_result.build := regexp_substr(a_version_no, c_version_part_regex, 1, 4);
- +
+ +else
- + 2 +
+ +raise_application_error(gc_invalid_version_no, 'Version string "'||a_version_no||'" is not a valid version');
- +
+ +end if;
- + 30 +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+ +procedure save_dbms_output_to_cache is
- +
+ +l_status number;
- +
+ +l_line varchar2(32767);
- + 116 +
+ +l_offset integer := 0;
- + 116 +
+ +l_lines ut_varchar2_rows := ut_varchar2_rows();
- + 116 +
+ +c_lines_limit constant integer := 100;
- +
+ +pragma autonomous_transaction;
- +
+ +- +
+ +procedure flush_lines(a_lines ut_varchar2_rows, a_offset integer) is
- +
+ +begin
- + 119 +
+ +if a_lines is not empty then
- + 4 +
+ +insert into ut_dbms_output_cache (seq_no,text)
- +
+ +select rownum+a_offset, column_value
- +
+ +from table(a_lines);
- +
+ +end if;
- +
+ +end;
- +
+ +begin
- + 419 +
+ +loop
- + 419 +
+ +dbms_output.get_line(line => l_line, status => l_status);
- + 419 +
+ +exit when l_status = 1;
- + 303 +
+ +l_lines := l_lines multiset union all ut_utils.convert_collection(ut_utils.clob_to_table(l_line||chr(7),4000));
- + 303 +
+ +if l_lines.count > c_lines_limit then
- + 3 +
+ +flush_lines(l_lines, l_offset);
- + 3 +
+ +l_offset := l_offset + l_lines.count;
- + 3 +
+ +l_lines.delete;
- +
+ +end if;
- +
+ +end loop;
- + 116 +
+ +flush_lines(l_lines, l_offset);
- + 116 +
+ +commit;
- +
+ +end;
- +
+ +- +
+ +procedure read_cache_to_dbms_output is
- +
+ +l_lines_data sys_refcursor;
- +
+ +l_lines ut_varchar2_rows;
- + 116 +
+ +c_lines_limit constant integer := 10000;
- +
+ +pragma autonomous_transaction;
- +
+ +begin
- + 116 +
+ +open l_lines_data for select text from ut_dbms_output_cache order by seq_no;
- + 116 +
+ +loop
- + 116 +
+ +fetch l_lines_data bulk collect into l_lines limit c_lines_limit;
- + 421 +
+ +for i in 1 .. l_lines.count loop
- + 305 +
+ +if substr(l_lines(i),-1) = chr(7) then
- + 303 +
+ +dbms_output.put_line(rtrim(l_lines(i),chr(7)));
- +
+ +else
- + 2 +
+ +dbms_output.put(l_lines(i));
- +
+ +end if;
- +
+ +end loop;
- + 116 +
+ +exit when l_lines_data%notfound;
- +
+ +end loop;
- + 116 +
+ +execute immediate 'truncate table ut_dbms_output_cache';
- + 116 +
+ +commit;
- +
+ +end;
- +
+ +- +
+ +function ut_owner return varchar2 is
- +
+ +begin
- + 1428 +
+ +return sys_context('userenv','current_schema');
- +
+ +end;
- +
+ +- +
+ +function scale_cardinality(a_cardinality natural) return natural is
- +
+ +begin
- + 396 +
+ +return case when a_cardinality > 0 then trunc(power(10,(floor(log(10,a_cardinality))+1))/3) else 1 end;
- +
+ +end;
- +
+ +- +
+ +function build_depreciation_warning(a_old_syntax varchar2, a_new_syntax varchar2) return varchar2 is
- +
+ +begin
- + 23 +
+ +return 'The syntax: "'||a_old_syntax||'" is deprecated.' ||chr(10)||
- +
+ +'Please use the new syntax: "'||a_new_syntax||'".' ||chr(10)||
- +
+ +'The deprecated syntax will not be supported in future releases.';
- +
+ +end;
- +
+ +- +
+ +function to_xml_number_format(a_value number) return varchar2 is
- +
+ +begin
- + 90 +
+ +return to_char(a_value, gc_number_format, 'NLS_NUMERIC_CHARACTERS=''. ''');
- +
+ +end;
- +
+ +- +
+ +function get_xml_header(a_encoding varchar2) return varchar2 is
- +
+ +begin
- + 38 +
+ +return
- +
+ +'<?xml version="1.0"'
- + 1 +
+ +||case
- + 1 +
+ +when a_encoding is not null
- +
+ +then ' encoding="'||upper(a_encoding)||'"'
- +
+ +end
- +
+ +||'?>';
- +
+ +end;
- +
+ +- +
+ +function trim_list_elements(a_list ut_varchar2_list, a_regexp_to_trim varchar2 default '[:space:]') return ut_varchar2_list is
- +
+ +l_trimmed_list ut_varchar2_list;
- +
+ +l_index integer;
- +
+ +begin
- + 800 +
+ +if a_list is not null then
- + 799 +
+ +l_trimmed_list := ut_varchar2_list();
- + 799 +
+ +l_index := a_list.first;
- +
+ +- + 1734 +
+ +while (l_index is not null) loop
- + 935 +
+ +l_trimmed_list.extend;
- + 935 +
+ +l_trimmed_list(l_trimmed_list.count) := regexp_replace(a_list(l_index), '(^['||a_regexp_to_trim||']*)|(['||a_regexp_to_trim||']*$)');
- + 935 +
+ +l_index := a_list.next(l_index);
- +
+ +end loop;
- +
+ +end if;
- +
+ +- + 800 +
+ +return l_trimmed_list;
- +
+ +end;
- +
+ +- +
+ +function filter_list(a_list in ut_varchar2_list, a_regexp_filter in varchar2) return ut_varchar2_list is
- +
+ +l_filtered_list ut_varchar2_list;
- +
+ +l_index integer;
- +
+ +begin
- + 770 +
+ +if a_list is not null then
- + 769 +
+ +l_filtered_list := ut_varchar2_list();
- + 769 +
+ +l_index := a_list.first;
- + 1651 +
+ +while (l_index is not null) loop
- + 882 +
+ +if regexp_like(a_list(l_index), a_regexp_filter) then
- + 875 +
+ +l_filtered_list.extend;
- + 875 +
+ +l_filtered_list(l_filtered_list.count) := a_list(l_index);
- +
+ +end if;
- + 882 +
+ +l_index := a_list.next(l_index);
- +
+ +end loop;
- +
+ +end if;
- +
+ +- + 770 +
+ +return l_filtered_list;
- +
+ +end;
- +
+ +- +
+ +function xmlgen_escaped_string(a_string in varchar2) return varchar2 is
- +
+ +l_result varchar2(4000) := a_string;
- +
+ +l_sql varchar2(32767) := q'!select q'[!'||a_string||q'!]' as "!'||a_string||'" from dual';
- +
+ +begin
- +
+ +if a_string is not null then
- +
+ +select extract(dbms_xmlgen.getxmltype(l_sql),'/*/*/*').getRootElement()
- +
+ +into l_result
- +
+ +from dual;
- +
+ +end if;
- +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+ +function replace_multiline_comments(a_source clob) return clob is
- +
+ +l_result clob;
- + 558 +
+ +l_ml_comment_start binary_integer := 1;
- + 558 +
+ +l_comment_start binary_integer := 1;
- + 558 +
+ +l_text_start binary_integer := 1;
- + 558 +
+ +l_escaped_text_start binary_integer := 1;
- +
+ +l_escaped_text_end_char varchar2(1 char);
- + 558 +
+ +l_end binary_integer := 1;
- +
+ +l_ml_comment clob;
- +
+ +l_newlines_count binary_integer;
- + 558 +
+ +l_offset binary_integer := 1;
- + 558 +
+ +l_length binary_integer := coalesce(dbms_lob.getlength(a_source), 0);
- +
+ +begin
- + 558 +
+ +l_ml_comment_start := instr(a_source,'/*');
- + 558 +
+ +l_comment_start := instr(a_source,'--');
- + 558 +
+ +l_text_start := instr(a_source,'''');
- + 558 +
+ +l_escaped_text_start := instr(a_source,q'[q']');
- + 739 +
+ +while l_offset > 0 and l_ml_comment_start > 0 loop
- +
+ +- + 181 +
+ +if l_ml_comment_start > 0 and (l_ml_comment_start < l_comment_start or l_comment_start = 0)
- + 1 +
+ +and (l_ml_comment_start < l_text_start or l_text_start = 0)and (l_ml_comment_start < l_escaped_text_start or l_escaped_text_start = 0)
- +
+ +then
- + 13 +
+ +l_end := instr(a_source,'*/',l_ml_comment_start+2);
- + 13 +
+ +append_to_clob(l_result, dbms_lob.substr(a_source, l_ml_comment_start-l_offset, l_offset));
- + 13 +
+ +if l_end > 0 then
- + 13 +
+ +l_ml_comment := substr(a_source, l_ml_comment_start, l_end-l_ml_comment_start);
- + 13 +
+ +l_newlines_count := length( l_ml_comment ) - length( translate( l_ml_comment, 'a'||chr(10), 'a') );
- + 13 +
+ +if l_newlines_count > 0 then
- + 6 +
+ +append_to_clob(l_result, lpad( chr(10), l_newlines_count, chr(10) ) );
- +
+ +end if;
- + 13 +
+ +l_end := l_end + 2;
- +
+ +end if;
- +
+ +else
- +
+ +- + 168 +
+ +if l_comment_start > 0 and (l_comment_start < l_ml_comment_start or l_ml_comment_start = 0)
- + 1 +
+ +and (l_comment_start < l_text_start or l_text_start = 0) and (l_comment_start < l_escaped_text_start or l_escaped_text_start = 0)
- +
+ +then
- + 163 +
+ +l_end := instr(a_source,chr(10),l_comment_start+2);
- + 163 +
+ +if l_end > 0 then
- + 163 +
+ +l_end := l_end + 1;
- +
+ +end if;
- + 2/3 + 5 +
+ +elsif l_text_start > 0 and (l_text_start < l_ml_comment_start or l_ml_comment_start = 0)
- + 1 +
+ +and (l_text_start < l_comment_start or l_comment_start = 0) and (l_text_start < l_escaped_text_start or l_escaped_text_start = 0)
- +
+ +then
- + 3 +
+ +l_end := instr(a_source,q'[']',l_text_start+1);
- +
+ +- +
+ +--skip double quotes while searching for end of quoted text
- + 3 +
+ +while l_end > 0 and l_end = instr(a_source,q'['']',l_text_start+1) loop
- +
+ +l_end := instr(a_source,q'[']',l_end+1);
- +
+ +end loop;
- + 3 +
+ +if l_end > 0 then
- + 3 +
+ +l_end := l_end + 1;
- +
+ +end if;
- +
+ +- + 2/3 + 2 +
+ +elsif l_escaped_text_start > 0 and (l_escaped_text_start < l_ml_comment_start or l_ml_comment_start = 0)
- + 3/4 + 1 +
+ +and (l_escaped_text_start < l_comment_start or l_comment_start = 0) and (l_escaped_text_start < l_text_start or l_text_start = 0)
- +
+ +then
- +
+ +--translate char "[" from the start of quoted text "q'[someting]'" into "]"
- + 2 +
+ +l_escaped_text_end_char := translate( substr(a_source, l_escaped_text_start + 2, 1), '[{(<', ']})>');
- + 2 +
+ +l_end := instr(a_source,l_escaped_text_end_char||'''',l_escaped_text_start + 3 );
- + 2 +
+ +if l_end > 0 then
- + 2 +
+ +l_end := l_end + 2;
- +
+ +end if;
- +
+ +end if;
- +
+ +- + 168 +
+ +if l_end = 0 then
- +
+ +append_to_clob(l_result, substr(a_source, l_offset, l_length-l_offset));
- +
+ +else
- + 168 +
+ +append_to_clob(l_result, substr(a_source, l_offset, l_end-l_offset));
- +
+ +end if;
- +
+ +end if;
- + 181 +
+ +l_offset := l_end;
- + 181 +
+ +if l_offset >= l_ml_comment_start then
- + 19 +
+ +l_ml_comment_start := instr(a_source,'/*',l_offset);
- +
+ +end if;
- + 181 +
+ +if l_offset >= l_comment_start then
- + 167 +
+ +l_comment_start := instr(a_source,'--',l_offset);
- +
+ +end if;
- + 181 +
+ +if l_offset >= l_text_start then
- + 166 +
+ +l_text_start := instr(a_source,'''',l_offset);
- +
+ +end if;
- + 181 +
+ +if l_offset >= l_escaped_text_start then
- + 171 +
+ +l_escaped_text_start := instr(a_source,q'[q']',l_offset);
- +
+ +end if;
- +
+ +end loop;
- + 558 +
+ +append_to_clob(l_result, substr(a_source, l_end));
- + 558 +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+ +function get_child_reporters(a_for_reporters ut_reporters_info := null) return ut_reporters_info is
- + 4 +
+ +l_for_reporters ut_reporters_info := a_for_reporters;
- +
+ +l_results ut_reporters_info;
- +
+ +begin
- + 4 +
+ +if l_for_reporters is null then
- + 1 +
+ +l_for_reporters := ut_reporters_info(ut_reporter_info('UT_REPORTER_BASE','N','N','N'));
- +
+ +end if;
- +
+ +- + 4 +
+ +select /*+ cardinality(f 10) */
- +
+ +ut_reporter_info(
- +
+ +object_name => t.type_name,
- +
+ +is_output_reporter =>
- +
+ +case
- +
+ +when f.is_output_reporter = 'Y' or t.type_name = 'UT_OUTPUT_REPORTER_BASE'
- +
+ +then 'Y' else 'N'
- +
+ +end,
- +
+ +is_instantiable => case when t.instantiable = 'YES' then 'Y' else 'N' end,
- +
+ +is_final => case when t.final = 'YES' then 'Y' else 'N' end
- +
+ +)
- +
+ +bulk collect into l_results
- +
+ +from user_types t
- +
+ +join (select * from table(l_for_reporters) where is_final = 'N' ) f
- +
+ +on f.object_name = supertype_name;
- +
+ +- + 4 +
+ +return l_results;
- +
+ +end;
- +
+ +- +
+ +function remove_error_from_stack(a_error_stack varchar2, a_ora_code number) return varchar2 is
- +
+ +l_caller_stack_line varchar2(4000);
- + 4 +
+ +l_ora_search_pattern varchar2(500) := '^ORA'||a_ora_code||': (.*)$';
- +
+ +begin
- + 4 +
+ +l_caller_stack_line := regexp_replace(srcstr => a_error_stack
- +
+ +,pattern => l_ora_search_pattern
- +
+ +,replacestr => null
- +
+ +,position => 1
- +
+ +,occurrence => 1
- +
+ +,modifier => 'm');
- + 4 +
+ +return l_caller_stack_line;
- +
+ +end;
- +
+ +- +
+ +/**
- +
+ +* Change string into unicode to match xmlgen format _00<unicode>_
- +
+ +* https://docs.oracle.com/en/database/oracle/oracle-database/12.2/adxdb/generation-of-XML-data-from-relational-data.html#GUID-5BE09A7D-80D8-4734-B9AF-4A61F27FA9B2
- +
+ +* secion v3.1.8.3169-develop
- +
+ +*/
- +
+ +function char_to_xmlgen_unicode(a_character varchar2) return varchar2 is
- +
+ +begin
- + 20 +
+ +return '_x00'||rawtohex(utl_raw.cast_to_raw(a_character))||'_';
- +
+ +end;
- +
+ +- +
+ +/**
- +
+ +* Build valid XML column name as element names can contain letters, digits, hyphens, underscores, and periods
- +
+ +*/
- +
+ +function build_valid_xml_name(a_preprocessed_name varchar2) return varchar2 is
- +
+ +l_post_processed varchar2(4000);
- +
+ +begin
- + 1/2 + 92 +
+ +for i in (select regexp_substr( a_preprocessed_name ,'(.{1})', 1, level, null, 1 ) AS string_char,level level_no
- +
+ +from dual connect by level <= regexp_count(a_preprocessed_name, '(.{1})'))
- +
+ +loop
- + 60 +
+ +if i.level_no = 1 and regexp_like(i.string_char,gc_invalid_first_xml_char) then
- + 16 +
+ +l_post_processed := l_post_processed || char_to_xmlgen_unicode(i.string_char);
- + 44 +
+ +elsif regexp_like(i.string_char,gc_invalid_xml_char) then
- + 4 +
+ +l_post_processed := l_post_processed || char_to_xmlgen_unicode(i.string_char);
- +
+ +else
- + 40 +
+ +l_post_processed := l_post_processed || i.string_char;
- +
+ +end if;
- +
+ +end loop;
- + 16 +
+ +return l_post_processed;
- +
+ +end;
- +
+ +- +
+ +function get_valid_xml_name(a_name varchar2) return varchar2 is
- +
+ +l_valid_name varchar2(4000);
- +
+ +begin
- + 1226 +
+ +if regexp_like(a_name,gc_full_valid_xml_name) then
- + 1210 +
+ +l_valid_name := a_name;
- +
+ +else
- + 16 +
+ +l_valid_name := build_valid_xml_name(a_name);
- +
+ +end if;
- + 1226 +
+ +return l_valid_name;
- +
+ +end;
- +
+ +- +
+ +function to_cdata(a_lines ut_varchar2_rows) return ut_varchar2_rows is
- +
+ +l_results ut_varchar2_rows;
- +
+ +begin
- + 29 +
+ +if a_lines is not empty then
- + 29 +
+ +ut_utils.append_to_list( l_results, gc_cdata_start_tag);
- + 80 +
+ +for i in 1 .. a_lines.count loop
- + 51 +
+ +ut_utils.append_to_list( l_results, replace( a_lines(i), gc_cdata_end_tag, gc_cdata_end_tag_wrap ) );
- +
+ +end loop;
- + 29 +
+ +ut_utils.append_to_list( l_results, gc_cdata_end_tag);
- +
+ +else
- +
+ +l_results := a_lines;
- +
+ +end if;
- + 29 +
+ +return l_results;
- +
+ +end;
- +
+ +- +
+ +function to_cdata(a_clob clob) return clob is
- +
+ +l_result clob;
- +
+ +begin
- + 9 +
+ +if a_clob is not null and a_clob != empty_clob() then
- + 9 +
+ +l_result := replace( a_clob, gc_cdata_end_tag, gc_cdata_end_tag_wrap );
- +
+ +else
- +
+ +l_result := a_clob;
- +
+ +end if;
- + 9 +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+ +function add_prefix(a_list ut_varchar2_list, a_prefix varchar2, a_connector varchar2 := '/') return ut_varchar2_list is
- + 73 +
+ +l_result ut_varchar2_list := ut_varchar2_list();
- +
+ +l_idx binary_integer;
- +
+ +begin
- + 73 +
+ +if a_prefix is not null then
- + 65 +
+ +l_idx := a_list.first;
- + 69 +
+ +while l_idx is not null loop
- + 4 +
+ +l_result.extend;
- + 4 +
+ +l_result(l_idx) := add_prefix(a_list(l_idx), a_prefix, a_connector);
- + 4 +
+ +l_idx := a_list.next(l_idx);
- +
+ +end loop;
- +
+ +end if;
- + 73 +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+ +function add_prefix(a_item varchar2, a_prefix varchar2, a_connector varchar2 := '/') return varchar2 is
- +
+ +begin
- + 4 +
+ +return a_prefix||a_connector||trim(leading a_connector from a_item);
- +
+ +end;
- +
+ +- +
+ +function strip_prefix(a_item varchar2, a_prefix varchar2, a_connector varchar2 := '/') return varchar2 is
- +
+ +begin
- + 380 +
+ +return regexp_replace(a_item,a_prefix||a_connector);
- +
+ +end;
- +
+ +- +
+ +function get_hash(a_data raw, a_hash_type binary_integer := dbms_crypto.hash_sh1) return t_hash is
- +
+ +begin
- + 390 +
+ +return dbms_crypto.hash(a_data, a_hash_type);
- +
+ +end;
- +
+ +- +
+ +function get_hash(a_data clob, a_hash_type binary_integer := dbms_crypto.hash_sh1) return t_hash is
- +
+ +begin
- + 48 +
+ +return dbms_crypto.hash(a_data, a_hash_type);
- +
+ +end;
- +
+ +- +
+ +function qualified_sql_name(a_name varchar2) return varchar2 is
- +
+ +begin
- + 1580 +
+ +return
- + 1 +
+ +case
- + 1 +
+ +when a_name is not null
- +
+ +then sys.dbms_assert.qualified_sql_name(a_name)
- +
+ +end;
- +
+ +end;
- +
+ +- +
+end ut_utils;
+UT3.UT_COMPOUND_DATA_HELPER
99.09 % lines covered
220 relevant lines. 218 lines covered (including 1 lines partially covered ) and 2 lines missed+ +
- +
+ +package body ut_compound_data_helper is
- +
+ +/*
- +
+ +utPLSQL - Version 3
- +
+ +Copyright 2016 - 2019 utPLSQL Project
- +
+ +- +
+ +Licensed under the Apache License, Version 2.0 (the "License"):
- +
+ +you may not use this file except in compliance with the License.
- +
+ +You may obtain a copy of the License at
- +
+ +- +
+ +http://www.apache.org/licenses/LICENSE-2.0
- +
+ +- +
+ +Unless required by applicable law or agreed to in writing, software
- +
+ +distributed under the License is distributed on an "AS IS" BASIS,
- +
+ +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
+ +See the License for the specific language governing permissions and
- +
+ +limitations under the License.
- +
+ +*/
- +
+ +- +
+ +g_diff_count integer;
- +
+ +type t_type_name_map is table of varchar2(128) index by binary_integer;
- +
+ +type t_types_no_length is table of varchar2(128) index by varchar2(128);
- +
+ +g_type_name_map t_type_name_map;
- +
+ +g_anytype_name_map t_type_name_map;
- +
+ +g_type_no_length_map t_types_no_length;
- +
+ +- + 1 +
+ +g_compare_sql_template varchar2(4000) :=
- +
+ +q'[
- +
+ +with exp as (
- +
+ +select
- +
+ +ucd.*,
- +
+ +{:duplicate_number:} dup_no
- +
+ +from (
- +
+ +select
- +
+ +ucd.item_data
- +
+ +,x.data_id data_id
- +
+ +,position + x.item_no item_no
- +
+ +{:columns:}
- +
+ +from ut_compound_data_tmp x,
- +
+ +xmltable('/ROWSET/ROW' passing x.item_data columns
- +
+ +item_data xmltype path '*'
- +
+ +,position for ordinality
- +
+ +{:xml_to_columns:} ) ucd
- +
+ +where data_id = :exp_guid
- +
+ +) ucd
- +
+ +)
- +
+ +, act as (
- +
+ +select
- +
+ +ucd.*,
- +
+ +{:duplicate_number:} dup_no
- +
+ +from (
- +
+ +select
- +
+ +ucd.item_data
- +
+ +,x.data_id data_id
- +
+ +,position + x.item_no item_no
- +
+ +{:columns:}
- +
+ +from ut_compound_data_tmp x,
- +
+ +xmltable('/ROWSET/ROW' passing x.item_data columns
- +
+ +item_data xmltype path '*'
- +
+ +,position for ordinality
- +
+ +{:xml_to_columns:} ) ucd
- +
+ +where data_id = :act_guid
- +
+ +) ucd
- +
+ +)
- +
+ +select
- +
+ +a.item_data as act_item_data,
- +
+ +a.data_id act_data_id,
- +
+ +e.item_data as exp_item_data,
- +
+ +e.data_id exp_data_id,
- +
+ +{:item_no:} as item_no,
- +
+ +nvl(e.dup_no,a.dup_no) dup_no
- +
+ +from act a {:join_type:} exp e on ( {:join_condition:} )
- +
+ +where {:where_condition:}]';
- +
+ +- +
+ +function get_columns_diff(
- +
+ +a_expected ut_cursor_column_tab,
- +
+ +a_actual ut_cursor_column_tab,
- +
+ +a_order_enforced boolean := false
- +
+ +) return tt_column_diffs is
- +
+ +l_results tt_column_diffs;
- +
+ +begin
- + 158 +
+ +execute immediate q'[with
- +
+ +expected_cols as (
- +
+ +select display_path exp_column_name,column_position exp_col_pos,
- +
+ +replace(column_type_name,'VARCHAR2','CHAR') exp_col_type_compare, column_type_name exp_col_type
- +
+ +from table(:a_expected)
- +
+ +where parent_name is null and hierarchy_level = 1 and column_name is not null
- +
+ +),
- +
+ +actual_cols as (
- +
+ +select display_path act_column_name,column_position act_col_pos,
- +
+ +replace(column_type_name,'VARCHAR2','CHAR') act_col_type_compare, column_type_name act_col_type
- +
+ +from table(:a_actual)
- +
+ +where parent_name is null and hierarchy_level = 1 and column_name is not null
- +
+ +),
- +
+ +joined_cols as (
- +
+ +select e.*,a.*]'
- + 1 +
+ +|| case when a_order_enforced then ',
- +
+ +row_number() over(partition by case when a.act_col_pos + e.exp_col_pos is not null then 1 end order by a.act_col_pos) a_pos_nn,
- +
+ +row_number() over(partition by case when a.act_col_pos + e.exp_col_pos is not null then 1 end order by e.exp_col_pos) e_pos_nn'
- +
+ +else
- +
+ +null
- +
+ +end ||q'[
- +
+ +from expected_cols e
- +
+ +full outer join actual_cols a
- +
+ +on e.exp_column_name = a.act_column_name
- +
+ +)
- +
+ +select case
- +
+ +when exp_col_pos is null and act_col_pos is not null then '+'
- +
+ +when exp_col_pos is not null and act_col_pos is null then '-'
- +
+ +when exp_col_type_compare != act_col_type_compare then 't'
- +
+ +else 'p'
- +
+ +end as diff_type,
- +
+ +exp_column_name, exp_col_type, exp_col_pos,
- +
+ +act_column_name, act_col_type, act_col_pos
- +
+ +from joined_cols
- +
+ +--column is unexpected (extra) or missing
- +
+ +where act_col_pos is null or exp_col_pos is null
- +
+ +--column type is not matching (except CHAR/VARCHAR2)
- +
+ +or act_col_type_compare != exp_col_type_compare]'
- + 1 +
+ +|| case when a_order_enforced then q'[
- +
+ +--column position is not matching (both when excluded extra/missing columns as well as when they are included)
- +
+ +or (a_pos_nn != e_pos_nn and exp_col_pos != act_col_pos)]'
- +
+ +else
- +
+ +null
- +
+ +end ||q'[
- +
+ +order by exp_col_pos, act_col_pos]'
- +
+ +bulk collect into l_results using a_expected, a_actual;
- + 158 +
+ +return l_results;
- +
+ +end;
- +
+ +- +
+ +function generate_not_equal_stmt(
- +
+ +a_data_info ut_cursor_column, a_pk_table ut_varchar2_list
- +
+ +) return varchar2
- +
+ +is
- + 418 +
+ +l_pk_tab ut_varchar2_list := coalesce(a_pk_table,ut_varchar2_list());
- +
+ +l_index integer;
- +
+ +l_sql_stmt varchar2(32767);
- + 418 +
+ +l_exists boolean := false;
- +
+ +begin
- + 418 +
+ +l_index := l_pk_tab.first;
- + 418 +
+ +if l_pk_tab.count > 0 then
- + 129 +
+ +loop
- + 129 +
+ +if a_data_info.access_path = l_pk_tab(l_index) then
- + 39 +
+ +l_exists := true;
- +
+ +end if;
- + 129 +
+ +exit when l_index = l_pk_tab.count or (a_data_info.access_path = l_pk_tab(l_index));
- + 11 +
+ +l_index := a_pk_table.next(l_index);
- +
+ +end loop;
- +
+ +end if;
- + 418 +
+ +if not(l_exists) then
- + 379 +
+ +l_sql_stmt := ' (decode(a.'||a_data_info.transformed_name||','||' e.'||a_data_info.transformed_name||',1,0) = 0)';
- +
+ +end if;
- + 418 +
+ +return l_sql_stmt;
- +
+ +end;
- +
+ +- +
+ +function generate_join_by_stmt(
- +
+ +a_data_info ut_cursor_column, a_pk_table ut_varchar2_list
- +
+ +) return varchar2
- +
+ +is
- + 418 +
+ +l_pk_tab ut_varchar2_list := coalesce(a_pk_table,ut_varchar2_list());
- +
+ +l_index integer;
- +
+ +l_sql_stmt varchar2(32767);
- +
+ +begin
- + 418 +
+ +if l_pk_tab.count <> 0 then
- + 118 +
+ +l_index:= l_pk_tab.first;
- + 129 +
+ +loop
- + 129 +
+ +if l_pk_tab(l_index) in (a_data_info.access_path, a_data_info.parent_name) then
- +
+ +--When then table is nested and join is on whole table
- + 44 +
+ +l_sql_stmt := l_sql_stmt ||' a.'||a_data_info.transformed_name||q'[ = ]'||' e.'||a_data_info.transformed_name;
- +
+ +end if;
- + 129 +
+ +exit when (a_data_info.access_path = l_pk_tab(l_index)) or l_index = l_pk_tab.count;
- + 11 +
+ +l_index := l_pk_tab.next(l_index);
- +
+ +end loop;
- +
+ +end if;
- + 418 +
+ +return l_sql_stmt;
- +
+ +end;
- +
+ +- +
+ +function generate_equal_sql(a_col_name in varchar2) return varchar2 is
- +
+ +begin
- + 418 +
+ +return ' decode(a.'||a_col_name||','||' e.'||a_col_name||',1,0) = 1 ';
- +
+ +end;
- +
+ +- +
+ +function generate_partition_stmt(
- +
+ +a_data_info ut_cursor_column, a_pk_table in ut_varchar2_list, a_alias varchar2 := 'ucd.'
- +
+ +) return varchar2
- +
+ +is
- +
+ +l_index integer;
- +
+ +l_sql_stmt varchar2(32767);
- +
+ +begin
- + 418 +
+ +if a_pk_table is not empty then
- + 118 +
+ +l_index:= a_pk_table.first;
- + 129 +
+ +loop
- + 129 +
+ +if a_pk_table(l_index) in (a_data_info.access_path, a_data_info.parent_name) then
- +
+ +--When then table is nested and join is on whole table
- + 44 +
+ +l_sql_stmt := l_sql_stmt ||a_alias||a_data_info.transformed_name;
- +
+ +end if;
- + 129 +
+ +exit when (a_data_info.access_path = a_pk_table(l_index)) or l_index = a_pk_table.count;
- + 11 +
+ +l_index := a_pk_table.next(l_index);
- +
+ +end loop;
- +
+ +else
- + 300 +
+ +l_sql_stmt := a_alias||a_data_info.transformed_name;
- +
+ +end if;
- + 418 +
+ +return l_sql_stmt;
- +
+ +end;
- +
+ +- +
+ +function generate_select_stmt(a_data_info ut_cursor_column, a_alias varchar2 := 'ucd.')
- +
+ +return varchar2
- +
+ +is
- + 418 +
+ +l_alias varchar2(10) := a_alias;
- +
+ +l_col_syntax varchar2(4000);
- +
+ +begin
- + 418 +
+ +if a_data_info.is_sql_diffable = 0 then
- + 11 +
+ +l_col_syntax := 'ut_utils.get_hash('||l_alias||a_data_info.transformed_name||'.getClobVal()) as '||a_data_info.transformed_name ;
- + 407 +
+ +elsif a_data_info.is_sql_diffable = 1 and a_data_info.column_type = 'DATE' then
- + 4 +
+ +l_col_syntax := 'to_date('||l_alias||a_data_info.transformed_name||') as '|| a_data_info.transformed_name;
- + 403 +
+ +elsif a_data_info.is_sql_diffable = 1 and a_data_info.column_type in ('TIMESTAMP') then
- + 5 +
+ +l_col_syntax := 'to_timestamp('||l_alias||a_data_info.transformed_name||','''||ut_utils.gc_timestamp_format||''') as '|| a_data_info.transformed_name;
- + 398 +
+ +elsif a_data_info.is_sql_diffable = 1 and a_data_info.column_type in ('TIMESTAMP WITH TIME ZONE') then
- + 1 +
+ +l_col_syntax := 'to_timestamp_tz('||l_alias||a_data_info.transformed_name||','''||ut_utils.gc_timestamp_tz_format||''') as '|| a_data_info.transformed_name;
- + 397 +
+ +elsif a_data_info.is_sql_diffable = 1 and a_data_info.column_type in ('TIMESTAMP WITH LOCAL TIME ZONE') then
- + 1 +
+ +l_col_syntax := ' cast( to_timestamp_tz('||l_alias||a_data_info.transformed_name||','''||ut_utils.gc_timestamp_tz_format||''') AS TIMESTAMP WITH LOCAL TIME ZONE) as '|| a_data_info.transformed_name;
- +
+ +else
- + 396 +
+ +l_col_syntax := l_alias||a_data_info.transformed_name||' as '|| a_data_info.transformed_name;
- +
+ +end if;
- + 418 +
+ +return l_col_syntax;
- +
+ +end;
- +
+ +- +
+ +function generate_xmltab_stmt(a_data_info ut_cursor_column) return varchar2 is
- +
+ +l_col_type varchar2(4000);
- +
+ +begin
- + 418 +
+ +if a_data_info.is_sql_diffable = 0 then
- + 11 +
+ +l_col_type := 'XMLTYPE';
- + 407 +
+ +elsif a_data_info.is_sql_diffable = 1 and a_data_info.column_type in ('DATE','TIMESTAMP','TIMESTAMP WITH TIME ZONE',
- + 1 +
+ +'TIMESTAMP WITH LOCAL TIME ZONE') then
- + 11 +
+ +l_col_type := 'VARCHAR2(50)';
- + 396 +
+ +elsif a_data_info.is_sql_diffable = 1 and type_no_length(a_data_info.column_type) then
- + 9 +
+ +l_col_type := a_data_info.column_type;
- + 387 +
+ +elsif a_data_info.is_sql_diffable = 1 and a_data_info.column_type in ('VARCHAR2','CHAR') then
- + 211 +
+ +l_col_type := 'VARCHAR2('||greatest(a_data_info.column_len,4000)||')';
- + 176 +
+ +elsif a_data_info.is_sql_diffable = 1 and a_data_info.column_type in ('NUMBER') then
- +
+ +--We cannot use a precision and scale as dbms_sql.describe_columns3 return precision 0 for dual table
- +
+ +-- there is also no need for that as we not process data but only read and compare as they are stored
- + 169 +
+ +l_col_type := a_data_info.column_type;
- +
+ +else
- + 7 +
+ +l_col_type := a_data_info.column_type
- + 1 +
+ +||case when a_data_info.column_len is not null
- +
+ +then '('||a_data_info.column_len||')'
- +
+ +else null
- +
+ +end;
- +
+ +end if;
- + 418 +
+ +return a_data_info.transformed_name||' '||l_col_type||q'[ PATH ']'||a_data_info.access_path||q'[']';
- +
+ +end;
- +
+ +- +
+ +procedure gen_sql_pieces_out_of_cursor(
- +
+ +a_data_info ut_cursor_column_tab,
- +
+ +a_pk_table ut_varchar2_list,
- +
+ +a_unordered boolean,
- +
+ +a_xml_stmt out nocopy clob,
- +
+ +a_select_stmt out nocopy clob,
- +
+ +a_partition_stmt out nocopy clob,
- +
+ +a_join_by_stmt out nocopy clob,
- +
+ +a_not_equal_stmt out nocopy clob
- +
+ +) is
- +
+ +l_partition_tmp clob;
- + 173 +
+ +l_xmltab_list ut_varchar2_list := ut_varchar2_list();
- + 173 +
+ +l_select_list ut_varchar2_list := ut_varchar2_list();
- + 173 +
+ +l_partition_list ut_varchar2_list := ut_varchar2_list();
- + 173 +
+ +l_equal_list ut_varchar2_list := ut_varchar2_list();
- + 173 +
+ +l_join_by_list ut_varchar2_list := ut_varchar2_list();
- + 173 +
+ +l_not_equal_list ut_varchar2_list := ut_varchar2_list();
- +
+ +- +
+ +procedure add_element_to_list(a_list in out ut_varchar2_list, a_list_element in varchar2)
- +
+ +is
- +
+ +begin
- + 2508 +
+ +if a_list_element is not null then
- + 2021 +
+ +a_list.extend;
- + 2021 +
+ +a_list(a_list.last) := a_list_element;
- +
+ +end if;
- +
+ +end;
- +
+ +- +
+ +begin
- + 173 +
+ +if a_data_info is not empty then
- + 627 +
+ +for i in 1..a_data_info.count loop
- + 464 +
+ +if a_data_info(i).has_nested_col = 0 then
- +
+ +--Get XMLTABLE column list
- + 418 +
+ +add_element_to_list(l_xmltab_list,generate_xmltab_stmt(a_data_info(i)));
- +
+ +--Get Select statment list of columns
- + 418 +
+ +add_element_to_list(l_select_list, generate_select_stmt(a_data_info(i)));
- +
+ +--Get columns by which we partition
- + 418 +
+ +add_element_to_list(l_partition_list,generate_partition_stmt(a_data_info(i), a_pk_table));
- +
+ +--Get equal statement
- + 418 +
+ +add_element_to_list(l_equal_list,generate_equal_sql(a_data_info(i).transformed_name));
- +
+ +--Generate join by stmt
- + 418 +
+ +add_element_to_list(l_join_by_list,generate_join_by_stmt(a_data_info(i), a_pk_table));
- +
+ +--Generate not equal stmt
- + 418 +
+ +add_element_to_list(l_not_equal_list,generate_not_equal_stmt(a_data_info(i), a_pk_table));
- +
+ +end if;
- +
+ +end loop;
- +
+ +- + 163 +
+ +a_xml_stmt := nullif(','||ut_utils.table_to_clob(l_xmltab_list, ' , '),',');
- + 163 +
+ +a_select_stmt := nullif(','||ut_utils.table_to_clob(l_select_list, ' , '),',');
- + 163 +
+ +l_partition_tmp := ut_utils.table_to_clob(l_partition_list, ' , ');
- + 163 +
+ +ut_utils.append_to_clob(a_partition_stmt,' row_number() over (partition by '||l_partition_tmp||' order by '||l_partition_tmp||' ) ');
- +
+ +- + 163 +
+ +if a_pk_table.count > 0 then
- +
+ +-- If key defined do the join or these and where on diffrences
- + 34 +
+ +a_join_by_stmt := ut_utils.table_to_clob(l_join_by_list, ' and ');
- + 129 +
+ +elsif a_unordered then
- +
+ +-- If no key defined do the join on all columns
- + 27 +
+ +a_join_by_stmt := ' e.dup_no = a.dup_no and '||ut_utils.table_to_clob(l_equal_list, ' and ');
- +
+ +else
- +
+ +-- Else join on rownumber
- + 102 +
+ +a_join_by_stmt := 'a.item_no = e.item_no ';
- +
+ +end if;
- + 163 +
+ +a_not_equal_stmt := ut_utils.table_to_clob(l_not_equal_list, ' or ');
- +
+ +else
- +
+ +--Partition by piece when no data
- + 10 +
+ +ut_utils.append_to_clob(a_partition_stmt,' 1 ');
- + 10 +
+ +a_join_by_stmt := 'a.item_no = e.item_no ';
- +
+ +end if;
- +
+ +end;
- +
+ +- +
+ +function gen_compare_sql(
- +
+ +a_other ut_data_value_refcursor,
- +
+ +a_join_by_list ut_varchar2_list,
- +
+ +a_unordered boolean,
- +
+ +a_inclusion_type boolean,
- +
+ +a_is_negated boolean
- +
+ +) return clob is
- +
+ +l_compare_sql clob;
- +
+ +l_xmltable_stmt clob;
- +
+ +l_select_stmt clob;
- +
+ +l_partition_stmt clob;
- +
+ +l_join_on_stmt clob;
- +
+ +l_not_equal_stmt clob;
- +
+ +l_where_stmt clob;
- +
+ +l_join_by_list ut_varchar2_list;
- +
+ +- +
+ +function get_join_type(a_inclusion_compare in boolean,a_negated in boolean) return varchar2 is
- +
+ +begin
- + 173 +
+ +return
- + 1 +
+ +case
- + 1 +
+ +when a_inclusion_compare and not(a_negated) then ' right outer join '
- + 1 +
+ +when a_inclusion_compare and a_negated then ' inner join '
- +
+ +else ' full outer join '
- +
+ +end;
- +
+ +end;
- +
+ +- +
+ +function get_item_no(a_unordered boolean) return varchar2 is
- +
+ +begin
- + 173 +
+ +return
- + 1 +
+ +case
- + 1 +
+ +when a_unordered then 'row_number() over ( order by nvl(e.item_no,a.item_no))'
- +
+ +else 'nvl(e.item_no,a.item_no) '
- +
+ +end;
- +
+ +end;
- +
+ +- +
+ +begin
- +
+ +/**
- +
+ +* We already estabilished cursor equality so now we add anydata root if we compare anydata
- +
+ +* to join by.
- +
+ +*/
- + 173 +
+ +l_join_by_list :=
- + 1 +
+ +case
- + 1 +
+ +when a_other is of (ut_data_value_anydata) then ut_utils.add_prefix(a_join_by_list, a_other.cursor_details.get_root)
- +
+ +else a_join_by_list
- +
+ +end;
- +
+ +- + 173 +
+ +dbms_lob.createtemporary(l_compare_sql, true);
- +
+ +--Initiate a SQL template with placeholders
- + 173 +
+ +ut_utils.append_to_clob(l_compare_sql, g_compare_sql_template);
- +
+ +--Generate a pieceso of dynamic SQL that will substitute placeholders
- + 173 +
+ +gen_sql_pieces_out_of_cursor(
- +
+ +a_other.cursor_details.cursor_columns_info, l_join_by_list, a_unordered,
- +
+ +l_xmltable_stmt, l_select_stmt, l_partition_stmt, l_join_on_stmt,
- +
+ +l_not_equal_stmt
- +
+ +);
- +
+ +- + 173 +
+ +l_compare_sql := replace(l_compare_sql,'{:duplicate_number:}',l_partition_stmt);
- + 173 +
+ +l_compare_sql := replace(l_compare_sql,'{:columns:}',l_select_stmt);
- + 173 +
+ +l_compare_sql := replace(l_compare_sql,'{:xml_to_columns:}',l_xmltable_stmt);
- + 173 +
+ +l_compare_sql := replace(l_compare_sql,'{:item_no:}',get_item_no(a_unordered));
- + 173 +
+ +l_compare_sql := replace(l_compare_sql,'{:join_type:}',get_join_type(a_inclusion_type,a_is_negated));
- + 173 +
+ +l_compare_sql := replace(l_compare_sql,'{:join_condition:}',l_join_on_stmt);
- +
+ +- + 173 +
+ +if l_not_equal_stmt is not null and ((l_join_by_list.count > 0 and not a_is_negated) or (not a_unordered)) then
- + 130 +
+ +ut_utils.append_to_clob(l_where_stmt,' ( '||l_not_equal_stmt||' ) or ');
- +
+ +end if;
- +
+ +--If its inclusion we expect a actual set to fully match and have no extra elements over expected
- + 173 +
+ +if a_inclusion_type then
- + 20 +
+ +ut_utils.append_to_clob(l_where_stmt,case when a_is_negated then ' 1 = 1 ' else ' ( a.data_id is null ) ' end);
- +
+ +else
- + 153 +
+ +ut_utils.append_to_clob(l_where_stmt,' (a.data_id is null or e.data_id is null) ');
- +
+ +end if;
- +
+ +- + 173 +
+ +l_compare_sql := replace(l_compare_sql,'{:where_condition:}',l_where_stmt);
- + 173 +
+ +return l_compare_sql;
- +
+ +end;
- +
+ +- +
+ +function get_column_extract_path(a_cursor_info ut_cursor_column_tab) return ut_varchar2_list is
- + 110 +
+ +l_column_list ut_varchar2_list := ut_varchar2_list();
- +
+ +begin
- + 394 +
+ +for i in 1..a_cursor_info.count loop
- + 284 +
+ +l_column_list.extend;
- + 284 +
+ +l_column_list(l_column_list.last) := a_cursor_info(i).access_path;
- +
+ +end loop;
- + 110 +
+ +return l_column_list;
- +
+ +end;
- +
+ +- +
+ +function get_rows_diff_by_sql(
- +
+ +a_act_cursor_info ut_cursor_column_tab, a_exp_cursor_info ut_cursor_column_tab,
- +
+ +a_expected_dataset_guid raw, a_actual_dataset_guid raw, a_diff_id raw,
- +
+ +a_join_by_list ut_varchar2_list, a_unordered boolean, a_enforce_column_order boolean := false,
- +
+ +a_extract_path varchar2
- +
+ +) return tt_row_diffs is
- + 55 +
+ +l_act_extract_xpath varchar2(32767):= ut_utils.to_xpath(get_column_extract_path(a_act_cursor_info));
- + 55 +
+ +l_exp_extract_xpath varchar2(32767):= ut_utils.to_xpath(get_column_extract_path(a_exp_cursor_info));
- + 55 +
+ +l_join_xpath varchar2(32767) := ut_utils.to_xpath(a_join_by_list);
- +
+ +l_results tt_row_diffs;
- +
+ +l_sql varchar2(32767);
- +
+ +begin
- + 55 +
+ +l_sql := q'[
- +
+ +with exp as (
- +
+ +select
- +
+ +exp_item_data, exp_data_id, item_no rn, rownum col_no, pk_value,
- +
+ +s.column_value col, s.column_value.getRootElement() col_name,
- +
+ +nvl(s.column_value.getclobval(),empty_clob()) col_val
- +
+ +from (
- +
+ +select
- +
+ +exp_data_id, extract( ucd.exp_item_data, :column_path ) exp_item_data, item_no,
- +
+ +replace( extract( ucd.exp_item_data, :join_by ).getclobval(), chr(10) ) pk_value
- +
+ +from ut_compound_data_diff_tmp ucd
- +
+ +where diff_id = :diff_id
- +
+ +and ucd.exp_data_id = :self_guid
- +
+ +) i,
- +
+ +table( xmlsequence( extract(i.exp_item_data,:extract_path) ) ) s
- +
+ +),
- +
+ +act as (
- +
+ +select
- +
+ +act_item_data, act_data_id, item_no rn, rownum col_no, pk_value,
- +
+ +s.column_value col, s.column_value.getRootElement() col_name,
- +
+ +nvl(s.column_value.getclobval(),empty_clob()) col_val
- +
+ +from (
- +
+ +select
- +
+ +act_data_id, extract( ucd.act_item_data, :column_path ) act_item_data, item_no,
- +
+ +replace( extract( ucd.act_item_data, :join_by ).getclobval(), chr(10) ) pk_value
- +
+ +from ut_compound_data_diff_tmp ucd
- +
+ +where diff_id = :diff_id
- +
+ +and ucd.act_data_id = :other_guid
- +
+ +) i,
- +
+ +table( xmlsequence( extract(i.act_item_data,:extract_path) ) ) s
- +
+ +)
- +
+ +select rn, diff_type, diffed_row, pk_value pk_value
- +
+ +from (
- +
+ +select rn, diff_type, diffed_row, pk_value,
- +
+ +case when diff_type = 'Actual:' then 1 else 2 end rnk,
- +
+ +1 final_order,
- +
+ +col_name
- +
+ +from ( ]'
- + 1 +
+ +|| case when a_unordered then q'[
- +
+ +select rn, diff_type, xmlserialize(content data_item no indent) diffed_row, pk_value, col_name
- +
+ +from (
- +
+ +select nvl(exp.rn, act.rn) rn,
- +
+ +nvl(exp.pk_value, act.pk_value) pk_value,
- +
+ +exp.col exp_item,
- +
+ +act.col act_item,
- +
+ +nvl(exp.col_name,act.col_name) col_name
- +
+ +from exp
- +
+ +join act
- +
+ +on exp.rn = act.rn and exp.col_name = act.col_name
- +
+ +where dbms_lob.compare(exp.col_val, act.col_val) != 0
- +
+ +)
- +
+ +unpivot ( data_item for diff_type in (exp_item as 'Expected:', act_item as 'Actual:') ) ]'
- +
+ +else q'[
- +
+ +select rn, diff_type, xmlserialize(content data_item no indent) diffed_row, null pk_value, col_name
- +
+ +from (
- +
+ +select nvl(exp.rn, act.rn) rn,
- +
+ +xmlagg(exp.col order by exp.col_no) exp_item,
- +
+ +xmlagg(act.col order by act.col_no) act_item,
- +
+ +max(nvl(exp.col_name,act.col_name)) col_name
- +
+ +from exp exp
- +
+ +join act act
- +
+ +on exp.rn = act.rn and exp.col_name = act.col_name
- +
+ +where dbms_lob.compare(exp.col_val, act.col_val) != 0
- +
+ +group by (exp.rn, act.rn)
- +
+ +)
- +
+ +unpivot ( data_item for diff_type in (exp_item as 'Expected:', act_item as 'Actual:') ) ]'
- +
+ +end ||q'[
- +
+ +)
- +
+ +union all
- +
+ +select
- +
+ +item_no as rn,
- +
+ +case when exp_data_id is null then 'Extra:' else 'Missing:' end as diff_type,
- +
+ +xmlserialize(
- +
+ +content (
- +
+ +extract( (case when exp_data_id is null then act_item_data else exp_item_data end),'/*/*')
- +
+ +) no indent
- +
+ +) diffed_row,
- +
+ +nvl2(
- +
+ +:join_by,
- +
+ +replace(
- +
+ +extract( case when exp_data_id is null then act_item_data else exp_item_data end, :join_by ).getclobval(),
- +
+ +chr(10)
- +
+ +),
- +
+ +null
- +
+ +) pk_value,
- +
+ +case when exp_data_id is null then 1 else 2 end rnk,
- +
+ +2 final_order,
- +
+ +null col_name
- +
+ +from ut_compound_data_diff_tmp i
- +
+ +where diff_id = :diff_id
- +
+ +and act_data_id is null or exp_data_id is null
- +
+ +)
- +
+ +order by final_order,]'
- + 5/6 + 1 +
+ +||case when a_enforce_column_order or (not(a_enforce_column_order) and not(a_unordered)) then
- +
+ +q'[
- +
+ +case when final_order = 1 then rn else rnk end,
- +
+ +case when final_order = 1 then rnk else rn end
- +
+ +]'
- + 1 +
+ +when a_unordered then
- +
+ +q'[
- +
+ +case when final_order = 1 then col_name else to_char(rnk) end,
- +
+ +case when final_order = 1 then to_char(rn) else col_name end,
- +
+ +case when final_order = 1 then to_char(rnk) else col_name end
- +
+ +]'
- +
+ +else
- +
+ +null
- +
+ +end;
- + 55 +
+ +execute immediate l_sql
- +
+ +bulk collect into l_results
- +
+ +using l_exp_extract_xpath, l_join_xpath, a_diff_id, a_expected_dataset_guid,a_extract_path,
- +
+ +l_act_extract_xpath, l_join_xpath, a_diff_id, a_actual_dataset_guid,a_extract_path,
- +
+ +l_join_xpath, l_join_xpath, a_diff_id;
- + 55 +
+ +return l_results;
- +
+ +end;
- +
+ +- +
+ +function get_fixed_size_hash(a_string varchar2, a_base integer :=0,a_size integer := 9999999) return number is
- +
+ +begin
- + 383 +
+ +return dbms_utility.get_hash_value(a_string,a_base,a_size);
- +
+ +end;
- +
+ +- +
+ +procedure insert_diffs_result(a_diff_tab t_diff_tab, a_diff_id raw) is
- +
+ +begin
- + 173 +
+ +forall idx in 1..a_diff_tab.count save exceptions
- +
+ +insert into ut_compound_data_diff_tmp
- +
+ +( diff_id, act_item_data, act_data_id, exp_item_data, exp_data_id, item_no, duplicate_no )
- +
+ +values
- +
+ +(a_diff_id,
- +
+ +xmlelement( name "ROW", a_diff_tab(idx).act_item_data), a_diff_tab(idx).act_data_id,
- +
+ +xmlelement( name "ROW", a_diff_tab(idx).exp_item_data), a_diff_tab(idx).exp_data_id,
- +
+ +a_diff_tab(idx).item_no, a_diff_tab(idx).dup_no);
- +
+ +exception
- +
+ +when ut_utils.ex_failure_for_all then
- +
+ +raise_application_error(ut_utils.gc_dml_for_all,'Failure to insert a diff tmp data.');
- +
+ +end;
- +
+ +- +
+ +procedure set_rows_diff(a_rows_diff integer) is
- +
+ +begin
- + 173 +
+ +g_diff_count := a_rows_diff;
- +
+ +end;
- +
+ +- +
+ +procedure cleanup_diff is
- +
+ +begin
- + 570 +
+ +g_diff_count := 0;
- +
+ +end;
- +
+ +- +
+ +function get_rows_diff_count return integer is
- +
+ +begin
- + 161 +
+ +return g_diff_count;
- +
+ +end;
- +
+ +- +
+ +function is_sql_compare_allowed(a_type_name varchar2)
- +
+ +return boolean is
- +
+ +l_assert boolean;
- +
+ +begin
- +
+ +--clob/blob/xmltype/object/nestedcursor/nestedtable
- + 1107 +
+ +if a_type_name IN (g_type_name_map(dbms_sql.blob_type),
- + 1 +
+ +g_type_name_map(dbms_sql.clob_type),
- + 1 +
+ +g_type_name_map(dbms_sql.long_type),
- + 1 +
+ +g_type_name_map(dbms_sql.long_raw_type),
- + 1 +
+ +g_type_name_map(dbms_sql.bfile_type),
- + 1 +
+ +g_anytype_name_map(dbms_types.typecode_namedcollection))
- +
+ +then
- + 18 +
+ +l_assert := false;
- +
+ +else
- + 1089 +
+ +l_assert := true;
- +
+ +end if;
- + 1107 +
+ +return l_assert;
- +
+ +end;
- +
+ +- +
+ +function get_column_type_desc(a_type_code in integer, a_dbms_sql_desc in boolean)
- +
+ +return varchar2 is
- +
+ +begin
- + 1226 +
+ +return
- + 1 +
+ +case
- + 1 +
+ +when a_dbms_sql_desc then g_type_name_map(a_type_code)
- +
+ +else g_anytype_name_map(a_type_code)
- +
+ +end;
- +
+ +end;
- +
+ +- +
+ +function get_compare_cursor(a_diff_cursor_text in clob,a_self_id raw, a_other_id raw) return sys_refcursor is
- +
+ +l_diff_cursor sys_refcursor;
- +
+ +begin
- + 173 +
+ +open l_diff_cursor for a_diff_cursor_text using a_self_id, a_other_id;
- + 173 +
+ +return l_diff_cursor;
- +
+ +end;
- +
+ +- +
+ +function create_err_cursor_msg(a_error_stack varchar2) return varchar2 is
- +
+ +begin
- + 4 +
+ +return 'SQL exception thrown when fetching data from cursor:'||
- +
+ +ut_utils.remove_error_from_stack(sqlerrm,ut_utils.gc_xml_processing)||chr(10)||
- +
+ +ut_expectation_processor.who_called_expectation(a_error_stack)||chr(10)||
- +
+ +'Check the query and data for errors.';
- +
+ +end;
- +
+ +- +
+ +procedure save_cursor_data_for_diff(a_data_id raw, a_set_id integer, a_xml xmltype) is
- +
+ +begin
- + 363 +
+ +insert into ut_compound_data_tmp (data_id, item_no, item_data) values (a_data_id, a_set_id, a_xml);
- +
+ +end;
- +
+ +- +
+ +function get_row_data_as_xml(a_data_id raw, a_max_rows integer) return ut_utils.t_clob_tab is
- +
+ +l_results ut_utils.t_clob_tab;
- +
+ +begin
- + 50 +
+ +select xmlserialize( content ucd.item_data no indent)
- +
+ +bulk collect into l_results
- +
+ +from ut_compound_data_tmp tmp
- +
+ +,xmltable ( '/ROWSET' passing tmp.item_data
- +
+ +columns item_data xmltype PATH '*'
- +
+ +) ucd
- +
+ +where tmp.data_id = a_data_id
- +
+ +and rownum <= a_max_rows;
- +
+ +- + 50 +
+ +return l_results;
- +
+ +end;
- +
+ +- +
+ +function type_no_length ( a_type_name varchar2) return boolean is
- +
+ +begin
- + 396 +
+ +return case
- + 1 +
+ +when g_type_no_length_map.exists(a_type_name) then
- +
+ +true
- +
+ +else
- +
+ +false
- +
+ +end;
- +
+ +end;
- +
+ +- +
+ +function compare_json_data(a_act_json_data ut_json_leaf_tab,a_exp_json_data ut_json_leaf_tab) return tt_json_diff_tab is
- + 10 +
+ +l_result_diff tt_json_diff_tab := tt_json_diff_tab();
- +
+ +begin
- +
+ +- + 10 +
+ +with
- +
+ +differences as (
- +
+ +select case
- +
+ +when (a.element_name is null or e.element_name is null) then gc_json_missing
- +
+ +when a.json_type != e.json_type then gc_json_type
- +
+ +when (decode(a.element_value,e.element_value,1,0) = 0) then gc_json_notequal
- +
+ +else gc_json_unknown
- +
+ +end as difference_type,
- +
+ +case
- +
+ +when (a.element_name is null or e.element_name is null) then 1
- +
+ +when a.json_type != e.json_type then 2
- +
+ +when (decode(a.element_value,e.element_value,1,0) = 0) then 3
- +
+ +else 4
- +
+ +end as order_by_type,
- +
+ +a.element_name as act_element_name,
- +
+ +a.element_value as act_element_value,
- +
+ +a.hierarchy_level as act_hierarchy_level,
- +
+ +a.index_position as act_index_position,
- +
+ +a.json_type as act_json_type,
- +
+ +a.access_path as act_access_path,
- +
+ +a.parent_name as act_par_name,
- +
+ +a.parent_path as act_parent_path,
- +
+ +e.element_name as exp_element_name,
- +
+ +e.element_value as exp_element_value,
- +
+ +e.hierarchy_level as exp_hierarchy_level,
- +
+ +e.index_position as exp_index_position,
- +
+ +e.json_type as exp_json_type,
- +
+ +e.access_path as exp_access_path,
- +
+ +e.parent_name as exp_par_name,
- +
+ +e.parent_path as exp_parent_path
- +
+ +from table(a_act_json_data) a
- +
+ +full outer join table(a_exp_json_data) e
- +
+ +on decode(a.parent_name,e.parent_name,1,0)= 1
- +
+ +and decode(a.parent_path,e.parent_path,1,0)= 1
- +
+ +and (
- +
+ +case when a.parent_type = 'object' or e.parent_type = 'object' then
- +
+ +decode(a.element_name,e.element_name,1,0)
- +
+ +else 1 end = 1
- +
+ +)
- +
+ +and (
- +
+ +case when a.parent_type = 'array' or e.parent_type = 'array' then
- +
+ +decode(a.index_position,e.index_position,1,0)
- +
+ +else 1 end = 1
- +
+ +)
- +
+ +and a.hierarchy_level = e.hierarchy_level
- +
+ +where (a.element_name is null or e.element_name is null)
- +
+ +or (a.json_type != e.json_type)
- +
+ +or (decode(a.element_value,e.element_value,1,0) = 0)
- +
+ +)
- +
+ +select difference_type,
- +
+ +act_element_name, act_element_value, act_json_type, act_access_path, act_parent_path,
- +
+ +exp_element_name, exp_element_value, exp_json_type, exp_access_path, exp_parent_path
- +
+ +bulk collect into l_result_diff
- +
+ +from differences a
- +
+ +where not exists (
- +
+ +select 1 from differences b
- +
+ +where (a.act_par_name = b.act_element_name and a.act_hierarchy_level - 1 = b.act_hierarchy_level)
- +
+ +or (a.exp_par_name = b.exp_element_name and a.exp_hierarchy_level - 1 = b.exp_hierarchy_level)
- +
+ +and a.difference_type = gc_json_missing and b.difference_type = gc_json_missing
- +
+ +)
- +
+ +order by order_by_type,
- +
+ +nvl(act_hierarchy_level,exp_hierarchy_level),
- +
+ +nvl(act_index_position,exp_index_position) nulls first,
- +
+ +nvl(act_element_name,exp_element_name) ;
- + 10 +
+ +return l_result_diff;
- +
+ +end;
- +
+ +- +
+ +function insert_json_diffs(a_diff_id raw, a_act_json_data ut_json_leaf_tab, a_exp_json_data ut_json_leaf_tab) return integer is
- + 10 +
+ +l_diffs tt_json_diff_tab := compare_json_data(a_act_json_data,a_exp_json_data);
- +
+ +begin
- + 10 +
+ +forall i in 1..l_diffs.count
- + 1 +
+ +insert into ut_json_data_diff_tmp (
- +
+ +diff_id, difference_type,
- +
+ +act_element_name, act_element_value, act_json_type, act_access_path, act_parent_path,
- +
+ +exp_element_name, exp_element_value, exp_json_type, exp_access_path, exp_parent_path
- +
+ +)
- +
+ +values (
- +
+ +a_diff_id,l_diffs(i).difference_type,
- +
+ +l_diffs(i).act_element_name,l_diffs(i).act_element_value,l_diffs(i).act_json_type, l_diffs(i).act_access_path, l_diffs(i).act_parent_path,
- +
+ +l_diffs(i).exp_element_name,l_diffs(i).exp_element_value,l_diffs(i).exp_json_type,l_diffs(i).exp_access_path, l_diffs(i).exp_parent_path
- +
+ +);
- +
+ +- + 10 +
+ +return l_diffs.count;
- +
+ +end;
- +
+ +- +
+ +function get_json_diffs_type(a_diff_id raw) return tt_json_diff_type_tab is
- + 10 +
+ +l_diffs_summary tt_json_diff_type_tab := tt_json_diff_type_tab();
- +
+ +begin
- + 10 +
+ +select d.difference_type,count(1)
- +
+ +bulk collect into l_diffs_summary
- +
+ +from ut_json_data_diff_tmp d
- +
+ +where diff_id = a_diff_id
- +
+ +group by d.difference_type;
- +
+ +- + 10 +
+ +return l_diffs_summary;
- +
+ +end;
- +
+ +- +
+ +function get_json_diffs_tmp(a_diff_id raw) return tt_json_diff_tab is
- +
+ +l_diffs tt_json_diff_tab;
- +
+ +begin
- + 10 +
+ +select difference_type,
- +
+ +act_element_name, act_element_value, act_json_type, act_access_path, act_parent_path,
- +
+ +exp_element_name, exp_element_value, exp_json_type, exp_access_path, exp_parent_path
- +
+ +bulk collect into l_diffs
- +
+ +from ut_json_data_diff_tmp
- +
+ +where diff_id = a_diff_id;
- +
+ +- + 10 +
+ +return l_diffs;
- +
+ +end;
- +
+ +- +
+ +begin
- + 2 +
+ +g_anytype_name_map(dbms_types.typecode_date) := 'DATE';
- + 1 +
+ +g_anytype_name_map(dbms_types.typecode_number) := 'NUMBER';
- + 1 +
+ +g_anytype_name_map(3 /*INTEGER in object type*/) := 'NUMBER';
- + 1 +
+ +g_anytype_name_map(dbms_types.typecode_raw) := 'RAW';
- + 1 +
+ +g_anytype_name_map(dbms_types.typecode_char) := 'CHAR';
- + 1 +
+ +g_anytype_name_map(dbms_types.typecode_varchar2) := 'VARCHAR2';
- + 1 +
+ +g_anytype_name_map(dbms_types.typecode_varchar) := 'VARCHAR';
- + 1 +
+ +g_anytype_name_map(dbms_types.typecode_blob) := 'BLOB';
- + 1 +
+ +g_anytype_name_map(dbms_types.typecode_bfile) := 'BFILE';
- + 1 +
+ +g_anytype_name_map(dbms_types.typecode_clob) := 'CLOB';
- + 1 +
+ +g_anytype_name_map(dbms_types.typecode_timestamp) := 'TIMESTAMP';
- + 1 +
+ +g_anytype_name_map(dbms_types.typecode_timestamp_tz) := 'TIMESTAMP WITH TIME ZONE';
- + 1 +
+ +g_anytype_name_map(dbms_types.typecode_timestamp_ltz) := 'TIMESTAMP WITH LOCAL TIME ZONE';
- + 1 +
+ +g_anytype_name_map(dbms_types.typecode_interval_ym) := 'INTERVAL YEAR TO MONTH';
- + 1 +
+ +g_anytype_name_map(dbms_types.typecode_interval_ds) := 'INTERVAL DAY TO SECOND';
- + 1 +
+ +g_anytype_name_map(dbms_types.typecode_bfloat) := 'BINARY_FLOAT';
- + 1 +
+ +g_anytype_name_map(dbms_types.typecode_bdouble) := 'BINARY_DOUBLE';
- + 1 +
+ +g_anytype_name_map(dbms_types.typecode_urowid) := 'UROWID';
- + 1 +
+ +g_anytype_name_map(dbms_types.typecode_varray) := 'VARRRAY';
- + 1 +
+ +g_anytype_name_map(dbms_types.typecode_table) := 'TABLE';
- + 1 +
+ +g_anytype_name_map(dbms_types.typecode_namedcollection) := 'NAMEDCOLLECTION';
- + 1 +
+ +g_anytype_name_map(dbms_types.typecode_object) := 'OBJECT';
- +
+ +- + 2 +
+ +g_type_name_map( dbms_sql.binary_bouble_type ) := 'BINARY_DOUBLE';
- + 1 +
+ +g_type_name_map( dbms_sql.bfile_type ) := 'BFILE';
- + 1 +
+ +g_type_name_map( dbms_sql.binary_float_type ) := 'BINARY_FLOAT';
- + 1 +
+ +g_type_name_map( dbms_sql.blob_type ) := 'BLOB';
- + 1 +
+ +g_type_name_map( dbms_sql.long_raw_type ) := 'LONG RAW';
- + 1 +
+ +g_type_name_map( dbms_sql.char_type ) := 'CHAR';
- + 1 +
+ +g_type_name_map( dbms_sql.clob_type ) := 'CLOB';
- + 1 +
+ +g_type_name_map( dbms_sql.long_type ) := 'LONG';
- + 1 +
+ +g_type_name_map( dbms_sql.date_type ) := 'DATE';
- + 1 +
+ +g_type_name_map( dbms_sql.interval_day_to_second_type ) := 'INTERVAL DAY TO SECOND';
- + 1 +
+ +g_type_name_map( dbms_sql.interval_year_to_month_type ) := 'INTERVAL YEAR TO MONTH';
- + 1 +
+ +g_type_name_map( dbms_sql.raw_type ) := 'RAW';
- + 1 +
+ +g_type_name_map( dbms_sql.timestamp_type ) := 'TIMESTAMP';
- + 1 +
+ +g_type_name_map( dbms_sql.timestamp_with_tz_type ) := 'TIMESTAMP WITH TIME ZONE';
- + 1 +
+ +g_type_name_map( dbms_sql.timestamp_with_local_tz_type ) := 'TIMESTAMP WITH LOCAL TIME ZONE';
- + 1 +
+ +g_type_name_map( dbms_sql.varchar2_type ) := 'VARCHAR2';
- + 1 +
+ +g_type_name_map( dbms_sql.number_type ) := 'NUMBER';
- + 1 +
+ +g_type_name_map( dbms_sql.rowid_type ) := 'ROWID';
- + 1 +
+ +g_type_name_map( dbms_sql.urowid_type ) := 'UROWID';
- + 1 +
+ +g_type_name_map( dbms_sql.user_defined_type ) := 'USER_DEFINED_TYPE';
- + 1 +
+ +g_type_name_map( dbms_sql.ref_type ) := 'REF_TYPE';
- +
+ +- +
+ +- +
+ +/**
- +
+ +* List of types that have no length but can produce a max_len from desc_cursor function.
- +
+ +*/
- + 1 +
+ +g_type_no_length_map('ROWID') := 'ROWID';
- + 1 +
+ +g_type_no_length_map('INTERVAL DAY TO SECOND') := 'INTERVAL DAY TO SECOND';
- + 1 +
+ +g_type_no_length_map('INTERVAL YEAR TO MONTH') := 'INTERVAL YEAR TO MONTH';
- + 1 +
+ +g_type_no_length_map('BINARY_DOUBLE') := 'BINARY_DOUBLE';
- + 1 +
+ +g_type_no_length_map('BINARY_FLOAT') := 'BINARY_FLOAT';
- +
+end;
+UT3.UT_COMPOUND_DATA_VALUE
100 % lines covered
12 relevant lines. 12 lines covered and 0 lines missed+ +
- +
+ +type body ut_compound_data_value as
- +
+ +/*
- +
+ +utPLSQL - Version 3
- +
+ +Copyright 2016 - 2019 utPLSQL Project
- +
+ +- +
+ +Licensed under the Apache License, Version 2.0 (the "License"):
- +
+ +you may not use this file except in compliance with the License.
- +
+ +You may obtain a copy of the License at
- +
+ +- +
+ +http://www.apache.org/licenses/LICENSE-2.0
- +
+ +- +
+ +Unless required by applicable law or agreed to in writing, software
- +
+ +distributed under the License is distributed on an "AS IS" BASIS,
- +
+ +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
+ +See the License for the specific language governing permissions and
- +
+ +limitations under the License.
- +
+ +*/
- +
+ +- +
+ +member function get_elements_count_info return varchar2 is
- +
+ +begin
- + 364 +
+ +return case when elements_count is null then ' [ null ]' else ' [ count = '||elements_count||' ]' end;
- +
+ +end;
- +
+ +- +
+ +overriding member function get_object_info return varchar2 is
- +
+ +begin
- + 270 +
+ +return self.data_type||get_elements_count_info();
- +
+ +end;
- +
+ +- +
+ +overriding member function is_null return boolean is
- +
+ +begin
- + 1362 +
+ +return ut_utils.int_to_boolean(self.is_data_null);
- +
+ +end;
- +
+ +- +
+ +overriding member function is_diffable return boolean is
- +
+ +begin
- + 179 +
+ +return true;
- +
+ +end;
- +
+ +- +
+ +overriding member function is_multi_line return boolean is
- +
+ +begin
- + 79 +
+ +return not self.is_null();
- +
+ +end;
- +
+ +- +
+ +overriding member function to_string return varchar2 is
- +
+ +l_result clob;
- +
+ +l_result_string varchar2(32767);
- +
+ +begin
- + 50 +
+ +if not self.is_null() then
- + 50 +
+ +dbms_lob.createtemporary(l_result, true);
- + 50 +
+ +ut_utils.append_to_clob(l_result,'Data:'||chr(10));
- + 50 +
+ +ut_utils.append_to_clob(
- +
+ +l_result,
- +
+ +ut_compound_data_helper.get_row_data_as_xml( self.data_id, ut_utils.gc_diff_max_rows )
- +
+ +);
- +
+ +- + 50 +
+ +l_result_string := ut_utils.to_string(l_result,null);
- + 50 +
+ +dbms_lob.freetemporary(l_result);
- +
+ +end if;
- + 50 +
+ +return l_result_string;
- +
+ +end;
- +
+ +- +
+end;
+UT3.UT_CURSOR_COLUMN
95.83 % lines covered
24 relevant lines. 23 lines covered and 1 lines missed+ +
- +
+ +type body ut_cursor_column as
- +
+ +- +
+ +member procedure init(
- +
+ +self in out nocopy ut_cursor_column,
- +
+ +a_col_name varchar2, a_col_schema_name varchar2,
- +
+ +a_col_type_name varchar2, a_col_max_len integer, a_parent_name varchar2 := null, a_hierarchy_level integer := 1,
- +
+ +a_col_position integer, a_col_type varchar2, a_collection integer,a_access_path in varchar2, a_col_precision in integer,
- +
+ +a_col_scale integer
- +
+ +) is
- +
+ +begin
- + 1226 +
+ +self.parent_name := a_parent_name; --Name of the parent if its nested
- + 1226 +
+ +self.hierarchy_level := a_hierarchy_level; --Hierarchy level
- + 1226 +
+ +self.column_position := a_col_position; --Position of the column in cursor/ type
- + 1226 +
+ +self.column_len := a_col_max_len; --length of column
- + 1226 +
+ +self.column_precision := a_col_precision;
- + 1226 +
+ +self.column_scale := a_col_scale;
- + 1226 +
+ +self.column_name := TRIM( BOTH '''' FROM a_col_name); --name of the column
- + 1226 +
+ +self.column_type_name := coalesce(a_col_type_name,a_col_type); --type name e.g. test_dummy_object or varchar2
- + 1226 +
+ +self.xml_valid_name := ut_utils.get_valid_xml_name(self.column_name);
- + 1226 +
+ +self.display_path := case when a_access_path is null then
- +
+ +self.column_name
- +
+ +else
- +
+ +a_access_path||'/'||self.column_name
- +
+ +end; --Access path used for incldue exclude eg/ TEST_DUMMY_OBJECT/VARCHAR2
- + 1226 +
+ +self.access_path := case when a_access_path is null then
- +
+ +self.xml_valid_name
- +
+ +else
- +
+ +a_access_path||'/'||self.xml_valid_name
- +
+ +end; --Access path used for XMLTABLE query
- + 1226 +
+ +self.filter_path := '/'||self.access_path; --Filter path will differ from access path in anydata type
- + 1226 +
+ +self.transformed_name := case when length(self.xml_valid_name) > 30 then
- +
+ +'"'||ut_compound_data_helper.get_fixed_size_hash(self.parent_name||self.xml_valid_name)||'"'
- + 1 +
+ +when self.parent_name is null then
- +
+ +'"'||self.xml_valid_name||'"'
- +
+ +else
- +
+ +'"'||ut_compound_data_helper.get_fixed_size_hash(self.parent_name||self.xml_valid_name)||'"'
- +
+ +end; --when is nestd we need to hash name to make sure we dont exceed 30 char
- + 1226 +
+ +self.column_type := a_col_type; --column type e.g. user_defined , varchar2
- + 1226 +
+ +self.column_schema := a_col_schema_name; -- schema name
- + 1226 +
+ +self.is_sql_diffable := case
- + 1 +
+ +when lower(self.column_type) = 'user_defined_type' then
- +
+ +0
- +
+ +-- Due to bug in 11g/12.1 collection fails on varchar 4000+
- + 1 +
+ +when (lower(self.column_type) in ('varchar2','char')) and (self.column_len > 4000) then
- +
+ +0
- +
+ +else
- +
+ +ut_utils.boolean_to_int(ut_compound_data_helper.is_sql_compare_allowed(self.column_type))
- +
+ +end; --can we directly compare or do we need to hash value
- + 1226 +
+ +self.is_collection := a_collection;
- + 1226 +
+ +self.has_nested_col := case when lower(self.column_type) = 'user_defined_type' and self.is_collection = 0 then 1 else 0 end;
- +
+ +end;
- +
+ +- +
+ +constructor function ut_cursor_column( self in out nocopy ut_cursor_column,
- +
+ +a_col_name varchar2, a_col_schema_name varchar2,
- +
+ +a_col_type_name varchar2, a_col_max_len integer, a_parent_name varchar2 := null, a_hierarchy_level integer := 1,
- +
+ +a_col_position integer, a_col_type in varchar2, a_collection integer,a_access_path in varchar2, a_col_precision in integer,
- +
+ +a_col_scale integer
- +
+ +) return self as result is
- +
+ +begin
- + 1226 +
+ +init(a_col_name, a_col_schema_name, a_col_type_name, a_col_max_len, a_parent_name,a_hierarchy_level, a_col_position,
- +
+ +a_col_type, a_collection,a_access_path,a_col_precision,a_col_scale);
- + 1226 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +constructor function ut_cursor_column( self in out nocopy ut_cursor_column) return self as result is
- +
+ +begin
- +
+ +return;
- +
+ +end;
- +
+end;
+UT3.UT_CURSOR_DETAILS
100 % lines covered
62 relevant lines. 62 lines covered and 0 lines missed+ +
- +
+ +type body ut_cursor_details as
- +
+ +- +
+ +member function equals( a_other ut_cursor_details, a_match_options ut_matcher_options ) return boolean is
- +
+ +l_diffs integer;
- +
+ +begin
- + 161 +
+ +select count(1) into l_diffs
- +
+ +from table(self.cursor_columns_info) a
- +
+ +full outer join table(a_other.cursor_columns_info) e
- +
+ +on decode(a.parent_name,e.parent_name,1,0)= 1
- +
+ +and a.column_name = e.column_name
- +
+ +and replace(a.column_type,'VARCHAR2','CHAR') = replace(e.column_type,'VARCHAR2','CHAR')
- +
+ +and ( a.column_position = e.column_position or a_match_options.columns_are_unordered_flag = 1 )
- +
+ +where a.column_name is null or e.column_name is null;
- + 161 +
+ +return l_diffs = 0;
- +
+ +end;
- +
+ +- +
+ +member procedure desc_compound_data(
- +
+ +self in out nocopy ut_cursor_details, a_compound_data anytype,
- +
+ +a_parent_name in varchar2, a_level in integer, a_access_path in varchar2
- +
+ +) is
- + 145 +
+ +l_idx pls_integer := 1;
- +
+ +l_elements_info ut_metadata.t_anytype_members_rec;
- +
+ +l_element_info ut_metadata.t_anytype_elem_info_rec;
- +
+ +l_is_collection boolean;
- +
+ +begin
- + 145 +
+ +l_elements_info := ut_metadata.get_anytype_members_info( a_compound_data );
- + 145 +
+ +l_is_collection := ut_metadata.is_collection(l_elements_info.type_code);
- + 145 +
+ +if l_elements_info.elements_count is null then
- + 16 +
+ +l_element_info := ut_metadata.get_attr_elem_info( a_compound_data );
- + 16 +
+ +self.cursor_columns_info.extend;
- + 16 +
+ +self.cursor_columns_info(cursor_columns_info.last) :=
- +
+ +ut_cursor_column(
- +
+ +l_elements_info.type_name,
- +
+ +l_elements_info.schema_name,
- +
+ +null,
- +
+ +l_elements_info.length,
- +
+ +a_parent_name,
- +
+ +a_level,
- +
+ +l_idx,
- +
+ +ut_compound_data_helper.get_column_type_desc(l_elements_info.type_code,false),
- +
+ +ut_utils.boolean_to_int(l_is_collection),
- +
+ +a_access_path,
- +
+ +l_elements_info.precision,
- +
+ +l_elements_info.scale
- +
+ +);
- + 16 +
+ +if l_element_info.attr_elt_type is not null then
- + 16 +
+ +desc_compound_data(
- +
+ +l_element_info.attr_elt_type, l_elements_info.type_name,
- +
+ +a_level + 1, a_access_path || '/' || l_elements_info.type_name
- +
+ +);
- +
+ +end if;
- +
+ +else
- + 494 +
+ +while l_idx <= l_elements_info.elements_count loop
- + 365 +
+ +l_element_info := ut_metadata.get_attr_elem_info( a_compound_data, l_idx );
- +
+ +- + 365 +
+ +self.cursor_columns_info.extend;
- + 365 +
+ +self.cursor_columns_info(cursor_columns_info.last) :=
- +
+ +ut_cursor_column(
- +
+ +l_element_info.attribute_name,
- +
+ +l_elements_info.schema_name,
- +
+ +null,
- +
+ +l_element_info.length,
- +
+ +a_parent_name,
- +
+ +a_level,
- +
+ +l_idx,
- +
+ +ut_compound_data_helper.get_column_type_desc(l_element_info.type_code,false),
- +
+ +ut_utils.boolean_to_int(l_is_collection),
- +
+ +a_access_path,
- +
+ +l_elements_info.precision,
- +
+ +l_elements_info.scale
- +
+ +);
- + 365 +
+ +if l_element_info.attr_elt_type is not null then
- + 10 +
+ +desc_compound_data(
- +
+ +l_element_info.attr_elt_type, l_element_info.attribute_name,
- +
+ +a_level + 1, a_access_path || '/' || l_element_info.attribute_name
- +
+ +);
- +
+ +end if;
- + 365 +
+ +l_idx := l_idx + 1;
- +
+ +end loop;
- +
+ +end if;
- +
+ +end;
- +
+ +- +
+ +constructor function ut_cursor_details(self in out nocopy ut_cursor_details) return self as result is
- +
+ +begin
- + 454 +
+ +self.cursor_columns_info := ut_cursor_column_tab();
- + 454 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +constructor function ut_cursor_details(
- +
+ +self in out nocopy ut_cursor_details,
- +
+ +a_cursor_number in number
- +
+ +) return self as result is
- +
+ +l_columns_count pls_integer;
- +
+ +l_columns_desc dbms_sql.desc_tab3;
- +
+ +l_is_collection boolean;
- + 393 +
+ +l_hierarchy_level integer := 1;
- +
+ +begin
- + 393 +
+ +self.cursor_columns_info := ut_cursor_column_tab();
- + 393 +
+ +self.is_anydata := 0;
- + 393 +
+ +dbms_sql.describe_columns3(a_cursor_number, l_columns_count, l_columns_desc);
- +
+ +- +
+ +/**
- +
+ +* Due to a bug with object being part of cursor in ANYDATA scenario
- +
+ +* oracle fails to revert number to cursor. We ar using dbms_sql.close cursor to close it
- +
+ +* to avoid leaving open cursors behind.
- +
+ +* a_cursor := dbms_sql.to_refcursor(l_cursor_number);
- +
+ +**/
- + 1238 +
+ +for pos in 1 .. l_columns_count loop
- + 845 +
+ +l_is_collection := ut_metadata.is_collection( l_columns_desc(pos).col_schema_name, l_columns_desc(pos).col_type_name );
- + 845 +
+ +self.cursor_columns_info.extend;
- + 845 +
+ +self.cursor_columns_info(self.cursor_columns_info.last) :=
- +
+ +ut_cursor_column(
- +
+ +l_columns_desc(pos).col_name,
- +
+ +l_columns_desc(pos).col_schema_name,
- +
+ +l_columns_desc(pos).col_type_name,
- +
+ +l_columns_desc(pos).col_max_len,
- +
+ +null,
- +
+ +l_hierarchy_level,
- +
+ +pos,
- +
+ +ut_compound_data_helper.get_column_type_desc(l_columns_desc(pos).col_type,true),
- +
+ +ut_utils.boolean_to_int(l_is_collection),
- +
+ +null,
- +
+ +l_columns_desc(pos).col_precision,
- +
+ +l_columns_desc(pos).col_scale
- +
+ +);
- +
+ +- + 845 +
+ +if l_columns_desc(pos).col_type = dbms_sql.user_defined_type or l_is_collection then
- + 119 +
+ +desc_compound_data(
- +
+ +ut_metadata.get_user_defined_type( l_columns_desc(pos).col_schema_name, l_columns_desc(pos).col_type_name ),
- +
+ +l_columns_desc(pos).col_name,
- +
+ +l_hierarchy_level + 1,
- +
+ +l_columns_desc(pos).col_name
- +
+ +);
- +
+ +end if;
- +
+ +end loop;
- + 393 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +member function contains_collection return boolean is
- +
+ +l_collection_elements number;
- +
+ +begin
- + 15 +
+ +select count(1) into l_collection_elements
- +
+ +from table(cursor_columns_info) c
- +
+ +where c.is_collection = 1 and rownum = 1;
- + 15 +
+ +return l_collection_elements > 0;
- +
+ +end;
- +
+ +- +
+ +member function get_missing_join_by_columns( a_expected_columns ut_varchar2_list ) return ut_varchar2_list is
- +
+ +l_result ut_varchar2_list;
- +
+ +begin
- +
+ +--regexp_replace(c.access_path,'^\/?([^\/]+\/){1}')
- + 162 +
+ +select fl.column_value
- +
+ +bulk collect into l_result
- +
+ +from table(a_expected_columns) fl
- +
+ +where not exists (
- +
+ +select 1 from table(self.cursor_columns_info) c
- +
+ +where regexp_like(c.filter_path,'^/?'||fl.column_value||'($|/.*)' )
- +
+ +)
- +
+ +order by fl.column_value;
- + 162 +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+ +member procedure filter_columns(self in out nocopy ut_cursor_details, a_match_options ut_matcher_options) is
- + 700 +
+ +l_result ut_cursor_details := self;
- + 700 +
+ +l_column_tab ut_cursor_column_tab := ut_cursor_column_tab();
- +
+ +l_column ut_cursor_column;
- + 700 +
+ +c_xpath_extract_reg constant varchar2(50) := '^((/ROW/)|^(//)|^(/\*/))?(.*)';
- +
+ +begin
- + 700 +
+ +if l_result.cursor_columns_info is not null then
- +
+ +- +
+ +--limit columns to those on the include items minus exclude items
- + 700 +
+ +if a_match_options.include.items.count > 0 then
- +
+ +-- if include - exclude = 0 then keep all columns
- + 86 +
+ +if a_match_options.include.items != a_match_options.exclude.items then
- + 86 +
+ +with included_columns as (
- +
+ +select regexp_replace( column_value, c_xpath_extract_reg, '\5' ) col_names
- +
+ +from table(a_match_options.include.items)
- +
+ +minus
- +
+ +select regexp_replace( column_value, c_xpath_extract_reg, '\5' ) col_names
- +
+ +from table(a_match_options.exclude.items)
- +
+ +)
- +
+ +select value(x)
- +
+ +bulk collect into l_result.cursor_columns_info
- +
+ +from table(self.cursor_columns_info) x
- +
+ +where exists(
- +
+ +select 1 from included_columns f where regexp_like(x.filter_path,'^/?'||f.col_names||'($|/.*)' )
- +
+ +)
- +
+ +or x.hierarchy_level = case when self.is_anydata = 1 then 1 else 0 end ;
- +
+ +end if;
- + 614 +
+ +elsif a_match_options.exclude.items.count > 0 then
- + 122 +
+ +with excluded_columns as (
- +
+ +select regexp_replace( column_value, c_xpath_extract_reg, '\5' ) col_names
- +
+ +from table(a_match_options.exclude.items)
- +
+ +)
- +
+ +select value(x)
- +
+ +bulk collect into l_result.cursor_columns_info
- +
+ +from table(self.cursor_columns_info) x
- +
+ +where not exists(
- +
+ +select 1 from excluded_columns f where regexp_like(x.filter_path,'^/?'||f.col_names||'($|/.*)' )
- +
+ +);
- +
+ +end if;
- +
+ +- +
+ +--Rewrite column order after columns been excluded
- + 700 +
+ +for i in (
- + 2599 +
+ +select parent_name, access_path, display_path, has_nested_col,
- +
+ +transformed_name, hierarchy_level,
- +
+ +rownum as new_position, xml_valid_name,
- +
+ +column_name, column_type, column_type_name, column_schema,
- +
+ +column_len, column_precision ,column_scale ,is_sql_diffable, is_collection,value(x) col_info
- +
+ +from table(l_result.cursor_columns_info) x
- +
+ +order by x.column_position asc
- +
+ +) loop
- + 1899 +
+ +l_column := i.col_info;
- + 1899 +
+ +l_column.column_position := i.new_position;
- + 1899 +
+ +l_column_tab.extend;
- + 1899 +
+ +l_column_tab(l_column_tab.last) := l_column;
- +
+ +end loop;
- +
+ +- + 700 +
+ +l_result.cursor_columns_info := l_column_tab;
- + 700 +
+ +self := l_result;
- +
+ +end if;
- +
+ +end;
- +
+ +- +
+ +member function get_xml_children(a_parent_name varchar2 := null) return xmltype is
- +
+ +l_result xmltype;
- +
+ +begin
- + 50 +
+ +select xmlagg(xmlelement(evalname t.column_name,t.column_type_name))
- +
+ +into l_result
- +
+ +from table(self.cursor_columns_info) t
- +
+ +where (a_parent_name is null and parent_name is null and hierarchy_level = 1 and column_name is not null)
- +
+ +having count(*) > 0;
- + 50 +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+ +member function get_root return varchar2 is
- +
+ +l_root varchar2(250);
- +
+ +begin
- + 200 +
+ +if self.cursor_columns_info.count > 0 then
- + 192 +
+ +select x.access_path into l_root from table(self.cursor_columns_info) x
- +
+ +where x.hierarchy_level = 1;
- +
+ +else
- + 8 +
+ +l_root := null;
- +
+ +end if;
- + 200 +
+ +return l_root;
- +
+ +end;
- +
+ +- +
+ +member procedure strip_root_from_anydata(self in out nocopy ut_cursor_details) is
- + 127 +
+ +l_root varchar2(250) := get_root();
- +
+ +begin
- + 127 +
+ +self.is_anydata := 1;
- + 507 +
+ +for i in 1..cursor_columns_info.count loop
- + 380 +
+ +self.cursor_columns_info(i).filter_path := '/'||ut_utils.strip_prefix(self.cursor_columns_info(i).access_path,l_root);
- +
+ +end loop;
- +
+ +end;
- +
+end;
+UT3.UT_DATA_VALUE
93.33 % lines covered
15 relevant lines. 14 lines covered and 1 lines missed+ +
- +
+ +type body ut_data_value as
- +
+ +/*
- +
+ +utPLSQL - Version 3
- +
+ +Copyright 2016 - 2019 utPLSQL Project
- +
+ +- +
+ +Licensed under the Apache License, Version 2.0 (the "License"):
- +
+ +you may not use this file except in compliance with the License.
- +
+ +You may obtain a copy of the License at
- +
+ +- +
+ +http://www.apache.org/licenses/LICENSE-2.0
- +
+ +- +
+ +Unless required by applicable law or agreed to in writing, software
- +
+ +distributed under the License is distributed on an "AS IS" BASIS,
- +
+ +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
+ +See the License for the specific language governing permissions and
- +
+ +limitations under the License.
- +
+ +*/
- + 428 +
+ +order member function compare(a_other ut_data_value) return integer is
- +
+ +begin
- + 428 +
+ +return compare_implementation(a_other);
- +
+ +end;
- +
+ +- +
+ +member function is_diffable return boolean is
- +
+ +begin
- + 165 +
+ +return false;
- +
+ +end;
- +
+ +- +
+ +member function is_empty return boolean is
- +
+ +begin
- + 2 +
+ +raise value_error;
- +
+ +end;
- +
+ +- +
+ +member function diff( a_other ut_data_value, a_match_options ut_matcher_options ) return varchar2 is
- +
+ +begin
- +
+ +return null;
- +
+ +end;
- +
+ +- +
+ +member function is_multi_line return boolean is
- +
+ +begin
- + 722 +
+ +return false;
- +
+ +end;
- +
+ +- +
+ +member function get_object_info return varchar2 is
- +
+ +begin
- + 746 +
+ +return self.data_type;
- +
+ +end;
- +
+ +- +
+ +final member function to_string_report(a_add_new_line_for_multi_line boolean := false, a_with_object_info boolean := true) return varchar2 is
- +
+ +l_result varchar2(32767);
- +
+ +l_info varchar2(32767);
- +
+ +begin
- + 997 +
+ +if a_with_object_info then
- + 825 +
+ +l_info := '('||get_object_info()||')';
- +
+ +end if;
- + 997 +
+ +if self.is_multi_line() then
- + 74 +
+ +l_result :=
- +
+ +l_info || chr(10) || ut_utils.indent_lines( rtrim(self.to_string(),chr(10)), a_include_first_line =>true );
- + 74 +
+ +if a_add_new_line_for_multi_line then
- + 62 +
+ +l_result := l_result || chr(10);
- +
+ +end if;
- +
+ +else
- + 923 +
+ +l_result := self.to_string() || ' ' || l_info;
- +
+ +end if;
- + 997 +
+ +return l_result;
- +
+ +end;
- +
+end;
+UT3.UT_DATA_VALUE_ANYDATA
79.59 % lines covered
49 relevant lines. 39 lines covered and 10 lines missed+ +
- +
+ +type body ut_data_value_anydata as
- +
+ +/*
- +
+ +utPLSQL - Version 3
- +
+ +Copyright 2016 - 2019 utPLSQL Project
- +
+ +- +
+ +Licensed under the Apache License, Version 2.0 (the "License"):
- +
+ +you may not use this file except in compliance with the License.
- +
+ +You may obtain a copy of the License at
- +
+ +- +
+ +http://www.apache.org/licenses/LICENSE-2.0
- +
+ +- +
+ +Unless required by applicable law or agreed to in writing, software
- +
+ +distributed under the License is distributed on an "AS IS" BASIS,
- +
+ +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
+ +See the License for the specific language governing permissions and
- +
+ +limitations under the License.
- +
+ +*/
- +
+ +- +
+ +overriding member function get_object_info return varchar2 is
- +
+ +begin
- + 153 +
+ +return self.data_type || case when self.compound_type = 'collection' then self.get_elements_count_info() end;
- +
+ +end;
- +
+ +- +
+ +member function get_extract_path(a_data_value anydata) return varchar2 is
- +
+ +l_path varchar2(10);
- +
+ +begin
- + 127 +
+ +if self.compound_type = 'object' then
- + 55 +
+ +l_path := '/*/*';
- +
+ +else
- + 144 +
+ +case when ut_metadata.has_collection_members(a_data_value) then
- + 34 +
+ +l_path := '/*/*';
- +
+ +else
- + 38 +
+ +l_path := '/*';
- +
+ +end case;
- +
+ +end if;
- + 127 +
+ +return l_path;
- +
+ +end;
- +
+ +- +
+ +member function get_cursor_sql_from_anydata(a_data_value anydata) return varchar2 is
- +
+ +l_cursor_sql varchar2(32767);
- +
+ +begin
- + 127 +
+ +l_cursor_sql := '
- +
+ +declare
- +
+ +l_data '||self.data_type||';
- +
+ +l_value anydata := :a_value;
- +
+ +l_status integer;
- +
+ +l_tmp_refcursor sys_refcursor;
- +
+ +begin
- +
+ +l_status := l_value.get'||self.compound_type||'(l_data); '||
- + 1 +
+ +case when self.compound_type = 'collection' then
- +
+ +q'[ open :l_tmp_refcursor for select value(x) as "]'||
- +
+ +ut_metadata.get_object_name(ut_metadata.get_collection_element(a_data_value))||
- +
+ +q'[" from table(l_data) x;]'
- +
+ +else
- +
+ +q'[ open :l_tmp_refcursor for select l_data as "]'||ut_metadata.get_object_name(self.data_type)||
- +
+ +q'[" from dual;]'
- +
+ +end ||
- +
+ +'end;';
- + 127 +
+ +return l_cursor_sql;
- +
+ +end;
- +
+ +- +
+ +member procedure init(self in out nocopy ut_data_value_anydata, a_value anydata) is
- +
+ +l_refcursor sys_refcursor;
- +
+ +cursor_not_open exception;
- +
+ +l_cursor_number number;
- +
+ +l_anydata_sql varchar2(32767);
- +
+ +begin
- + 173 +
+ +self.data_type := ut_metadata.get_anydata_typename(a_value);
- + 173 +
+ +self.compound_type := get_instance(a_value);
- + 173 +
+ +self.is_data_null := ut_metadata.is_anytype_null(a_value,self.compound_type);
- + 173 +
+ +self.data_id := sys_guid();
- + 173 +
+ +self.self_type := $$plsql_unit;
- + 173 +
+ +self.cursor_details := ut_cursor_details();
- +
+ +- + 284 +
+ +ut_compound_data_helper.cleanup_diff;
- +
+ +- + 173 +
+ +if not self.is_null() then
- + 127 +
+ +self.extract_path := get_extract_path(a_value);
- + 127 +
+ +l_anydata_sql := get_cursor_sql_from_anydata(a_value);
- + 127 +
+ +execute immediate l_anydata_sql using in a_value, in out l_refcursor;
- + 127 +
+ +if l_refcursor%isopen then
- + 127 +
+ +self.extract_cursor(l_refcursor);
- + 127 +
+ +l_cursor_number := dbms_sql.to_cursor_number(l_refcursor);
- + 127 +
+ +self.cursor_details := ut_cursor_details(l_cursor_number);
- + 127 +
+ +self.cursor_details.strip_root_from_anydata;
- + 127 +
+ +dbms_sql.close_cursor(l_cursor_number);
- +
+ +elsif not l_refcursor%isopen then
- +
+ +raise cursor_not_open;
- +
+ +end if;
- +
+ +end if;
- +
+ +exception
- +
+ +when cursor_not_open then
- +
+ +raise_application_error(-20155, 'Cursor is not open');
- +
+ +when others then
- +
+ +if l_refcursor%isopen then
- +
+ +close l_refcursor;
- +
+ +end if;
- +
+ +raise;
- +
+ +end;
- +
+ +- +
+ +member function get_instance(a_data_value anydata) return varchar2 is
- +
+ +l_result varchar2(30);
- +
+ +begin
- + 173 +
+ +l_result := ut_metadata.get_anydata_compound_type(a_data_value);
- + 173 +
+ +if l_result not in ('object','collection') then
- +
+ +raise_application_error(-20000, 'Data type '||a_data_value.gettypename||' in ANYDATA is not supported by utPLSQL');
- +
+ +end if;
- + 173 +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+ +constructor function ut_data_value_anydata(self in out nocopy ut_data_value_anydata, a_value anydata) return self as result
- +
+ +is
- +
+ +begin
- + 173 +
+ +init(a_value);
- + 173 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +overriding member function compare_implementation(
- +
+ +a_other ut_data_value,
- +
+ +a_match_options ut_matcher_options,
- +
+ +a_inclusion_compare boolean := false,
- +
+ +a_is_negated boolean := false
- +
+ +) return integer is
- + 57 +
+ +l_result integer := 0;
- +
+ +begin
- + 57 +
+ +if not a_other is of (ut_data_value_anydata) then
- +
+ +raise value_error;
- +
+ +end if;
- + 57 +
+ +l_result := l_result + (self as ut_data_value_refcursor).compare_implementation(a_other,a_match_options,a_inclusion_compare,a_is_negated);
- + 57 +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+ +overriding member function is_empty return boolean is
- +
+ +begin
- + 10 +
+ +if self.compound_type = 'collection' then
- + 6 +
+ +return self.elements_count = 0;
- +
+ +else
- + 4 +
+ +raise value_error;
- +
+ +end if;
- +
+ +end;
- +
+end;
+UT3.UT_DATA_VALUE_BLOB
100 % lines covered
15 relevant lines. 15 lines covered and 0 lines missed+ +
- +
+ +type body ut_data_value_blob as
- +
+ +/*
- +
+ +utPLSQL - Version 3
- +
+ +Copyright 2016 - 2019 utPLSQL Project
- +
+ +- +
+ +Licensed under the Apache License, Version 2.0 (the "License"):
- +
+ +you may not use this file except in compliance with the License.
- +
+ +You may obtain a copy of the License at
- +
+ +- +
+ +http://www.apache.org/licenses/LICENSE-2.0
- +
+ +- +
+ +Unless required by applicable law or agreed to in writing, software
- +
+ +distributed under the License is distributed on an "AS IS" BASIS,
- +
+ +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
+ +See the License for the specific language governing permissions and
- +
+ +limitations under the License.
- +
+ +*/
- +
+ +- +
+ +constructor function ut_data_value_blob(self in out nocopy ut_data_value_blob, a_value blob) return self as result is
- +
+ +begin
- + 38 +
+ +self.data_value := a_value;
- + 38 +
+ +self.self_type := $$plsql_unit;
- + 38 +
+ +self.data_type := 'blob';
- + 38 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +overriding member function is_null return boolean is
- +
+ +begin
- + 58 +
+ +return (self.data_value is null);
- +
+ +end;
- +
+ +- +
+ +overriding member function is_empty return boolean is
- + 4 +
+ +l_result boolean := false;
- +
+ +begin
- + 4 +
+ +if self.data_value is not null and dbms_lob.compare( self.data_value, empty_blob()) = 0 then
- + 2 +
+ +l_result := true;
- +
+ +end if;
- + 4 +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+ +overriding member function to_string return varchar2 is
- +
+ +begin
- + 35 +
+ +return ut_utils.to_string(self.data_value);
- +
+ +end;
- +
+ +- +
+ +overriding member function compare_implementation(a_other ut_data_value) return integer is
- +
+ +l_result integer;
- +
+ +l_other ut_data_value_blob;
- +
+ +begin
- + 8 +
+ +if a_other is of (ut_data_value_blob) then
- + 8 +
+ +l_other := treat(a_other as ut_data_value_blob);
- + 8 +
+ +l_result := dbms_lob.compare( self.data_value, l_other.data_value);
- +
+ +end if;
- + 8 +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+ +overriding member function is_multi_line return boolean is
- +
+ +begin
- + 29 +
+ +return not self.is_null() and dbms_lob.getlength(self.data_value) > 100;
- +
+ +end;
- +
+end;
+UT3.UT_DATA_VALUE_BOOLEAN
93.75 % lines covered
16 relevant lines. 15 lines covered and 1 lines missed+ +
- +
+ +type body ut_data_value_boolean as
- +
+ +/*
- +
+ +utPLSQL - Version 3
- +
+ +Copyright 2016 - 2019 utPLSQL Project
- +
+ +- +
+ +Licensed under the Apache License, Version 2.0 (the "License"):
- +
+ +you may not use this file except in compliance with the License.
- +
+ +You may obtain a copy of the License at
- +
+ +- +
+ +http://www.apache.org/licenses/LICENSE-2.0
- +
+ +- +
+ +Unless required by applicable law or agreed to in writing, software
- +
+ +distributed under the License is distributed on an "AS IS" BASIS,
- +
+ +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
+ +See the License for the specific language governing permissions and
- +
+ +limitations under the License.
- +
+ +*/
- +
+ +- +
+ +constructor function ut_data_value_boolean(self in out nocopy ut_data_value_boolean, a_value boolean) return self as result is
- +
+ +begin
- + 42 +
+ +self.data_value := ut_utils.boolean_to_int(a_value);
- + 42 +
+ +self.self_type := $$plsql_unit;
- + 42 +
+ +self.data_type := 'boolean';
- + 42 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +overriding member function is_null return boolean is
- +
+ +begin
- + 28 +
+ +return (self.data_value is null);
- +
+ +end;
- +
+ +- +
+ +overriding member function to_string return varchar2 is
- +
+ +begin
- + 36 +
+ +return ut_utils.to_string(ut_utils.int_to_boolean(self.data_value));
- +
+ +end;
- +
+ +- +
+ +overriding member function compare_implementation(a_other ut_data_value) return integer is
- +
+ +l_other ut_data_value_boolean;
- +
+ +l_result integer;
- +
+ +begin
- + 9 +
+ +if a_other is of (ut_data_value_boolean) then
- + 9 +
+ +l_other := treat(a_other as ut_data_value_boolean);
- + 9 +
+ +if self.data_value = l_other.data_value then
- + 1 +
+ +l_result := 0;
- + 8 +
+ +elsif self.data_value > l_other.data_value then
- + 1 +
+ +l_result := 1;
- + 7 +
+ +elsif self.data_value < l_other.data_value then
- + 1 +
+ +l_result := -1;
- +
+ +end if;
- +
+ +else
- +
+ +raise value_error;
- +
+ +end if;
- + 9 +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+end;
+UT3.UT_DATA_VALUE_CLOB
100 % lines covered
15 relevant lines. 15 lines covered and 0 lines missed+ +
- +
+ +type body ut_data_value_clob as
- +
+ +/*
- +
+ +utPLSQL - Version 3
- +
+ +Copyright 2016 - 2019 utPLSQL Project
- +
+ +- +
+ +Licensed under the Apache License, Version 2.0 (the "License"):
- +
+ +you may not use this file except in compliance with the License.
- +
+ +You may obtain a copy of the License at
- +
+ +- +
+ +http://www.apache.org/licenses/LICENSE-2.0
- +
+ +- +
+ +Unless required by applicable law or agreed to in writing, software
- +
+ +distributed under the License is distributed on an "AS IS" BASIS,
- +
+ +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
+ +See the License for the specific language governing permissions and
- +
+ +limitations under the License.
- +
+ +*/
- +
+ +- +
+ +constructor function ut_data_value_clob(self in out nocopy ut_data_value_clob, a_value clob) return self as result is
- +
+ +begin
- + 63 +
+ +self.data_value := a_value;
- + 63 +
+ +self.self_type := $$plsql_unit;
- + 63 +
+ +self.data_type := 'clob';
- + 63 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +overriding member function is_null return boolean is
- +
+ +begin
- + 74 +
+ +return (self.data_value is null);
- +
+ +end;
- +
+ +- +
+ +overriding member function is_empty return boolean is
- + 4 +
+ +l_result boolean := false;
- +
+ +begin
- + 4 +
+ +if self.data_value is not null and dbms_lob.compare( self.data_value, empty_clob()) = 0 then
- + 2 +
+ +l_result := true;
- +
+ +end if;
- + 4 +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+ +overriding member function to_string return varchar2 is
- +
+ +begin
- + 51 +
+ +return ut_utils.to_string(self.data_value);
- +
+ +end;
- +
+ +- +
+ +overriding member function compare_implementation(a_other ut_data_value) return integer is
- +
+ +l_result integer;
- +
+ +l_other ut_data_value_clob;
- +
+ +begin
- + 8 +
+ +if a_other is of (ut_data_value_clob) then
- + 8 +
+ +l_other := treat(a_other as ut_data_value_clob);
- + 8 +
+ +l_result := dbms_lob.compare( self.data_value, l_other.data_value);
- +
+ +end if;
- + 8 +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+ +overriding member function is_multi_line return boolean is
- +
+ +begin
- + 45 +
+ +return not self.is_null() and (dbms_lob.getlength(self.data_value) > 100 or dbms_lob.instr(self.data_value,chr(10)) > 0);
- +
+ +end;
- +
+ +- +
+end;
+UT3.UT_DATA_VALUE_DATE
93.75 % lines covered
16 relevant lines. 15 lines covered and 1 lines missed+ +
- +
+ +type body ut_data_value_date as
- +
+ +/*
- +
+ +utPLSQL - Version 3
- +
+ +Copyright 2016 - 2019 utPLSQL Project
- +
+ +- +
+ +Licensed under the Apache License, Version 2.0 (the "License"):
- +
+ +you may not use this file except in compliance with the License.
- +
+ +You may obtain a copy of the License at
- +
+ +- +
+ +http://www.apache.org/licenses/LICENSE-2.0
- +
+ +- +
+ +Unless required by applicable law or agreed to in writing, software
- +
+ +distributed under the License is distributed on an "AS IS" BASIS,
- +
+ +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
+ +See the License for the specific language governing permissions and
- +
+ +limitations under the License.
- +
+ +*/
- +
+ +- +
+ +constructor function ut_data_value_date(self in out nocopy ut_data_value_date, a_value date) return self as result is
- +
+ +begin
- + 86 +
+ +self.data_value := a_value;
- + 86 +
+ +self.self_type := $$plsql_unit;
- + 86 +
+ +self.data_type := 'date';
- + 86 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +overriding member function is_null return boolean is
- +
+ +begin
- + 26 +
+ +return (self.data_value is null);
- +
+ +end;
- +
+ +- +
+ +overriding member function to_string return varchar2 is
- +
+ +begin
- + 80 +
+ +return ut_utils.to_string(self.data_value);
- +
+ +end;
- +
+ +- +
+ +overriding member function compare_implementation(a_other ut_data_value) return integer is
- +
+ +l_result integer;
- +
+ +l_other ut_data_value_date;
- +
+ +begin
- + 40 +
+ +if a_other is of (ut_data_value_date) then
- + 40 +
+ +l_other := treat(a_other as ut_data_value_date);
- + 40 +
+ +if self.data_value = l_other.data_value then
- + 5 +
+ +l_result := 0;
- + 35 +
+ +elsif self.data_value > l_other.data_value then
- + 15 +
+ +l_result := 1;
- + 20 +
+ +elsif self.data_value < l_other.data_value then
- + 8 +
+ +l_result := -1;
- +
+ +end if;
- +
+ +else
- +
+ +raise value_error;
- +
+ +end if;
- + 40 +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+end;
+UT3.UT_DATA_VALUE_DSINTERVAL
100 % lines covered
15 relevant lines. 15 lines covered and 0 lines missed+ +
- +
+ +type body ut_data_value_dsinterval as
- +
+ +/*
- +
+ +utPLSQL - Version 3
- +
+ +Copyright 2016 - 2019 utPLSQL Project
- +
+ +- +
+ +Licensed under the Apache License, Version 2.0 (the "License"):
- +
+ +you may not use this file except in compliance with the License.
- +
+ +You may obtain a copy of the License at
- +
+ +- +
+ +http://www.apache.org/licenses/LICENSE-2.0
- +
+ +- +
+ +Unless required by applicable law or agreed to in writing, software
- +
+ +distributed under the License is distributed on an "AS IS" BASIS,
- +
+ +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
+ +See the License for the specific language governing permissions and
- +
+ +limitations under the License.
- +
+ +*/
- +
+ +- +
+ +constructor function ut_data_value_dsinterval(self in out nocopy ut_data_value_dsinterval, a_value dsinterval_unconstrained) return self as result is
- +
+ +begin
- + 76 +
+ +self.data_value := a_value;
- + 76 +
+ +self.self_type := $$plsql_unit;
- + 76 +
+ +self.data_type := 'interval day to second';
- + 76 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +overriding member function is_null return boolean is
- +
+ +begin
- + 20 +
+ +return (self.data_value is null);
- +
+ +end;
- +
+ +- +
+ +overriding member function to_string return varchar2 is
- +
+ +begin
- + 72 +
+ +return ut_utils.to_string(self.data_value);
- +
+ +end;
- +
+ +- +
+ +overriding member function compare_implementation(a_other ut_data_value) return integer is
- +
+ +l_result integer;
- +
+ +l_other ut_data_value_dsinterval;
- +
+ +begin
- + 40 +
+ +if a_other is of (ut_data_value_dsinterval) then
- + 40 +
+ +l_other := treat(a_other as ut_data_value_dsinterval);
- + 40 +
+ +if self.data_value = l_other.data_value then
- + 5 +
+ +l_result := 0;
- + 35 +
+ +elsif self.data_value > l_other.data_value then
- + 16 +
+ +l_result := 1;
- + 19 +
+ +elsif self.data_value < l_other.data_value then
- + 7 +
+ +l_result := -1;
- +
+ +end if;
- +
+ +end if;
- + 40 +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+end;
+UT3.UT_DATA_VALUE_JSON
98.39 % lines covered
62 relevant lines. 61 lines covered and 1 lines missed+ +
- +
+ +type body ut_data_value_json as
- +
+ +/*
- +
+ +utPLSQL - Version 3
- +
+ +Copyright 2016 - 2019 utPLSQL Project
- +
+ +- +
+ +Licensed under the Apache License, Version 2.0 (the "License"):
- +
+ +you may not use this file except in compliance with the License.
- +
+ +You may obtain a copy of the License at
- +
+ +- +
+ +http://www.apache.org/licenses/LICENSE-2.0
- +
+ +- +
+ +Unless required by applicable law or agreed to in writing, software
- +
+ +distributed under the License is distributed on an "AS IS" BASIS,
- +
+ +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
+ +See the License for the specific language governing permissions and
- +
+ +limitations under the License.
- +
+ +*/
- +
+ +- +
+ +member procedure init (self in out nocopy ut_data_value_json, a_value json_element_t) is
- +
+ +begin
- + 33 +
+ +self.is_data_null := case when a_value is null then 1 else 0 end;
- + 33 +
+ +self.data_value := case when a_value is null then null else a_value.to_clob end;
- + 33 +
+ +self.self_type := $$plsql_unit;
- + 33 +
+ +self.data_type := 'json';
- + 33 +
+ +self.json_tree := ut_json_tree_details(a_value);
- + 33 +
+ +self.data_id := sys_guid();
- +
+ +end;
- +
+ +- +
+ +constructor function ut_data_value_json(self in out nocopy ut_data_value_json, a_value json_element_t) return self as result is
- +
+ +begin
- + 33 +
+ +init(a_value);
- + 33 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +overriding member function is_null return boolean is
- +
+ +begin
- + 38 +
+ +return (ut_utils.int_to_boolean(self.is_data_null));
- +
+ +end;
- +
+ +- +
+ +overriding member function is_empty return boolean is
- +
+ +begin
- + 4 +
+ +return self.data_value = '{}';
- +
+ +end;
- +
+ +- +
+ +overriding member function to_string return varchar2 is
- +
+ +begin
- + 8 +
+ +return ut_utils.to_string(self.data_value);
- +
+ +end;
- +
+ +- +
+ +overriding member function diff( a_other ut_data_value, a_match_options ut_matcher_options ) return varchar2 is
- +
+ +l_result clob;
- + 10 +
+ +l_results ut_utils.t_clob_tab := ut_utils.t_clob_tab();
- +
+ +l_result_string varchar2(32767);
- +
+ +l_other ut_data_value_json;
- + 10 +
+ +l_self ut_data_value_json := self;
- +
+ +l_diff_id ut_utils.t_hash;
- + 10 +
+ +c_max_rows integer := ut_utils.gc_diff_max_rows;
- +
+ +l_diffs ut_compound_data_helper.tt_json_diff_tab;
- +
+ +l_message varchar2(32767);
- +
+ +- +
+ +function get_diff_by_type(a_diff_id raw) return clob is
- + 10 +
+ +l_diff_summary ut_compound_data_helper.tt_json_diff_type_tab := ut_compound_data_helper.get_json_diffs_type(a_diff_id);
- + 10 +
+ +l_message_list ut_varchar2_list := ut_varchar2_list();
- +
+ +begin
- + 16 +
+ +for i in 1..l_diff_summary.count loop
- + 6 +
+ +l_message_list.extend;
- + 6 +
+ +l_message_list(l_message_list.last) := l_diff_summary(i).no_of_occurence||' '||l_diff_summary(i).difference_type;
- +
+ +end loop;
- + 10 +
+ +return ut_utils.table_to_clob(l_message_list,', ');
- +
+ +end;
- +
+ +- +
+ +function get_json_diff_text (a_json_diff ut_compound_data_helper.t_json_diff_rec) return clob is
- +
+ +begin
- + 41 +
+ +return
- + 1 +
+ +case
- + 1 +
+ +when a_json_diff.difference_type = ut_compound_data_helper.gc_json_missing
- +
+ +then
- + 1 +
+ +case
- + 1 +
+ +when a_json_diff.act_element_name is not null then q'[ Missing property: ]'||a_json_diff.act_element_name
- + 1 +
+ +when a_json_diff.exp_element_name is not null then q'[ Extra property: ]'||a_json_diff.exp_element_name
- +
+ +end || ' on path: '||nvl(a_json_diff.act_parent_path,a_json_diff.exp_parent_path)
- +
+ +else
- + 1 +
+ +case
- + 1 +
+ +when a_json_diff.difference_type = ut_compound_data_helper.gc_json_type
- +
+ +then q'[ Actual type: ']'||a_json_diff.act_json_type||q'[' was expected to be: ']'||a_json_diff.exp_json_type||q'[']'
- + 1 +
+ +when a_json_diff.difference_type = ut_compound_data_helper.gc_json_notequal
- +
+ +then q'[ Actual value: ]'||a_json_diff.act_element_value||q'[ was expected to be: ]'||a_json_diff.exp_element_value
- +
+ +end || ' on path: '||nvl(a_json_diff.act_access_path,a_json_diff.exp_access_path)
- +
+ +end;
- +
+ +end;
- +
+ +- +
+ +begin
- + 10 +
+ +if not a_other is of (ut_data_value_json) then
- +
+ +raise value_error;
- +
+ +end if;
- + 10 +
+ +dbms_lob.createtemporary(l_result, true);
- + 10 +
+ +l_other := treat(a_other as ut_data_value_json);
- + 10 +
+ +l_diff_id := ut_utils.get_hash(self.data_id||l_other.data_id);
- +
+ +- + 10 +
+ +if not l_self.is_null and not l_other.is_null then
- + 10 +
+ +l_diffs := ut_compound_data_helper.get_json_diffs_tmp(l_diff_id);
- +
+ +- + 10 +
+ +l_message := ' '||l_diffs.count|| ' differences found' ||
- + 1 +
+ +case when l_diffs.count > c_max_rows then ', showing first '|| c_max_rows else null end||chr(10);
- + 10 +
+ +ut_utils.append_to_clob( l_result, l_message );
- + 10 +
+ +l_message := get_diff_by_type(l_diff_id)||chr(10);
- + 10 +
+ +ut_utils.append_to_clob( l_result, l_message );
- +
+ +- + 51 +
+ +for i in 1 .. least( c_max_rows, l_diffs.count ) loop
- + 41 +
+ +l_results.extend;
- + 41 +
+ +l_results(l_results.last) := get_json_diff_text(l_diffs(i));
- +
+ +end loop;
- + 10 +
+ +ut_utils.append_to_clob(l_result, l_results);
- +
+ +- +
+ +end if;
- +
+ +- + 10 +
+ +if l_result != empty_clob() then
- + 10 +
+ +l_result_string := chr(10) || 'Diff:' || ut_utils.to_string(l_result,null);
- +
+ +end if;
- + 10 +
+ +dbms_lob.freetemporary(l_result);
- + 10 +
+ +return l_result_string;
- +
+ +end;
- +
+ +- +
+ +overriding member function compare_implementation(a_other ut_data_value) return integer is
- + 10 +
+ +l_self ut_data_value_json := self;
- + 10 +
+ +l_other ut_data_value := a_other;
- +
+ +begin
- + 10 +
+ +return l_self.compare_implementation( l_other, null );
- +
+ +end;
- +
+ +- +
+ +member function compare_implementation(a_other in ut_data_value,a_match_options ut_matcher_options) return
- +
+ +integer is
- +
+ +l_result integer;
- +
+ +l_other ut_data_value_json;
- +
+ +l_diff_id ut_utils.t_hash;
- +
+ +begin
- + 10 +
+ +if a_other is of (ut_data_value_json) then
- + 10 +
+ +l_other := treat(a_other as ut_data_value_json);
- + 10 +
+ +l_diff_id := ut_utils.get_hash(self.data_id||l_other.data_id);
- + 10 +
+ +l_result :=
- + 1 +
+ +case
- + 1 +
+ +when ut_compound_data_helper.insert_json_diffs(
- +
+ +l_diff_id, self.json_tree.json_tree_info, l_other.json_tree.json_tree_info
- +
+ +) > 0 then 1
- +
+ +else 0
- +
+ +end;
- +
+ +end if;
- + 10 +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+ +member function get_elements_count return integer is
- +
+ +begin
- + 10 +
+ +return json_element_t.parse(self.data_value).get_size;
- +
+ +end;
- +
+ +- +
+ +member function get_json_count_info return varchar2 is
- +
+ +begin
- + 5 +
+ +return self.data_type||' [ count = '||self.get_elements_count||' ]';
- +
+ +end;
- +
+ +- +
+ +overriding member function get_object_info return varchar2 is
- +
+ +begin
- + 28 +
+ +return self.data_type;
- +
+ +end;
- +
+ +- +
+end;
+UT3.UT_DATA_VALUE_NUMBER
93.75 % lines covered
16 relevant lines. 15 lines covered and 1 lines missed+ +
- +
+ +type body ut_data_value_number as
- +
+ +/*
- +
+ +utPLSQL - Version 3
- +
+ +Copyright 2016 - 2019 utPLSQL Project
- +
+ +- +
+ +Licensed under the Apache License, Version 2.0 (the "License"):
- +
+ +you may not use this file except in compliance with the License.
- +
+ +You may obtain a copy of the License at
- +
+ +- +
+ +http://www.apache.org/licenses/LICENSE-2.0
- +
+ +- +
+ +Unless required by applicable law or agreed to in writing, software
- +
+ +distributed under the License is distributed on an "AS IS" BASIS,
- +
+ +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
+ +See the License for the specific language governing permissions and
- +
+ +limitations under the License.
- +
+ +*/
- +
+ +- +
+ +constructor function ut_data_value_number(self in out nocopy ut_data_value_number, a_value number) return self as result is
- +
+ +begin
- + 237 +
+ +self.data_value := a_value;
- + 237 +
+ +self.self_type := $$plsql_unit;
- + 237 +
+ +self.data_type := 'number';
- + 237 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +overriding member function is_null return boolean is
- +
+ +begin
- + 60 +
+ +return (self.data_value is null);
- +
+ +end;
- +
+ +- +
+ +overriding member function to_string return varchar2 is
- +
+ +begin
- + 215 +
+ +return ut_utils.to_string(self.data_value);
- +
+ +end;
- +
+ +- +
+ +overriding member function compare_implementation(a_other ut_data_value) return integer is
- +
+ +l_result integer;
- +
+ +l_other ut_data_value_number;
- +
+ +begin
- + 104 +
+ +if a_other is of (ut_data_value_number) then
- + 104 +
+ +l_other := treat(a_other as ut_data_value_number);
- + 104 +
+ +if self.data_value = l_other.data_value then
- + 54 +
+ +l_result := 0;
- + 50 +
+ +elsif self.data_value > l_other.data_value then
- + 29 +
+ +l_result := 1;
- + 21 +
+ +elsif self.data_value < l_other.data_value then
- + 9 +
+ +l_result := -1;
- +
+ +end if;
- +
+ +else
- +
+ +raise value_error;
- +
+ +end if;
- + 104 +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+end;
+UT3.UT_DATA_VALUE_REFCURSOR
93.57 % lines covered
171 relevant lines. 160 lines covered and 11 lines missed+ +
- +
+ +type body ut_data_value_refcursor as
- +
+ +/*
- +
+ +utPLSQL - Version 3
- +
+ +Copyright 2016 - 2019 utPLSQL Project
- +
+ +- +
+ +Licensed under the Apache License, Version 2.0 (the "License"):
- +
+ +you may not use this file except in compliance with the License.
- +
+ +You may obtain a copy of the License at
- +
+ +- +
+ +http://www.apache.org/licenses/LICENSE-2.0
- +
+ +- +
+ +Unless required by applicable law or agreed to in writing, software
- +
+ +distributed under the License is distributed on an "AS IS" BASIS,
- +
+ +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
+ +See the License for the specific language governing permissions and
- +
+ +limitations under the License.
- +
+ +*/
- +
+ +- +
+ +constructor function ut_data_value_refcursor(self in out nocopy ut_data_value_refcursor, a_value sys_refcursor)
- +
+ +return self as result is
- +
+ +begin
- + 281 +
+ +init(a_value);
- + 276 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +member procedure extract_cursor(self in out nocopy ut_data_value_refcursor, a_value sys_refcursor)
- +
+ +is
- + 397 +
+ +c_bulk_rows constant integer := 10000;
- + 397 +
+ +l_cursor sys_refcursor := a_value;
- +
+ +l_ctx number;
- +
+ +l_xml xmltype;
- + 397 +
+ +l_ut_owner varchar2(250) := ut_utils.ut_owner;
- + 397 +
+ +l_set_id integer := 0;
- + 397 +
+ +l_elements_count number := 0;
- +
+ +begin
- +
+ +-- We use DBMS_XMLGEN in order to:
- +
+ +-- 1) be able to process data in bulks (set of rows)
- +
+ +-- 2) be able to influence the ROWSET/ROW tags
- +
+ +-- 3) be able to influence the way NULL values are handled (empty TAG)
- +
+ +-- 4) be able to influence the way TIMESTAMP is formatted.
- +
+ +-- Due to Oracle feature/bug, it is not possible to change the DATE formatting of cursor data
- +
+ +-- AFTER the cursor was opened.
- +
+ +-- The only solution for this is to change NLS settings before opening the cursor.
- +
+ +--
- +
+ +-- This would work fine if we could use DBMS_XMLGEN.restartQuery.
- +
+ +-- The restartQuery fails however if PLSQL variables of TIMESTAMP/INTERVAL or CLOB/BLOB are used.
- + 621 +
+ +ut_expectation_processor.set_xml_nls_params();
- + 397 +
+ +l_ctx := dbms_xmlgen.newContext(l_cursor);
- + 397 +
+ +dbms_xmlgen.setNullHandling(l_ctx, dbms_xmlgen.empty_tag);
- + 397 +
+ +dbms_xmlgen.setMaxRows(l_ctx, c_bulk_rows);
- + 760 +
+ +loop
- + 760 +
+ +l_xml := dbms_xmlgen.getxmltype(l_ctx);
- + 756 +
+ +exit when dbms_xmlgen.getNumRowsProcessed(l_ctx) = 0;
- +
+ +--Bug in oracle 12.2+ where XML binary storage trimming insignificant whitespaces.
- +
+ +$if dbms_db_version.version = 12 and dbms_db_version.release >= 2 or dbms_db_version.version > 12 $then
- + 363 +
+ +l_xml := xmltype( replace(l_xml.getClobVal(),'<ROWSET','<ROWSET xml:space=''preserve'''));
- +
+ +$else
- +
+ +null;
- +
+ +$end
- + 363 +
+ +l_elements_count := l_elements_count + dbms_xmlgen.getNumRowsProcessed(l_ctx);
- + 363 +
+ +ut_compound_data_helper.save_cursor_data_for_diff( self.data_id, l_set_id, l_xml );
- + 363 +
+ +l_set_id := l_set_id + c_bulk_rows;
- +
+ +end loop;
- +
+ +- + 393 +
+ +ut_expectation_processor.reset_nls_params();
- + 393 +
+ +dbms_xmlgen.closeContext(l_ctx);
- + 393 +
+ +self.elements_count := l_elements_count;
- +
+ +exception
- + 8 +
+ +when others then
- + 4 +
+ +ut_expectation_processor.reset_nls_params();
- + 4 +
+ +dbms_xmlgen.closeContext(l_ctx);
- + 4 +
+ +raise;
- +
+ +end;
- +
+ +- +
+ +member procedure init(self in out nocopy ut_data_value_refcursor, a_value sys_refcursor) is
- + 281 +
+ +l_cursor sys_refcursor := a_value;
- +
+ +cursor_not_open exception;
- +
+ +l_cursor_number number;
- +
+ +begin
- + 281 +
+ +self.is_data_null := ut_utils.boolean_to_int(l_cursor is null);
- + 281 +
+ +self.self_type := $$plsql_unit;
- + 281 +
+ +self.data_id := sys_guid();
- + 281 +
+ +self.data_type := 'refcursor';
- + 281 +
+ +self.compound_type := 'refcursor';
- + 281 +
+ +self.extract_path := '/*';
- + 434 +
+ +ut_compound_data_helper.cleanup_diff;
- + 281 +
+ +self.cursor_details := ut_cursor_details();
- +
+ +- + 281 +
+ +if l_cursor is not null then
- + 271 +
+ +if l_cursor%isopen then
- +
+ +--Get some more info regarding cursor, including if it containts collection columns and what is their name
- + 270 +
+ +extract_cursor(l_cursor);
- + 266 +
+ +l_cursor_number := dbms_sql.to_cursor_number(l_cursor);
- + 266 +
+ +self.cursor_details := ut_cursor_details(l_cursor_number);
- + 266 +
+ +dbms_sql.close_cursor(l_cursor_number);
- + 1 +
+ +elsif not l_cursor%isopen then
- + 1 +
+ +raise cursor_not_open;
- +
+ +end if;
- +
+ +end if;
- +
+ +exception
- + 2 +
+ +when cursor_not_open then
- + 1 +
+ +raise_application_error(-20155, 'Cursor is not open');
- + 8 +
+ +when ut_utils.ex_xml_processing then
- + 4 +
+ +if l_cursor%isopen then
- + 4 +
+ +close l_cursor;
- +
+ +end if;
- + 4 +
+ +raise_application_error(ut_utils.gc_failed_open_cur,
- +
+ +ut_compound_data_helper.create_err_cursor_msg(dbms_utility.format_call_stack()));
- +
+ +when others then
- +
+ +if l_cursor%isopen then
- +
+ +close l_cursor;
- +
+ +end if;
- +
+ +raise;
- +
+ +end;
- +
+ +- +
+ +overriding member function to_string return varchar2 is
- +
+ +l_result clob;
- +
+ +l_result_string varchar2(32767);
- +
+ +begin
- + 71 +
+ +if not self.is_null() then
- + 50 +
+ +dbms_lob.createtemporary(l_result, true);
- + 50 +
+ +ut_utils.append_to_clob(l_result, 'Data-types:'||chr(10));
- +
+ +- + 50 +
+ +if self.cursor_details.cursor_columns_info.count > 0 then
- + 50 +
+ +ut_utils.append_to_clob( l_result, self.cursor_details.get_xml_children().getclobval() );
- +
+ +end if;
- + 50 +
+ +ut_utils.append_to_clob(l_result,chr(10)||(self as ut_compound_data_value).to_string());
- + 50 +
+ +l_result_string := ut_utils.to_string(l_result,null);
- + 50 +
+ +dbms_lob.freetemporary(l_result);
- +
+ +end if;
- + 71 +
+ +return l_result_string;
- +
+ +end;
- +
+ +- +
+ +overriding member function diff( a_other ut_data_value, a_match_options ut_matcher_options ) return varchar2 is
- +
+ +l_result clob;
- + 169 +
+ +l_results ut_utils.t_clob_tab := ut_utils.t_clob_tab();
- +
+ +l_result_string varchar2(32767);
- +
+ +l_other ut_data_value_refcursor;
- + 169 +
+ +l_self ut_data_value_refcursor := self;
- +
+ +l_column_diffs ut_compound_data_helper.tt_column_diffs;
- +
+ +- +
+ +l_other_cols ut_cursor_column_tab;
- +
+ +l_self_cols ut_cursor_column_tab;
- +
+ +- + 169 +
+ +l_act_missing_pk ut_varchar2_list := ut_varchar2_list();
- + 169 +
+ +l_exp_missing_pk ut_varchar2_list := ut_varchar2_list();
- +
+ +- + 169 +
+ +c_max_rows integer := ut_utils.gc_diff_max_rows;
- +
+ +l_diff_id ut_utils.t_hash;
- +
+ +l_diff_row_count integer;
- +
+ +l_row_diffs ut_compound_data_helper.tt_row_diffs;
- +
+ +l_message varchar2(32767);
- +
+ +- +
+ +function get_col_diff_text(a_col ut_compound_data_helper.t_column_diffs) return varchar2 is
- +
+ +begin
- + 27 +
+ +return
- + 1 +
+ +case a_col.diff_type
- + 1 +
+ +when '-' then
- +
+ +' Column <'||a_col.expected_name||'> [data-type: '||a_col.expected_type||'] is missing. Expected column position: '||a_col.expected_pos||'.'
- + 1 +
+ +when '+' then
- +
+ +' Column <'||a_col.actual_name||'> [position: '||a_col.actual_pos||', data-type: '||a_col.actual_type||'] is not expected in results.'
- + 1 +
+ +when 't' then
- +
+ +' Column <'||a_col.actual_name||'> data-type is invalid. Expected: '||a_col.expected_type||',' ||' actual: '||a_col.actual_type||'.'
- + 1 +
+ +when 'p' then
- +
+ +' Column <'||a_col.actual_name||'> is misplaced. Expected position: '||a_col.expected_pos||',' ||' actual position: '||a_col.actual_pos||'.'
- +
+ +end;
- +
+ +end;
- +
+ +- +
+ +function remove_incomparable_cols(
- +
+ +a_cursor_details ut_cursor_column_tab, a_column_diffs ut_compound_data_helper.tt_column_diffs
- +
+ +) return ut_cursor_column_tab is
- + 24 +
+ +l_missing_cols ut_varchar2_list := ut_varchar2_list();
- +
+ +l_result ut_cursor_column_tab;
- +
+ +begin
- + 78 +
+ +for i in 1 .. a_column_diffs.count loop
- + 54 +
+ +if a_column_diffs(i).diff_type in ('-','+') then
- + 36 +
+ +l_missing_cols.extend;
- + 36 +
+ +l_missing_cols(l_missing_cols.last) := coalesce(a_column_diffs(i).expected_name, a_column_diffs(i).actual_name);
- +
+ +end if;
- +
+ +end loop;
- + 24 +
+ +select value(i) bulk collect into l_result
- +
+ +from table(a_cursor_details) i
- +
+ +where i.access_path not in (
- +
+ +select c.column_value
- +
+ +from table(l_missing_cols) c
- +
+ +);
- + 24 +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+ +function get_diff_message (a_row_diff ut_compound_data_helper.t_row_diffs, a_is_unordered boolean) return varchar2 is
- +
+ +begin
- + 224 +
+ +if a_is_unordered then
- + 68 +
+ +if a_row_diff.pk_value is not null then
- + 42 +
+ +return ' PK '||a_row_diff.pk_value||' - '||rpad(a_row_diff.diff_type,10)||a_row_diff.diffed_row;
- +
+ +else
- + 26 +
+ +return rpad(a_row_diff.diff_type,10)||a_row_diff.diffed_row;
- +
+ +end if;
- +
+ +else
- + 156 +
+ +return ' Row No. '||a_row_diff.rn||' - '||rpad(a_row_diff.diff_type,10)||a_row_diff.diffed_row;
- +
+ +end if;
- +
+ +end;
- +
+ +- +
+ +begin
- + 169 +
+ +if not a_other is of (ut_data_value_refcursor) then
- +
+ +raise value_error;
- +
+ +end if;
- + 169 +
+ +l_other := treat(a_other as ut_data_value_refcursor);
- + 169 +
+ +l_other.cursor_details.filter_columns(a_match_options);
- + 169 +
+ +l_self.cursor_details.filter_columns(a_match_options);
- +
+ +- + 169 +
+ +l_other_cols := l_other.cursor_details.cursor_columns_info;
- + 169 +
+ +l_self_cols := l_self.cursor_details.cursor_columns_info;
- +
+ +- + 169 +
+ +dbms_lob.createtemporary(l_result,true);
- +
+ +--diff columns
- + 169 +
+ +if not l_self.is_null and not l_other.is_null then
- + 158 +
+ +l_column_diffs := ut_compound_data_helper.get_columns_diff(
- +
+ +l_self.cursor_details.cursor_columns_info,
- +
+ +l_other.cursor_details.cursor_columns_info,
- +
+ +a_match_options.ordered_columns()
- +
+ +);
- +
+ +- + 158 +
+ +if l_column_diffs is not empty then
- + 12 +
+ +ut_utils.append_to_clob(l_result,chr(10) || 'Columns:' || chr(10));
- + 12 +
+ +l_other_cols := remove_incomparable_cols( l_other_cols, l_column_diffs );
- + 12 +
+ +l_self_cols := remove_incomparable_cols( l_self_cols, l_column_diffs );
- + 39 +
+ +for i in 1 .. l_column_diffs.count loop
- + 27 +
+ +l_results.extend;
- + 27 +
+ +l_results(l_results.last) := get_col_diff_text(l_column_diffs(i));
- +
+ +end loop;
- + 12 +
+ +ut_utils.append_to_clob(l_result, l_results);
- +
+ +end if;
- +
+ +end if;
- +
+ +- +
+ +--check for missing pk
- + 169 +
+ +if a_match_options.join_by.items.count > 0 then
- + 39 +
+ +l_act_missing_pk := l_other.cursor_details.get_missing_join_by_columns( a_match_options.join_by.items );
- + 39 +
+ +l_exp_missing_pk := l_self.cursor_details.get_missing_join_by_columns( a_match_options.join_by.items );
- +
+ +end if;
- +
+ +- +
+ +--diff rows and row elements if the pk is not missing
- + 169 +
+ +if l_act_missing_pk.count + l_exp_missing_pk.count = 0 then
- + 161 +
+ +l_diff_id := ut_utils.get_hash( l_self.data_id || l_other.data_id );
- +
+ +- +
+ +-- First tell how many rows are different
- + 161 +
+ +l_diff_row_count := ut_compound_data_helper.get_rows_diff_count;
- + 161 +
+ +if l_diff_row_count > 0 then
- + 55 +
+ +l_row_diffs := ut_compound_data_helper.get_rows_diff_by_sql(
- +
+ +l_self_cols, l_other_cols, l_self.data_id, l_other.data_id,
- +
+ +l_diff_id,
- + 1 +
+ +case
- + 1 +
+ +when
- +
+ +l_self.cursor_details.is_anydata = 1 then ut_utils.add_prefix(a_match_options.join_by.items, l_self.cursor_details.get_root)
- +
+ +else
- +
+ +a_match_options.join_by.items
- +
+ +end,
- +
+ +a_match_options.unordered,a_match_options.ordered_columns(), self.extract_path
- +
+ +);
- + 55 +
+ +l_message := chr(10)
- +
+ +||'Rows: [ ' || l_diff_row_count ||' differences'
- + 1 +
+ +|| case when l_diff_row_count > c_max_rows and l_row_diffs.count > 0 then ', showing first '||c_max_rows end
- + 1 +
+ +||' ]'||chr(10)|| case when l_row_diffs.count = 0 then ' All rows are different as the columns are not matching.' else null end;
- + 55 +
+ +ut_utils.append_to_clob( l_result, l_message );
- + 55 +
+ +l_results := ut_utils.t_clob_tab();
- + 279 +
+ +for i in 1 .. l_row_diffs.count loop
- + 224 +
+ +l_results.extend;
- + 224 +
+ +l_results(l_results.last) := get_diff_message(l_row_diffs(i),a_match_options.unordered);
- +
+ +end loop;
- + 55 +
+ +ut_utils.append_to_clob(l_result,l_results);
- + 106 +
+ +elsif l_column_diffs is not empty then
- + 4 +
+ +l_message:= chr(10)||'Rows: [ all different ]'||chr(10)||' All rows are different as the columns position is not matching.';
- + 4 +
+ +ut_utils.append_to_clob( l_result, l_message );
- +
+ +end if;
- +
+ +else
- + 8 +
+ +ut_utils.append_to_clob(l_result,chr(10) || 'Unable to join sets:' || chr(10));
- +
+ +- + 16 +
+ +for i in 1 .. l_exp_missing_pk.count loop
- + 8 +
+ +ut_utils.append_to_clob(l_result, ' Join key '||l_exp_missing_pk(i)||' does not exists in expected'||chr(10));
- +
+ +end loop;
- +
+ +- + 16 +
+ +for i in 1 .. l_act_missing_pk.count loop
- + 8 +
+ +ut_utils.append_to_clob(l_result, ' Join key '||l_act_missing_pk(i)||' does not exists in actual'||chr(10));
- +
+ +end loop;
- +
+ +- + 8 +
+ +if l_self.cursor_details.contains_collection() or l_other.cursor_details.contains_collection() then
- + 1 +
+ +ut_utils.append_to_clob(l_result,' Please make sure that your join clause is not refferring to collection element'|| chr(10));
- +
+ +end if;
- +
+ +- +
+ +end if;
- + 169 +
+ +if l_result != empty_clob() then
- + 67 +
+ +l_result_string := chr(10) || 'Diff:' || ut_utils.to_string(l_result,null);
- +
+ +end if;
- + 169 +
+ +dbms_lob.freetemporary(l_result);
- + 169 +
+ +return l_result_string;
- +
+ +end;
- +
+ +- +
+ +overriding member function compare_implementation(a_other ut_data_value) return integer is
- +
+ +begin
- +
+ +return compare_implementation( a_other, null );
- +
+ +end;
- +
+ +- +
+ +member function compare_implementation(
- +
+ +a_other ut_data_value,
- +
+ +a_match_options ut_matcher_options,
- +
+ +a_inclusion_compare boolean := false,
- +
+ +a_is_negated boolean := false
- +
+ +) return integer is
- + 181 +
+ +l_result integer := 0;
- + 181 +
+ +l_self ut_data_value_refcursor := self;
- +
+ +l_other ut_data_value_refcursor;
- +
+ +l_diff_cursor_text clob;
- +
+ +- +
+ +function compare_data(
- +
+ +a_self ut_data_value_refcursor,
- +
+ +a_other ut_data_value_refcursor,
- +
+ +a_diff_cursor_text clob
- +
+ +) return integer is
- +
+ +l_diff_id ut_utils.t_hash;
- +
+ +l_result integer;
- +
+ +--We will start with number od differences being displayed.
- +
+ +l_cursor sys_refcursor;
- +
+ +l_diff_tab ut_compound_data_helper.t_diff_tab;
- + 173 +
+ +l_diif_rowcount integer :=0;
- +
+ +begin
- + 173 +
+ +l_diff_id := ut_utils.get_hash(a_self.data_id||a_other.data_id);
- +
+ +- +
+ +begin
- + 173 +
+ +l_cursor := ut_compound_data_helper.get_compare_cursor(a_diff_cursor_text,
- +
+ +a_self.data_id, a_other.data_id);
- +
+ +--fetch and save rows for display of diff
- + 173 +
+ +fetch l_cursor bulk collect into l_diff_tab limit ut_utils.gc_diff_max_rows;
- +
+ +exception when others then
- +
+ +if l_cursor%isopen then
- +
+ +close l_cursor;
- +
+ +end if;
- +
+ +raise;
- +
+ +end;
- +
+ +- + 173 +
+ +ut_compound_data_helper.insert_diffs_result( l_diff_tab, l_diff_id );
- +
+ +--fetch rows for count only
- + 233 +
+ +loop
- + 233 +
+ +exit when l_diff_tab.count = 0;
- + 60 +
+ +l_diif_rowcount := l_diif_rowcount + l_diff_tab.count;
- + 60 +
+ +fetch l_cursor bulk collect into l_diff_tab limit ut_utils.gc_bc_fetch_limit;
- +
+ +end loop;
- +
+ +- + 173 +
+ +ut_compound_data_helper.set_rows_diff(l_diif_rowcount);
- +
+ +- +
+ +--result is OK only if both are same
- + 173 +
+ +if l_diif_rowcount = 0 and a_self.is_null = a_other.is_null then
- + 113 +
+ +l_result := 0;
- +
+ +else
- + 60 +
+ +l_result := 1;
- +
+ +end if;
- + 173 +
+ +close l_cursor;
- + 173 +
+ +return l_result;
- +
+ +end;
- +
+ +begin
- + 181 +
+ +if not a_other is of (ut_data_value_refcursor) then
- +
+ +raise value_error;
- +
+ +end if;
- +
+ +- + 181 +
+ +l_other := treat(a_other as ut_data_value_refcursor);
- + 181 +
+ +l_other.cursor_details.filter_columns( a_match_options );
- + 181 +
+ +l_self.cursor_details.filter_columns( a_match_options );
- +
+ +- + 181 +
+ +if a_match_options.join_by.items.count > 0 then
- + 42 +
+ +l_result :=
- +
+ +l_self.cursor_details.get_missing_join_by_columns( a_match_options.join_by.items ).count
- +
+ ++ l_other.cursor_details.get_missing_join_by_columns( a_match_options.join_by.items ).count;
- +
+ +end if;
- +
+ +- + 181 +
+ +if l_result = 0 then
- + 173 +
+ +if not l_self.is_null() and not l_other.is_null() and not l_self.cursor_details.equals( l_other.cursor_details, a_match_options ) then
- + 10 +
+ +l_result := 1;
- +
+ +end if;
- + 173 +
+ +l_diff_cursor_text := ut_compound_data_helper.gen_compare_sql(
- +
+ +l_other,
- +
+ +a_match_options.join_by.items,
- +
+ +a_match_options.unordered(),
- +
+ +a_inclusion_compare,
- +
+ +a_is_negated
- +
+ +);
- + 173 +
+ +l_result := l_result + compare_data( l_self, l_other, l_diff_cursor_text );
- +
+ +end if;
- + 181 +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+ +overriding member function is_empty return boolean is
- +
+ +begin
- + 11 +
+ +return self.elements_count = 0;
- +
+ +end;
- +
+ +- +
+end;
+UT3.UT_DATA_VALUE_TIMESTAMP
93.75 % lines covered
16 relevant lines. 15 lines covered and 1 lines missed+ +
- +
+ +type body ut_data_value_timestamp as
- +
+ +/*
- +
+ +utPLSQL - Version 3
- +
+ +Copyright 2016 - 2019 utPLSQL Project
- +
+ +- +
+ +Licensed under the Apache License, Version 2.0 (the "License"):
- +
+ +you may not use this file except in compliance with the License.
- +
+ +You may obtain a copy of the License at
- +
+ +- +
+ +http://www.apache.org/licenses/LICENSE-2.0
- +
+ +- +
+ +Unless required by applicable law or agreed to in writing, software
- +
+ +distributed under the License is distributed on an "AS IS" BASIS,
- +
+ +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
+ +See the License for the specific language governing permissions and
- +
+ +limitations under the License.
- +
+ +*/
- +
+ +- +
+ +constructor function ut_data_value_timestamp(self in out nocopy ut_data_value_timestamp, a_value timestamp_unconstrained) return self as result is
- +
+ +begin
- + 92 +
+ +self.data_value := a_value;
- + 92 +
+ +self.self_type := $$plsql_unit;
- + 92 +
+ +self.data_type := 'timestamp';
- + 92 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +overriding member function is_null return boolean is
- +
+ +begin
- + 26 +
+ +return (self.data_value is null);
- +
+ +end;
- +
+ +- +
+ +overriding member function to_string return varchar2 is
- +
+ +begin
- + 86 +
+ +return ut_utils.to_string(self.data_value);
- +
+ +end;
- +
+ +- +
+ +overriding member function compare_implementation(a_other ut_data_value) return integer is
- +
+ +l_result integer;
- +
+ +l_other ut_data_value_timestamp;
- +
+ +begin
- + 44 +
+ +if a_other is of (ut_data_value_timestamp) then
- + 44 +
+ +l_other := treat(a_other as ut_data_value_timestamp);
- + 44 +
+ +if self.data_value = l_other.data_value then
- + 5 +
+ +l_result := 0;
- + 39 +
+ +elsif self.data_value > l_other.data_value then
- + 18 +
+ +l_result := 1;
- + 21 +
+ +elsif self.data_value < l_other.data_value then
- + 9 +
+ +l_result := -1;
- +
+ +end if;
- +
+ +else
- +
+ +raise value_error;
- +
+ +end if;
- + 44 +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+end;
+UT3.UT_DATA_VALUE_TIMESTAMP_LTZ
93.75 % lines covered
16 relevant lines. 15 lines covered and 1 lines missed+ +
- +
+ +type body ut_data_value_timestamp_ltz as
- +
+ +/*
- +
+ +utPLSQL - Version 3
- +
+ +Copyright 2016 - 2019 utPLSQL Project
- +
+ +- +
+ +Licensed under the Apache License, Version 2.0 (the "License"):
- +
+ +you may not use this file except in compliance with the License.
- +
+ +You may obtain a copy of the License at
- +
+ +- +
+ +http://www.apache.org/licenses/LICENSE-2.0
- +
+ +- +
+ +Unless required by applicable law or agreed to in writing, software
- +
+ +distributed under the License is distributed on an "AS IS" BASIS,
- +
+ +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
+ +See the License for the specific language governing permissions and
- +
+ +limitations under the License.
- +
+ +*/
- +
+ +- +
+ +constructor function ut_data_value_timestamp_ltz(self in out nocopy ut_data_value_timestamp_ltz, a_value timestamp_ltz_unconstrained) return self as result is
- +
+ +begin
- + 92 +
+ +self.data_value := a_value;
- + 92 +
+ +self.self_type := $$plsql_unit;
- + 92 +
+ +self.data_type := 'timestamp with local time zone';
- + 92 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +overriding member function is_null return boolean is
- +
+ +begin
- + 26 +
+ +return (self.data_value is null);
- +
+ +end;
- +
+ +- +
+ +overriding member function to_string return varchar2 is
- +
+ +begin
- + 86 +
+ +return ut_utils.to_string(self.data_value);
- +
+ +end;
- +
+ +- +
+ +overriding member function compare_implementation(a_other ut_data_value) return integer is
- +
+ +l_result integer;
- +
+ +l_other ut_data_value_timestamp_ltz;
- +
+ +begin
- + 44 +
+ +if a_other is of (ut_data_value_timestamp_ltz) then
- + 44 +
+ +l_other := treat(a_other as ut_data_value_timestamp_ltz);
- + 44 +
+ +if self.data_value = l_other.data_value then
- + 5 +
+ +l_result := 0;
- + 39 +
+ +elsif self.data_value > l_other.data_value then
- + 18 +
+ +l_result := 1;
- + 21 +
+ +elsif self.data_value < l_other.data_value then
- + 9 +
+ +l_result := -1;
- +
+ +end if;
- +
+ +else
- +
+ +raise value_error;
- +
+ +end if;
- + 44 +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+end;
+UT3.UT_DATA_VALUE_TIMESTAMP_TZ
93.75 % lines covered
16 relevant lines. 15 lines covered and 1 lines missed+ +
- +
+ +type body ut_data_value_timestamp_tz as
- +
+ +/*
- +
+ +utPLSQL - Version 3
- +
+ +Copyright 2016 - 2019 utPLSQL Project
- +
+ +- +
+ +Licensed under the Apache License, Version 2.0 (the "License"):
- +
+ +you may not use this file except in compliance with the License.
- +
+ +You may obtain a copy of the License at
- +
+ +- +
+ +http://www.apache.org/licenses/LICENSE-2.0
- +
+ +- +
+ +Unless required by applicable law or agreed to in writing, software
- +
+ +distributed under the License is distributed on an "AS IS" BASIS,
- +
+ +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
+ +See the License for the specific language governing permissions and
- +
+ +limitations under the License.
- +
+ +*/
- +
+ +- +
+ +constructor function ut_data_value_timestamp_tz(self in out nocopy ut_data_value_timestamp_tz, a_value timestamp_tz_unconstrained) return self as result is
- +
+ +begin
- + 88 +
+ +self.data_value := a_value;
- + 88 +
+ +self.self_type := $$plsql_unit;
- + 88 +
+ +self.data_type := 'timestamp with time zone';
- + 88 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +overriding member function is_null return boolean is
- +
+ +begin
- + 26 +
+ +return (self.data_value is null);
- +
+ +end;
- +
+ +- +
+ +overriding member function to_string return varchar2 is
- +
+ +begin
- + 86 +
+ +return ut_utils.to_string(self.data_value);
- +
+ +end;
- +
+ +- +
+ +overriding member function compare_implementation(a_other ut_data_value) return integer is
- +
+ +l_result integer;
- +
+ +l_other ut_data_value_timestamp_tz;
- +
+ +begin
- + 44 +
+ +if a_other is of (ut_data_value_timestamp_tz) then
- + 44 +
+ +l_other := treat(a_other as ut_data_value_timestamp_tz);
- + 44 +
+ +if self.data_value = l_other.data_value then
- + 5 +
+ +l_result := 0;
- + 39 +
+ +elsif self.data_value > l_other.data_value then
- + 18 +
+ +l_result := 1;
- + 21 +
+ +elsif self.data_value < l_other.data_value then
- + 9 +
+ +l_result := -1;
- +
+ +end if;
- +
+ +else
- +
+ +raise value_error;
- +
+ +end if;
- + 44 +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+end;
+UT3.UT_DATA_VALUE_VARCHAR2
94.12 % lines covered
17 relevant lines. 16 lines covered and 1 lines missed+ +
- +
+ +type body ut_data_value_varchar2 as
- +
+ +/*
- +
+ +utPLSQL - Version 3
- +
+ +Copyright 2016 - 2019 utPLSQL Project
- +
+ +- +
+ +Licensed under the Apache License, Version 2.0 (the "License"):
- +
+ +you may not use this file except in compliance with the License.
- +
+ +You may obtain a copy of the License at
- +
+ +- +
+ +http://www.apache.org/licenses/LICENSE-2.0
- +
+ +- +
+ +Unless required by applicable law or agreed to in writing, software
- +
+ +distributed under the License is distributed on an "AS IS" BASIS,
- +
+ +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
+ +See the License for the specific language governing permissions and
- +
+ +limitations under the License.
- +
+ +*/
- +
+ +- +
+ +constructor function ut_data_value_varchar2(self in out nocopy ut_data_value_varchar2, a_value varchar2) return self as result is
- +
+ +begin
- + 361 +
+ +self.data_value := a_value;
- + 361 +
+ +self.self_type := $$plsql_unit;
- + 361 +
+ +self.data_type := 'varchar2';
- + 361 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +overriding member function is_null return boolean is
- +
+ +begin
- + 174 +
+ +return (self.data_value is null);
- +
+ +end;
- +
+ +- +
+ +overriding member function to_string return varchar2 is
- +
+ +begin
- + 127 +
+ +return ut_utils.to_string(self.data_value);
- +
+ +end;
- +
+ +- +
+ +overriding member function compare_implementation(a_other ut_data_value) return integer is
- +
+ +l_result integer;
- +
+ +l_other ut_data_value_varchar2;
- +
+ +begin
- + 37 +
+ +if a_other is of (ut_data_value_varchar2) then
- + 37 +
+ +l_other := treat(a_other as ut_data_value_varchar2);
- + 37 +
+ +if self.data_value = l_other.data_value then
- + 3 +
+ +l_result := 0;
- + 34 +
+ +elsif self.data_value > l_other.data_value then
- + 16 +
+ +l_result := 1;
- + 18 +
+ +elsif self.data_value < l_other.data_value then
- + 6 +
+ +l_result := -1;
- +
+ +end if;
- +
+ +else
- +
+ +raise value_error;
- +
+ +end if;
- + 37 +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+ +overriding member function is_multi_line return boolean is
- +
+ +begin
- + 122 +
+ +return not self.is_null() and (length(self.data_value) > 100 or instr(self.data_value,chr(10)) > 0);
- +
+ +end;
- +
+ +- +
+end;
+UT3.UT_DATA_VALUE_YMINTERVAL
100 % lines covered
15 relevant lines. 15 lines covered and 0 lines missed+ +
- +
+ +type body ut_data_value_yminterval as
- +
+ +/*
- +
+ +utPLSQL - Version 3
- +
+ +Copyright 2016 - 2019 utPLSQL Project
- +
+ +- +
+ +Licensed under the Apache License, Version 2.0 (the "License"):
- +
+ +you may not use this file except in compliance with the License.
- +
+ +You may obtain a copy of the License at
- +
+ +- +
+ +http://www.apache.org/licenses/LICENSE-2.0
- +
+ +- +
+ +Unless required by applicable law or agreed to in writing, software
- +
+ +distributed under the License is distributed on an "AS IS" BASIS,
- +
+ +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
+ +See the License for the specific language governing permissions and
- +
+ +limitations under the License.
- +
+ +*/
- +
+ +- +
+ +constructor function ut_data_value_yminterval(self in out nocopy ut_data_value_yminterval, a_value yminterval_unconstrained) return self as result is
- +
+ +begin
- + 76 +
+ +self.data_value := a_value;
- + 76 +
+ +self.self_type := $$plsql_unit;
- + 76 +
+ +self.data_type := 'interval year to month';
- + 76 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +overriding member function is_null return boolean is
- +
+ +begin
- + 20 +
+ +return (self.data_value is null);
- +
+ +end;
- +
+ +- +
+ +overriding member function to_string return varchar2 is
- +
+ +begin
- + 72 +
+ +return ut_utils.to_string(self.data_value);
- +
+ +end;
- +
+ +- +
+ +overriding member function compare_implementation(a_other ut_data_value) return integer is
- +
+ +l_result integer;
- +
+ +l_other ut_data_value_yminterval;
- +
+ +begin
- + 40 +
+ +if a_other is of (ut_data_value_yminterval) then
- + 40 +
+ +l_other := treat(a_other as ut_data_value_yminterval);
- + 40 +
+ +if self.data_value = l_other.data_value then
- + 5 +
+ +l_result := 0;
- + 35 +
+ +elsif self.data_value > l_other.data_value then
- + 16 +
+ +l_result := 1;
- + 19 +
+ +elsif self.data_value < l_other.data_value then
- + 7 +
+ +l_result := -1;
- +
+ +end if;
- +
+ +end if;
- + 40 +
+ +return l_result;
- +
+ +end;
- +
+end;
+UT3.UT_JSON_LEAF
100 % lines covered
12 relevant lines. 12 lines covered and 0 lines missed+ +
- +
+ +type body ut_json_leaf as
- +
+ +- +
+ +member procedure init( self in out nocopy ut_json_leaf,
- +
+ +a_element_name varchar2, a_element_value varchar2,a_parent_name varchar2,
- +
+ +a_access_path varchar2, a_hierarchy_level integer, a_index_position integer, a_json_type in varchar2,
- +
+ +a_parent_type varchar2, a_array_element integer:=0, a_parent_path varchar2) is
- +
+ +begin
- + 1654 +
+ +self.element_name := a_element_name;
- + 1654 +
+ +self.element_value := a_element_value;
- + 1654 +
+ +self.parent_name := a_parent_name;
- + 1654 +
+ +self.hierarchy_level := a_hierarchy_level;
- + 1654 +
+ +self.access_path := a_access_path;
- + 1654 +
+ +self.index_position := a_index_position;
- + 1654 +
+ +self.json_type := a_json_type;
- + 1654 +
+ +self.is_array_element := a_array_element;
- + 1654 +
+ +self.parent_type := a_parent_type;
- + 1654 +
+ +self.parent_path := a_parent_path;
- +
+ +end;
- +
+ +- +
+ +constructor function ut_json_leaf( self in out nocopy ut_json_leaf,
- +
+ +a_element_name varchar2, a_element_value varchar2,a_parent_name varchar2,
- +
+ +a_access_path varchar2, a_hierarchy_level integer, a_index_position integer, a_json_type in varchar2,
- +
+ +a_parent_type varchar2, a_array_element integer:=0, a_parent_path varchar2)
- +
+ +return self as result is
- +
+ +begin
- + 1654 +
+ +init(a_element_name,a_element_value,a_parent_name, a_access_path, a_hierarchy_level, a_index_position,
- +
+ +a_json_type,a_parent_type,a_array_element, a_parent_path);
- + 1654 +
+ +return;
- +
+ +end;
- +
+ +- +
+end;
+UT3.UT_JSON_TREE_DETAILS
93.94 % lines covered
66 relevant lines. 62 lines covered (including 6 lines partially covered ) and 4 lines missed+ +
- +
+ +type body ut_json_tree_details as
- +
+ +- +
+ +member function get_json_type(a_json_piece json_element_t) return varchar2 is
- +
+ +begin
- + 1654 +
+ +return
- + 1 +
+ +case
- + 1 +
+ +when a_json_piece.is_object then 'object'
- + 1 +
+ +when a_json_piece.is_array then 'array'
- + 1 +
+ +when a_json_piece.is_string then 'string'
- + 1 +
+ +when a_json_piece.is_number then 'number'
- + 1 +
+ +when a_json_piece.is_boolean then 'boolean'
- + 1 +
+ +when a_json_piece.is_true then 'true'
- + 1 +
+ +when a_json_piece.is_false then 'false'
- + 1 +
+ +when a_json_piece.is_null then 'null'
- +
+ +when a_json_piece.is_date then 'date'
- +
+ +when a_json_piece.is_timestamp then 'timestamp'
- +
+ +when a_json_piece.is_scalar then 'scalar'
- +
+ +else null
- +
+ +end;
- +
+ +end;
- +
+ +- +
+ +member function get_json_value(a_json_piece json_element_t, a_key varchar2) return varchar2 is
- +
+ +l_json_el json_element_t;
- +
+ +l_val varchar2(4000);
- +
+ +begin
- + 1148 +
+ +l_json_el := treat(a_json_piece as json_object_t).get(a_key);
- + 1148 +
+ +case
- + 1855 +
+ +when l_json_el.is_string then l_val := ut_utils.to_string(l_json_el.to_string(),null);
- + 700 +
+ +when l_json_el.is_number then l_val := ut_utils.to_string(l_json_el.to_number());
- + 232 +
+ +when l_json_el.is_boolean then l_val := ut_utils.to_string(l_json_el.to_boolean());
- +
+ +-- when l_json_el.is_true then l_val := ut_utils.to_string(l_json_el.to_boolean());
- +
+ +-- when l_json_el.is_false then l_val := ut_utils.to_string(l_json_el.to_boolean());
- + 1/2 + 132 +
+ +when l_json_el.is_date then l_val := ut_utils.to_string(l_json_el.to_date());
- + 1/2 + 132 +
+ +when l_json_el.is_timestamp then l_val := ut_utils.to_string(l_json_el.to_date());
- + 132 +
+ +else null;
- +
+ +end case;
- + 1148 +
+ +return l_val;
- +
+ +end;
- +
+ +- +
+ +member function get_json_value(a_json_piece json_element_t, a_key integer) return varchar2 is
- +
+ +l_json_el json_element_t;
- +
+ +l_val varchar2(4000);
- +
+ +begin
- + 506 +
+ +l_json_el := treat(a_json_piece as json_array_t).get(a_key);
- + 506 +
+ +case
- + 860 +
+ +when l_json_el.is_string then l_val := ut_utils.to_string(l_json_el.to_string(),null);
- + 1/2 + 152 +
+ +when l_json_el.is_number then l_val := ut_utils.to_string(l_json_el.to_number());
- + 1/2 + 152 +
+ +when l_json_el.is_boolean then l_val := ut_utils.to_string(l_json_el.to_boolean());
- +
+ +-- when l_json_el.is_true then l_val := ut_utils.to_string(l_json_el.to_boolean());
- +
+ +-- when l_json_el.is_false then l_val := ut_utils.to_string(l_json_el.to_boolean());
- + 1/2 + 152 +
+ +when l_json_el.is_date then l_val := ut_utils.to_string(l_json_el.to_date());
- + 1/2 + 152 +
+ +when l_json_el.is_timestamp then l_val := ut_utils.to_string(l_json_el.to_date());
- + 152 +
+ +else null;
- +
+ +end case;
- + 506 +
+ +return l_val;
- +
+ +end;
- +
+ +- +
+ +member procedure add_json_leaf(
- +
+ +self in out nocopy ut_json_tree_details,
- +
+ +a_element_name varchar2,
- +
+ +a_element_value varchar2,
- +
+ +a_parent_name varchar2,
- +
+ +a_access_path varchar2,
- +
+ +a_hierarchy_level integer,
- +
+ +a_index_position integer,
- +
+ +a_json_type varchar2,
- +
+ +a_parent_type varchar2,
- +
+ +a_array_element integer := 0,
- +
+ +a_parent_path varchar2
- +
+ +) is
- +
+ +begin
- + 1654 +
+ +self.json_tree_info.extend;
- + 1654 +
+ +self.json_tree_info(self.json_tree_info.last) :=
- +
+ +ut_json_leaf(
- +
+ +a_element_name, a_element_value, a_parent_name, a_access_path,
- +
+ +a_hierarchy_level, a_index_position,a_json_type, a_parent_type,
- +
+ +a_array_element, a_parent_path
- +
+ +);
- +
+ +end;
- +
+ +- +
+ +member procedure traverse_object(
- +
+ +self in out nocopy ut_json_tree_details,
- +
+ +a_json_piece json_element_t,
- +
+ +a_parent_name varchar2 := null,
- +
+ +a_hierarchy_level integer := 1,
- +
+ +a_access_path varchar2 := '$'
- +
+ +) as
- +
+ +l_keys json_key_list;
- + 187 +
+ +l_object json_object_t := treat(a_json_piece as json_object_t);
- +
+ +l_path varchar2(32767);
- +
+ +l_type varchar2(50);
- +
+ +l_name varchar2(4000);
- +
+ +begin
- + 187 +
+ +l_keys := coalesce(l_object.get_keys,json_key_list());
- +
+ +- + 1335 +
+ +for i in 1 .. l_keys.count loop
- + 1148 +
+ +l_type := get_json_type(l_object.get(l_keys(i)));
- + 1148 +
+ +l_name := '"'||l_keys(i)||'"';
- + 1148 +
+ +l_path := a_access_path||'.'||l_name;
- +
+ +- + 1148 +
+ +add_json_leaf(
- +
+ +l_name,
- +
+ +get_json_value(l_object,l_keys(i)),
- +
+ +a_parent_name,
- +
+ +l_path,
- +
+ +a_hierarchy_level,
- +
+ +i,
- +
+ +l_type,
- +
+ +'object',
- +
+ +0,
- +
+ +a_access_path
- +
+ +);
- + 1148 +
+ +case l_type
- + 1148 +
+ +when 'array' then
- + 112 +
+ +traverse_array (
- +
+ +treat (l_object.get (l_keys(i)) as json_array_t),
- +
+ +l_name,
- +
+ +a_hierarchy_level + 1,
- +
+ +l_path
- +
+ +);
- + 1036 +
+ +when 'object' then
- + 17 +
+ +traverse_object(
- +
+ +treat (l_object.get (l_keys(i)) as json_object_t),
- +
+ +l_name,
- +
+ +a_hierarchy_level+1,
- +
+ +l_path
- +
+ +);
- +
+ +else
- + 1019 +
+ +null;
- +
+ +end case;
- +
+ +end loop;
- +
+ +end traverse_object;
- +
+ +- +
+ +member procedure traverse_array(
- +
+ +self in out nocopy ut_json_tree_details,
- +
+ +a_json_piece json_element_t,
- +
+ +a_parent_name varchar2 := null,
- +
+ +a_hierarchy_level integer := 1,
- +
+ +a_access_path varchar2 := '$'
- +
+ +) as
- +
+ +l_array json_array_t;
- +
+ +l_type varchar2(50);
- +
+ +l_name varchar2(4000);
- +
+ +l_path varchar2(32767);
- +
+ +begin
- + 125 +
+ +l_array := treat(a_json_piece as json_array_t);
- +
+ +- + 631 +
+ +for i in 0 .. l_array.get_size - 1 loop
- + 506 +
+ +l_type := get_json_type(l_array.get(i));
- + 506 +
+ +l_name := case when l_type = 'object' then l_type else l_array.get(i).stringify end;
- + 506 +
+ +l_path := a_access_path||'['||i||']';
- +
+ +- + 506 +
+ +add_json_leaf(
- +
+ +l_name,
- +
+ +get_json_value(a_json_piece,i),
- +
+ +a_parent_name,
- +
+ +l_path,
- +
+ +a_hierarchy_level,
- +
+ +i,
- +
+ +l_type,
- +
+ +'array',
- +
+ +1,
- +
+ +l_path
- +
+ +);
- + 506 +
+ +case l_type
- + 506 +
+ +when 'array' then
- +
+ +traverse_array (
- +
+ +treat (l_array.get (i) as json_array_t),
- +
+ +l_name,
- +
+ +a_hierarchy_level + 1,
- +
+ +l_path
- +
+ +);
- + 506 +
+ +when 'object' then
- + 152 +
+ +traverse_object(
- +
+ +treat (l_array.get (i) as json_object_t),
- +
+ +l_name,
- +
+ +a_hierarchy_level + 1,
- +
+ +l_path
- +
+ +);
- +
+ +else
- + 354 +
+ +null;
- +
+ +end case;
- +
+ +end loop;
- +
+ +end traverse_array;
- +
+ +- +
+ +member procedure init(self in out nocopy ut_json_tree_details,a_json_doc in json_element_t, a_level_in integer := 0) is
- +
+ +begin
- + 31 +
+ +if a_json_doc.is_object then
- + 18 +
+ +traverse_object(treat (a_json_doc as json_object_t));
- + 13 +
+ +elsif a_json_doc.is_array then
- + 13 +
+ +traverse_array(treat (a_json_doc as json_array_t));
- +
+ +end if;
- +
+ +end;
- +
+ +- +
+ +constructor function ut_json_tree_details(
- +
+ +self in out nocopy ut_json_tree_details, a_json_doc in json_element_t, a_level_in integer := 0
- +
+ +) return self as result is
- +
+ +begin
- + 33 +
+ +self.json_tree_info := ut_json_leaf_tab();
- + 33 +
+ +if a_json_doc is not null then
- + 31 +
+ +init(a_json_doc,a_level_in);
- +
+ +end if;
- + 33 +
+ +return;
- +
+ +end;
- +
+ +- +
+end;
+UT3.UT_KEY_ANYVALUES
42.11 % lines covered
19 relevant lines. 8 lines covered and 11 lines missed+ +
- +
+ +type body ut_key_anyvalues as
- +
+ +/*
- +
+ +utPLSQL - Version 3
- +
+ +Copyright 2016 - 2019 utPLSQL Project
- +
+ +- +
+ +Licensed under the Apache License, Version 2.0 (the "License"):
- +
+ +you may not use this file except in compliance with the License.
- +
+ +You may obtain a copy of the License at
- +
+ +- +
+ +http://www.apache.org/licenses/LICENSE-2.0
- +
+ +- +
+ +Unless required by applicable law or agreed to in writing, software
- +
+ +distributed under the License is distributed on an "AS IS" BASIS,
- +
+ +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
+ +See the License for the specific language governing permissions and
- +
+ +limitations under the License.
- +
+ +*/
- +
+ +constructor function ut_key_anyvalues(self in out nocopy ut_key_anyvalues) return self as result is
- +
+ +begin
- + 225 +
+ +self.self_type := $$plsql_unit;
- + 225 +
+ +self.pairs := ut_key_anyval_pairs();
- + 225 +
+ +return;
- +
+ +end;
- +
+ +member function put(a_item ut_key_anyval_pair) return ut_key_anyvalues is
- + 225 +
+ +l_result ut_key_anyvalues := self;
- +
+ +begin
- + 225 +
+ +l_result.pairs.extend();
- + 225 +
+ +l_result.pairs(l_result.pairs.last) := a_item;
- + 225 +
+ +return l_result;
- +
+ +end;
- +
+ +member function put(a_key varchar2, a_value anydata) return ut_key_anyvalues is
- +
+ +begin
- +
+ +return put(ut_key_anyval_pair(a_key, ut_data_value_anydata(a_value)));
- +
+ +end;
- +
+ +- +
+ +member function put(a_key varchar2, a_value blob) return ut_key_anyvalues is
- +
+ +begin
- +
+ +return put(ut_key_anyval_pair(a_key, ut_data_value_blob(a_value)));
- +
+ +end;
- +
+ +- +
+ +member function put(a_key varchar2, a_value boolean) return ut_key_anyvalues is
- +
+ +begin
- +
+ +return put(ut_key_anyval_pair(a_key, ut_data_value_boolean(a_value)));
- +
+ +end;
- +
+ +- +
+ +member function put(a_key varchar2, a_value clob) return ut_key_anyvalues is
- +
+ +begin
- +
+ +return put(ut_key_anyval_pair(a_key, ut_data_value_clob(a_value)));
- +
+ +end;
- +
+ +- +
+ +member function put(a_key varchar2, a_value date) return ut_key_anyvalues is
- +
+ +begin
- +
+ +return put(ut_key_anyval_pair(a_key, ut_data_value_date(a_value)));
- +
+ +end;
- +
+ +- +
+ +member function put(a_key varchar2, a_value number) return ut_key_anyvalues is
- +
+ +begin
- +
+ +return put(ut_key_anyval_pair(a_key, ut_data_value_number(a_value)));
- +
+ +end;
- +
+ +member function put(a_key varchar2, a_value timestamp_unconstrained) return ut_key_anyvalues is
- +
+ +begin
- +
+ +return put(ut_key_anyval_pair(a_key, ut_data_value_timestamp(a_value)));
- +
+ +end;
- +
+ +- +
+ +member function put(a_key varchar2, a_value timestamp_ltz_unconstrained) return ut_key_anyvalues is
- +
+ +begin
- +
+ +return put(ut_key_anyval_pair(a_key, ut_data_value_timestamp_ltz(a_value)));
- +
+ +end;
- +
+ +- +
+ +member function put(a_key varchar2, a_value timestamp_tz_unconstrained) return ut_key_anyvalues is
- +
+ +begin
- +
+ +return put(ut_key_anyval_pair(a_key, ut_data_value_timestamp_tz(a_value)));
- +
+ +end;
- +
+ +- +
+ +member function put(a_key varchar2, a_value varchar2) return ut_key_anyvalues is
- +
+ +begin
- + 225 +
+ +return put(ut_key_anyval_pair(a_key, ut_data_value_varchar2(a_value)));
- +
+ +end;
- +
+ +- +
+ +member function put(a_key varchar2, a_value yminterval_unconstrained) return ut_key_anyvalues is
- +
+ +begin
- +
+ +return put(ut_key_anyval_pair(a_key, ut_data_value_yminterval(a_value)));
- +
+ +end;
- +
+ +- +
+ +member function put(a_key varchar2, a_value dsinterval_unconstrained) return ut_key_anyvalues is
- +
+ +begin
- +
+ +return put(ut_key_anyval_pair(a_key, ut_data_value_dsinterval(a_value)));
- +
+ +end;
- +
+end;
+UT3.UT_BE_BETWEEN
100 % lines covered
28 relevant lines. 28 lines covered and 0 lines missed+ +
- +
+ +type body ut_be_between is
- +
+ +/*
- +
+ +utPLSQL - Version 3
- +
+ +Copyright 2016 - 2019 utPLSQL Project
- +
+ +- +
+ +Licensed under the Apache License, Version 2.0 (the "License"):
- +
+ +you may not use this file except in compliance with the License.
- +
+ +You may obtain a copy of the License at
- +
+ +- +
+ +http://www.apache.org/licenses/LICENSE-2.0
- +
+ +- +
+ +Unless required by applicable law or agreed to in writing, software
- +
+ +distributed under the License is distributed on an "AS IS" BASIS,
- +
+ +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
+ +See the License for the specific language governing permissions and
- +
+ +limitations under the License.
- +
+ +*/
- +
+ +- +
+ +member procedure init(self in out nocopy ut_be_between, a_lower_bound ut_data_value, a_upper_bound ut_data_value) is
- +
+ +begin
- + 71 +
+ +self.self_type := $$plsql_unit;
- + 71 +
+ +self.lower_bound := a_lower_bound;
- + 71 +
+ +self.upper_bound := a_upper_bound;
- +
+ +end;
- +
+ +- +
+ +constructor function ut_be_between(self in out nocopy ut_be_between, a_lower_bound date, a_upper_bound date)
- +
+ +return self as result is
- +
+ +begin
- + 8 +
+ +init(ut_data_value_date(a_lower_bound), ut_data_value_date(a_upper_bound));
- + 8 +
+ +return;
- +
+ +end;
- +
+ +constructor function ut_be_between(self in out nocopy ut_be_between, a_lower_bound number, a_upper_bound number)
- +
+ +return self as result is
- +
+ +begin
- + 8 +
+ +init(ut_data_value_number(a_lower_bound), ut_data_value_number(a_upper_bound));
- + 8 +
+ +return;
- +
+ +end;
- +
+ +constructor function ut_be_between(self in out nocopy ut_be_between, a_lower_bound varchar2, a_upper_bound varchar2)
- +
+ +return self as result is
- +
+ +begin
- + 9 +
+ +init(ut_data_value_varchar2(a_lower_bound), ut_data_value_varchar2(a_upper_bound));
- + 9 +
+ +return;
- +
+ +end;
- +
+ +constructor function ut_be_between(self in out nocopy ut_be_between, a_lower_bound timestamp_unconstrained, a_upper_bound timestamp_unconstrained)
- +
+ +return self as result is
- +
+ +begin
- + 10 +
+ +init(ut_data_value_timestamp(a_lower_bound), ut_data_value_timestamp(a_upper_bound));
- + 10 +
+ +return;
- +
+ +end;
- +
+ +constructor function ut_be_between(self in out nocopy ut_be_between, a_lower_bound timestamp_tz_unconstrained, a_upper_bound timestamp_tz_unconstrained)
- +
+ +return self as result is
- +
+ +begin
- + 10 +
+ +init(ut_data_value_timestamp_tz(a_lower_bound), ut_data_value_timestamp_tz(a_upper_bound));
- + 10 +
+ +return;
- +
+ +end;
- +
+ +constructor function ut_be_between(self in out nocopy ut_be_between, a_lower_bound timestamp_ltz_unconstrained, a_upper_bound timestamp_ltz_unconstrained)
- +
+ +return self as result is
- +
+ +begin
- + 10 +
+ +init(ut_data_value_timestamp_ltz(a_lower_bound), ut_data_value_timestamp_ltz(a_upper_bound));
- + 10 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +constructor function ut_be_between(self in out nocopy ut_be_between, a_lower_bound yminterval_unconstrained, a_upper_bound yminterval_unconstrained)
- +
+ +return self as result is
- +
+ +begin
- + 8 +
+ +init(ut_data_value_yminterval(a_lower_bound), ut_data_value_yminterval(a_upper_bound));
- + 8 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +constructor function ut_be_between(self in out nocopy ut_be_between, a_lower_bound dsinterval_unconstrained, a_upper_bound dsinterval_unconstrained)
- +
+ +return self as result is
- +
+ +begin
- + 8 +
+ +init(ut_data_value_dsinterval(a_lower_bound), ut_data_value_dsinterval(a_upper_bound));
- + 8 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +overriding member function run_matcher(self in out nocopy ut_be_between, a_actual ut_data_value) return boolean is
- +
+ +l_lower_result boolean;
- +
+ +l_upper_result boolean;
- +
+ +l_result boolean;
- +
+ +begin
- + 71 +
+ +if self.lower_bound.data_type = a_actual.data_type then
- + 70 +
+ +l_lower_result := a_actual >= self.lower_bound;
- + 70 +
+ +l_upper_result := a_actual <= self.upper_bound;
- + 70 +
+ +if l_lower_result is not null and l_upper_result is not null then
- + 38 +
+ +l_result := l_lower_result and l_upper_result;
- +
+ +end if;
- +
+ +else
- + 1 +
+ +l_result := (self as ut_matcher).run_matcher(a_actual);
- +
+ +end if;
- + 71 +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+ +overriding member function failure_message(a_actual ut_data_value) return varchar2 is
- +
+ +begin
- + 35 +
+ +return (self as ut_matcher).failure_message(a_actual)
- +
+ +|| ': '|| self.lower_bound.to_string_report(true,false)
- +
+ +|| ' and ' || self.upper_bound.to_string_report(a_with_object_info => false);
- +
+ +end;
- +
+ +- +
+ +overriding member function failure_message_when_negated(a_actual ut_data_value) return varchar2 is
- +
+ +begin
- + 35 +
+ +return (self as ut_matcher).failure_message_when_negated(a_actual)
- +
+ +|| ': '|| self.lower_bound.to_string_report(true,false)
- +
+ +|| ' and ' || self.upper_bound.to_string_report(a_with_object_info => false);
- +
+ +end;
- +
+ +- +
+end;
+UT3.UT_BE_EMPTY
100 % lines covered
6 relevant lines. 6 lines covered and 0 lines missed+ +
- +
+ +type body ut_be_empty as
- +
+ +/*
- +
+ +utPLSQL - Version 3
- +
+ +Copyright 2016 - 2019 utPLSQL Project
- +
+ +- +
+ +Licensed under the Apache License, Version 2.0 (the "License"):
- +
+ +you may not use this file except in compliance with the License.
- +
+ +You may obtain a copy of the License at
- +
+ +- +
+ +http://www.apache.org/licenses/LICENSE-2.0
- +
+ +- +
+ +Unless required by applicable law or agreed to in writing, software
- +
+ +distributed under the License is distributed on an "AS IS" BASIS,
- +
+ +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
+ +See the License for the specific language governing permissions and
- +
+ +limitations under the License.
- +
+ +*/
- +
+ +- +
+ +member procedure init(self in out nocopy ut_be_empty) is
- +
+ +begin
- + 35 +
+ +self.self_type := $$plsql_unit;
- +
+ +end;
- +
+ +- +
+ +constructor function ut_be_empty(self in out nocopy ut_be_empty) return self as result is
- +
+ +begin
- + 35 +
+ +init();
- + 35 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +overriding member function run_matcher(self in out nocopy ut_be_empty, a_actual ut_data_value) return boolean is
- +
+ +l_result boolean;
- +
+ +begin
- + 35 +
+ +return a_actual.is_empty();
- +
+ +exception
- + 12 +
+ +when value_error then
- + 6 +
+ +return (self as ut_matcher).run_matcher(a_actual);
- +
+ +end;
- +
+ +- +
+end;
+UT3.UT_BE_FALSE
100 % lines covered
6 relevant lines. 6 lines covered and 0 lines missed+ +
- +
+ +type body ut_be_false as
- +
+ +/*
- +
+ +utPLSQL - Version 3
- +
+ +Copyright 2016 - 2019 utPLSQL Project
- +
+ +- +
+ +Licensed under the Apache License, Version 2.0 (the "License"):
- +
+ +you may not use this file except in compliance with the License.
- +
+ +You may obtain a copy of the License at
- +
+ +- +
+ +http://www.apache.org/licenses/LICENSE-2.0
- +
+ +- +
+ +Unless required by applicable law or agreed to in writing, software
- +
+ +distributed under the License is distributed on an "AS IS" BASIS,
- +
+ +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
+ +See the License for the specific language governing permissions and
- +
+ +limitations under the License.
- +
+ +*/
- +
+ +- +
+ +constructor function ut_be_false(self in out nocopy ut_be_false) return self as result is
- +
+ +begin
- + 8 +
+ +self.self_type := $$plsql_unit;
- + 8 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +overriding member function run_matcher(self in out nocopy ut_be_false, a_actual ut_data_value) return boolean is
- +
+ +l_result boolean;
- +
+ +begin
- + 8 +
+ +if a_actual is of (ut_data_value_boolean) then
- + 6 +
+ +l_result := not ut_utils.int_to_boolean(treat(a_actual as ut_data_value_boolean).data_value);
- +
+ +else
- + 2 +
+ +l_result := (self as ut_matcher).run_matcher(a_actual);
- +
+ +end if;
- + 8 +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+end;
+UT3.UT_BE_GREATER_OR_EQUAL
100 % lines covered
22 relevant lines. 22 lines covered and 0 lines missed+ +
- +
+ +type body ut_be_greater_or_equal AS
- +
+ +/*
- +
+ +utPLSQL - Version 3
- +
+ +Copyright 2016 - 2019 utPLSQL Project
- +
+ +- +
+ +Licensed under the Apache License, Version 2.0 (the "License"):
- +
+ +you may not use this file except in compliance with the License.
- +
+ +You may obtain a copy of the License at
- +
+ +- +
+ +http://www.apache.org/licenses/LICENSE-2.0
- +
+ +- +
+ +Unless required by applicable law or agreed to in writing, software
- +
+ +distributed under the License is distributed on an "AS IS" BASIS,
- +
+ +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
+ +See the License for the specific language governing permissions and
- +
+ +limitations under the License.
- +
+ +*/
- +
+ +- +
+ +member procedure init(self in out nocopy ut_be_greater_or_equal, a_expected ut_data_value) is
- +
+ +begin
- + 29 +
+ +self.self_type := $$plsql_unit;
- + 29 +
+ +self.expected := a_expected;
- +
+ +end;
- +
+ +- +
+ +constructor function ut_be_greater_or_equal(self in out nocopy ut_be_greater_or_equal, a_expected date) return self as result is
- +
+ +begin
- + 4 +
+ +init(ut_data_value_date(a_expected));
- + 4 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +constructor function ut_be_greater_or_equal(self in out nocopy ut_be_greater_or_equal, a_expected NUMBER) return self as result is
- +
+ +begin
- + 5 +
+ +init(ut_data_value_number(a_expected));
- + 5 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +constructor function ut_be_greater_or_equal(self in out nocopy ut_be_greater_or_equal, a_expected timestamp_unconstrained) return self as result is
- +
+ +begin
- + 4 +
+ +init(ut_data_value_timestamp(a_expected));
- + 4 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +constructor function ut_be_greater_or_equal(self in out nocopy ut_be_greater_or_equal, a_expected timestamp_tz_unconstrained) return self as result is
- +
+ +begin
- + 4 +
+ +init(ut_data_value_timestamp_tz(a_expected));
- + 4 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +constructor function ut_be_greater_or_equal(self in out nocopy ut_be_greater_or_equal, a_expected timestamp_ltz_unconstrained) return self as result is
- +
+ +begin
- + 4 +
+ +init(ut_data_value_timestamp_ltz(a_expected));
- + 4 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +constructor function ut_be_greater_or_equal(self in out nocopy ut_be_greater_or_equal, a_expected yminterval_unconstrained) return self as RESULT IS
- +
+ +begin
- + 4 +
+ +init(ut_data_value_yminterval(a_expected));
- + 4 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +constructor function ut_be_greater_or_equal(self in out nocopy ut_be_greater_or_equal, a_expected dsinterval_unconstrained) return self as RESULT IS
- +
+ +begin
- + 4 +
+ +init(ut_data_value_dsinterval(a_expected));
- + 4 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +overriding member function run_matcher(self in out nocopy ut_be_greater_or_equal, a_actual ut_data_value) return boolean is
- +
+ +l_result boolean;
- +
+ +begin
- + 29 +
+ +if self.expected.data_type = a_actual.data_type then
- + 28 +
+ +l_result := a_actual >= self.expected;
- +
+ +else
- + 1 +
+ +l_result := (self as ut_matcher).run_matcher(a_actual);
- +
+ +end if;
- + 29 +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+ +overriding member function failure_message(a_actual ut_data_value) return varchar2 is
- +
+ +begin
- + 21 +
+ +return (self as ut_matcher).failure_message(a_actual) || ': '|| expected.to_string_report();
- +
+ +end;
- +
+ +- +
+ +overriding member function failure_message_when_negated(a_actual ut_data_value) return varchar2 is
- +
+ +begin
- + 7 +
+ +return (self as ut_matcher).failure_message_when_negated(a_actual) || ': '|| expected.to_string_report();
- +
+ +end;
- +
+ +- +
+end;
+UT3.UT_BE_GREATER_THAN
100 % lines covered
22 relevant lines. 22 lines covered and 0 lines missed+ +
- +
+ +type body ut_be_greater_than AS
- +
+ +/*
- +
+ +utPLSQL - Version 3
- +
+ +Copyright 2016 - 2019 utPLSQL Project
- +
+ +- +
+ +Licensed under the Apache License, Version 2.0 (the "License"):
- +
+ +you may not use this file except in compliance with the License.
- +
+ +You may obtain a copy of the License at
- +
+ +- +
+ +http://www.apache.org/licenses/LICENSE-2.0
- +
+ +- +
+ +Unless required by applicable law or agreed to in writing, software
- +
+ +distributed under the License is distributed on an "AS IS" BASIS,
- +
+ +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
+ +See the License for the specific language governing permissions and
- +
+ +limitations under the License.
- +
+ +*/
- +
+ +- +
+ +member procedure init(self in out nocopy ut_be_greater_than, a_expected ut_data_value) is
- +
+ +begin
- + 30 +
+ +self.self_type := $$plsql_unit;
- + 30 +
+ +self.expected := a_expected;
- +
+ +end;
- +
+ +- +
+ +constructor function ut_be_greater_than(self in out nocopy ut_be_greater_than, a_expected date) return self as result is
- +
+ +begin
- + 4 +
+ +init(ut_data_value_date(a_expected));
- + 4 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +constructor function ut_be_greater_than(self in out nocopy ut_be_greater_than, a_expected NUMBER) return self as result is
- +
+ +begin
- + 6 +
+ +init(ut_data_value_number(a_expected));
- + 6 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +constructor function ut_be_greater_than(self in out nocopy ut_be_greater_than, a_expected timestamp_unconstrained) return self as result is
- +
+ +begin
- + 4 +
+ +init(ut_data_value_timestamp(a_expected));
- + 4 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +constructor function ut_be_greater_than(self in out nocopy ut_be_greater_than, a_expected timestamp_tz_unconstrained) return self as result is
- +
+ +begin
- + 4 +
+ +init(ut_data_value_timestamp_tz(a_expected));
- + 4 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +constructor function ut_be_greater_than(self in out nocopy ut_be_greater_than, a_expected timestamp_ltz_unconstrained) return self as result is
- +
+ +begin
- + 4 +
+ +init(ut_data_value_timestamp_ltz(a_expected));
- + 4 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +constructor function ut_be_greater_than(self in out nocopy ut_be_greater_than, a_expected yminterval_unconstrained) return self as RESULT IS
- +
+ +begin
- + 4 +
+ +init(ut_data_value_yminterval(a_expected));
- + 4 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +constructor function ut_be_greater_than(self in out nocopy ut_be_greater_than, a_expected dsinterval_unconstrained) return self as RESULT IS
- +
+ +begin
- + 4 +
+ +init(ut_data_value_dsinterval(a_expected));
- + 4 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +overriding member function run_matcher(self in out nocopy ut_be_greater_than, a_actual ut_data_value) return boolean is
- +
+ +l_result boolean;
- +
+ +begin
- + 30 +
+ +if self.expected.data_type = a_actual.data_type then
- + 29 +
+ +l_result := a_actual > self.expected;
- +
+ +else
- + 1 +
+ +l_result := (self as ut_matcher).run_matcher(a_actual);
- +
+ +end if;
- + 30 +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+ +overriding member function failure_message(a_actual ut_data_value) return varchar2 is
- +
+ +begin
- + 22 +
+ +return (self as ut_matcher).failure_message(a_actual) || ': '|| expected.to_string_report();
- +
+ +end;
- +
+ +- +
+ +overriding member function failure_message_when_negated(a_actual ut_data_value) return varchar2 is
- +
+ +begin
- + 7 +
+ +return (self as ut_matcher).failure_message_when_negated(a_actual) || ': '|| expected.to_string_report();
- +
+ +end;
- +
+ +- +
+end;
+UT3.UT_BE_LESS_OR_EQUAL
100 % lines covered
22 relevant lines. 22 lines covered and 0 lines missed+ +
- +
+ +type body ut_be_less_or_equal AS
- +
+ +/*
- +
+ +utPLSQL - Version 3
- +
+ +Copyright 2016 - 2019 utPLSQL Project
- +
+ +- +
+ +Licensed under the Apache License, Version 2.0 (the "License"):
- +
+ +you may not use this file except in compliance with the License.
- +
+ +You may obtain a copy of the License at
- +
+ +- +
+ +http://www.apache.org/licenses/LICENSE-2.0
- +
+ +- +
+ +Unless required by applicable law or agreed to in writing, software
- +
+ +distributed under the License is distributed on an "AS IS" BASIS,
- +
+ +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
+ +See the License for the specific language governing permissions and
- +
+ +limitations under the License.
- +
+ +*/
- +
+ +- +
+ +member procedure init(self in out nocopy ut_be_less_or_equal, a_expected ut_data_value) is
- +
+ +begin
- + 29 +
+ +self.self_type := $$plsql_unit;
- + 29 +
+ +self.expected := a_expected;
- +
+ +end;
- +
+ +- +
+ +constructor function ut_be_less_or_equal(self in out nocopy ut_be_less_or_equal, a_expected date) return self as result is
- +
+ +begin
- + 4 +
+ +init(ut_data_value_date(a_expected));
- + 4 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +constructor function ut_be_less_or_equal(self in out nocopy ut_be_less_or_equal, a_expected NUMBER) return self as result is
- +
+ +begin
- + 5 +
+ +init(ut_data_value_number(a_expected));
- + 5 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +constructor function ut_be_less_or_equal(self in out nocopy ut_be_less_or_equal, a_expected timestamp_unconstrained) return self as result is
- +
+ +begin
- + 4 +
+ +init(ut_data_value_timestamp(a_expected));
- + 4 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +constructor function ut_be_less_or_equal(self in out nocopy ut_be_less_or_equal, a_expected timestamp_tz_unconstrained) return self as result is
- +
+ +begin
- + 4 +
+ +init(ut_data_value_timestamp_tz(a_expected));
- + 4 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +constructor function ut_be_less_or_equal(self in out nocopy ut_be_less_or_equal, a_expected timestamp_ltz_unconstrained) return self as result is
- +
+ +begin
- + 4 +
+ +init(ut_data_value_timestamp_ltz(a_expected));
- + 4 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +constructor function ut_be_less_or_equal(self in out nocopy ut_be_less_or_equal, a_expected yminterval_unconstrained) return self as RESULT IS
- +
+ +begin
- + 4 +
+ +init(ut_data_value_yminterval(a_expected));
- + 4 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +constructor function ut_be_less_or_equal(self in out nocopy ut_be_less_or_equal, a_expected dsinterval_unconstrained) return self as RESULT IS
- +
+ +begin
- + 4 +
+ +init(ut_data_value_dsinterval(a_expected));
- + 4 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +overriding member function run_matcher(self in out nocopy ut_be_less_or_equal, a_actual ut_data_value) return boolean is
- +
+ +l_result boolean;
- +
+ +begin
- + 29 +
+ +if self.expected.data_type = a_actual.data_type then
- + 28 +
+ +l_result := a_actual <= self.expected;
- +
+ +else
- + 1 +
+ +l_result := (self as ut_matcher).run_matcher(a_actual);
- +
+ +end if;
- + 29 +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+ +overriding member function failure_message(a_actual ut_data_value) return varchar2 is
- +
+ +begin
- + 21 +
+ +return (self as ut_matcher).failure_message(a_actual) || ': '|| expected.to_string_report();
- +
+ +end;
- +
+ +- +
+ +overriding member function failure_message_when_negated(a_actual ut_data_value) return varchar2 is
- +
+ +begin
- + 7 +
+ +return (self as ut_matcher).failure_message_when_negated(a_actual) || ': '|| expected.to_string_report();
- +
+ +end;
- +
+ +- +
+end;
+UT3.UT_BE_LESS_THAN
100 % lines covered
22 relevant lines. 22 lines covered and 0 lines missed+ +
- +
+ +type body ut_be_less_than as
- +
+ +/*
- +
+ +utPLSQL - Version 3
- +
+ +Copyright 2016 - 2019 utPLSQL Project
- +
+ +- +
+ +Licensed under the Apache License, Version 2.0 (the "License"):
- +
+ +you may not use this file except in compliance with the License.
- +
+ +You may obtain a copy of the License at
- +
+ +- +
+ +http://www.apache.org/licenses/LICENSE-2.0
- +
+ +- +
+ +Unless required by applicable law or agreed to in writing, software
- +
+ +distributed under the License is distributed on an "AS IS" BASIS,
- +
+ +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
+ +See the License for the specific language governing permissions and
- +
+ +limitations under the License.
- +
+ +*/
- +
+ +- +
+ +member procedure init(self in out nocopy ut_be_less_than, a_expected ut_data_value) is
- +
+ +begin
- + 29 +
+ +self.self_type := $$plsql_unit;
- + 29 +
+ +self.expected := a_expected;
- +
+ +end;
- +
+ +- +
+ +constructor function ut_be_less_than(self in out nocopy ut_be_less_than, a_expected date) return self as result is
- +
+ +begin
- + 4 +
+ +init(ut_data_value_date(a_expected));
- + 4 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +constructor function ut_be_less_than(self in out nocopy ut_be_less_than, a_expected number) return self as result is
- +
+ +begin
- + 5 +
+ +init(ut_data_value_number(a_expected));
- + 5 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +constructor function ut_be_less_than(self in out nocopy ut_be_less_than, a_expected timestamp_unconstrained)
- +
+ +return self as result is
- +
+ +begin
- + 4 +
+ +init(ut_data_value_timestamp(a_expected));
- + 4 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +constructor function ut_be_less_than(self in out nocopy ut_be_less_than, a_expected timestamp_tz_unconstrained)
- +
+ +return self as result is
- +
+ +begin
- + 4 +
+ +init(ut_data_value_timestamp_tz(a_expected));
- + 4 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +constructor function ut_be_less_than(self in out nocopy ut_be_less_than, a_expected timestamp_ltz_unconstrained)
- +
+ +return self as result is
- +
+ +begin
- + 4 +
+ +init(ut_data_value_timestamp_ltz(a_expected));
- + 4 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +constructor function ut_be_less_than(self in out nocopy ut_be_less_than, a_expected yminterval_unconstrained)
- +
+ +return self as result is
- +
+ +begin
- + 4 +
+ +init(ut_data_value_yminterval(a_expected));
- + 4 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +constructor function ut_be_less_than(self in out nocopy ut_be_less_than, a_expected dsinterval_unconstrained)
- +
+ +return self as result is
- +
+ +begin
- + 4 +
+ +init(ut_data_value_dsinterval(a_expected));
- + 4 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +overriding member function run_matcher(self in out nocopy ut_be_less_than, a_actual ut_data_value) return boolean is
- +
+ +l_result boolean;
- +
+ +begin
- + 29 +
+ +if self.expected.data_type = a_actual.data_type then
- + 28 +
+ +l_result := a_actual < self.expected;
- +
+ +else
- + 1 +
+ +l_result := (self as ut_matcher).run_matcher(a_actual);
- +
+ +end if;
- + 29 +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+ +overriding member function failure_message(a_actual ut_data_value) return varchar2 is
- +
+ +begin
- + 21 +
+ +return (self as ut_matcher).failure_message(a_actual) || ': '|| expected.to_string_report();
- +
+ +end;
- +
+ +- +
+ +overriding member function failure_message_when_negated(a_actual ut_data_value) return varchar2 is
- +
+ +begin
- + 7 +
+ +return (self as ut_matcher).failure_message_when_negated(a_actual) || ': '|| expected.to_string_report();
- +
+ +end;
- +
+ +- +
+end;
+UT3.UT_BE_LIKE
100 % lines covered
23 relevant lines. 23 lines covered and 0 lines missed+ +
- +
+ +type body ut_be_like as
- +
+ +/*
- +
+ +utPLSQL - Version 3
- +
+ +Copyright 2016 - 2019 utPLSQL Project
- +
+ +- +
+ +Licensed under the Apache License, Version 2.0 (the "License"):
- +
+ +you may not use this file except in compliance with the License.
- +
+ +You may obtain a copy of the License at
- +
+ +- +
+ +http://www.apache.org/licenses/LICENSE-2.0
- +
+ +- +
+ +Unless required by applicable law or agreed to in writing, software
- +
+ +distributed under the License is distributed on an "AS IS" BASIS,
- +
+ +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
+ +See the License for the specific language governing permissions and
- +
+ +limitations under the License.
- +
+ +*/
- +
+ +- +
+ +constructor function ut_be_like(self in out nocopy ut_be_like, a_mask in varchar2, a_escape_char in varchar2 := null) return self as result is
- +
+ +begin
- + 17 +
+ +self.self_type := $$plsql_unit;
- + 17 +
+ +self.mask := a_mask;
- + 17 +
+ +self.escape_char := a_escape_char;
- + 17 +
+ +return;
- +
+ +end ut_be_like;
- +
+ +- +
+ +overriding member function run_matcher(self in out nocopy ut_be_like, a_actual ut_data_value) return boolean is
- +
+ +l_value clob;
- +
+ +l_result boolean;
- +
+ +begin
- + 17 +
+ +if a_actual is of (ut_data_value_varchar2, ut_data_value_clob) then
- +
+ +- + 16 +
+ +if a_actual is of (ut_data_value_varchar2) then
- + 8 +
+ +l_value := treat(a_actual as ut_data_value_varchar2).data_value;
- +
+ +else
- + 8 +
+ +l_value := treat(a_actual as ut_data_value_clob).data_value;
- +
+ +end if;
- +
+ +- + 16 +
+ +if escape_char is not null then
- + 8 +
+ +l_result := l_value like mask escape escape_char;
- +
+ +else
- + 8 +
+ +l_result := l_value like mask;
- +
+ +end if;
- +
+ +else
- + 1 +
+ +l_result := (self as ut_matcher).run_matcher(a_actual);
- +
+ +end if;
- + 17 +
+ +return l_result;
- +
+ +end run_matcher;
- +
+ +- +
+ +overriding member function failure_message(a_actual ut_data_value) return varchar2 is
- +
+ +l_result varchar2(32767);
- +
+ +begin
- + 8 +
+ +l_result := (self as ut_matcher).failure_message(a_actual);
- + 8 +
+ +if self.escape_char is not null then
- + 4 +
+ +l_result := l_result || ': '|| ut_data_value_varchar2(self.mask).to_string_report(true, false) || ', escape ''' || self.escape_char ||'''';
- +
+ +else
- + 4 +
+ +l_result := l_result || ': '|| ut_data_value_varchar2(self.mask).to_string_report(false, false);
- +
+ +end if;
- + 8 +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+ +overriding member function failure_message_when_negated(a_actual ut_data_value) return varchar2 is
- +
+ +l_result varchar2(32767);
- +
+ +begin
- + 8 +
+ +l_result := (self as ut_matcher).failure_message_when_negated(a_actual);
- + 8 +
+ +if self.escape_char is not null then
- + 4 +
+ +l_result := l_result || ': '|| ut_data_value_varchar2(self.mask).to_string_report(true, false) || ', escape ''' || self.escape_char ||'''';
- +
+ +else
- + 4 +
+ +l_result := l_result || ': '|| ut_data_value_varchar2(self.mask).to_string_report(false, false);
- +
+ +end if;
- + 8 +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+end;
+UT3.UT_BE_NOT_NULL
100 % lines covered
3 relevant lines. 3 lines covered and 0 lines missed+ +
- +
+ +type body ut_be_not_null as
- +
+ +/*
- +
+ +utPLSQL - Version 3
- +
+ +Copyright 2016 - 2019 utPLSQL Project
- +
+ +- +
+ +Licensed under the Apache License, Version 2.0 (the "License"):
- +
+ +you may not use this file except in compliance with the License.
- +
+ +You may obtain a copy of the License at
- +
+ +- +
+ +http://www.apache.org/licenses/LICENSE-2.0
- +
+ +- +
+ +Unless required by applicable law or agreed to in writing, software
- +
+ +distributed under the License is distributed on an "AS IS" BASIS,
- +
+ +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
+ +See the License for the specific language governing permissions and
- +
+ +limitations under the License.
- +
+ +*/
- +
+ +- +
+ +constructor function ut_be_not_null(self in out nocopy ut_be_not_null) return self as result is
- +
+ +begin
- + 30 +
+ +self.self_type := $$plsql_unit;
- + 30 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +overriding member function run_matcher(self in out nocopy ut_be_not_null, a_actual ut_data_value) return boolean is
- +
+ +begin
- + 30 +
+ +return not a_actual.is_null;
- +
+ +end;
- +
+ +- +
+end;
+UT3.UT_BE_NULL
100 % lines covered
3 relevant lines. 3 lines covered and 0 lines missed+ +
- +
+ +type body ut_be_null as
- +
+ +/*
- +
+ +utPLSQL - Version 3
- +
+ +Copyright 2016 - 2019 utPLSQL Project
- +
+ +- +
+ +Licensed under the Apache License, Version 2.0 (the "License"):
- +
+ +you may not use this file except in compliance with the License.
- +
+ +You may obtain a copy of the License at
- +
+ +- +
+ +http://www.apache.org/licenses/LICENSE-2.0
- +
+ +- +
+ +Unless required by applicable law or agreed to in writing, software
- +
+ +distributed under the License is distributed on an "AS IS" BASIS,
- +
+ +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
+ +See the License for the specific language governing permissions and
- +
+ +limitations under the License.
- +
+ +*/
- +
+ +- +
+ +constructor function ut_be_null(self in out nocopy ut_be_null) return self as result is
- +
+ +begin
- + 72 +
+ +self.self_type := $$plsql_unit;
- + 72 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +overriding member function run_matcher(self in out nocopy ut_be_null, a_actual ut_data_value) return boolean is
- +
+ +begin
- + 72 +
+ +return a_actual.is_null;
- +
+ +end;
- +
+ +- +
+end;
+UT3.UT_BE_TRUE
100 % lines covered
6 relevant lines. 6 lines covered and 0 lines missed+ +
- +
+ +type body ut_be_true as
- +
+ +/*
- +
+ +utPLSQL - Version 3
- +
+ +Copyright 2016 - 2019 utPLSQL Project
- +
+ +- +
+ +Licensed under the Apache License, Version 2.0 (the "License"):
- +
+ +you may not use this file except in compliance with the License.
- +
+ +You may obtain a copy of the License at
- +
+ +- +
+ +http://www.apache.org/licenses/LICENSE-2.0
- +
+ +- +
+ +Unless required by applicable law or agreed to in writing, software
- +
+ +distributed under the License is distributed on an "AS IS" BASIS,
- +
+ +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
+ +See the License for the specific language governing permissions and
- +
+ +limitations under the License.
- +
+ +*/
- +
+ +- +
+ +constructor function ut_be_true(self in out nocopy ut_be_true) return self as result is
- +
+ +begin
- + 8 +
+ +self.self_type := $$plsql_unit;
- + 8 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +overriding member function run_matcher(self in out nocopy ut_be_true, a_actual ut_data_value) return boolean is
- +
+ +l_result boolean;
- +
+ +begin
- + 8 +
+ +if a_actual is of (ut_data_value_boolean) then
- + 6 +
+ +l_result := ut_utils.int_to_boolean( treat(a_actual as ut_data_value_boolean).data_value);
- +
+ +else
- + 2 +
+ +l_result := (self as ut_matcher).run_matcher(a_actual);
- +
+ +end if;
- + 8 +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+end;
+UT3.UT_COMPARISON_MATCHER
100 % lines covered
3 relevant lines. 3 lines covered and 0 lines missed+ +
- +
+ +type body ut_comparison_matcher as
- +
+ +/*
- +
+ +utPLSQL - Version 3
- +
+ +Copyright 2016 - 2019 utPLSQL Project
- +
+ +- +
+ +Licensed under the Apache License, Version 2.0 (the "License"):
- +
+ +you may not use this file except in compliance with the License.
- +
+ +You may obtain a copy of the License at
- +
+ +- +
+ +http://www.apache.org/licenses/LICENSE-2.0
- +
+ +- +
+ +Unless required by applicable law or agreed to in writing, software
- +
+ +distributed under the License is distributed on an "AS IS" BASIS,
- +
+ +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
+ +See the License for the specific language governing permissions and
- +
+ +limitations under the License.
- +
+ +*/
- +
+ +- +
+ +overriding member function error_message(a_actual ut_data_value) return varchar2 is
- +
+ +l_result varchar2(32767);
- +
+ +begin
- + 512 +
+ +if ut_utils.int_to_boolean(self.is_errored) then
- + 43 +
+ +l_result := 'Actual ('||a_actual.data_type||') cannot be compared to Expected ('||expected.data_type||') using matcher '''||self.name()||'''.';
- +
+ +end if;
- + 512 +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+end;
+UT3.UT_CONTAIN
87.5 % lines covered
16 relevant lines. 14 lines covered and 2 lines missed+ +
- +
+ +type body ut_contain as
- +
+ +/*
- +
+ +utPLSQL - Version 3
- +
+ +Copyright 2016 - 2019 utPLSQL Project
- +
+ +- +
+ +Licensed under the Apache License, Version 2.0 (the "License"):
- +
+ +you may not use this file except in compliance with the License.
- +
+ +You may obtain a copy of the License at
- +
+ +- +
+ +http://www.apache.org/licenses/LICENSE-2.0
- +
+ +- +
+ +Unless required by applicable law or agreed to in writing, software
- +
+ +distributed under the License is distributed on an "AS IS" BASIS,
- +
+ +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
+ +See the License for the specific language governing permissions and
- +
+ +limitations under the License.
- +
+ +*/
- +
+ +- +
+ +constructor function ut_contain(self in out nocopy ut_contain, a_expected sys_refcursor) return self as result is
- +
+ +begin
- + 18 +
+ +self.init(ut_data_value_refcursor(a_expected), null, $$plsql_unit);
- + 18 +
+ +self.options.unordered();
- + 18 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +constructor function ut_contain(self in out nocopy ut_contain, a_expected anydata) return self as result is
- +
+ +begin
- + 2 +
+ +self.init(ut_data_value_anydata(a_expected), null, $$plsql_unit);
- + 2 +
+ +self.options.unordered();
- + 2 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +overriding member function run_matcher(self in out nocopy ut_contain, a_actual ut_data_value) return boolean is
- +
+ +l_result boolean;
- +
+ +begin
- + 20 +
+ +if self.expected.data_type = a_actual.data_type then
- + 20 +
+ +l_result :=
- +
+ +( 0
- +
+ += treat( self.expected as ut_data_value_refcursor )
- +
+ +.compare_implementation( a_actual, self.options, true, self.is_negated() )
- +
+ +);
- +
+ +else
- +
+ +l_result := (self as ut_matcher).run_matcher(a_actual);
- +
+ +end if;
- + 20 +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+ +overriding member function run_matcher_negated(self in out nocopy ut_contain, a_actual ut_data_value) return boolean is
- +
+ +begin
- + 5 +
+ +return run_matcher(a_actual);
- +
+ +end;
- +
+ +- +
+ +overriding member function failure_message(a_actual ut_data_value) return varchar2 is
- +
+ +l_result varchar2(32767);
- +
+ +begin
- + 15 +
+ +if self.expected.data_type = a_actual.data_type and self.expected.is_diffable then
- + 15 +
+ +l_result :=
- +
+ +'Actual: '||a_actual.get_object_info()||self.description()||': '||self.expected.get_object_info()
- +
+ +|| treat(expected as ut_data_value_refcursor).diff( a_actual, self.options );
- +
+ +else
- +
+ +l_result := (self as ut_matcher).failure_message(a_actual) || ': '|| self.expected.to_string_report();
- +
+ +end if;
- + 15 +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+ +overriding member function failure_message_when_negated(a_actual ut_data_value) return varchar2 is
- +
+ +l_result varchar2(32767);
- +
+ +begin
- + 5 +
+ +return (self as ut_matcher).failure_message_when_negated(a_actual) || ':'|| expected.to_string_report();
- +
+ +end;
- +
+ +- +
+end;
+UT3.UT_EQUAL
91.4 % lines covered
93 relevant lines. 85 lines covered and 8 lines missed+ +
- +
+ +type body ut_equal as
- +
+ +/*
- +
+ +utPLSQL - Version 3
- +
+ +Copyright 2016 - 2019 utPLSQL Project
- +
+ +- +
+ +Licensed under the Apache License, Version 2.0 (the "License"):
- +
+ +you may not use this file except in compliance with the License.
- +
+ +You may obtain a copy of the License at
- +
+ +- +
+ +http://www.apache.org/licenses/LICENSE-2.0
- +
+ +- +
+ +Unless required by applicable law or agreed to in writing, software
- +
+ +distributed under the License is distributed on an "AS IS" BASIS,
- +
+ +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
+ +See the License for the specific language governing permissions and
- +
+ +limitations under the License.
- +
+ +*/
- +
+ +- +
+ +member procedure init(self in out nocopy ut_equal, a_expected ut_data_value, a_nulls_are_equal boolean, a_self_type varchar2 := null) is
- +
+ +begin
- + 395 +
+ +self.expected := a_expected;
- + 395 +
+ +self.options := ut_matcher_options( a_nulls_are_equal );
- + 395 +
+ +self.self_type := nvl( a_self_type, $$plsql_unit );
- +
+ +end;
- +
+ +- +
+ +member function equal_with_nulls(a_assert_result boolean, a_actual ut_data_value) return boolean is
- +
+ +begin
- + 511 +
+ +ut_utils.debug_log('ut_equal.equal_with_nulls :' || ut_utils.to_test_result(a_assert_result) || ':');
- + 511 +
+ +return ( a_assert_result or ( self.expected.is_null() and a_actual.is_null() and options.nulls_are_equal ) );
- +
+ +end;
- +
+ +- +
+ +constructor function ut_equal(self in out nocopy ut_equal, a_expected anydata, a_nulls_are_equal boolean := null) return self as result is
- +
+ +begin
- + 60 +
+ +init(ut_data_value_anydata(a_expected), a_nulls_are_equal);
- + 60 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +constructor function ut_equal(self in out nocopy ut_equal, a_expected anydata, a_exclude varchar2, a_nulls_are_equal boolean := null) return self as result is
- +
+ +l_deprecated integer;
- +
+ +begin
- + 1 +
+ +ut_expectation_processor.add_depreciation_warning(
- +
+ +'equal( a_expected anydata, a_exclude varchar2 )',
- +
+ +'equal( a_expected anydata ).exclude( a_exclude varchar2 )'
- +
+ +);
- + 1 +
+ +init(ut_data_value_anydata(a_expected), a_nulls_are_equal);
- + 1 +
+ +self.options.exclude.add_items(a_exclude);
- + 1 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +constructor function ut_equal(self in out nocopy ut_equal, a_expected anydata, a_exclude ut_varchar2_list, a_nulls_are_equal boolean := null) return self as result is
- +
+ +begin
- + 1 +
+ +ut_expectation_processor.add_depreciation_warning(
- +
+ +'equal( a_expected anydata, a_exclude ut_varchar2_list )',
- +
+ +'equal( a_expected anydata ).exclude( a_exclude ut_varchar2_list )'
- +
+ +);
- + 1 +
+ +init(ut_data_value_anydata(a_expected), a_nulls_are_equal);
- + 1 +
+ +self.options.exclude.add_items(a_exclude);
- + 1 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +constructor function ut_equal(self in out nocopy ut_equal, a_expected blob, a_nulls_are_equal boolean := null) return self as result is
- +
+ +begin
- + 10 +
+ +init(ut_data_value_blob(a_expected), a_nulls_are_equal);
- + 10 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +constructor function ut_equal(self in out nocopy ut_equal, a_expected boolean, a_nulls_are_equal boolean := null) return self as result is
- +
+ +begin
- + 13 +
+ +init(ut_data_value_boolean(a_expected), a_nulls_are_equal);
- + 13 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +constructor function ut_equal(self in out nocopy ut_equal, a_expected clob, a_nulls_are_equal boolean := null) return self as result is
- +
+ +begin
- + 10 +
+ +init(ut_data_value_clob(a_expected), a_nulls_are_equal);
- + 10 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +constructor function ut_equal(self in out nocopy ut_equal, a_expected date, a_nulls_are_equal boolean := null) return self as result is
- +
+ +begin
- + 10 +
+ +init(ut_data_value_date(a_expected), a_nulls_are_equal);
- + 10 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +constructor function ut_equal(self in out nocopy ut_equal, a_expected number, a_nulls_are_equal boolean := null) return self as result is
- +
+ +begin
- + 75 +
+ +init(ut_data_value_number(a_expected), a_nulls_are_equal);
- + 75 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +constructor function ut_equal(self in out nocopy ut_equal, a_expected sys_refcursor, a_nulls_are_equal boolean := null) return self as result is
- +
+ +begin
- + 108 +
+ +init(ut_data_value_refcursor(a_expected), a_nulls_are_equal);
- + 106 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +constructor function ut_equal(self in out nocopy ut_equal, a_expected sys_refcursor, a_exclude varchar2, a_nulls_are_equal boolean := null) return self as result is
- +
+ +begin
- + 1 +
+ +ut_expectation_processor.add_depreciation_warning(
- +
+ +'equal( a_expected sys_refcursor, a_exclude varchar2 )',
- +
+ +'equal( a_expected sys_refcursor ).exclude( a_exclude varchar2 )'
- +
+ +);
- + 1 +
+ +init(ut_data_value_refcursor(a_expected), a_nulls_are_equal);
- + 1 +
+ +self.options.exclude.add_items(a_exclude);
- + 1 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +constructor function ut_equal(self in out nocopy ut_equal, a_expected sys_refcursor, a_exclude ut_varchar2_list, a_nulls_are_equal boolean := null) return self as result is
- +
+ +begin
- + 1 +
+ +ut_expectation_processor.add_depreciation_warning(
- +
+ +'equal( a_expected sys_refcursor, a_exclude ut_varchar2_list )',
- +
+ +'equal( a_expected sys_refcursor ).exclude( a_exclude ut_varchar2_list )'
- +
+ +);
- + 1 +
+ +init(ut_data_value_refcursor(a_expected), a_nulls_are_equal);
- + 1 +
+ +self.options.exclude.add_items(a_exclude);
- + 1 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +constructor function ut_equal(self in out nocopy ut_equal, a_expected timestamp_unconstrained, a_nulls_are_equal boolean := null) return self as result is
- +
+ +begin
- + 12 +
+ +init(ut_data_value_timestamp(a_expected), a_nulls_are_equal);
- + 12 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +constructor function ut_equal(self in out nocopy ut_equal, a_expected timestamp_tz_unconstrained, a_nulls_are_equal boolean := null) return self as result is
- +
+ +begin
- + 10 +
+ +init(ut_data_value_timestamp_tz(a_expected), a_nulls_are_equal);
- + 10 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +constructor function ut_equal(self in out nocopy ut_equal, a_expected timestamp_ltz_unconstrained, a_nulls_are_equal boolean := null) return self as result is
- +
+ +begin
- + 10 +
+ +init(ut_data_value_timestamp_ltz(a_expected), a_nulls_are_equal);
- + 10 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +constructor function ut_equal(self in out nocopy ut_equal, a_expected varchar2, a_nulls_are_equal boolean := null) return self as result is
- +
+ +begin
- + 25 +
+ +init(ut_data_value_varchar2(a_expected), a_nulls_are_equal);
- + 25 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +constructor function ut_equal(self in out nocopy ut_equal, a_expected yminterval_unconstrained, a_nulls_are_equal boolean := null) return self as result is
- +
+ +begin
- + 10 +
+ +init(ut_data_value_yminterval(a_expected), a_nulls_are_equal);
- + 10 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +constructor function ut_equal(self in out nocopy ut_equal, a_expected dsinterval_unconstrained, a_nulls_are_equal boolean := null) return self as result is
- +
+ +begin
- + 10 +
+ +init(ut_data_value_dsinterval(a_expected), a_nulls_are_equal);
- + 10 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +constructor function ut_equal(self in out nocopy ut_equal, a_expected json_element_t, a_nulls_are_equal boolean := null) return self as result is
- +
+ +begin
- + 10 +
+ +init(ut_data_value_json(a_expected), a_nulls_are_equal);
- + 10 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +member function include(a_items varchar2) return ut_equal is
- +
+ +l_result ut_equal := self;
- +
+ +begin
- +
+ +l_result.options.include.add_items(a_items);
- +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+ +member function include(a_items ut_varchar2_list) return ut_equal is
- + 22 +
+ +l_result ut_equal := self;
- +
+ +begin
- + 22 +
+ +l_result.options.include.add_items(a_items);
- + 22 +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+ +member function exclude(a_items varchar2) return ut_equal is
- + 11 +
+ +l_result ut_equal := self;
- +
+ +begin
- + 11 +
+ +l_result.options.exclude.add_items(a_items);
- + 11 +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+ +member function exclude(a_items ut_varchar2_list) return ut_equal is
- + 23 +
+ +l_result ut_equal := self;
- +
+ +begin
- + 23 +
+ +l_result.options.exclude.add_items(a_items);
- + 23 +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+ +member function unordered return ut_equal is
- + 15 +
+ +l_result ut_equal := self;
- +
+ +begin
- + 15 +
+ +l_result.options.unordered();
- + 15 +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+ +member function join_by(a_columns varchar2) return ut_equal is
- +
+ +l_result ut_equal := self;
- +
+ +begin
- +
+ +l_result.options.unordered();
- +
+ +l_result.options.join_by.add_items(a_columns);
- +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+ +member function join_by(a_columns ut_varchar2_list) return ut_equal is
- + 42 +
+ +l_result ut_equal := self;
- +
+ +begin
- + 42 +
+ +l_result.options.unordered();
- + 42 +
+ +l_result.options.join_by.add_items(a_columns);
- + 42 +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+ +member function uc return ut_equal is
- +
+ +begin
- +
+ +return unordered_columns;
- +
+ +end;
- +
+ +- +
+ +member function unordered_columns return ut_equal is
- + 10 +
+ +l_result ut_equal := self;
- +
+ +begin
- + 10 +
+ +l_result.options.unordered_columns();
- + 10 +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+ +overriding member function run_matcher(self in out nocopy ut_equal, a_actual ut_data_value) return boolean is
- +
+ +l_result boolean;
- +
+ +begin
- + 375 +
+ +if self.expected.data_type = a_actual.data_type then
- + 336 +
+ +if self.expected is of (ut_data_value_anydata) then
- + 55 +
+ +l_result := 0 = treat(self.expected as ut_data_value_anydata).compare_implementation( a_actual, options );
- + 281 +
+ +elsif self.expected is of (ut_data_value_refcursor) then
- + 106 +
+ +l_result := 0 = treat(self.expected as ut_data_value_refcursor).compare_implementation( a_actual, options );
- +
+ +else
- + 175 +
+ +l_result := equal_with_nulls((self.expected = a_actual), a_actual);
- +
+ +end if;
- + 336 +
+ +l_result := equal_with_nulls( l_result, a_actual );
- +
+ +else
- + 39 +
+ +l_result := (self as ut_matcher).run_matcher(a_actual);
- +
+ +end if;
- + 375 +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+ +overriding member function failure_message(a_actual ut_data_value) return varchar2 is
- +
+ +l_result varchar2(32767);
- +
+ +begin
- + 329 +
+ +if self.expected.data_type = a_actual.data_type and self.expected.is_diffable then
- + 164 +
+ +l_result :=
- +
+ +'Actual: '||a_actual.get_object_info()||self.description()||': '||self.expected.get_object_info()
- + 1 +
+ +||case
- + 1 +
+ +when self.expected is of (ut_data_value_refcursor) then
- +
+ +treat(expected as ut_data_value_refcursor).diff( a_actual, options )
- + 1 +
+ +when self.expected is of (ut_data_value_json) then
- +
+ +treat(expected as ut_data_value_json).diff( a_actual, options )
- +
+ +else
- +
+ +expected.diff( a_actual, options )
- +
+ +end;
- +
+ +else
- + 165 +
+ +l_result := (self as ut_matcher).failure_message(a_actual) || ': '|| self.expected.to_string_report();
- +
+ +end if;
- + 329 +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+ +overriding member function failure_message_when_negated(a_actual ut_data_value) return varchar2 is
- +
+ +l_result varchar2(32767);
- +
+ +begin
- + 7 +
+ +return (self as ut_matcher).failure_message_when_negated(a_actual) || ': '|| expected.to_string_report();
- +
+ +end;
- +
+ +- +
+end;
+UT3.UT_HAVE_COUNT
100 % lines covered
11 relevant lines. 11 lines covered and 0 lines missed+ +
- +
+ +type body ut_have_count as
- +
+ +/*
- +
+ +utPLSQL - Version 3
- +
+ +Copyright 2016 - 2019 utPLSQL Project
- +
+ +- +
+ +Licensed under the Apache License, Version 2.0 (the "License"):
- +
+ +you may not use this file except in compliance with the License.
- +
+ +You may obtain a copy of the License at
- +
+ +- +
+ +http://www.apache.org/licenses/LICENSE-2.0
- +
+ +- +
+ +Unless required by applicable law or agreed to in writing, software
- +
+ +distributed under the License is distributed on an "AS IS" BASIS,
- +
+ +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
+ +See the License for the specific language governing permissions and
- +
+ +limitations under the License.
- +
+ +*/
- +
+ +- +
+ +constructor function ut_have_count(self in out nocopy ut_have_count, a_expected integer) return self as result is
- +
+ +begin
- + 25 +
+ +self.self_type := $$plsql_unit;
- + 25 +
+ +self.expected := a_expected;
- + 25 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +overriding member function run_matcher(self in out nocopy ut_have_count, a_actual ut_data_value) return boolean is
- +
+ +l_result boolean;
- +
+ +begin
- + 25 +
+ +if a_actual is of(ut_data_value_refcursor) and ( treat (a_actual as ut_data_value_refcursor).compound_type != 'object') then
- + 14 +
+ +l_result := ( self.expected = treat(a_actual as ut_data_value_refcursor).elements_count );
- + 11 +
+ +elsif a_actual is of(ut_data_value_json) then
- + 5 +
+ +l_result := ( self.expected = treat(a_actual as ut_data_value_json).get_elements_count );
- +
+ +else
- + 6 +
+ +l_result := (self as ut_matcher).run_matcher(a_actual);
- +
+ +end if;
- + 25 +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+ +overriding member function failure_message(a_actual ut_data_value) return varchar2 is
- +
+ +begin
- + 12 +
+ +return 'Actual: (' || case when a_actual is of (ut_data_value_json) then
- +
+ +treat(a_actual as ut_data_value_json).get_json_count_info() else a_actual.get_object_info() end||
- +
+ +') was expected to have [ count = '||ut_utils.to_string(self.expected)||' ]';
- +
+ +end;
- +
+ +- +
+ +overriding member function failure_message_when_negated(a_actual ut_data_value) return varchar2 is
- +
+ +begin
- + 7 +
+ +return 'Actual: ' || case when a_actual is of (ut_data_value_json) then
- +
+ +treat(a_actual as ut_data_value_json).get_json_count_info() else a_actual.get_object_info() end||
- +
+ +' was expected not to have [ count = '||ut_utils.to_string(self.expected)||' ]';
- +
+ +end;
- +
+ +- +
+end;
+UT3.UT_MATCH
100 % lines covered
20 relevant lines. 20 lines covered and 0 lines missed+ +
- +
+ +type body ut_match as
- +
+ +/*
- +
+ +utPLSQL - Version 3
- +
+ +Copyright 2016 - 2019 utPLSQL Project
- +
+ +- +
+ +Licensed under the Apache License, Version 2.0 (the "License"):
- +
+ +you may not use this file except in compliance with the License.
- +
+ +You may obtain a copy of the License at
- +
+ +- +
+ +http://www.apache.org/licenses/LICENSE-2.0
- +
+ +- +
+ +Unless required by applicable law or agreed to in writing, software
- +
+ +distributed under the License is distributed on an "AS IS" BASIS,
- +
+ +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
+ +See the License for the specific language governing permissions and
- +
+ +limitations under the License.
- +
+ +*/
- +
+ +- +
+ +constructor function ut_match(self in out nocopy ut_match, a_pattern in varchar2, a_modifiers in varchar2 default null) return self as result is
- +
+ +begin
- + 17 +
+ +self.self_type := $$plsql_unit;
- + 17 +
+ +self.pattern := a_pattern;
- + 17 +
+ +self.modifiers := a_modifiers;
- + 17 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +overriding member function run_matcher(self in out nocopy ut_match, a_actual ut_data_value) return boolean is
- +
+ +l_result boolean;
- +
+ +begin
- + 17 +
+ +if a_actual is of (ut_data_value_varchar2) then
- + 8 +
+ +l_result := regexp_like(treat(a_actual as ut_data_value_varchar2).data_value, pattern, modifiers);
- + 9 +
+ +elsif a_actual is of (ut_data_value_clob) then
- + 8 +
+ +l_result := regexp_like(treat(a_actual as ut_data_value_clob).data_value, pattern, modifiers);
- +
+ +else
- + 1 +
+ +l_result := (self as ut_matcher).run_matcher(a_actual);
- +
+ +end if;
- + 17 +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+ +overriding member function failure_message(a_actual ut_data_value) return varchar2 is
- +
+ +l_result varchar2(32767);
- +
+ +begin
- + 8 +
+ +l_result := (self as ut_matcher).failure_message(a_actual);
- + 8 +
+ +if self.modifiers is not null then
- + 4 +
+ +l_result := l_result || ': '|| ut_data_value_varchar2(self.pattern).to_string_report(true, false) || ', modifiers ''' || self.modifiers ||'''';
- +
+ +else
- + 4 +
+ +l_result := l_result || ': '|| ut_data_value_varchar2(self.pattern).to_string_report(false, false);
- +
+ +end if;
- + 8 +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+ +overriding member function failure_message_when_negated(a_actual ut_data_value) return varchar2 is
- +
+ +l_result varchar2(32767);
- +
+ +begin
- + 8 +
+ +l_result := (self as ut_matcher).failure_message_when_negated(a_actual);
- + 8 +
+ +if self.modifiers is not null then
- + 4 +
+ +l_result := l_result || ': '|| ut_data_value_varchar2(self.pattern).to_string_report(true, false) || ', modifiers ''' || self.modifiers ||'''';
- +
+ +else
- + 4 +
+ +l_result := l_result || ': '|| ut_data_value_varchar2(self.pattern).to_string_report(false, false);
- +
+ +end if;
- + 8 +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+end;
+UT3.UT_MATCHER
100 % lines covered
17 relevant lines. 17 lines covered and 0 lines missed+ +
- +
+ +type body ut_matcher as
- +
+ +/*
- +
+ +utPLSQL - Version 3
- +
+ +Copyright 2016 - 2019 utPLSQL Project
- +
+ +- +
+ +Licensed under the Apache License, Version 2.0 (the "License"):
- +
+ +you may not use this file except in compliance with the License.
- +
+ +You may obtain a copy of the License at
- +
+ +- +
+ +http://www.apache.org/licenses/LICENSE-2.0
- +
+ +- +
+ +Unless required by applicable law or agreed to in writing, software
- +
+ +distributed under the License is distributed on an "AS IS" BASIS,
- +
+ +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
+ +See the License for the specific language governing permissions and
- +
+ +limitations under the License.
- +
+ +*/
- +
+ +- +
+ +member function run_matcher(self in out nocopy ut_matcher, a_actual ut_data_value) return boolean is
- +
+ +begin
- + 62 +
+ +ut_utils.debug_log('Failure - ut_matcher.run_matcher'||'(a_actual '||a_actual.data_type||')');
- + 62 +
+ +self.is_errored := ut_utils.boolean_to_int(true);
- +
+ +-- self.error_message := 'The matcher '''||name()||''' cannot be used';
- +
+ +-- if self.expected is not null then
- +
+ +-- self.error_message := self.error_message ||' for comparison of data type ('||self.expected.data_type||')';
- +
+ +-- end if;
- +
+ +-- self.error_message := self.error_message ||' with data type ('||a_actual.data_type||').';
- + 62 +
+ +return null;
- +
+ +end;
- +
+ +- +
+ +member function run_matcher_negated(self in out nocopy ut_matcher, a_actual ut_data_value) return boolean is
- +
+ +begin
- + 169 +
+ +return not run_matcher(a_actual);
- +
+ +end;
- +
+ +- +
+ +member function name return varchar2 is
- +
+ +begin
- + 776 +
+ +return replace(ltrim(lower(self.self_type),'ut_'),'_',' ');
- +
+ +end;
- +
+ +- +
+ +member function description return varchar2 is
- +
+ +begin
- + 573 +
+ +return ' was expected to '||name();
- +
+ +end;
- +
+ +- +
+ +member function description_when_negated return varchar2 is
- +
+ +begin
- + 141 +
+ +return ' was expected not to '||name();
- +
+ +end;
- +
+ +- +
+ +member function error_message(a_actual ut_data_value) return varchar2 is
- +
+ +l_result varchar2(32767);
- +
+ +begin
- + 283 +
+ +if ut_utils.int_to_boolean(self.is_errored) then
- + 19 +
+ +l_result := 'The matcher '''||name()||''' cannot be used with data type ('||a_actual.data_type||').';
- +
+ +end if;
- + 283 +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+ +member function failure_message(a_actual ut_data_value) return varchar2 is
- +
+ +begin
- + 394 +
+ +return 'Actual: ' || a_actual.to_string_report(true) || description();
- +
+ +end;
- +
+ +- +
+ +member function failure_message_when_negated(a_actual ut_data_value) return varchar2 is
- +
+ +begin
- + 141 +
+ +return 'Actual: ' || a_actual.to_string_report(true) || description_when_negated();
- +
+ +end;
- +
+ +- +
+ +member procedure negated is
- +
+ +begin
- + 6 +
+ +is_negated_flag := ut_utils.boolean_to_int(true);
- +
+ +end;
- +
+ +- +
+ +member function negated return ut_matcher is
- + 6 +
+ +l_result ut_matcher := self;
- +
+ +begin
- + 6 +
+ +l_result.negated();
- + 6 +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+ +member function is_negated return boolean is
- +
+ +begin
- + 645 +
+ +return coalesce(ut_utils.int_to_boolean(is_negated_flag), false);
- +
+ +end;
- +
+ +- +
+end;
+UT3.UT_MATCHER_OPTIONS
92.31 % lines covered
13 relevant lines. 12 lines covered and 1 lines missed+ +
- +
+ +type body ut_matcher_options as
- +
+ +/*
- +
+ +utPLSQL - Version 3
- +
+ +Copyright 2016 - 2019 utPLSQL Project
- +
+ +- +
+ +Licensed under the Apache License, Version 2.0 (the "License"):
- +
+ +you may not use this file except in compliance with the License.
- +
+ +You may obtain a copy of the License at
- +
+ +- +
+ +http://www.apache.org/licenses/LICENSE-2.0
- +
+ +- +
+ +Unless required by applicable law or agreed to in writing, software
- +
+ +distributed under the License is distributed on an "AS IS" BASIS,
- +
+ +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
+ +See the License for the specific language governing permissions and
- +
+ +limitations under the License.
- +
+ +*/
- +
+ +- +
+ +constructor function ut_matcher_options(self in out nocopy ut_matcher_options, a_nulls_are_equal in boolean := null) return self as result is
- +
+ +begin
- + 395 +
+ +nulls_are_equal_flag := ut_utils.boolean_to_int( coalesce(a_nulls_are_equal, ut_expectation_processor.nulls_are_equal()) );
- + 395 +
+ +is_unordered := ut_utils.boolean_to_int(false);
- + 395 +
+ +columns_are_unordered_flag := ut_utils.boolean_to_int(false);
- + 395 +
+ +include := ut_matcher_options_items();
- + 395 +
+ +exclude := ut_matcher_options_items();
- + 395 +
+ +join_by := ut_matcher_options_items();
- + 395 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +member procedure nulls_are_equal(self in out nocopy ut_matcher_options) is
- +
+ +begin
- +
+ +self.nulls_are_equal_flag := ut_utils.boolean_to_int(true);
- +
+ +end;
- +
+ +- +
+ +member function nulls_are_equal return boolean is
- +
+ +begin
- + 66 +
+ +return ut_utils.int_to_boolean(self.nulls_are_equal_flag);
- +
+ +end;
- +
+ +- +
+ +member procedure unordered_columns(self in out nocopy ut_matcher_options) is
- +
+ +begin
- + 10 +
+ +columns_are_unordered_flag := ut_utils.boolean_to_int(true);
- +
+ +end;
- +
+ +- +
+ +member function ordered_columns return boolean is
- +
+ +begin
- + 213 +
+ +return not ut_utils.int_to_boolean(columns_are_unordered_flag);
- +
+ +end;
- +
+ +- +
+ +member procedure unordered(self in out nocopy ut_matcher_options) is
- +
+ +begin
- + 77 +
+ +is_unordered := ut_utils.boolean_to_int(true);
- +
+ +end;
- +
+ +- +
+ +member function unordered return boolean is
- +
+ +begin
- + 452 +
+ +return ut_utils.int_to_boolean(is_unordered);
- +
+ +end;
- +
+end;
+UT3.UT_MATCHER_OPTIONS_ITEMS
88.89 % lines covered
9 relevant lines. 8 lines covered and 1 lines missed+ +
- +
+ +type body ut_matcher_options_items is
- +
+ +/*
- +
+ +utPLSQL - Version 3
- +
+ +Copyright 2016 - 2019 utPLSQL Project
- +
+ +- +
+ +Licensed under the Apache License, Version 2.0 (the "License"):
- +
+ +you may not use this file except in compliance with the License.
- +
+ +You may obtain a copy of the License at
- +
+ +- +
+ +http://www.apache.org/licenses/LICENSE-2.0
- +
+ +- +
+ +Unless required by applicable law or agreed to in writing, software
- +
+ +distributed under the License is distributed on an "AS IS" BASIS,
- +
+ +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
+ +See the License for the specific language governing permissions and
- +
+ +limitations under the License.
- +
+ +*/
- +
+ +- +
+ +constructor function ut_matcher_options_items(self in out nocopy ut_matcher_options_items) return self as result is
- +
+ +begin
- + 1185 +
+ +items := ut_varchar2_list();
- + 1185 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +member procedure add_items(self in out nocopy ut_matcher_options_items, a_items varchar2) is
- +
+ +begin
- + 136 +
+ +items :=
- +
+ +items
- +
+ +multiset union all
- +
+ +ut_utils.filter_list(
- +
+ +ut_utils.trim_list_elements(
- +
+ +ut_utils.string_to_table( replace( a_items , '|', ',' ), ',' )
- +
+ +)
- +
+ +, '.+'
- +
+ +);
- +
+ +end;
- +
+ +- +
+ +member procedure add_items(self in out nocopy ut_matcher_options_items, a_items ut_varchar2_list) is
- +
+ +l_idx binary_integer;
- +
+ +begin
- + 89 +
+ +if a_items is not null then
- + 89 +
+ +l_idx := a_items.first;
- + 212 +
+ +while l_idx is not null loop
- + 123 +
+ +add_items( a_items(l_idx) );
- + 123 +
+ +l_idx := a_items.next(l_idx);
- +
+ +end loop;
- +
+ +end if;
- +
+ +end;
- +
+ +- +
+ +member function to_xpath return varchar2 is
- +
+ +begin
- +
+ +return ut_utils.to_xpath(items);
- +
+ +end;
- +
+ +- +
+end;
+UT3.UT_EXPECTATION
98.62 % lines covered
145 relevant lines. 143 lines covered and 2 lines missed+ +
- +
+ +type body ut_expectation as
- +
+ +/*
- +
+ +utPLSQL - Version 3
- +
+ +Copyright 2016 - 2019 utPLSQL Project
- +
+ +- +
+ +Licensed under the Apache License, Version 2.0 (the "License"):
- +
+ +you may not use this file except in compliance with the License.
- +
+ +You may obtain a copy of the License at
- +
+ +- +
+ +http://www.apache.org/licenses/LICENSE-2.0
- +
+ +- +
+ +Unless required by applicable law or agreed to in writing, software
- +
+ +distributed under the License is distributed on an "AS IS" BASIS,
- +
+ +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
+ +See the License for the specific language governing permissions and
- +
+ +limitations under the License.
- +
+ +*/
- +
+ +member procedure to_(self in ut_expectation, a_matcher ut_matcher) is
- +
+ +l_expectation_result boolean;
- + 625 +
+ +l_matcher ut_matcher := a_matcher;
- +
+ +l_message varchar2(32767);
- +
+ +begin
- + 625 +
+ +if a_matcher.is_negated() then
- + 4 +
+ +self.not_to( a_matcher );
- +
+ +else
- + 621 +
+ +l_expectation_result := l_matcher.run_matcher( self.actual_data );
- + 621 +
+ +l_expectation_result := coalesce(l_expectation_result,false);
- + 621 +
+ +l_message := coalesce( l_matcher.error_message( self.actual_data ), l_matcher.failure_message( self.actual_data ) );
- + 621 +
+ +ut_expectation_processor.add_expectation_result( ut_expectation_result( ut_utils.to_test_result( l_expectation_result ), self.description, l_message ) );
- +
+ +end if;
- +
+ +end;
- +
+ +- +
+ +member procedure not_to(self in ut_expectation, a_matcher ut_matcher) is
- +
+ +l_expectation_result boolean;
- + 174 +
+ +l_matcher ut_matcher := a_matcher;
- +
+ +l_message varchar2(32767);
- +
+ +begin
- + 174 +
+ +l_expectation_result := coalesce( l_matcher.run_matcher_negated( self.actual_data ), false );
- +
+ +- + 174 +
+ +l_message := coalesce( l_matcher.error_message( self.actual_data ), l_matcher.failure_message_when_negated( self.actual_data ) );
- + 174 +
+ +ut_expectation_processor.add_expectation_result( ut_expectation_result( ut_utils.to_test_result( l_expectation_result ), self.description, l_message ) );
- +
+ +end;
- +
+ +- +
+ +member procedure to_be_null(self in ut_expectation) is
- +
+ +begin
- + 42 +
+ +self.to_( ut_be_null() );
- +
+ +end;
- +
+ +- +
+ +member procedure to_be_not_null(self in ut_expectation) is
- +
+ +begin
- + 29 +
+ +self.to_( ut_be_not_null() );
- +
+ +end;
- +
+ +- +
+ +member procedure not_to_be_null(self in ut_expectation) is
- +
+ +begin
- + 30 +
+ +self.not_to( ut_be_null() );
- +
+ +end;
- +
+ +- +
+ +member procedure not_to_be_not_null(self in ut_expectation) is
- +
+ +begin
- + 1 +
+ +self.not_to( ut_be_not_null() );
- +
+ +end;
- +
+ +- +
+ +member procedure to_be_true(self in ut_expectation) is
- +
+ +begin
- + 4 +
+ +self.to_( ut_be_true() );
- +
+ +end;
- +
+ +- +
+ +member procedure to_be_false(self in ut_expectation) is
- +
+ +begin
- + 4 +
+ +self.to_( ut_be_false() );
- +
+ +end;
- +
+ +- +
+ +member procedure not_to_be_true(self in ut_expectation) is
- +
+ +begin
- + 4 +
+ +self.not_to( ut_be_true() );
- +
+ +end;
- +
+ +- +
+ +member procedure not_to_be_false(self in ut_expectation) is
- +
+ +begin
- + 4 +
+ +self.not_to( ut_be_false() );
- +
+ +end;
- +
+ +- +
+ +member procedure to_be_empty(self in ut_expectation) is
- +
+ +begin
- + 14 +
+ +self.to_( ut_be_empty() );
- +
+ +end;
- +
+ +- +
+ +member procedure not_to_be_empty(self in ut_expectation) is
- +
+ +begin
- + 11 +
+ +self.not_to( ut_be_empty() );
- +
+ +end;
- +
+ +- +
+ +member procedure to_equal(self in ut_expectation, a_expected anydata, a_nulls_are_equal boolean := null) is
- +
+ +begin
- + 32 +
+ +self.to_( ut_equal(a_expected, a_nulls_are_equal) );
- +
+ +end;
- +
+ +- +
+ +member procedure to_equal(self in ut_expectation, a_expected anydata, a_exclude varchar2, a_nulls_are_equal boolean := null) is
- +
+ +begin
- + 4 +
+ +ut_expectation_processor.add_warning(
- +
+ +ut_utils.build_depreciation_warning(
- +
+ +'to_equal( a_expected anydata, a_exclude varchar2 )',
- +
+ +'to_equal( a_expected anydata ).exclude( a_exclude varchar2 )'
- +
+ +)
- +
+ +);
- + 4 +
+ +self.to_( ut_equal(a_expected, a_nulls_are_equal).exclude(a_exclude) );
- +
+ +end;
- +
+ +- +
+ +member procedure to_equal(self in ut_expectation, a_expected anydata, a_exclude ut_varchar2_list, a_nulls_are_equal boolean := null) is
- +
+ +begin
- + 2 +
+ +ut_expectation_processor.add_warning(
- +
+ +ut_utils.build_depreciation_warning(
- +
+ +'to_equal( a_expected anydata, a_exclude ut_varchar2_list )',
- +
+ +'to_equal( a_expected anydata ).exclude( a_exclude ut_varchar2_list )'
- +
+ +)
- +
+ +);
- + 2 +
+ +self.to_( ut_equal(a_expected, a_nulls_are_equal).exclude(a_exclude) );
- +
+ +end;
- +
+ +- +
+ +member procedure to_equal(self in ut_expectation, a_expected blob, a_nulls_are_equal boolean := null) is
- +
+ +begin
- + 9 +
+ +self.to_( ut_equal(a_expected, a_nulls_are_equal) );
- +
+ +end;
- +
+ +- +
+ +member procedure to_equal(self in ut_expectation, a_expected boolean, a_nulls_are_equal boolean := null) is
- +
+ +begin
- + 11 +
+ +self.to_( ut_equal(a_expected, a_nulls_are_equal) );
- +
+ +end;
- +
+ +- +
+ +member procedure to_equal(self in ut_expectation, a_expected clob, a_nulls_are_equal boolean := null) is
- +
+ +begin
- + 9 +
+ +self.to_( ut_equal(a_expected, a_nulls_are_equal) );
- +
+ +end;
- +
+ +- +
+ +member procedure to_equal(self in ut_expectation, a_expected date, a_nulls_are_equal boolean := null) is
- +
+ +begin
- + 9 +
+ +self.to_( ut_equal(a_expected, a_nulls_are_equal) );
- +
+ +end;
- +
+ +- +
+ +member procedure to_equal(self in ut_expectation, a_expected number, a_nulls_are_equal boolean := null) is
- +
+ +begin
- + 73 +
+ +self.to_( ut_equal(a_expected, a_nulls_are_equal) );
- +
+ +end;
- +
+ +- +
+ +member procedure to_equal(self in ut_expectation, a_expected sys_refcursor, a_nulls_are_equal boolean := null) is
- +
+ +begin
- + 38 +
+ +self.to_( ut_equal(a_expected, a_nulls_are_equal) );
- +
+ +end;
- +
+ +- +
+ +member procedure to_equal(self in ut_expectation, a_expected sys_refcursor, a_exclude varchar2, a_nulls_are_equal boolean := null) is
- +
+ +begin
- + 5 +
+ +ut_expectation_processor.add_depreciation_warning(
- +
+ +'to_equal( a_expected sys_refcursor, a_exclude varchar2 )',
- +
+ +'to_equal( a_expected sys_refcursor ).exclude( a_exclude varchar2 )'
- +
+ +);
- + 5 +
+ +self.to_( ut_equal(a_expected, a_nulls_are_equal).exclude(a_exclude) );
- +
+ +end;
- +
+ +- +
+ +member procedure to_equal(self in ut_expectation, a_expected sys_refcursor, a_exclude ut_varchar2_list, a_nulls_are_equal boolean := null) is
- +
+ +begin
- + 4 +
+ +ut_expectation_processor.add_depreciation_warning(
- +
+ +'to_equal( a_expected sys_refcursor, a_exclude ut_varchar2_list )',
- +
+ +'to_equal( a_expected sys_refcursor ).exclude( a_exclude ut_varchar2_list )'
- +
+ +);
- + 4 +
+ +self.to_( ut_equal(a_expected, a_nulls_are_equal).exclude(a_exclude) );
- +
+ +end;
- +
+ +- +
+ +member procedure to_equal(self in ut_expectation, a_expected timestamp_unconstrained, a_nulls_are_equal boolean := null) is
- +
+ +begin
- + 10 +
+ +self.to_( ut_equal(a_expected, a_nulls_are_equal) );
- +
+ +end;
- +
+ +- +
+ +member procedure to_equal(self in ut_expectation, a_expected timestamp_ltz_unconstrained, a_nulls_are_equal boolean := null) is
- +
+ +begin
- + 9 +
+ +self.to_( ut_equal(a_expected, a_nulls_are_equal) );
- +
+ +end;
- +
+ +- +
+ +member procedure to_equal(self in ut_expectation, a_expected timestamp_tz_unconstrained, a_nulls_are_equal boolean := null) is
- +
+ +begin
- + 9 +
+ +self.to_( ut_equal(a_expected, a_nulls_are_equal) );
- +
+ +end;
- +
+ +- +
+ +member procedure to_equal(self in ut_expectation, a_expected varchar2, a_nulls_are_equal boolean := null) is
- +
+ +begin
- + 23 +
+ +self.to_( ut_equal(a_expected, a_nulls_are_equal) );
- +
+ +end;
- +
+ +- +
+ +member procedure to_equal(self in ut_expectation, a_expected yminterval_unconstrained, a_nulls_are_equal boolean := null) is
- +
+ +begin
- + 9 +
+ +self.to_( ut_equal(a_expected, a_nulls_are_equal) );
- +
+ +end;
- +
+ +- +
+ +member procedure to_equal(self in ut_expectation, a_expected dsinterval_unconstrained, a_nulls_are_equal boolean := null) is
- +
+ +begin
- + 9 +
+ +self.to_( ut_equal(a_expected, a_nulls_are_equal) );
- +
+ +end;
- +
+ +- +
+ +member procedure to_equal(self in ut_expectation, a_expected json_element_t, a_nulls_are_equal boolean := null) is
- +
+ +begin
- + 10 +
+ +self.to_( ut_equal(a_expected, a_nulls_are_equal) );
- +
+ +end;
- +
+ +- +
+ +member procedure not_to_equal(self in ut_expectation, a_expected anydata, a_nulls_are_equal boolean := null) is
- +
+ +begin
- + 3 +
+ +self.not_to( ut_equal(a_expected, a_nulls_are_equal) );
- +
+ +end;
- +
+ +- +
+ +member procedure not_to_equal(self in ut_expectation, a_expected anydata, a_exclude varchar2, a_nulls_are_equal boolean := null) is
- +
+ +begin
- + 1 +
+ +ut_expectation_processor.add_depreciation_warning(
- +
+ +'not_to_equal( a_expected anydata, a_exclude varchar2 )',
- +
+ +'not_to_equal( a_expected anydata ).exclude( a_exclude varchar2 )'
- +
+ +);
- + 1 +
+ +self.not_to( ut_equal(a_expected, a_nulls_are_equal).exclude(a_exclude) );
- +
+ +end;
- +
+ +- +
+ +member procedure not_to_equal(self in ut_expectation, a_expected anydata, a_exclude ut_varchar2_list, a_nulls_are_equal boolean := null) is
- +
+ +begin
- + 1 +
+ +ut_expectation_processor.add_depreciation_warning(
- +
+ +'not_to_equal( a_expected anydata, a_exclude ut_varchar2_list )',
- +
+ +'not_to_equal( a_expected anydata ).exclude( a_exclude ut_varchar2_list )'
- +
+ +);
- + 1 +
+ +self.not_to( ut_equal(a_expected, a_nulls_are_equal).exclude(a_exclude) );
- +
+ +end;
- +
+ +- +
+ +member procedure not_to_equal(self in ut_expectation, a_expected blob, a_nulls_are_equal boolean := null) is
- +
+ +begin
- + 1 +
+ +self.not_to( ut_equal(a_expected, a_nulls_are_equal) );
- +
+ +end;
- +
+ +- +
+ +member procedure not_to_equal(self in ut_expectation, a_expected boolean, a_nulls_are_equal boolean := null) is
- +
+ +begin
- + 2 +
+ +self.not_to( ut_equal(a_expected, a_nulls_are_equal) );
- +
+ +end;
- +
+ +- +
+ +member procedure not_to_equal(self in ut_expectation, a_expected clob, a_nulls_are_equal boolean := null) is
- +
+ +begin
- + 1 +
+ +self.not_to( ut_equal(a_expected, a_nulls_are_equal) );
- +
+ +end;
- +
+ +- +
+ +member procedure not_to_equal(self in ut_expectation, a_expected date, a_nulls_are_equal boolean := null) is
- +
+ +begin
- + 1 +
+ +self.not_to( ut_equal(a_expected, a_nulls_are_equal) );
- +
+ +end;
- +
+ +- +
+ +member procedure not_to_equal(self in ut_expectation, a_expected number, a_nulls_are_equal boolean := null) is
- +
+ +begin
- + 2 +
+ +self.not_to( ut_equal(a_expected, a_nulls_are_equal) );
- +
+ +end;
- +
+ +- +
+ +member procedure not_to_equal(self in ut_expectation, a_expected sys_refcursor, a_nulls_are_equal boolean := null) is
- +
+ +begin
- + 2 +
+ +self.not_to( ut_equal(a_expected, a_nulls_are_equal) );
- +
+ +end;
- +
+ +- +
+ +member procedure not_to_equal(self in ut_expectation, a_expected sys_refcursor, a_exclude varchar2, a_nulls_are_equal boolean := null) is
- +
+ +begin
- + 1 +
+ +ut_expectation_processor.add_depreciation_warning(
- +
+ +'not_to_equal( a_expected sys_refcursor, a_exclude varchar2 )',
- +
+ +'not_to_equal( a_expected sys_refcursor ).exclude( a_exclude varchar2 )'
- +
+ +);
- + 1 +
+ +self.not_to( ut_equal(a_expected, a_nulls_are_equal).exclude(a_exclude) );
- +
+ +end;
- +
+ +- +
+ +member procedure not_to_equal(self in ut_expectation, a_expected sys_refcursor, a_exclude ut_varchar2_list, a_nulls_are_equal boolean := null) is
- +
+ +begin
- + 1 +
+ +ut_expectation_processor.add_depreciation_warning(
- +
+ +'not_to_equal( a_expected sys_refcursor, a_exclude ut_varchar2_list )',
- +
+ +'not_to_equal( a_expected sys_refcursor ).exclude( a_exclude ut_varchar2_list )'
- +
+ +);
- + 1 +
+ +self.not_to( ut_equal(a_expected, a_nulls_are_equal).exclude(a_exclude) );
- +
+ +end;
- +
+ +- +
+ +member procedure not_to_equal(self in ut_expectation, a_expected timestamp_unconstrained, a_nulls_are_equal boolean := null) is
- +
+ +begin
- + 2 +
+ +self.not_to( ut_equal(a_expected, a_nulls_are_equal) );
- +
+ +end;
- +
+ +- +
+ +member procedure not_to_equal(self in ut_expectation, a_expected timestamp_ltz_unconstrained, a_nulls_are_equal boolean := null) is
- +
+ +begin
- + 1 +
+ +self.not_to( ut_equal(a_expected, a_nulls_are_equal) );
- +
+ +end;
- +
+ +- +
+ +member procedure not_to_equal(self in ut_expectation, a_expected timestamp_tz_unconstrained, a_nulls_are_equal boolean := null) is
- +
+ +begin
- + 1 +
+ +self.not_to( ut_equal(a_expected, a_nulls_are_equal) );
- +
+ +end;
- +
+ +- +
+ +member procedure not_to_equal(self in ut_expectation, a_expected varchar2, a_nulls_are_equal boolean := null) is
- +
+ +begin
- + 2 +
+ +self.not_to( ut_equal(a_expected, a_nulls_are_equal) );
- +
+ +end;
- +
+ +- +
+ +member procedure not_to_equal(self in ut_expectation, a_expected yminterval_unconstrained, a_nulls_are_equal boolean := null) is
- +
+ +begin
- + 1 +
+ +self.not_to( ut_equal(a_expected, a_nulls_are_equal) );
- +
+ +end;
- +
+ +- +
+ +member procedure not_to_equal(self in ut_expectation, a_expected dsinterval_unconstrained, a_nulls_are_equal boolean := null) is
- +
+ +begin
- + 1 +
+ +self.not_to( ut_equal(a_expected, a_nulls_are_equal) );
- +
+ +end;
- +
+ +- +
+ +member procedure not_to_equal(self in ut_expectation, a_expected json_element_t, a_nulls_are_equal boolean := null) is
- +
+ +begin
- +
+ +self.not_to( ut_equal(a_expected, a_nulls_are_equal) );
- +
+ +end;
- +
+ +- +
+ +member procedure to_be_like(self in ut_expectation, a_mask in varchar2, a_escape_char in varchar2 := null) is
- +
+ +begin
- + 9 +
+ +self.to_( ut_be_like(a_mask, a_escape_char) );
- +
+ +end;
- +
+ +- +
+ +- +
+ +member procedure to_match(self in ut_expectation, a_pattern in varchar2, a_modifiers in varchar2 default null) is
- +
+ +begin
- + 9 +
+ +self.to_( ut_match(a_pattern, a_modifiers) );
- +
+ +end;
- +
+ +- +
+ +- +
+ +member procedure not_to_be_like(self in ut_expectation, a_mask in varchar2, a_escape_char in varchar2 := null) is
- +
+ +begin
- + 8 +
+ +self.not_to( ut_be_like(a_mask, a_escape_char) );
- +
+ +end;
- +
+ +- +
+ +- +
+ +member procedure not_to_match(self in ut_expectation, a_pattern in varchar2, a_modifiers in varchar2 default null) is
- +
+ +begin
- + 8 +
+ +self.not_to( ut_match(a_pattern, a_modifiers) );
- +
+ +end;
- +
+ +- +
+ +- +
+ +member procedure to_be_between(self in ut_expectation, a_lower_bound date, a_upper_bound date) is
- +
+ +begin
- + 4 +
+ +self.to_( ut_be_between(a_lower_bound,a_upper_bound) );
- +
+ +end;
- +
+ +- +
+ +member procedure to_be_between(self in ut_expectation, a_lower_bound dsinterval_unconstrained, a_upper_bound dsinterval_unconstrained) is
- +
+ +begin
- + 4 +
+ +self.to_( ut_be_between(a_lower_bound,a_upper_bound) );
- +
+ +end;
- +
+ +- +
+ +member procedure to_be_between(self in ut_expectation, a_lower_bound number, a_upper_bound number) is
- +
+ +begin
- + 4 +
+ +self.to_( ut_be_between(a_lower_bound,a_upper_bound) );
- +
+ +end;
- +
+ +- +
+ +member procedure to_be_between(self in ut_expectation, a_lower_bound timestamp_unconstrained, a_upper_bound timestamp_unconstrained) is
- +
+ +begin
- + 5 +
+ +self.to_( ut_be_between(a_lower_bound, a_upper_bound) );
- +
+ +end;
- +
+ +- +
+ +member procedure to_be_between(self in ut_expectation, a_lower_bound timestamp_ltz_unconstrained, a_upper_bound timestamp_ltz_unconstrained) is
- +
+ +begin
- + 5 +
+ +self.to_( ut_be_between(a_lower_bound, a_upper_bound) );
- +
+ +end;
- +
+ +- +
+ +member procedure to_be_between(self in ut_expectation, a_lower_bound timestamp_tz_unconstrained, a_upper_bound timestamp_tz_unconstrained) is
- +
+ +begin
- + 5 +
+ +self.to_( ut_be_between(a_lower_bound, a_upper_bound) );
- +
+ +end;
- +
+ +- +
+ +member procedure to_be_between(self in ut_expectation, a_lower_bound varchar2, a_upper_bound varchar2) is
- +
+ +begin
- + 5 +
+ +self.to_( ut_be_between(a_lower_bound,a_upper_bound) );
- +
+ +end;
- +
+ +- +
+ +member procedure to_be_between(self in ut_expectation, a_lower_bound yminterval_unconstrained, a_upper_bound yminterval_unconstrained) is
- +
+ +begin
- + 4 +
+ +self.to_( ut_be_between(a_lower_bound,a_upper_bound) );
- +
+ +end;
- +
+ +- +
+ +- +
+ +member procedure to_be_greater_or_equal(self in ut_expectation, a_expected date) is
- +
+ +begin
- + 3 +
+ +self.to_( ut_be_greater_or_equal (a_expected) );
- +
+ +end;
- +
+ +- +
+ +member procedure to_be_greater_or_equal(self in ut_expectation, a_expected dsinterval_unconstrained) is
- +
+ +begin
- + 3 +
+ +self.to_( ut_be_greater_or_equal (a_expected) );
- +
+ +end;
- +
+ +- +
+ +member procedure to_be_greater_or_equal(self in ut_expectation, a_expected number) is
- +
+ +begin
- + 3 +
+ +self.to_( ut_be_greater_or_equal (a_expected) );
- +
+ +end;
- +
+ +- +
+ +member procedure to_be_greater_or_equal(self in ut_expectation, a_expected timestamp_unconstrained) is
- +
+ +begin
- + 3 +
+ +self.to_( ut_be_greater_or_equal (a_expected) );
- +
+ +end;
- +
+ +- +
+ +member procedure to_be_greater_or_equal(self in ut_expectation, a_expected timestamp_ltz_unconstrained) is
- +
+ +begin
- + 3 +
+ +self.to_( ut_be_greater_or_equal (a_expected) );
- +
+ +end;
- +
+ +- +
+ +member procedure to_be_greater_or_equal(self in ut_expectation, a_expected timestamp_tz_unconstrained) is
- +
+ +begin
- + 3 +
+ +self.to_( ut_be_greater_or_equal (a_expected) );
- +
+ +end;
- +
+ +- +
+ +member procedure to_be_greater_or_equal(self in ut_expectation, a_expected yminterval_unconstrained) is
- +
+ +begin
- + 3 +
+ +self.to_( ut_be_greater_or_equal (a_expected) );
- +
+ +end;
- +
+ +- +
+ +member procedure to_be_greater_than(self in ut_expectation, a_expected date) is
- +
+ +begin
- + 3 +
+ +self.to_( ut_be_greater_than (a_expected) );
- +
+ +end;
- +
+ +- +
+ +member procedure to_be_greater_than(self in ut_expectation, a_expected dsinterval_unconstrained) is
- +
+ +begin
- + 3 +
+ +self.to_( ut_be_greater_than (a_expected) );
- +
+ +end;
- +
+ +- +
+ +member procedure to_be_greater_than(self in ut_expectation, a_expected number) is
- +
+ +begin
- + 4 +
+ +self.to_( ut_be_greater_than (a_expected) );
- +
+ +end;
- +
+ +- +
+ +member procedure to_be_greater_than(self in ut_expectation, a_expected timestamp_unconstrained) is
- +
+ +begin
- + 3 +
+ +self.to_( ut_be_greater_than (a_expected) );
- +
+ +end;
- +
+ +- +
+ +member procedure to_be_greater_than(self in ut_expectation, a_expected timestamp_ltz_unconstrained) is
- +
+ +begin
- + 3 +
+ +self.to_( ut_be_greater_than (a_expected) );
- +
+ +end;
- +
+ +- +
+ +member procedure to_be_greater_than(self in ut_expectation, a_expected timestamp_tz_unconstrained) is
- +
+ +begin
- + 3 +
+ +self.to_( ut_be_greater_than (a_expected) );
- +
+ +end;
- +
+ +- +
+ +member procedure to_be_greater_than(self in ut_expectation, a_expected yminterval_unconstrained) is
- +
+ +begin
- + 3 +
+ +self.to_( ut_be_greater_than (a_expected) );
- +
+ +end;
- +
+ +- +
+ +- +
+ +member procedure to_be_less_or_equal(self in ut_expectation, a_expected date) is
- +
+ +begin
- + 3 +
+ +self.to_( ut_be_less_or_equal (a_expected) );
- +
+ +end;
- +
+ +- +
+ +member procedure to_be_less_or_equal(self in ut_expectation, a_expected dsinterval_unconstrained) is
- +
+ +begin
- + 3 +
+ +self.to_( ut_be_less_or_equal (a_expected) );
- +
+ +end;
- +
+ +- +
+ +member procedure to_be_less_or_equal(self in ut_expectation, a_expected number) is
- +
+ +begin
- + 3 +
+ +self.to_( ut_be_less_or_equal (a_expected) );
- +
+ +end;
- +
+ +- +
+ +member procedure to_be_less_or_equal(self in ut_expectation, a_expected timestamp_unconstrained) is
- +
+ +begin
- + 3 +
+ +self.to_( ut_be_less_or_equal (a_expected) );
- +
+ +end;
- +
+ +- +
+ +member procedure to_be_less_or_equal(self in ut_expectation, a_expected timestamp_ltz_unconstrained) is
- +
+ +begin
- + 3 +
+ +self.to_( ut_be_less_or_equal (a_expected) );
- +
+ +end;
- +
+ +- +
+ +member procedure to_be_less_or_equal(self in ut_expectation, a_expected timestamp_tz_unconstrained) is
- +
+ +begin
- + 3 +
+ +self.to_( ut_be_less_or_equal (a_expected) );
- +
+ +end;
- +
+ +- +
+ +member procedure to_be_less_or_equal(self in ut_expectation, a_expected yminterval_unconstrained) is
- +
+ +begin
- + 3 +
+ +self.to_( ut_be_less_or_equal (a_expected) );
- +
+ +end;
- +
+ +- +
+ +- +
+ +member procedure to_be_less_than(self in ut_expectation, a_expected date) is
- +
+ +begin
- + 3 +
+ +self.to_( ut_be_less_than (a_expected) );
- +
+ +end;
- +
+ +- +
+ +member procedure to_be_less_than(self in ut_expectation, a_expected dsinterval_unconstrained) is
- +
+ +begin
- + 3 +
+ +self.to_( ut_be_less_than (a_expected) );
- +
+ +end;
- +
+ +- +
+ +member procedure to_be_less_than(self in ut_expectation, a_expected number) is
- +
+ +begin
- + 3 +
+ +self.to_( ut_be_less_than (a_expected) );
- +
+ +end;
- +
+ +- +
+ +member procedure to_be_less_than(self in ut_expectation, a_expected timestamp_unconstrained) is
- +
+ +begin
- + 3 +
+ +self.to_( ut_be_less_than (a_expected) );
- +
+ +end;
- +
+ +- +
+ +member procedure to_be_less_than(self in ut_expectation, a_expected timestamp_ltz_unconstrained) is
- +
+ +begin
- + 3 +
+ +self.to_( ut_be_less_than (a_expected) );
- +
+ +end;
- +
+ +- +
+ +member procedure to_be_less_than(self in ut_expectation, a_expected timestamp_tz_unconstrained) is
- +
+ +begin
- + 3 +
+ +self.to_( ut_be_less_than (a_expected) );
- +
+ +end;
- +
+ +- +
+ +member procedure to_be_less_than(self in ut_expectation, a_expected yminterval_unconstrained) is
- +
+ +begin
- + 3 +
+ +self.to_( ut_be_less_than (a_expected) );
- +
+ +end;
- +
+ +- +
+ +- +
+ +member procedure not_to_be_between(self in ut_expectation, a_lower_bound date, a_upper_bound date) is
- +
+ +begin
- + 4 +
+ +self.not_to( ut_be_between(a_lower_bound,a_upper_bound) );
- +
+ +end;
- +
+ +- +
+ +member procedure not_to_be_between(self in ut_expectation, a_lower_bound dsinterval_unconstrained, a_upper_bound dsinterval_unconstrained) is
- +
+ +begin
- + 4 +
+ +self.not_to( ut_be_between(a_lower_bound,a_upper_bound) );
- +
+ +end;
- +
+ +- +
+ +member procedure not_to_be_between(self in ut_expectation, a_lower_bound number, a_upper_bound number) is
- +
+ +begin
- + 4 +
+ +self.not_to( ut_be_between(a_lower_bound,a_upper_bound) );
- +
+ +end;
- +
+ +- +
+ +member procedure not_to_be_between(self in ut_expectation, a_lower_bound timestamp_unconstrained, a_upper_bound timestamp_unconstrained) is
- +
+ +begin
- + 5 +
+ +self.not_to( ut_be_between(a_lower_bound, a_upper_bound) );
- +
+ +end;
- +
+ +- +
+ +member procedure not_to_be_between(self in ut_expectation, a_lower_bound timestamp_ltz_unconstrained, a_upper_bound timestamp_ltz_unconstrained) is
- +
+ +begin
- + 5 +
+ +self.not_to( ut_be_between(a_lower_bound, a_upper_bound) );
- +
+ +end;
- +
+ +- +
+ +member procedure not_to_be_between(self in ut_expectation, a_lower_bound timestamp_tz_unconstrained, a_upper_bound timestamp_tz_unconstrained) is
- +
+ +begin
- + 5 +
+ +self.not_to( ut_be_between(a_lower_bound, a_upper_bound) );
- +
+ +end;
- +
+ +- +
+ +member procedure not_to_be_between(self in ut_expectation, a_lower_bound varchar2, a_upper_bound varchar2) is
- +
+ +begin
- + 4 +
+ +self.not_to( ut_be_between(a_lower_bound,a_upper_bound) );
- +
+ +end;
- +
+ +- +
+ +member procedure not_to_be_between(self in ut_expectation, a_lower_bound yminterval_unconstrained, a_upper_bound yminterval_unconstrained) is
- +
+ +begin
- + 4 +
+ +self.not_to( ut_be_between(a_lower_bound,a_upper_bound) );
- +
+ +end;
- +
+ +- +
+ +- +
+ +member procedure not_to_be_greater_or_equal(self in ut_expectation, a_expected date) is
- +
+ +begin
- + 1 +
+ +self.not_to( ut_be_greater_or_equal (a_expected) );
- +
+ +end;
- +
+ +- +
+ +member procedure not_to_be_greater_or_equal(self in ut_expectation, a_expected dsinterval_unconstrained) is
- +
+ +begin
- + 1 +
+ +self.not_to( ut_be_greater_or_equal (a_expected) );
- +
+ +end;
- +
+ +- +
+ +member procedure not_to_be_greater_or_equal(self in ut_expectation, a_expected number) is
- +
+ +begin
- + 1 +
+ +self.not_to( ut_be_greater_or_equal (a_expected) );
- +
+ +end;
- +
+ +- +
+ +member procedure not_to_be_greater_or_equal(self in ut_expectation, a_expected timestamp_unconstrained) is
- +
+ +begin
- + 1 +
+ +self.not_to( ut_be_greater_or_equal (a_expected) );
- +
+ +end;
- +
+ +- +
+ +member procedure not_to_be_greater_or_equal(self in ut_expectation, a_expected timestamp_ltz_unconstrained) is
- +
+ +begin
- + 1 +
+ +self.not_to( ut_be_greater_or_equal (a_expected) );
- +
+ +end;
- +
+ +- +
+ +member procedure not_to_be_greater_or_equal(self in ut_expectation, a_expected timestamp_tz_unconstrained) is
- +
+ +begin
- + 1 +
+ +self.not_to( ut_be_greater_or_equal (a_expected) );
- +
+ +end;
- +
+ +- +
+ +member procedure not_to_be_greater_or_equal(self in ut_expectation, a_expected yminterval_unconstrained) is
- +
+ +begin
- + 1 +
+ +self.not_to( ut_be_greater_or_equal (a_expected) );
- +
+ +end;
- +
+ +- +
+ +- +
+ +member procedure not_to_be_greater_than(self in ut_expectation, a_expected date) is
- +
+ +begin
- + 1 +
+ +self.not_to( ut_be_greater_than (a_expected) );
- +
+ +end;
- +
+ +- +
+ +member procedure not_to_be_greater_than(self in ut_expectation, a_expected dsinterval_unconstrained) is
- +
+ +begin
- + 1 +
+ +self.not_to( ut_be_greater_than (a_expected) );
- +
+ +end;
- +
+ +- +
+ +member procedure not_to_be_greater_than(self in ut_expectation, a_expected number) is
- +
+ +begin
- + 1 +
+ +self.not_to( ut_be_greater_than (a_expected) );
- +
+ +end;
- +
+ +- +
+ +member procedure not_to_be_greater_than(self in ut_expectation, a_expected timestamp_unconstrained) is
- +
+ +begin
- + 1 +
+ +self.not_to( ut_be_greater_than (a_expected) );
- +
+ +end;
- +
+ +- +
+ +member procedure not_to_be_greater_than(self in ut_expectation, a_expected timestamp_ltz_unconstrained) is
- +
+ +begin
- + 1 +
+ +self.not_to( ut_be_greater_than (a_expected) );
- +
+ +end;
- +
+ +- +
+ +member procedure not_to_be_greater_than(self in ut_expectation, a_expected timestamp_tz_unconstrained) is
- +
+ +begin
- + 1 +
+ +self.not_to( ut_be_greater_than (a_expected) );
- +
+ +end;
- +
+ +- +
+ +member procedure not_to_be_greater_than(self in ut_expectation, a_expected yminterval_unconstrained) is
- +
+ +begin
- + 1 +
+ +self.not_to( ut_be_greater_than (a_expected) );
- +
+ +end;
- +
+ +- +
+ +- +
+ +member procedure not_to_be_less_or_equal(self in ut_expectation, a_expected date) is
- +
+ +begin
- + 1 +
+ +self.not_to( ut_be_less_or_equal (a_expected) );
- +
+ +end;
- +
+ +- +
+ +member procedure not_to_be_less_or_equal(self in ut_expectation, a_expected dsinterval_unconstrained) is
- +
+ +begin
- + 1 +
+ +self.not_to( ut_be_less_or_equal (a_expected) );
- +
+ +end;
- +
+ +- +
+ +member procedure not_to_be_less_or_equal(self in ut_expectation, a_expected number) is
- +
+ +begin
- + 1 +
+ +self.not_to( ut_be_less_or_equal (a_expected) );
- +
+ +end;
- +
+ +- +
+ +member procedure not_to_be_less_or_equal(self in ut_expectation, a_expected timestamp_unconstrained) is
- +
+ +begin
- + 1 +
+ +self.not_to( ut_be_less_or_equal (a_expected) );
- +
+ +end;
- +
+ +- +
+ +member procedure not_to_be_less_or_equal(self in ut_expectation, a_expected timestamp_ltz_unconstrained) is
- +
+ +begin
- + 1 +
+ +self.not_to( ut_be_less_or_equal (a_expected) );
- +
+ +end;
- +
+ +- +
+ +member procedure not_to_be_less_or_equal(self in ut_expectation, a_expected timestamp_tz_unconstrained) is
- +
+ +begin
- + 1 +
+ +self.not_to( ut_be_less_or_equal (a_expected) );
- +
+ +end;
- +
+ +- +
+ +member procedure not_to_be_less_or_equal(self in ut_expectation, a_expected yminterval_unconstrained) is
- +
+ +begin
- + 1 +
+ +self.not_to( ut_be_less_or_equal (a_expected) );
- +
+ +end;
- +
+ +- +
+ +- +
+ +member procedure not_to_be_less_than(self in ut_expectation, a_expected date) is
- +
+ +begin
- + 1 +
+ +self.not_to( ut_be_less_than (a_expected) );
- +
+ +end;
- +
+ +- +
+ +member procedure not_to_be_less_than(self in ut_expectation, a_expected dsinterval_unconstrained) is
- +
+ +begin
- + 1 +
+ +self.not_to( ut_be_less_than (a_expected) );
- +
+ +end;
- +
+ +- +
+ +member procedure not_to_be_less_than(self in ut_expectation, a_expected number) is
- +
+ +begin
- + 1 +
+ +self.not_to( ut_be_less_than (a_expected) );
- +
+ +end;
- +
+ +- +
+ +member procedure not_to_be_less_than(self in ut_expectation, a_expected timestamp_unconstrained) is
- +
+ +begin
- + 1 +
+ +self.not_to( ut_be_less_than (a_expected) );
- +
+ +end;
- +
+ +- +
+ +member procedure not_to_be_less_than(self in ut_expectation, a_expected timestamp_ltz_unconstrained) is
- +
+ +begin
- + 1 +
+ +self.not_to( ut_be_less_than (a_expected) );
- +
+ +end;
- +
+ +- +
+ +member procedure not_to_be_less_than(self in ut_expectation, a_expected timestamp_tz_unconstrained) is
- +
+ +begin
- + 1 +
+ +self.not_to( ut_be_less_than (a_expected) );
- +
+ +end;
- +
+ +- +
+ +member procedure not_to_be_less_than(self in ut_expectation, a_expected yminterval_unconstrained) is
- +
+ +begin
- + 1 +
+ +self.not_to( ut_be_less_than (a_expected) );
- +
+ +end;
- +
+ +- +
+ +member procedure to_contain(self in ut_expectation, a_expected sys_refcursor) is
- +
+ +begin
- + 5 +
+ +self.to_( ut_contain(a_expected) );
- +
+ +end;
- +
+ +- +
+ +member procedure not_to_contain(self in ut_expectation, a_expected sys_refcursor) is
- +
+ +begin
- + 2 +
+ +self.not_to( ut_contain(a_expected).negated() );
- +
+ +end;
- +
+ +- +
+ +member procedure to_contain(self in ut_expectation, a_expected anydata) is
- +
+ +begin
- + 2 +
+ +self.to_( ut_contain(a_expected) );
- +
+ +end;
- +
+ +- +
+ +member procedure not_to_contain(self in ut_expectation, a_expected anydata) is
- +
+ +begin
- +
+ +self.not_to( ut_contain(a_expected).negated() );
- +
+ +end;
- +
+ +- +
+end;
+UT3.UT_EXPECTATION_COMPOUND
77.19 % lines covered
57 relevant lines. 44 lines covered and 13 lines missed+ +
- +
+ +type body ut_expectation_compound as
- +
+ +/*
- +
+ +utPLSQL - Version 3
- +
+ +Copyright 2016 - 2019 utPLSQL Project
- +
+ +- +
+ +Licensed under the Apache License, Version 2.0 (the "License"):
- +
+ +you may not use this file except in compliance with the License.
- +
+ +You may obtain a copy of the License at
- +
+ +- +
+ +http://www.apache.org/licenses/LICENSE-2.0
- +
+ +- +
+ +Unless required by applicable law or agreed to in writing, software
- +
+ +distributed under the License is distributed on an "AS IS" BASIS,
- +
+ +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
+ +See the License for the specific language governing permissions and
- +
+ +limitations under the License.
- +
+ +*/
- +
+ +- +
+ +constructor function ut_expectation_compound(self in out nocopy ut_expectation_compound, a_actual_data ut_data_value, a_description varchar2) return self as result is
- +
+ +begin
- + 259 +
+ +self.actual_data := a_actual_data;
- + 259 +
+ +self.description := a_description;
- + 259 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +member procedure to_have_count(self in ut_expectation_compound, a_expected integer) is
- +
+ +begin
- + 11 +
+ +self.to_( ut_have_count(a_expected) );
- +
+ +end;
- +
+ +- +
+ +member procedure not_to_have_count(self in ut_expectation_compound, a_expected integer) is
- +
+ +begin
- + 7 +
+ +self.not_to( ut_have_count(a_expected) );
- +
+ +end;
- +
+ +- +
+ +- +
+ +member function to_equal(a_expected anydata, a_nulls_are_equal boolean := null) return ut_expectation_compound is
- + 16 +
+ +l_result ut_expectation_compound := self;
- +
+ +begin
- + 16 +
+ +l_result.matcher := ut_equal(a_expected, a_nulls_are_equal);
- + 16 +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+ +member function not_to_equal(a_expected anydata, a_nulls_are_equal boolean := null) return ut_expectation_compound is
- + 1 +
+ +l_result ut_expectation_compound := self;
- +
+ +begin
- + 1 +
+ +l_result.matcher := ut_equal(a_expected, a_nulls_are_equal).negated();
- + 1 +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+ +member function to_equal(a_expected sys_refcursor, a_nulls_are_equal boolean := null) return ut_expectation_compound is
- + 57 +
+ +l_result ut_expectation_compound := self;
- +
+ +begin
- + 57 +
+ +l_result.matcher := ut_equal(a_expected, a_nulls_are_equal);
- + 57 +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+ +member function not_to_equal(a_expected sys_refcursor, a_nulls_are_equal boolean := null) return ut_expectation_compound is
- +
+ +l_result ut_expectation_compound := self;
- +
+ +begin
- +
+ +l_result.matcher := ut_equal(a_expected, a_nulls_are_equal).negated();
- +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+ +member function to_contain(a_expected sys_refcursor) return ut_expectation_compound is
- + 8 +
+ +l_result ut_expectation_compound := self;
- +
+ +begin
- + 8 +
+ +l_result.matcher := ut_contain(a_expected);
- + 8 +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+ +member function not_to_contain(a_expected sys_refcursor) return ut_expectation_compound is
- + 3 +
+ +l_result ut_expectation_compound := self;
- +
+ +begin
- + 3 +
+ +l_result.matcher := ut_contain(a_expected).negated();
- + 3 +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+ +member function to_contain(a_expected anydata) return ut_expectation_compound is
- +
+ +l_result ut_expectation_compound := self;
- +
+ +begin
- +
+ +l_result.matcher := ut_contain(a_expected);
- +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+ +member function not_to_contain(a_expected anydata) return ut_expectation_compound is
- +
+ +l_result ut_expectation_compound := self;
- +
+ +begin
- +
+ +l_result.matcher := ut_contain(a_expected).negated();
- +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+ +member function include(a_items varchar2) return ut_expectation_compound is
- +
+ +begin
- + 1 +
+ +return include( ut_varchar2_list( a_items ) );
- +
+ +end;
- +
+ +- +
+ +member function include(a_items ut_varchar2_list) return ut_expectation_compound is
- + 6 +
+ +l_result ut_expectation_compound := self;
- +
+ +begin
- + 6 +
+ +l_result.matcher := treat(l_result.matcher as ut_equal).include(a_items);
- + 6 +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+ +member procedure include(self in ut_expectation_compound, a_items varchar2) is
- +
+ +begin
- + 7 +
+ +include( ut_varchar2_list( a_items ) );
- +
+ +end;
- +
+ +- +
+ +member procedure include(self in ut_expectation_compound, a_items ut_varchar2_list) is
- +
+ +begin
- + 16 +
+ +self.to_( treat(matcher as ut_equal).include(a_items) );
- +
+ +end;
- +
+ +- +
+ +member function exclude(a_items varchar2) return ut_expectation_compound is
- +
+ +begin
- + 2 +
+ +return exclude( ut_varchar2_list( a_items ) );
- +
+ +end;
- +
+ +- +
+ +member function exclude(a_items ut_varchar2_list) return ut_expectation_compound is
- + 8 +
+ +l_result ut_expectation_compound := self;
- +
+ +begin
- + 8 +
+ +l_result.matcher := treat(l_result.matcher as ut_equal).exclude(a_items);
- + 8 +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+ +member procedure exclude(self in ut_expectation_compound, a_items varchar2) is
- +
+ +begin
- + 3 +
+ +exclude( ut_varchar2_list( a_items ) );
- +
+ +end;
- +
+ +- +
+ +member procedure exclude(self in ut_expectation_compound, a_items ut_varchar2_list) is
- +
+ +begin
- + 7 +
+ +self.to_( treat(matcher as ut_equal).exclude(a_items) );
- +
+ +end;
- +
+ +- +
+ +member function unordered return ut_expectation_compound is
- + 1 +
+ +l_result ut_expectation_compound := self;
- +
+ +begin
- + 1 +
+ +l_result.matcher := treat(l_result.matcher as ut_equal).unordered();
- + 1 +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+ +member procedure unordered(self in ut_expectation_compound) is
- +
+ +begin
- + 14 +
+ +self.to_( treat(matcher as ut_equal).unordered() );
- +
+ +end;
- +
+ +- +
+ +member function join_by(a_columns varchar2) return ut_expectation_compound is
- +
+ +begin
- + 3 +
+ +return join_by( ut_varchar2_list( a_columns ) );
- +
+ +end;
- +
+ +- +
+ +member function join_by(a_columns ut_varchar2_list) return ut_expectation_compound is
- +
+ +l_result ut_expectation_compound;
- +
+ +begin
- + 4 +
+ +l_result := self;
- + 4 +
+ +l_result.matcher := treat(l_result.matcher as ut_equal).join_by(a_columns);
- + 4 +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+ +member procedure join_by(self in ut_expectation_compound, a_columns varchar2) is
- +
+ +begin
- + 31 +
+ +join_by( ut_varchar2_list( a_columns ) );
- +
+ +end;
- +
+ +- +
+ +member procedure join_by(self in ut_expectation_compound, a_columns ut_varchar2_list) is
- +
+ +begin
- + 38 +
+ +self.to_( treat(matcher as ut_equal).join_by(a_columns) );
- +
+ +end;
- +
+ +- +
+ +member function unordered_columns return ut_expectation_compound is
- +
+ +l_result ut_expectation_compound;
- +
+ +begin
- +
+ +l_result := self;
- +
+ +l_result.matcher := treat(l_result.matcher as ut_equal).unordered_columns;
- +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+ +member procedure unordered_columns(self in ut_expectation_compound) is
- +
+ +begin
- + 10 +
+ +self.to_( treat(matcher as ut_equal).unordered_columns );
- +
+ +end;
- +
+ +- +
+ +member function uc return ut_expectation_compound is
- +
+ +begin
- +
+ +return unordered_columns;
- +
+ +end;
- +
+ +- +
+ +member procedure uc(self in ut_expectation_compound) is
- +
+ +begin
- + 5 +
+ +unordered_columns;
- +
+ +end;
- +
+ +- +
+end;
+UT3.UT_EXPECTATION_JSON
45.45 % lines covered
11 relevant lines. 5 lines covered and 6 lines missed+ +
- +
+ +type body ut_expectation_json as
- +
+ +/*
- +
+ +utPLSQL - Version 3
- +
+ +Copyright 2016 - 2019 utPLSQL Project
- +
+ +- +
+ +Licensed under the Apache License, Version 2.0 (the "License"):
- +
+ +you may not use this file except in compliance with the License.
- +
+ +You may obtain a copy of the License at
- +
+ +- +
+ +http://www.apache.org/licenses/LICENSE-2.0
- +
+ +- +
+ +Unless required by applicable law or agreed to in writing, software
- +
+ +distributed under the License is distributed on an "AS IS" BASIS,
- +
+ +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
+ +See the License for the specific language governing permissions and
- +
+ +limitations under the License.
- +
+ +*/
- +
+ +- +
+ +constructor function ut_expectation_json(self in out nocopy ut_expectation_json, a_actual_data ut_data_value, a_description varchar2) return self as result is
- +
+ +begin
- + 23 +
+ +self.actual_data := a_actual_data;
- + 23 +
+ +self.description := a_description;
- + 23 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +member function to_equal(a_expected json_element_t, a_nulls_are_equal boolean := null) return ut_expectation_json is
- +
+ +l_result ut_expectation_json := self;
- +
+ +begin
- +
+ +l_result.matcher := ut_equal(a_expected, a_nulls_are_equal);
- +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+ +member function not_to_equal(a_expected json_element_t, a_nulls_are_equal boolean := null) return ut_expectation_json is
- +
+ +l_result ut_expectation_json := self;
- +
+ +begin
- +
+ +l_result.matcher := ut_equal(a_expected, a_nulls_are_equal).negated();
- +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+ +member procedure to_have_count(self in ut_expectation_json, a_expected integer) is
- +
+ +begin
- + 3 +
+ +self.to_( ut_have_count(a_expected) );
- +
+ +end;
- +
+ +- +
+ +member procedure not_to_have_count(self in ut_expectation_json, a_expected integer) is
- +
+ +begin
- + 2 +
+ +self.not_to( ut_have_count(a_expected) );
- +
+ +end;
- +
+ +- +
+end;
+UT3.UT_ANSICONSOLE_HELPER
92.86 % lines covered
14 relevant lines. 13 lines covered and 1 lines missed+ +
- +
+ +package body ut_ansiconsole_helper as
- +
+ +/*
- +
+ +utPLSQL - Version 3
- +
+ +Copyright 2016 - 2019 utPLSQL Project
- +
+ +- +
+ +Licensed under the Apache License, Version 2.0 (the "License"):
- +
+ +you may not use this file except in compliance with the License.
- +
+ +You may obtain a copy of the License at
- +
+ +- +
+ +http://www.apache.org/licenses/LICENSE-2.0
- +
+ +- +
+ +Unless required by applicable law or agreed to in writing, software
- +
+ +distributed under the License is distributed on an "AS IS" BASIS,
- +
+ +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
+ +See the License for the specific language governing permissions and
- +
+ +limitations under the License.
- +
+ +*/
- + 1 +
+ +gc_red constant varchar2(7) := chr(27) || '[31m';
- + 1 +
+ +gc_green constant varchar2(7) := chr(27) || '[32m';
- + 1 +
+ +gc_yellow constant varchar2(7) := chr(27) || '[33m';
- + 1 +
+ +gc_cyan constant varchar2(7) := chr(27) || '[36m';
- + 1 +
+ +gc_reset constant varchar2(7) := chr(27) || '[0m';
- + 1 +
+ +g_enabled boolean := false;
- +
+ +- +
+ +procedure color_enabled(a_enabled boolean) is
- +
+ +begin
- + 116 +
+ +g_enabled := a_enabled;
- +
+ +end;
- +
+ +- +
+ +function add_color(a_text varchar2, a_color varchar2 := gc_reset) return varchar2 is
- +
+ +begin
- + 398 +
+ +if g_enabled and a_text is not null then
- +
+ +return a_color||a_text||gc_reset;
- +
+ +else
- + 398 +
+ +return a_text;
- +
+ +end if;
- +
+ +end;
- +
+ +- +
+ +function red(a_text varchar2) return varchar2 is
- +
+ +begin
- + 207 +
+ +return add_color(a_text, gc_red);
- +
+ +end;
- +
+ +- +
+ +function green(a_text varchar2) return varchar2 is
- +
+ +begin
- + 180 +
+ +return add_color(a_text, gc_green);
- +
+ +end;
- +
+ +- +
+ +function yellow(a_text varchar2) return varchar2 is
- +
+ +begin
- + 1 +
+ +return add_color(a_text, gc_yellow);
- +
+ +end;
- +
+ +- +
+ +function cyan(a_text varchar2) return varchar2 is
- +
+ +begin
- + 10 +
+ +return add_color(a_text, gc_cyan);
- +
+ +end;
- +
+ +- +
+end;
+UT3.UT_COVERAGE_COBERTURA_REPORTER
91.8 % lines covered
61 relevant lines. 56 lines covered and 5 lines missed+ +
- +
+ +type body ut_coverage_cobertura_reporter is
- +
+ +/*
- +
+ +utPLSQL - Version 3
- +
+ +Copyright 2016 - 2019 utPLSQL Project
- +
+ +- +
+ +Licensed under the Apache License, Version 2.0 (the "License"):
- +
+ +you may not use this file except in compliance with the License.
- +
+ +You may obtain a copy of the License at
- +
+ +- +
+ +http://www.apache.org/licenses/LICENSE-2.0
- +
+ +- +
+ +Unless required by applicable law or agreed to in writing, software
- +
+ +distributed under the License is distributed on an "AS IS" BASIS,
- +
+ +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
+ +See the License for the specific language governing permissions and
- +
+ +limitations under the License.
- +
+ +*/
- +
+ +- +
+ +constructor function ut_coverage_cobertura_reporter(
- +
+ +self in out nocopy ut_coverage_cobertura_reporter
- +
+ +) return self as result is
- +
+ +begin
- + 2 +
+ +self.init($$plsql_unit);
- + 2 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +- +
+ +overriding member procedure after_calling_run(self in out nocopy ut_coverage_cobertura_reporter, a_run in ut_run) as
- +
+ +l_report_lines ut_varchar2_list;
- + 2 +
+ +l_coverage_data ut_coverage.t_coverage;
- +
+ +- +
+ +function get_lines_xml(a_unit_coverage ut_coverage.t_unit_coverage) return clob is
- +
+ +l_file_part varchar2(32767);
- +
+ +l_result clob;
- +
+ +l_line_no binary_integer;
- +
+ +l_pct integer;
- +
+ +begin
- + 2 +
+ +dbms_lob.createtemporary(l_result, true);
- + 2 +
+ +l_line_no := a_unit_coverage.lines.first;
- + 2 +
+ +if l_line_no is null then
- + 16 +
+ +for i in 1 .. a_unit_coverage.total_lines loop
- + 15 +
+ +ut_utils.append_to_clob(l_result, '<line number="'||i||'" hits="0" branch="false"/>'||chr(10));
- +
+ +end loop;
- +
+ +else
- + 4 +
+ +while l_line_no is not null loop
- + 3 +
+ +if a_unit_coverage.lines(l_line_no).executions = 0 then
- + 1 +
+ +l_file_part := '<line number="'||l_line_no||'" hits="0" branch="false"/>'||chr(10);
- +
+ +else
- + 2 +
+ +l_file_part := '<line number="'||l_line_no||'" hits="'||a_unit_coverage.lines(l_line_no).executions||'"';
- + 2 +
+ +if a_unit_coverage.lines(l_line_no).covered_blocks < a_unit_coverage.lines(l_line_no).no_blocks then
- +
+ +l_file_part := l_file_part || ' branch="true"';
- +
+ +l_pct := (a_unit_coverage.lines(l_line_no).covered_blocks/a_unit_coverage.lines(l_line_no).no_blocks)*100;
- +
+ +l_file_part := l_file_part || ' condition-coverage="'||l_pct||'%';
- +
+ +l_file_part := l_file_part || ' ('||a_unit_coverage.lines(l_line_no).covered_blocks||'/'||a_unit_coverage.lines(l_line_no).no_blocks||')"';
- +
+ +else
- + 2 +
+ +l_file_part := l_file_part || ' branch="false"';
- +
+ +end if;
- + 2 +
+ +l_file_part := l_file_part ||'/>'||chr(10);
- +
+ +end if;
- + 3 +
+ +ut_utils.append_to_clob(l_result, l_file_part);
- + 3 +
+ +l_line_no := a_unit_coverage.lines.next(l_line_no);
- +
+ +end loop;
- +
+ +end if;
- + 2 +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+ +function get_coverage_xml(
- +
+ +a_coverage_data ut_coverage.t_coverage,
- +
+ +a_run ut_run
- +
+ +) return ut_varchar2_rows is
- +
+ +l_file_part varchar2(32767);
- + 2 +
+ +l_result ut_varchar2_rows := ut_varchar2_rows();
- +
+ +l_unit ut_coverage.t_full_name;
- +
+ +l_obj_name ut_coverage.t_object_name;
- + 2 +
+ +c_coverage_def constant varchar2(200) := '<!DOCTYPE coverage SYSTEM "http://cobertura.sourceforge.net/xml/coverage-04.dtd">';
- + 2 +
+ +c_file_footer constant varchar2(30) := '</file>';
- + 2 +
+ +c_coverage_footer constant varchar2(30) := '</coverage>';
- + 2 +
+ +c_sources_footer constant varchar2(30) := '</sources>';
- + 2 +
+ +c_packages_footer constant varchar2(30) := '</packages>';
- + 2 +
+ +c_package_footer constant varchar2(30) := '</package>';
- + 2 +
+ +c_class_footer constant varchar2(30) := '</class>';
- + 2 +
+ +c_lines_footer constant varchar2(30) := '</lines>';
- + 2 +
+ +l_epoch varchar2(50) := (sysdate - to_date('01-01-1970 00:00:00', 'dd-mm-yyyy hh24:mi:ss')) * 24 * 60 * 60;
- +
+ +begin
- +
+ +- + 2 +
+ +ut_utils.append_to_list( l_result, ut_utils.get_xml_header(a_run.client_character_set) );
- + 2 +
+ +ut_utils.append_to_list( l_result, c_coverage_def );
- +
+ +- +
+ +--write header
- + 2 +
+ +ut_utils.append_to_list(
- +
+ +l_result,
- +
+ +'<coverage line-rate="0" branch-rate="0.0" lines-covered="'
- +
+ +||a_coverage_data.covered_lines||'" lines-valid="'
- +
+ +||TO_CHAR(a_coverage_data.covered_lines + a_coverage_data.uncovered_lines)
- +
+ +||'" branches-covered="0" branches-valid="0" complexity="0" version="1" timestamp="'||l_epoch||'">'
- +
+ +);
- +
+ +- +
+ +- +
+ +--Write sources
- + 2 +
+ +l_unit := a_coverage_data.objects.first;
- + 2 +
+ +ut_utils.append_to_list( l_result, '<sources>' );
- +
+ +- + 4 +
+ +while l_unit is not null loop
- + 3 +
+ +ut_utils.append_to_list(l_result, '<source>'||dbms_xmlgen.convert(l_unit)||'</source>');
- + 2 +
+ +l_unit := a_coverage_data.objects.next(l_unit);
- +
+ +end loop;
- + 2 +
+ +ut_utils.append_to_list(l_result, c_sources_footer);
- +
+ +- +
+ +--write packages
- + 2 +
+ +l_unit := a_coverage_data.objects.first;
- + 2 +
+ +ut_utils.append_to_list(l_result, '<packages>');
- +
+ +- + 4 +
+ +while l_unit is not null loop
- + 2 +
+ +l_obj_name := a_coverage_data.objects(l_unit).name;
- + 2 +
+ +ut_utils.append_to_list(
- +
+ +l_result,
- +
+ +'<package name="'||dbms_xmlgen.convert(l_obj_name)||'" line-rate="0.0" branch-rate="0.0" complexity="0.0">'
- +
+ +);
- +
+ +- + 2 +
+ +ut_utils.append_to_list(
- +
+ +l_result,
- +
+ +'<class name="'||dbms_xmlgen.convert(l_obj_name)||'" filename="'
- +
+ +||dbms_xmlgen.convert(l_unit)||'" line-rate="0.0" branch-rate="0.0" complexity="0.0">'
- +
+ +);
- +
+ +- + 2 +
+ +ut_utils.append_to_list(l_result, '<lines>');
- +
+ +- + 2 +
+ +ut_utils.append_to_list( l_result, get_lines_xml(a_coverage_data.objects(l_unit)) );
- +
+ +- + 2 +
+ +ut_utils.append_to_list(l_result, c_lines_footer);
- + 2 +
+ +ut_utils.append_to_list(l_result, c_class_footer);
- + 2 +
+ +ut_utils.append_to_list(l_result, c_package_footer);
- +
+ +- + 2 +
+ +l_unit := a_coverage_data.objects.next(l_unit);
- +
+ +end loop;
- +
+ +- + 2 +
+ +ut_utils.append_to_list(l_result, c_packages_footer);
- + 2 +
+ +ut_utils.append_to_list(l_result, c_coverage_footer);
- + 2 +
+ +return l_result;
- +
+ +end;
- +
+ +begin
- + 3 +
+ +ut_coverage.coverage_stop();
- +
+ +- + 2 +
+ +l_coverage_data := ut_coverage.get_coverage_data(a_run.coverage_options);
- +
+ +- + 2 +
+ +self.print_text_lines( get_coverage_xml( l_coverage_data, a_run ) );
- +
+ +- + 2 +
+ +(self as ut_reporter_base).after_calling_run(a_run);
- +
+ +end;
- +
+ +- +
+ +overriding member function get_description return varchar2 as
- +
+ +begin
- +
+ +return 'Generates a Cobertura coverage report providing information on code coverage with line numbers.' || chr(10) ||
- +
+ +'Designed for Jenkins and TFS to report coverage. ' || chr(10) ||
- +
+ +'Cobertura Document Type Definition can be found: http://cobertura.sourceforge.net/xml/coverage-04.dtd.'|| chr(10) ||
- +
+ +'Sample file: https://github.com/leobalter/testing-examples/blob/master/solutions/3/report/cobertura-coverage.xml.';
- +
+ +end;
- +
+ +- +
+end;
+UT3.UT_COVERAGE_HTML_REPORTER
88.89 % lines covered
9 relevant lines. 8 lines covered and 1 lines missed+ +
- +
+ +type body ut_coverage_html_reporter is
- +
+ +/*
- +
+ +utPLSQL - Version 3
- +
+ +Copyright 2016 - 2019 utPLSQL Project
- +
+ +- +
+ +Licensed under the Apache License, Version 2.0 (the "License"):
- +
+ +you may not use this file except in compliance with the License.
- +
+ +You may obtain a copy of the License at
- +
+ +- +
+ +http://www.apache.org/licenses/LICENSE-2.0
- +
+ +- +
+ +Unless required by applicable law or agreed to in writing, software
- +
+ +distributed under the License is distributed on an "AS IS" BASIS,
- +
+ +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
+ +See the License for the specific language governing permissions and
- +
+ +limitations under the License.
- +
+ +*/
- +
+ +- +
+ +constructor function ut_coverage_html_reporter(
- +
+ +self in out nocopy ut_coverage_html_reporter,
- +
+ +a_project_name varchar2 := null,
- +
+ +a_html_report_assets_path varchar2 := null
- +
+ +) return self as result is
- +
+ +begin
- + 1 +
+ +self.init($$plsql_unit);
- + 1 +
+ +self.project_name := a_project_name;
- + 1 +
+ +assets_path := nvl(a_html_report_assets_path, ut_coverage_report_html_helper.get_default_html_assets_path());
- + 1 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +overriding member procedure after_calling_run(self in out nocopy ut_coverage_html_reporter, a_run in ut_run) as
- + 1 +
+ +l_coverage_data ut_coverage.t_coverage;
- +
+ +begin
- + 2 +
+ +ut_coverage.coverage_stop();
- + 1 +
+ +l_coverage_data := ut_coverage.get_coverage_data(a_run.coverage_options);
- +
+ +- + 1 +
+ +self.print_text_lines(
- +
+ +ut_coverage_report_html_helper.get_index(
- +
+ +a_coverage_data => l_coverage_data,
- +
+ +a_assets_path => self.assets_path,
- +
+ +a_project_name => self.project_name,
- +
+ +a_charset => a_run.client_character_set
- +
+ +)
- +
+ +);
- +
+ +end;
- +
+ +- +
+ +- +
+ +overriding member function get_description return varchar2 as
- +
+ +begin
- +
+ +return 'Generates a HTML coverage report with summary and line by line information on code coverage.' || chr(10) ||
- +
+ +'Based on open-source simplecov-html coverage reporter for Ruby.' || chr(10) ||
- +
+ +'Includes source code in the report.';
- +
+ +end;
- +
+ +- +
+end;
+UT3.UT_COVERAGE_REPORT_HTML_HELPER
94.44 % lines covered
108 relevant lines. 102 lines covered and 6 lines missed+ +
- +
+ +package body ut_coverage_report_html_helper is
- +
+ +/*
- +
+ +utPLSQL - Version 3
- +
+ +Copyright 2016 - 2019 utPLSQL Project
- +
+ +- +
+ +Licensed under the Apache License, Version 2.0 (the "License"):
- +
+ +you may not use this file except in compliance with the License.
- +
+ +You may obtain a copy of the License at
- +
+ +- +
+ +http://www.apache.org/licenses/LICENSE-2.0
- +
+ +- +
+ +Unless required by applicable law or agreed to in writing, software
- +
+ +distributed under the License is distributed on an "AS IS" BASIS,
- +
+ +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
+ +See the License for the specific language governing permissions and
- +
+ +limitations under the License.
- +
+ +*/
- +
+ +- + 1 +
+ +gc_green_coverage_pct constant integer := 90;
- + 1 +
+ +gc_yellow_coverage_pct constant integer := 80;
- +
+ +- + 1 +
+ +gc_green_css constant varchar2(10) := 'green';
- + 1 +
+ +gc_yellow_css constant varchar2(10) := 'yellow';
- + 1 +
+ +gc_red_css constant varchar2(10) := 'red';
- +
+ +- + 1 +
+ +gc_missed constant varchar2(7) := 'missed';
- + 1 +
+ +gc_skipped constant varchar2(7) := 'skipped';
- + 1 +
+ +gc_disabled constant varchar2(7) := 'never';
- + 1 +
+ +gc_covered constant varchar2(7) := 'covered';
- + 1 +
+ +gc_partcovered constant varchar2(7) := 'partcov';
- +
+ +- +
+ +function get_default_html_assets_path return varchar2 deterministic is
- + 1 +
+ +c_assets_path constant varchar2(200) := 'https://utplsql.github.io/utPLSQL-coverage-html/assets/';
- +
+ +begin
- + 1 +
+ +return c_assets_path;
- +
+ +end;
- +
+ +- +
+ +function coverage_css_class(a_covered_pct number) return varchar2 is
- +
+ +l_result varchar2(10);
- +
+ +begin
- + 5 +
+ +if a_covered_pct > gc_green_coverage_pct then
- +
+ +l_result := gc_green_css;
- + 5 +
+ +elsif a_covered_pct > gc_yellow_coverage_pct then
- +
+ +l_result := gc_yellow_css;
- +
+ +else
- + 5 +
+ +l_result := gc_red_css;
- +
+ +end if;
- + 5 +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+ +function line_status(a_executions in ut_coverage.t_line_executions) return varchar2 is
- +
+ +l_result varchar2(10);
- +
+ +begin
- + 16 +
+ +if a_executions.executions > 0 then
- + 3 +
+ +if NVL(a_executions.partcove,0) = 0 then
- + 2 +
+ +l_result := gc_covered;
- +
+ +else
- + 1 +
+ +l_result := gc_partcovered;
- +
+ +end if;
- + 13 +
+ +elsif a_executions.executions = 0 then
- + 1 +
+ +l_result := gc_missed;
- +
+ +else
- + 12 +
+ +l_result := gc_disabled;
- +
+ +end if;
- + 16 +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+ +function executions_per_line(a_executions number, a_lines integer) return integer is
- +
+ +begin
- + 3 +
+ +return nvl(a_executions / nullif(a_lines, 0), 0);
- +
+ +end;
- +
+ +- +
+ +function line_hits_css_class(a_line_hist number) return varchar2 is
- +
+ +l_result varchar2(10);
- +
+ +begin
- + 1 +
+ +if a_line_hist > 1 then
- +
+ +l_result := gc_green_css;
- + 1 +
+ +elsif a_line_hist = 1 then
- + 1 +
+ +l_result := gc_yellow_css;
- +
+ +else
- +
+ +l_result := gc_red_css;
- +
+ +end if;
- + 1 +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+ +function coverage_pct(a_covered_lines integer, a_uncovered_lines integer) return number is
- +
+ +begin
- + 4 +
+ +return ROUND(nvl(a_covered_lines / nullif(a_covered_lines + a_uncovered_lines, 0), 0) * 100, 2);
- +
+ +end;
- +
+ +- +
+ +function object_id(a_object_full_name varchar2) return varchar2 is
- +
+ +begin
- + 3 +
+ +return rawtohex(utl_raw.cast_to_raw(dbms_obfuscation_toolkit.md5(input_string => a_object_full_name)));
- +
+ +end;
- +
+ +- +
+ +function link_to_source_file(a_object_full_name varchar2) return varchar2 is
- +
+ +begin
- + 1 +
+ +return '<a href="#' || object_id(a_object_full_name) || '" class="src_link" title="' || a_object_full_name || '">' || a_object_full_name || '</a>';
- +
+ +end;
- +
+ +- +
+ +- +
+ +- +
+ +- +
+ +function get_details_file_content(
- +
+ +a_object_id varchar2,
- +
+ +a_unit ut_object_name,
- +
+ +a_unit_coverage ut_coverage.t_unit_coverage
- +
+ +) return ut_varchar2_rows is
- +
+ +- +
+ +function get_block_file_attributes(a_coverage_unit ut_coverage.t_unit_coverage) return varchar2 is
- +
+ +l_result varchar2(32767);
- +
+ +begin
- + 1 +
+ +if (a_coverage_unit.partcovered_lines is not null) AND (a_coverage_unit.partcovered_lines > 0) then
- + 1 +
+ +l_result := ' (including <span class="yellow"><b>'|| a_coverage_unit.partcovered_lines ||'</b> lines partially covered</span> )';
- +
+ +else
- +
+ +l_result := null;
- +
+ +end if;
- + 1 +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+ +function get_common_file_attributes(a_coverage_unit ut_coverage.t_unit_coverage) return varchar2 is
- +
+ +l_attributes varchar2(32767);
- +
+ +begin
- + 1 +
+ +l_attributes := '<div> <b>' ||(a_coverage_unit.covered_lines + a_coverage_unit.uncovered_lines)
- +
+ +||'</b> relevant lines. ' || '<span class="green"><b>' || a_coverage_unit.covered_lines
- +
+ +||'</b> lines covered</span>'
- +
+ +|| get_block_file_attributes(a_coverage_unit)
- +
+ +|| ' and <span class="red"><b>' || a_coverage_unit.uncovered_lines ||'</b> lines missed</span>';
- + 1 +
+ +return l_attributes;
- +
+ +end;
- +
+ +- +
+ +function build_details_file_content(a_object_id varchar2, a_object_full_name varchar2, a_source_code ut_varchar2_list, a_coverage_unit ut_coverage.t_unit_coverage)
- +
+ +return ut_varchar2_rows is
- +
+ +l_file_part varchar2(32767);
- + 1 +
+ +l_result ut_varchar2_rows := ut_varchar2_rows();
- +
+ +l_coverage_pct number(5, 2);
- +
+ +l_coverage_block_pct number(5, 2);
- +
+ +l_hits varchar2(30);
- +
+ +l_blocks varchar2(30);
- +
+ +begin
- +
+ +- + 1 +
+ +l_coverage_pct := coverage_pct(a_coverage_unit.covered_lines, a_coverage_unit.uncovered_lines);
- +
+ +- + 1 +
+ +l_file_part := '<div class="source_table" id="' || a_object_id || '"><div class="header"> <h3>' ||
- +
+ +dbms_xmlgen.convert(a_object_full_name) || '</h3><h4><span class="' || coverage_css_class(l_coverage_pct) || '">'
- +
+ +|| l_coverage_pct || ' %</span> lines covered</h4>'
- +
+ +||get_common_file_attributes(a_coverage_unit) ||'</div></div><pre><ol>';
- + 1 +
+ +ut_utils.append_to_list(l_result, l_file_part);
- +
+ +- + 17 +
+ +for line_no in 1 .. a_source_code.count loop
- + 16 +
+ +if not a_coverage_unit.lines.exists(line_no) then
- + 12 +
+ +l_file_part := '
- +
+ +<li class="' || line_status(null) || '" data-hits="" data-linenumber="' || line_no || '">
- +
+ +<code class="sql">' || (dbms_xmlgen.convert(a_source_code(line_no))) ||
- +
+ +'</code></li>';
- +
+ +else
- + 4 +
+ +l_hits := to_char(a_coverage_unit.lines(line_no).executions);
- + 4 +
+ +if nvl(a_coverage_unit.lines(line_no).covered_blocks,0) < nvl(a_coverage_unit.lines(line_no).no_blocks,0)
- + 1 +
+ +and nvl(a_coverage_unit.lines(line_no).partcove,0) = 1 then
- + 1 +
+ +l_blocks := to_char(a_coverage_unit.lines(line_no).covered_blocks) || chr(47)||
- +
+ +to_char(a_coverage_unit.lines(line_no).no_blocks);
- +
+ +else
- + 3 +
+ +l_blocks := null;
- +
+ +end if;
- +
+ +- + 4 +
+ +l_file_part := '
- +
+ +<li class="' || line_status(a_coverage_unit.lines(line_no)) || '" data-hits="' ||
- +
+ +dbms_xmlgen.convert(l_hits)|| '"'||
- + 1 +
+ +case
- + 1 +
+ +when l_blocks is not null
- +
+ +then ' data-blocks="'||dbms_xmlgen.convert(l_blocks)||'"'
- +
+ +else
- +
+ +null
- +
+ +end
- +
+ +||' data-linenumber="' || (line_no) || '">';
- + 4 +
+ +if a_coverage_unit.lines(line_no).executions > 0 then
- +
+ +- + 3 +
+ +l_file_part := l_file_part ||
- + 1 +
+ +case when l_blocks is not null
- +
+ +then '
- +
+ +<span class="blocks">' ||dbms_xmlgen.convert(l_blocks) ||
- +
+ +'</span>'
- +
+ +else
- +
+ +null
- +
+ +end
- +
+ +|| '
- +
+ +<span class="hits">' || dbms_xmlgen.convert(l_hits) ||
- +
+ +'</span>';
- +
+ +end if;
- + 4 +
+ +l_file_part := l_file_part || '
- +
+ +<code class="sql">' || (dbms_xmlgen.convert(a_source_code(line_no))) ||
- +
+ +'</code></li>';
- +
+ +end if;
- + 16 +
+ +ut_utils.append_to_list(l_result, l_file_part);
- +
+ +end loop;
- +
+ +- + 1 +
+ +l_file_part := '</ol></pre></div>';
- + 1 +
+ +ut_utils.append_to_list(l_result, l_file_part);
- + 1 +
+ +return l_result;
- +
+ +end;
- +
+ +begin
- + 1 +
+ +return build_details_file_content(
- +
+ +a_object_id,
- +
+ +a_unit.identity,
- +
+ +ut_coverage_helper.get_tmp_table_object_lines(a_unit.owner, a_unit.name),
- +
+ +a_unit_coverage
- +
+ +);
- +
+ +end;
- +
+ +- +
+ +function get_block_list_attributes(a_coverage_unit ut_coverage.t_coverage) return varchar2 is
- +
+ +l_result varchar2(32767);
- +
+ +begin
- + 1 +
+ +if (a_coverage_unit.partcovered_lines is not null) AND (a_coverage_unit.partcovered_lines > 0) then
- + 1 +
+ +l_result := ' (including <span class="yellow"><b>'|| a_coverage_unit.partcovered_lines ||'</b> lines partially covered</span> )';
- +
+ +else
- +
+ +l_result := null;
- +
+ +end if;
- + 1 +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+ +function file_list(a_title varchar2, a_coverage ut_coverage.t_coverage) return ut_varchar2_rows is
- +
+ +l_file_part varchar2(32767);
- + 1 +
+ +l_title varchar2(100) := 'All files';
- +
+ +l_coverage_pct number(5, 2);
- +
+ +l_coverage_block_pct number(5, 2);
- +
+ +l_result ut_varchar2_rows;
- + 1 +
+ +l_id varchar2(50) := object_id(a_title);
- + 1 +
+ +l_unit_coverage ut_coverage.t_unit_coverage;
- +
+ +l_unit ut_coverage.t_object_name;
- +
+ +begin
- + 1 +
+ +l_coverage_pct := coverage_pct(a_coverage.covered_lines, a_coverage.uncovered_lines);
- +
+ +- + 1 +
+ +l_file_part := '<div class="file_list_container" id="' || l_id || '">' || '<h2><span class="group_name">' || l_title ||
- +
+ +'</span>' || ' (<span class="covered_percent"><span class="' || coverage_css_class(l_coverage_pct) || '">' ||
- +
+ +l_coverage_pct || '%</span></span>' || ' lines covered'||
- +
+ +' at <span class="covered_strength">' ||
- +
+ +'<span class="' ||line_hits_css_class(executions_per_line(a_coverage.executions
- +
+ +,a_coverage.uncovered_lines + a_coverage.covered_lines)) || '">' ||
- +
+ +executions_per_line(a_coverage.executions, a_coverage.uncovered_lines + a_coverage.covered_lines)
- +
+ +|| '</span></span> hits/line)</h2>' || '<a id="a_' || l_id || '"></a>' || '<div><b>' ||
- +
+ +a_coverage.objects.count || '</b> files in total. </div><div>' || '<b>' ||
- +
+ +(a_coverage.uncovered_lines + a_coverage.covered_lines)
- +
+ +|| '</b> relevant lines. ' || '<span class="green"><b>' || a_coverage.covered_lines ||
- +
+ +'</b> lines covered</span>'|| get_block_list_attributes(a_coverage)
- +
+ +||' and <span class="red"><b>' || a_coverage.uncovered_lines || '</b> lines missed.</span>'||
- +
+ +'<table class="file_list"><thead>' || '<tr>' ||
- +
+ +'<th>File</th><th>% covered</th><th>Lines</th><th>Relevant Lines</th><th>Lines covered</th><th>Lines missed</th><th>'
- +
+ +||'Avg. Hits / Line </th>' ||
- +
+ +'</tr></thead><tbody>';
- + 1 +
+ +ut_utils.append_to_list( l_result, l_file_part );
- + 1 +
+ +l_unit := a_coverage.objects.first;
- + 2 +
+ +loop
- + 2 +
+ +exit when l_unit is null;
- + 1 +
+ +l_unit_coverage := a_coverage.objects(l_unit);
- + 1 +
+ +l_coverage_pct := coverage_pct(l_unit_coverage.covered_lines, l_unit_coverage.uncovered_lines);
- +
+ +- + 1 +
+ +l_file_part := chr(10) || '<tr>' || '<td class="strong">' || link_to_source_file(dbms_xmlgen.convert(l_unit)) ||
- +
+ +'</td>' || '<td class="' || coverage_css_class(l_coverage_pct) || ' strong">' || l_coverage_pct ||
- +
+ +' %</td>' || '<td>' || l_unit_coverage.total_lines || '</td>' || '<td>' ||
- +
+ +(l_unit_coverage.covered_lines + l_unit_coverage.uncovered_lines) || '</td>' || '<td>' ||
- +
+ +l_unit_coverage.covered_lines || '</td><td>' || l_unit_coverage.uncovered_lines || '</td>' ||
- +
+ +'<td>' || to_char(executions_per_line(l_unit_coverage.executions
- +
+ +,l_unit_coverage.uncovered_lines + l_unit_coverage.covered_lines))
- +
+ +|| '</td></tr>';
- + 1 +
+ +ut_utils.append_to_list( l_result, l_file_part );
- + 1 +
+ +l_unit := a_coverage.objects.next(l_unit);
- +
+ +end loop;
- + 1 +
+ +l_file_part := '</tbody></table></div>';
- + 1 +
+ +ut_utils.append_to_list( l_result, l_file_part );
- + 1 +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+ +/*
- +
+ +* public definitions
- +
+ +*/
- +
+ +function get_index(
- +
+ +a_coverage_data ut_coverage.t_coverage,
- +
+ +a_assets_path varchar2,
- +
+ +a_project_name varchar2 := null,
- +
+ +a_command_line varchar2 := null,
- +
+ +a_charset varchar2 := null
- +
+ +) return ut_varchar2_rows is
- +
+ +- +
+ +l_file_part varchar2(32767);
- + 1 +
+ +l_result ut_varchar2_rows := ut_varchar2_rows();
- +
+ +l_title varchar2(250);
- +
+ +l_coverage_pct number(5, 2);
- +
+ +l_time_str varchar2(50);
- +
+ +l_using varchar2(1000);
- +
+ +l_unit ut_coverage.t_full_name;
- +
+ +l_charset varchar2(1000);
- +
+ +begin
- + 1 +
+ +l_charset := coalesce(upper(a_charset),'UTF-8');
- + 1 +
+ +l_coverage_pct := coverage_pct(a_coverage_data.covered_lines, a_coverage_data.uncovered_lines);
- +
+ +- + 1 +
+ +l_time_str := to_char(sysdate,'yyyy-mm-dd"T"hh24:mi:ss');
- + 1 +
+ +l_using := case
- + 1 +
+ +when a_command_line is not null then
- +
+ +'<br/>using ' || dbms_xmlgen.convert(a_command_line)
- +
+ +end;
- + 1 +
+ +l_title := case
- + 1 +
+ +when a_project_name is null then
- +
+ +'Code coverage'
- +
+ +else
- +
+ +dbms_xmlgen.convert(a_project_name) || ' code coverage'
- +
+ +end;
- +
+ +--TODO - build main file containing total run data and per schema data
- + 1 +
+ +l_file_part := '<!DOCTYPE html><html xmlns=''http://www.w3.org/1999/xhtml''><head>' || '<title>' || l_title ||
- +
+ +'</title>' || '<meta http-equiv="content-type" content="text/html; charset='||l_charset||'" />' ||
- +
+ +'<script src=''' || a_assets_path || 'application.js''></script>' ||
- +
+ +'<link href=''' || a_assets_path ||
- +
+ +'application.css'' media=''screen, print'' rel=''stylesheet'' type=''text/css''/>' ||
- +
+ +'<link rel="shortcut icon" type="image/png" href="' || a_assets_path || 'favicon_' ||
- +
+ +coverage_css_class(l_coverage_pct) || '.png" />' || '<link rel="icon" type="image/png" href="' ||
- +
+ +a_assets_path || 'favicon_' || coverage_css_class(l_coverage_pct) || '.png" />' || '</head>' ||
- +
+ +'<body><div id="loading"><img src="' || a_assets_path || 'loading.gif" alt="loading"/></div>' ||
- +
+ +'<div id="wrapper" style="display:none;">' ||
- +
+ +'<div class="timestamp">Generated <abbr class="timeago" title="' || l_time_str || '">' || l_time_str ||
- +
+ +'</abbr></div>' || '<ul class="group_tabs"></ul>' || '<div id="content">';
- + 1 +
+ +ut_utils.append_to_list(l_result, l_file_part);
- +
+ +- + 1 +
+ +ut_utils.append_to_list(l_result, file_list('All files', a_coverage_data));
- +
+ +- + 1 +
+ +l_file_part := chr(10) || '</div><div id="footer">' ||
- +
+ +'Generated by <a href="http://github.com/utPLSQL/utPLSQL">utPLSQL ' || ut_utils.gc_version ||
- +
+ +'</a><br/>' ||
- +
+ +'Based on <a href="http://github.com/colszowka/simplecov-html">simplecov-html</a> v0.10.0 ' ||
- +
+ +l_using || '' || '</div><div class="source_files">';
- + 1 +
+ +ut_utils.append_to_list(l_result, l_file_part);
- +
+ +- + 1 +
+ +l_unit := a_coverage_data.objects.first;
- + 2 +
+ +loop
- + 2 +
+ +exit when l_unit is null;
- + 1 +
+ +ut_utils.append_to_list(
- +
+ +l_result,
- +
+ +get_details_file_content(
- +
+ +object_id(l_unit),
- +
+ +ut_object_name(a_coverage_data.objects(l_unit).owner,
- +
+ +a_coverage_data.objects(l_unit).name),
- +
+ +a_coverage_data.objects(l_unit)
- +
+ +)
- +
+ +);
- + 1 +
+ +l_unit := a_coverage_data.objects.next(l_unit);
- +
+ +end loop;
- +
+ +- + 1 +
+ +l_file_part := '</div></div></div></body></html>';
- +
+ +- + 1 +
+ +ut_utils.append_to_list(l_result, l_file_part);
- + 1 +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+end;
+UT3.UT_COVERAGE_SONAR_REPORTER
97.14 % lines covered
35 relevant lines. 34 lines covered and 1 lines missed+ +
- +
+ +type body ut_coverage_sonar_reporter is
- +
+ +/*
- +
+ +utPLSQL - Version 3
- +
+ +Copyright 2016 - 2019 utPLSQL Project
- +
+ +- +
+ +Licensed under the Apache License, Version 2.0 (the "License"):
- +
+ +you may not use this file except in compliance with the License.
- +
+ +You may obtain a copy of the License at
- +
+ +- +
+ +http://www.apache.org/licenses/LICENSE-2.0
- +
+ +- +
+ +Unless required by applicable law or agreed to in writing, software
- +
+ +distributed under the License is distributed on an "AS IS" BASIS,
- +
+ +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
+ +See the License for the specific language governing permissions and
- +
+ +limitations under the License.
- +
+ +*/
- +
+ +- +
+ +constructor function ut_coverage_sonar_reporter(
- +
+ +self in out nocopy ut_coverage_sonar_reporter
- +
+ +) return self as result is
- +
+ +begin
- + 5 +
+ +self.init($$plsql_unit);
- + 5 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +- +
+ +overriding member procedure after_calling_run(self in out nocopy ut_coverage_sonar_reporter, a_run in ut_run) as
- +
+ +- +
+ +function get_lines_xml(a_unit_coverage ut_coverage.t_unit_coverage) return ut_varchar2_rows is
- +
+ +l_file_part varchar2(32767);
- + 41 +
+ +l_result ut_varchar2_rows := ut_varchar2_rows();
- +
+ +l_line_no binary_integer;
- +
+ +begin
- + 41 +
+ +l_line_no := a_unit_coverage.lines.first;
- + 41 +
+ +if l_line_no is null then
- + 12356 +
+ +for i in 1 .. a_unit_coverage.total_lines loop
- + 12319 +
+ +ut_utils.append_to_list(l_result, '<lineToCover lineNumber="'||i||'" covered="false"/>');
- +
+ +end loop;
- +
+ +else
- + 19 +
+ +while l_line_no is not null loop
- + 15 +
+ +if a_unit_coverage.lines(l_line_no).executions = 0 then
- + 4 +
+ +l_file_part := '<lineToCover lineNumber="'||l_line_no||'" covered="false"/>';
- +
+ +else
- + 11 +
+ +l_file_part := '<lineToCover lineNumber="'||l_line_no||'" covered="true"';
- + 11 +
+ +if a_unit_coverage.lines(l_line_no).covered_blocks <= a_unit_coverage.lines(l_line_no).no_blocks then
- + 6 +
+ +l_file_part := l_file_part || ' branchesToCover="'||a_unit_coverage.lines(l_line_no).no_blocks||'"';
- + 6 +
+ +l_file_part := l_file_part || ' coveredBranches="'||a_unit_coverage.lines(l_line_no).covered_blocks||'"';
- +
+ +end if;
- + 11 +
+ +l_file_part := l_file_part ||'/>';
- +
+ +end if;
- + 15 +
+ +ut_utils.append_to_list(l_result, l_file_part);
- + 15 +
+ +l_line_no := a_unit_coverage.lines.next(l_line_no);
- +
+ +end loop;
- +
+ +end if;
- + 41 +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+ +function get_coverage_xml(
- +
+ +a_coverage_data ut_coverage.t_coverage,
- +
+ +a_run ut_run
- +
+ +) return ut_varchar2_rows is
- + 5 +
+ +l_result ut_varchar2_rows := ut_varchar2_rows();
- +
+ +l_unit ut_coverage.t_full_name;
- + 5 +
+ +c_coverage_header constant varchar2(30) := '<coverage version="1">';
- + 5 +
+ +c_file_footer constant varchar2(30) := '</file>';
- + 5 +
+ +c_coverage_footer constant varchar2(30) := '</coverage>';
- +
+ +begin
- +
+ +- + 5 +
+ +ut_utils.append_to_list(l_result, ut_utils.get_xml_header(a_run.client_character_set));
- + 5 +
+ +ut_utils.append_to_list(l_result, c_coverage_header);
- + 5 +
+ +l_unit := a_coverage_data.objects.first;
- + 46 +
+ +while l_unit is not null loop
- + 42 +
+ +ut_utils.append_to_list(l_result, '<file path="'||dbms_xmlgen.convert(l_unit)||'">');
- +
+ +- + 41 +
+ +ut_utils.append_to_list(l_result,get_lines_xml(a_coverage_data.objects(l_unit)));
- +
+ +- + 41 +
+ +ut_utils.append_to_list(l_result, c_file_footer);
- +
+ +- + 41 +
+ +l_unit := a_coverage_data.objects.next(l_unit);
- +
+ +end loop;
- + 5 +
+ +ut_utils.append_to_list(l_result, c_coverage_footer);
- + 5 +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+ +begin
- + 6 +
+ +ut_coverage.coverage_stop();
- +
+ +- + 5 +
+ +self.print_text_lines(
- +
+ +get_coverage_xml(
- +
+ +ut_coverage.get_coverage_data(a_run.coverage_options),
- +
+ +a_run
- +
+ +)
- +
+ +);
- +
+ +end;
- +
+ +- +
+ +overriding member function get_description return varchar2 as
- +
+ +begin
- +
+ +return 'Generates a JSON coverage report providing information on code coverage with line numbers.' || chr(10) ||
- +
+ +'Designed for [SonarQube](https://about.sonarqube.com/) to report coverage.' || chr(10) ||
- +
+ +'JSON format returned conforms with the Sonar specification: https://docs.sonarqube.org/display/SONAR/Generic+Test+Data';
- +
+ +end;
- +
+ +- +
+end;
+UT3.UT_COVERALLS_REPORTER
94.29 % lines covered
35 relevant lines. 33 lines covered and 2 lines missed+ +
- +
+ +type body ut_coveralls_reporter is
- +
+ +/*
- +
+ +utPLSQL - Version 3
- +
+ +Copyright 2016 - 2019 utPLSQL Project
- +
+ +- +
+ +Licensed under the Apache License, Version 2.0 (the "License"):
- +
+ +you may not use this file except in compliance with the License.
- +
+ +You may obtain a copy of the License at
- +
+ +- +
+ +http://www.apache.org/licenses/LICENSE-2.0
- +
+ +- +
+ +Unless required by applicable law or agreed to in writing, software
- +
+ +distributed under the License is distributed on an "AS IS" BASIS,
- +
+ +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
+ +See the License for the specific language governing permissions and
- +
+ +limitations under the License.
- +
+ +*/
- +
+ +- +
+ +constructor function ut_coveralls_reporter(
- +
+ +self in out nocopy ut_coveralls_reporter
- +
+ +) return self as result is
- +
+ +begin
- + 2 +
+ +self.init($$plsql_unit);
- + 2 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +overriding member procedure after_calling_run(self in out nocopy ut_coveralls_reporter, a_run in ut_run) as
- +
+ +- +
+ +function get_lines_json(a_unit_coverage ut_coverage.t_unit_coverage) return ut_varchar2_rows is
- +
+ +l_file_part varchar2(32767);
- + 2 +
+ +l_result ut_varchar2_rows := ut_varchar2_rows();
- +
+ +l_last_line_no binary_integer;
- + 2 +
+ +c_coverage_header constant varchar2(30) := '"coverage": [';
- + 2 +
+ +c_null constant varchar2(4) := 'null';
- +
+ +begin
- + 2 +
+ +ut_utils.append_to_list(l_result, c_coverage_header);
- +
+ +- + 2 +
+ +l_last_line_no := a_unit_coverage.lines.last;
- + 2 +
+ +if l_last_line_no is null then
- + 1 +
+ +ut_utils.append_to_list(
- +
+ +l_result
- +
+ +, rpad( to_clob( '0' ), ( a_unit_coverage.total_lines * 3 ) - 2, ','||chr(10)||'0' )
- +
+ +);
- +
+ +else
- + 8 +
+ +for line_no in 1 .. l_last_line_no loop
- + 7 +
+ +if a_unit_coverage.lines.exists(line_no) then
- + 3 +
+ +l_file_part := to_char(a_unit_coverage.lines(line_no).executions);
- +
+ +else
- + 4 +
+ +l_file_part := c_null;
- +
+ +end if;
- + 7 +
+ +if line_no < l_last_line_no then
- + 6 +
+ +l_file_part := l_file_part ||',';
- +
+ +end if;
- + 7 +
+ +ut_utils.append_to_list(l_result, l_file_part);
- +
+ +end loop;
- +
+ +end if;
- + 2 +
+ +ut_utils.append_to_list(l_result, ']');
- + 2 +
+ +return l_result;
- +
+ +end;
- +
+ +- +
+ +function get_coverage_json(
- +
+ +a_coverage_data ut_coverage.t_coverage
- +
+ +) return ut_varchar2_rows is
- + 2 +
+ +l_result ut_varchar2_rows := ut_varchar2_rows();
- +
+ +l_unit ut_coverage.t_full_name;
- + 2 +
+ +c_coverage_header constant varchar2(30) := '{"source_files":[';
- + 2 +
+ +c_coverage_footer constant varchar2(30) := ']}'||chr(10)||' ';
- +
+ +begin
- + 2 +
+ +ut_utils.append_to_list(l_result, c_coverage_header);
- + 2 +
+ +l_unit := a_coverage_data.objects.first;
- + 4 +
+ +while l_unit is not null loop
- + 2 +
+ +ut_utils.append_to_list(l_result, '{ "name": "'||l_unit||'",');
- +
+ +- + 2 +
+ +ut_utils.append_to_list(l_result,get_lines_json(a_coverage_data.objects(l_unit)));
- +
+ +- + 2 +
+ +ut_utils.append_to_list(l_result, '}');
- +
+ +- + 2 +
+ +l_unit := a_coverage_data.objects.next(l_unit);
- + 2 +
+ +if l_unit is not null then
- +
+ +ut_utils.append_to_list(l_result, ',');
- +
+ +end if;
- +
+ +end loop;
- + 2 +
+ +ut_utils.append_to_list(l_result, c_coverage_footer);
- + 2 +
+ +return l_result;
- +
+ +end;
- +
+ +begin
- + 3 +
+ +ut_coverage.coverage_stop();
- +
+ +- + 2 +
+ +self.print_text_lines(
- +
+ +get_coverage_json(
- +
+ +ut_coverage.get_coverage_data(a_run.coverage_options)
- +
+ +)
- +
+ +);
- +
+ +end;
- +
+ +- +
+ +overriding member function get_description return varchar2 as
- +
+ +begin
- +
+ +return 'Generates a JSON coverage report providing information on code coverage with line numbers.' || chr(10) ||
- +
+ +'Designed for [Coveralls](https://coveralls.io/).' || chr(10) ||
- +
+ +'JSON format conforms with specification: https://docs.coveralls.io/api-introduction';
- +
+ +end;
- +
+ +- +
+end;
+UT3.UT_DEBUG_REPORTER
100 % lines covered
25 relevant lines. 25 lines covered and 0 lines missed+ +
- +
+ +type body ut_debug_reporter is
- +
+ +/*
- +
+ +utPLSQL - Version 3
- +
+ +Copyright 2016 - 2019 utPLSQL Project
- +
+ +- +
+ +Licensed under the Apache License, Version 2.0 (the "License"):
- +
+ +you may not use this file except in compliance with the License.
- +
+ +You may obtain a copy of the License at
- +
+ +- +
+ +http://www.apache.org/licenses/LICENSE-2.0
- +
+ +- +
+ +Unless required by applicable law or agreed to in writing, software
- +
+ +distributed under the License is distributed on an "AS IS" BASIS,
- +
+ +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
+ +See the License for the specific language governing permissions and
- +
+ +limitations under the License.
- +
+ +*/
- +
+ +- +
+ +constructor function ut_debug_reporter(self in out nocopy ut_debug_reporter) return self as result is
- +
+ +begin
- + 1 +
+ +self.init($$plsql_unit,ut_output_clob_table_buffer());
- + 1 +
+ +self.start_time := current_timestamp();
- + 1 +
+ +self.event_time := current_timestamp();
- + 1 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +overriding member function get_supported_events return ut_varchar2_list is
- +
+ +begin
- + 1 +
+ +return ut_varchar2_list(ut_event_manager.gc_all);
- +
+ +end;
- +
+ +- +
+ +overriding member procedure on_event( self in out nocopy ut_debug_reporter, a_event_name varchar2, a_event_item ut_event_item) is
- + 76 +
+ +c_time constant timestamp := current_timestamp();
- + 76 +
+ +c_time_from_start constant interval day(0) to second(6) := (c_time - self.start_time);
- + 76 +
+ +c_time_from_prev constant interval day(0) to second(6) := (c_time - self.event_time);
- + 76 +
+ +l_stack varchar2(32767) := dbms_utility.format_call_stack();
- +
+ +begin
- + 76 +
+ +l_stack := regexp_replace(
- +
+ +substr( l_stack, instr( l_stack, chr(10), 1, 6 ) +1 ),
- +
+ +'[0-9abcdefx]+ +([0-9]+) +(package |type )?(body )?(.*)','at "\4", line \1');
- +
+ +- + 76 +
+ +if a_event_name = ut_event_manager.gc_initialize then
- + 1 +
+ +self.on_initialize(null);
- + 1 +
+ +self.print_text('<DEBUG_LOG>', ut_event_manager.gc_debug);
- +
+ +end if;
- + 76 +
+ +self.print_text('<DEBUG>', ut_event_manager.gc_debug);
- + 76 +
+ +self.print_text(
- +
+ +' <TIMESTAMP>' || ut_utils.to_string(c_time) || '</TIMESTAMP>' || chr(10)
- +
+ +|| ' <TIME_FROM_START>' || c_time_from_start || '</TIME_FROM_START>' || chr(10)
- +
+ +|| ' <TIME_FROM_PREVIOUS>' || c_time_from_prev || '</TIME_FROM_PREVIOUS>' || chr(10)
- +
+ +|| ' <EVENT_NAME>' || a_event_name || '</EVENT_NAME>',
- +
+ +ut_event_manager.gc_debug
- +
+ +);
- + 76 +
+ +self.print_text( ' <CALL_STACK>' || l_stack || '</CALL_STACK>', ut_event_manager.gc_debug);
- + 76 +
+ +if a_event_item is not null then
- + 53 +
+ +self.print_text_lines(
- +
+ +ut_utils.convert_collection(
- +
+ +ut_utils.clob_to_table( event_item_to_clob(a_event_item), ut_utils.gc_max_storage_varchar2_len )
- +
+ +),
- +
+ +ut_event_manager.gc_debug
- +
+ +);
- +
+ +end if;
- + 76 +
+ +self.print_text('</DEBUG>', ut_event_manager.gc_debug);
- + 76 +
+ +if a_event_name = ut_event_manager.gc_finalize then
- + 1 +
+ +self.print_text('</DEBUG_LOG>', ut_event_manager.gc_debug);
- + 1 +
+ +self.on_finalize(null);
- +
+ +end if;
- + 76 +
+ +self.event_time := current_timestamp();
- +
+ +end;
- +
+ +- +
+ +member function event_item_to_clob(a_event_item ut_event_item) return clob is
- +
+ +l_clob clob;
- +
+ +begin
- + 53 +
+ +select xmlserialize( content deletexml(xmltype(a_event_item),'/*/ITEMS|/*/ALL_EXPECTATIONS|/*/FAILED_EXPECTATIONS') as clob indent size = 2 ) into l_clob from dual;
- + 53 +
+ +return l_clob;
- +
+ +end;
- +
+ +- +
+end;
+UT3.UT_DOCUMENTATION_REPORTER
98.89 % lines covered
90 relevant lines. 89 lines covered and 1 lines missed+ +
- +
+ +type body ut_documentation_reporter is
- +
+ +/*
- +
+ +utPLSQL - Version 3
- +
+ +Copyright 2016 - 2019 utPLSQL Project
- +
+ +- +
+ +Licensed under the Apache License, Version 2.0 (the "License"):
- +
+ +you may not use this file except in compliance with the License.
- +
+ +You may obtain a copy of the License at
- +
+ +- +
+ +http://www.apache.org/licenses/LICENSE-2.0
- +
+ +- +
+ +Unless required by applicable law or agreed to in writing, software
- +
+ +distributed under the License is distributed on an "AS IS" BASIS,
- +
+ +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
+ +See the License for the specific language governing permissions and
- +
+ +limitations under the License.
- +
+ +*/
- +
+ +- +
+ +constructor function ut_documentation_reporter(self in out nocopy ut_documentation_reporter) return self as result is
- +
+ +begin
- + 71 +
+ +self.init($$plsql_unit);
- + 71 +
+ +self.lvl := 0;
- + 71 +
+ +self.failed_test_running_count := 0;
- + 71 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +member function tab(self in ut_documentation_reporter) return varchar2 is
- +
+ +begin
- + 1635 +
+ +return rpad(' ', self.lvl * 2);
- +
+ +end tab;
- +
+ +- +
+ +overriding member procedure print_clob(self in out nocopy ut_documentation_reporter, a_clob clob, a_item_type varchar2 := null) is
- +
+ +l_lines ut_varchar2_list;
- + 224 +
+ +l_out_lines ut_varchar2_rows := ut_varchar2_rows();
- +
+ +begin
- + 224 +
+ +if a_clob is not null and dbms_lob.getlength(a_clob) > 0 then
- + 158 +
+ +l_lines := ut_utils.clob_to_table(a_clob, ut_utils.gc_max_storage_varchar2_len - length(nvl(tab(),0)));
- + 614 +
+ +for i in 1 .. l_lines.count loop
- + 456 +
+ +if l_lines(i) is not null then
- + 298 +
+ +ut_utils.append_to_list(l_out_lines, tab() || l_lines(i) );
- +
+ +end if;
- +
+ +end loop;
- + 158 +
+ +(self as ut_output_reporter_base).print_text_lines(l_out_lines, a_item_type);
- +
+ +end if;
- +
+ +end;
- +
+ +- +
+ +overriding member procedure print_text(self in out nocopy ut_documentation_reporter, a_text varchar2, a_item_type varchar2 := null) is
- +
+ +l_lines ut_varchar2_list;
- +
+ +begin
- + 1035 +
+ +if a_text is not null then
- + 1018 +
+ +l_lines := ut_utils.string_to_table(a_text);
- + 2197 +
+ +for i in 1 .. l_lines.count loop
- + 1179 +
+ +(self as ut_output_reporter_base).print_text(tab || l_lines(i), a_item_type);
- +
+ +end loop;
- +
+ +end if;
- +
+ +end;
- +
+ +- +
+ +overriding member procedure before_calling_suite(self in out nocopy ut_documentation_reporter, a_suite ut_logical_suite) as
- +
+ +begin
- + 206 +
+ +self.print_text(coalesce(a_suite.description, a_suite.name));
- + 206 +
+ +lvl := lvl + 1;
- +
+ +end;
- +
+ +- +
+ +overriding member procedure after_calling_test(self in out nocopy ut_documentation_reporter, a_test ut_test) as
- +
+ +l_message varchar2(4000);
- +
+ +- +
+ +begin
- + 216 +
+ +l_message := coalesce(a_test.description, a_test.name)||' ['||round(a_test.execution_time,3)||' sec]';
- +
+ +--if test failed, then add it to the failures list, print failure with number
- + 216 +
+ +if a_test.result = ut_utils.gc_disabled then
- + 1 +
+ +self.print_yellow_text(l_message || ' (DISABLED)');
- + 215 +
+ +elsif a_test.result = ut_utils.gc_success then
- + 158 +
+ +self.print_green_text(l_message);
- + 57 +
+ +elsif a_test.result > ut_utils.gc_success then
- + 57 +
+ +failed_test_running_count := failed_test_running_count + 1;
- + 57 +
+ +self.print_red_text(l_message || ' (FAILED - ' || failed_test_running_count || ')');
- +
+ +end if;
- +
+ +- +
+ +-- reproduce the output from before/after procedures and the test
- + 216 +
+ +self.print_clob(a_test.get_serveroutputs);
- +
+ +end;
- +
+ +- +
+ +overriding member procedure after_calling_before_all(self in out nocopy ut_documentation_reporter, a_executable in ut_executable) is
- +
+ +begin
- + 7 +
+ +if a_executable.serveroutput is not null and a_executable.serveroutput != empty_clob() then
- + 4 +
+ +self.print_clob(a_executable.serveroutput);
- +
+ +end if;
- +
+ +end;
- +
+ +- +
+ +overriding member procedure after_calling_after_all(self in out nocopy ut_documentation_reporter, a_executable in ut_executable) is
- +
+ +begin
- + 5 +
+ +if a_executable.serveroutput is not null and a_executable.serveroutput != empty_clob() then
- + 4 +
+ +self.print_clob(a_executable.serveroutput);
- +
+ +end if;
- +
+ +end;
- +
+ +- +
+ +overriding member procedure after_calling_suite(self in out nocopy ut_documentation_reporter, a_suite ut_logical_suite) as
- +
+ +begin
- + 206 +
+ +lvl := lvl - 1;
- + 206 +
+ +if lvl = 0 then
- + 93 +
+ +self.print_text(' ');
- +
+ +end if;
- +
+ +end;
- +
+ +- +
+ +overriding member procedure after_calling_run(self in out nocopy ut_documentation_reporter, a_run in ut_run) as
- +
+ +l_summary_text varchar2(4000);
- + 70 +
+ +l_warning_index pls_integer := 0;
- +
+ +-- make all warning indexes uniformly indented
- + 70 +
+ +c_warnings_lpad constant integer := length(to_char(a_run.results_count.warnings_count));
- +
+ +- +
+ +procedure print_failure_for_expectation(a_expectation ut_expectation_result) is
- +
+ +l_lines ut_varchar2_list;
- +
+ +begin
- + 10 +
+ +l_lines := a_expectation.get_result_lines();
- + 33 +
+ +for i in 1 .. l_lines.count loop
- + 23 +
+ +self.print_red_text(l_lines(i));
- +
+ +end loop;
- + 10 +
+ +self.print_cyan_text(a_expectation.caller_info);
- + 10 +
+ +self.print_text(' ');
- +
+ +end;
- +
+ +- +
+ +procedure print_failures_for_test(a_test ut_test, a_failure_no in out nocopy integer) is
- +
+ +begin
- + 181 +
+ +if a_test.result > ut_utils.gc_success then
- + 57 +
+ +a_failure_no := a_failure_no + 1;
- + 57 +
+ +self.print_text(lpad(a_failure_no, length(failed_test_running_count) + 2, ' ') || ') ' ||
- +
+ +nvl(a_test.name, a_test.item.form_name));
- + 57 +
+ +self.lvl := self.lvl + 3;
- +
+ +- + 57 +
+ +self.print_red_text(ut_utils.table_to_clob(a_test.get_error_stack_traces()));
- +
+ +- + 67 +
+ +for j in 1 .. a_test.failed_expectations.count loop
- + 10 +
+ +print_failure_for_expectation(a_test.failed_expectations(j));
- +
+ +end loop;
- +
+ +- + 57 +
+ +self.lvl := self.lvl - 3;
- +
+ +end if;
- +
+ +end;
- +
+ +- +
+ +procedure print_failures_from_suite(a_suite ut_logical_suite, a_failure_no in out nocopy integer) is
- +
+ +begin
- + 417 +
+ +for i in 1 .. a_suite.items.count loop
- + 267 +
+ +if a_suite.items(i) is of(ut_logical_suite) then
- + 86 +
+ +print_failures_from_suite(treat(a_suite.items(i) as ut_logical_suite), a_failure_no);
- + 181 +
+ +elsif a_suite.items(i) is of(ut_test) then
- + 181 +
+ +print_failures_for_test(treat(a_suite.items(i) as ut_test), a_failure_no);
- +
+ +end if;
- +
+ +end loop;
- +
+ +end;
- +
+ +- +
+ +procedure print_failures_details(a_run in ut_run) is
- + 70 +
+ +l_failure_no integer := 0;
- +
+ +begin
- + 70 +
+ +if a_run.results_count.failure_count > 0 or a_run.results_count.errored_count > 0 then
- +
+ +- + 46 +
+ +self.print_text('Failures:');
- + 46 +
+ +self.print_text(' ');
- + 110 +
+ +for i in 1 .. a_run.items.count loop
- + 64 +
+ +print_failures_from_suite(treat(a_run.items(i) as ut_logical_suite), l_failure_no);
- +
+ +end loop;
- +
+ +end if;
- +
+ +end;
- +
+ +- +
+ +procedure print_item_warnings(a_item in ut_suite_item) is
- +
+ +l_items ut_suite_items;
- +
+ +begin
- + 29 +
+ +if a_item is of (ut_logical_suite) then
- + 6 +
+ +l_items := treat(a_item as ut_logical_suite).items;
- + 32 +
+ +for i in 1 .. l_items.count loop
- + 26 +
+ +print_item_warnings(l_items(i));
- +
+ +end loop;
- +
+ +end if;
- +
+ +- + 29 +
+ +if a_item.warnings is not null and a_item.warnings.count > 0 then
- + 26 +
+ +for i in 1 .. a_item.warnings.count loop
- + 22 +
+ +l_warning_index := l_warning_index + 1;
- + 22 +
+ +self.print_text(' ' || lpad(l_warning_index, c_warnings_lpad) || ') ' || a_item.path);
- + 22 +
+ +self.lvl := self.lvl + 3;
- + 22 +
+ +self.print_red_text(a_item.warnings(i));
- + 22 +
+ +self.lvl := self.lvl - 3;
- +
+ +end loop;
- + 4 +
+ +self.print_text(' ');
- +
+ +end if;
- +
+ +end;
- +
+ +- +
+ +procedure print_warnings(a_run in ut_run) is
- +
+ +begin
- + 70 +
+ +if a_run.results_count.warnings_count > 0 then
- + 3 +
+ +self.print_text(' ');
- + 3 +
+ +self.print_text('Warnings:');
- + 3 +
+ +self.print_text(' ');
- + 6 +
+ +for i in 1 .. a_run.items.count loop
- + 3 +
+ +print_item_warnings(treat(a_run.items(i) as ut_suite_item));
- +
+ +end loop;
- +
+ +end if;
- +
+ +end;
- +
+ +- +
+ +begin
- + 70 +
+ +print_failures_details(a_run);
- + 70 +
+ +print_warnings(a_run);
- + 70 +
+ +self.print_text('Finished in ' || a_run.execution_time || ' seconds');
- +
+ +- + 70 +
+ +l_summary_text :=
- +
+ +a_run.results_count.total_count || ' tests, '
- +
+ +|| a_run.results_count.failure_count || ' failed, ' || a_run.results_count.errored_count || ' errored, '
- +
+ +|| a_run.results_count.disabled_count ||' disabled, ' || a_run.results_count.warnings_count || ' warning(s)';
- + 70 +
+ +if a_run.results_count.failure_count + a_run.results_count.errored_count + a_run.results_count.warnings_count > 0 then
- + 48 +
+ +self.print_red_text(l_summary_text);
- +
+ +else
- + 22 +
+ +self.print_green_text(l_summary_text);
- +
+ +end if;
- + 70 +
+ +if a_run.random_test_order_seed is not null then
- + 4 +
+ +self.print_text('Tests were executed with random order seed '''||a_run.random_test_order_seed||'''.');
- +
+ +end if;
- + 70 +
+ +self.print_text(' ');
- + 70 +
+ +(self as ut_reporter_base).after_calling_run(a_run);
- +
+ +end;
- +
+ +- +
+ +overriding member function get_description return varchar2 as
- +
+ +begin
- +
+ +return 'A textual pretty-print of unit test results (usually use for console output)';
- +
+ +end;
- +
+ +- +
+end;
+UT3.UT_JUNIT_REPORTER
93.85 % lines covered
65 relevant lines. 61 lines covered and 4 lines missed+ +
- +
+ +type body ut_junit_reporter is
- +
+ +/*
- +
+ +utPLSQL - Version 3
- +
+ +Copyright 2016 - 2019 utPLSQL Project
- +
+ +- +
+ +Licensed under the Apache License, Version 2.0 (the "License"):
- +
+ +you may not use this file except in compliance with the License.
- +
+ +You may obtain a copy of the License at
- +
+ +- +
+ +http://www.apache.org/licenses/LICENSE-2.0
- +
+ +- +
+ +Unless required by applicable law or agreed to in writing, software
- +
+ +distributed under the License is distributed on an "AS IS" BASIS,
- +
+ +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
+ +See the License for the specific language governing permissions and
- +
+ +limitations under the License.
- +
+ +*/
- +
+ +- +
+ +constructor function ut_junit_reporter(self in out nocopy ut_junit_reporter) return self as result is
- +
+ +begin
- + 11 +
+ +self.init($$plsql_unit);
- + 11 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +overriding member procedure after_calling_run(self in out nocopy ut_junit_reporter, a_run in ut_run) is
- + 12 +
+ +l_suite_id integer := 0;
- + 12 +
+ +l_tests_count integer := a_run.results_count.disabled_count + a_run.results_count.success_count +
- +
+ +a_run.results_count.failure_count + a_run.results_count.errored_count;
- +
+ +- +
+ +function get_path(a_path_with_name varchar2, a_name varchar2) return varchar2 is
- +
+ +begin
- + 19 +
+ +return regexp_substr(a_path_with_name, '(.*)\.' ||a_name||'$',subexpression=>1);
- +
+ +end;
- +
+ +- +
+ +procedure print_test_elements(a_test ut_test) is
- + 19 +
+ +l_results ut_varchar2_rows := ut_varchar2_rows();
- +
+ +l_output clob;
- +
+ +begin
- + 19 +
+ +ut_utils.append_to_list(
- +
+ +l_results,
- +
+ +'<testcase classname="' || dbms_xmlgen.convert(get_path(a_test.path, a_test.name)) || '"' || ' assertions="'
- +
+ +|| nvl(a_test.all_expectations.count,0) || self.get_common_item_attributes(a_test)
- + 1 +
+ +|| case when a_test.result != ut_utils.gc_success then
- +
+ +' status="' || ut_utils.test_result_to_char(a_test.result) || '"' end || '>'
- +
+ +);
- + 19 +
+ +if a_test.result = ut_utils.gc_disabled then
- + 2 +
+ +ut_utils.append_to_list( l_results, '<skipped/>' );
- +
+ +end if;
- + 19 +
+ +if a_test.result = ut_utils.gc_error then
- + 2 +
+ +ut_utils.append_to_list( l_results, '<error>');
- + 2 +
+ +ut_utils.append_to_list( l_results, ut_utils.to_cdata( ut_utils.convert_collection( a_test.get_error_stack_traces() ) ) );
- + 2 +
+ +ut_utils.append_to_list( l_results, '</error>');
- + 17 +
+ +elsif a_test.result > ut_utils.gc_success then
- + 8 +
+ +ut_utils.append_to_list( l_results, '<failure>');
- + 8 +
+ +ut_utils.append_to_list( l_results, ut_utils.to_cdata( a_test.get_failed_expectation_lines() ) );
- + 8 +
+ +ut_utils.append_to_list( l_results, '</failure>');
- +
+ +end if;
- +
+ +- + 19 +
+ +l_output := a_test.get_serveroutputs();
- + 19 +
+ +if l_output is not null then
- + 6 +
+ +ut_utils.append_to_list( l_results, '<system-out>');
- + 6 +
+ +ut_utils.append_to_list( l_results, ut_utils.to_cdata( a_test.get_serveroutputs() ) );
- + 6 +
+ +ut_utils.append_to_list( l_results, '</system-out>' );
- +
+ +else
- + 13 +
+ +ut_utils.append_to_list( l_results, '<system-out/>');
- +
+ +end if;
- + 19 +
+ +ut_utils.append_to_list( l_results, '<system-err/>');
- + 19 +
+ +ut_utils.append_to_list( l_results, '</testcase>');
- +
+ +- + 19 +
+ +self.print_text_lines(l_results);
- +
+ +end;
- +
+ +- +
+ +procedure print_suite_elements(a_suite ut_logical_suite, a_suite_id in out nocopy integer) is
- + 24 +
+ +l_count integer := a_suite.results_count.disabled_count + a_suite.results_count.success_count +
- +
+ +a_suite.results_count.failure_count + a_suite.results_count.errored_count;
- +
+ +l_suite ut_suite;
- + 24 +
+ +l_tests ut_suite_items := ut_suite_items();
- + 24 +
+ +l_results ut_varchar2_rows := ut_varchar2_rows();
- +
+ +l_data clob;
- +
+ +l_errors ut_varchar2_list;
- +
+ +begin
- + 24 +
+ +a_suite_id := a_suite_id + 1;
- + 24 +
+ +self.print_text('<testsuite tests="' || l_count || '"' || ' id="' || a_suite_id || '"' || ' package="' ||
- +
+ +dbms_xmlgen.convert(a_suite.path) || '" ' || self.get_common_suite_attributes(a_suite) || '>');
- +
+ +- +
+ +-- Becasue testsuites have to appear before test we capture test and leave it for later.
- + 55 +
+ +for i in 1 .. a_suite.items.count loop
- + 31 +
+ +if a_suite.items(i) is of(ut_test) then
- + 19 +
+ +l_tests.extend;
- + 19 +
+ +l_tests(l_tests.last) := treat(a_suite.items(i) as ut_test);
- + 12 +
+ +elsif a_suite.items(i) is of(ut_logical_suite) then
- + 12 +
+ +print_suite_elements(treat(a_suite.items(i) as ut_logical_suite), a_suite_id);
- +
+ +end if;
- +
+ +end loop;
- +
+ +- +
+ +-- Now when all testsuite are printed do the testcases.
- + 43 +
+ +for i in 1 .. l_tests.count loop
- + 19 +
+ +print_test_elements(treat(l_tests(i) as ut_test));
- +
+ +end loop;
- +
+ +- + 24 +
+ +if a_suite is of(ut_suite) then
- + 14 +
+ +l_suite := treat(a_suite as ut_suite);
- +
+ +- + 14 +
+ +l_data := l_suite.get_serveroutputs();
- + 14 +
+ +if l_data is not null then
- + 2 +
+ +ut_utils.append_to_list( l_results, '<system-out>');
- + 2 +
+ +ut_utils.append_to_list( l_results, ut_utils.to_cdata( l_data ) );
- + 2 +
+ +ut_utils.append_to_list( l_results, '</system-out>');
- +
+ +else
- + 12 +
+ +ut_utils.append_to_list( l_results, '<system-out/>');
- +
+ +end if;
- +
+ +- + 14 +
+ +l_errors := l_suite.get_error_stack_traces();
- + 14 +
+ +if l_errors is not empty then
- +
+ +ut_utils.append_to_list( l_results, '<system-err>');
- +
+ +ut_utils.append_to_list( l_results, ut_utils.to_cdata( ut_utils.convert_collection( l_errors ) ) );
- +
+ +ut_utils.append_to_list( l_results, '</system-err>');
- +
+ +else
- + 14 +
+ +ut_utils.append_to_list( l_results, '<system-err/>');
- +
+ +end if;
- +
+ +end if;
- + 24 +
+ +ut_utils.append_to_list( l_results, '</testsuite>');
- +
+ +- + 24 +
+ +self.print_text_lines(l_results);
- +
+ +end;
- +
+ +- +
+ +begin
- + 12 +
+ +l_suite_id := 0;
- + 12 +
+ +self.print_text(ut_utils.get_xml_header(a_run.client_character_set));
- + 12 +
+ +self.print_text('<testsuites tests="' || l_tests_count || '"' || self.get_common_suite_attributes(a_run) || '>');
- + 24 +
+ +for i in 1 .. a_run.items.count loop
- + 12 +
+ +print_suite_elements(treat(a_run.items(i) as ut_logical_suite), l_suite_id);
- +
+ +end loop;
- + 12 +
+ +self.print_text('</testsuites>');
- +
+ +end;
- +
+ +- +
+ +member function get_common_item_attributes(a_item ut_suite_item) return varchar2 is
- +
+ +begin
- + 55 +
+ +return '" name="' || dbms_xmlgen.convert(nvl(a_item.description, a_item.name))
- +
+ +|| '" time="' || ut_utils.to_xml_number_format(a_item.execution_time()) || '" ';
- +
+ +end;
- +
+ +- +
+ +member function get_common_suite_attributes(a_item ut_suite_item) return varchar2 is
- +
+ +begin
- + 36 +
+ +return ' disabled="' || a_item.results_count.disabled_count
- +
+ +|| '" errors="' || a_item.results_count.errored_count
- +
+ +|| '" failures="' || a_item.results_count.failure_count
- +
+ +|| get_common_item_attributes(a_item);
- +
+ +end;
- +
+ +- +
+ +overriding member function get_description return varchar2 as
- +
+ +begin
- +
+ +return 'Provides outcomes in a format conforming with JUnit 4 and above as defined in: https://gist.github.com/kuzuha/232902acab1344d6b578';
- +
+ +end;
- +
+ +- +
+end;
UT3.UT_REALTIME_REPORTER
100 % lines covered
138 relevant lines. 138 lines covered and 0 lines missed+ +
- +
+ +type body ut_realtime_reporter is
- +
+ +/*
- +
+ +utPLSQL - Version 3
- +
+ +Copyright 2016 - 2019 utPLSQL Project
- +
+ +- +
+ +Licensed under the Apache License, Version 2.0 (the "License"):
- +
+ +you may not use this file except in compliance with the License.
- +
+ +You may obtain a copy of the License at
- +
+ +- +
+ +http://www.apache.org/licenses/LICENSE-2.0
- +
+ +- +
+ +Unless required by applicable law or agreed to in writing, software
- +
+ +distributed under the License is distributed on an "AS IS" BASIS,
- +
+ +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
+ +See the License for the specific language governing permissions and
- +
+ +limitations under the License.
- +
+ +*/
- +
+ +- +
+ +constructor function ut_realtime_reporter(
- +
+ +self in out nocopy ut_realtime_reporter
- +
+ +) return self as result is
- +
+ +begin
- + 2 +
+ +self.init($$plsql_unit,ut_output_clob_table_buffer());
- + 2 +
+ +total_number_of_tests := 0;
- + 2 +
+ +current_test_number := 0;
- + 2 +
+ +current_indent := 0;
- + 2 +
+ +print_buffer := ut_varchar2_rows();
- + 2 +
+ +return;
- +
+ +end;
- +
+ +- +
+ +overriding member procedure before_calling_run(
- +
+ +self in out nocopy ut_realtime_reporter,
- +
+ +a_run in ut_run
- +
+ +) is
- +
+ +procedure print_test_elements(
- +
+ +a_test in ut_test
- +
+ +) is
- +
+ +begin
- + 8 +
+ +total_number_of_tests := total_number_of_tests + 1;
- + 8 +
+ +self.print_start_node('test', 'id', a_test.path);
- + 8 +
+ +self.print_node('executableType', a_test.item.executable_type);
- + 8 +
+ +self.print_node('ownerName', a_test.item.owner_name);
- + 8 +
+ +self.print_node('objectName', a_test.item.object_name);
- + 8 +
+ +self.print_node('procedureName', a_test.item.procedure_name);
- + 8 +
+ +self.print_node('disabled', case when a_test.get_disabled_flag() then 'true' else 'false' end);
- + 8 +
+ +self.print_node('name', a_test.name);
- + 8 +
+ +self.print_node('description', a_test.description);
- + 8 +
+ +self.print_node('testNumber', to_char(total_number_of_tests));
- + 8 +
+ +self.print_end_node('test');
- +
+ +end print_test_elements;
- +
+ +- +
+ +procedure print_suite_elements(
- +
+ +a_suite in ut_logical_suite
- +
+ +) is
- +
+ +begin
- + 6 +
+ +self.print_start_node('suite', 'id', a_suite.path);
- + 6 +
+ +self.print_node('name', a_suite.name);
- + 6 +
+ +self.print_node('description', a_suite.description);
- +
+ +<<suite_elements>>
- + 6 +
+ +self.print_start_node('items');
- + 19 +
+ +for i in 1 .. a_suite.items.count loop
- + 13 +
+ +if a_suite.items(i) is of(ut_test) then
- + 8 +
+ +print_test_elements(treat(a_suite.items(i) as ut_test));
- + 5 +
+ +elsif a_suite.items(i) is of(ut_logical_suite) then
- + 5 +
+ +print_suite_elements(treat(a_suite.items(i) as ut_logical_suite));
- +
+ +end if;
- +
+ +end loop suite_elements;
- + 6 +
+ +self.print_end_node('items');
- + 6 +
+ +self.print_end_node('suite');
- +
+ +end print_suite_elements;
- +
+ +begin
- + 1 +
+ +xml_header := ut_utils.get_xml_header(a_run.client_character_set);
- + 1 +
+ +self.print_xml_fragment(xml_header);
- + 1 +
+ +self.print_start_node('event', 'type', 'pre-run');
- + 1 +
+ +self.print_start_node('items');
- +
+ +<<items>>
- + 2 +
+ +for i in 1 .. a_run.items.count loop
- + 1 +
+ +print_suite_elements(treat(a_run.items(i) as ut_logical_suite));
- +
+ +end loop items;
- + 1 +
+ +self.print_end_node('items');
- + 1 +
+ +self.print_node('totalNumberOfTests', to_char(total_number_of_tests));
- + 1 +
+ +self.print_end_node('event');
- + 1 +
+ +self.flush_print_buffer('pre-run');
- +
+ +end before_calling_run;
- +
+ +- +
+ +overriding member procedure after_calling_run(
- +
+ +self in out nocopy ut_realtime_reporter,
- +
+ +a_run in ut_run
- +
+ +) is
- +
+ +begin
- + 1 +
+ +self.print_xml_fragment(xml_header);
- + 1 +
+ +self.print_start_node('event', 'type', 'post-run');
- + 1 +
+ +self.print_start_node('run');
- + 1 +
+ +self.print_node('startTime', to_char(a_run.start_time, 'YYYY-MM-DD"T"HH24:MI:SS.FF6'));
- + 1 +
+ +self.print_node('endTime', to_char(a_run.end_time, 'YYYY-MM-DD"T"HH24:MI:SS.FF6'));
- + 1 +
+ +self.print_node('executionTime', ut_utils.to_xml_number_format(a_run.execution_time()));
- + 1 +
+ +self.print_start_node('counter');
- + 1 +
+ +self.print_node('disabled', to_char(a_run.results_count.disabled_count));
- + 1 +
+ +self.print_node('success', to_char(a_run.results_count.success_count));
- + 1 +
+ +self.print_node('failure', to_char(a_run.results_count.failure_count));
- + 1 +
+ +self.print_node('error', to_char(a_run.results_count.errored_count));
- + 1 +
+ +self.print_node('warning', to_char(a_run.results_count.warnings_count));
- + 1 +
+ +self.print_end_node('counter');
- + 1 +
+ +self.print_cdata_node('errorStack', ut_utils.table_to_clob(a_run.get_error_stack_traces(), chr(10)||chr(10)));
- + 1 +
+ +self.print_cdata_node('serverOutput', a_run.get_serveroutputs());
- + 1 +
+ +self.print_end_node('run');
- + 1 +
+ +self.print_end_node('event');
- + 1 +
+ +self.flush_print_buffer('post-run');
- +
+ +end after_calling_run;
- +
+ +- +
+ +overriding member procedure before_calling_suite(
- +
+ +self in out nocopy ut_realtime_reporter,
- +
+ +a_suite in ut_logical_suite
- +
+ +) is
- +
+ +begin
- + 6 +
+ +self.print_xml_fragment(xml_header);
- + 6 +
+ +self.print_start_node('event', 'type', 'pre-suite');
- + 6 +
+ +self.print_start_node('suite', 'id', a_suite.path);
- + 6 +
+ +self.print_end_node('suite');
- + 6 +
+ +self.print_end_node('event');
- + 6 +
+ +self.flush_print_buffer('pre-suite');
- +
+ +end before_calling_suite;
- +
+ +- +
+ +overriding member procedure after_calling_suite(
- +
+ +self in out nocopy ut_realtime_reporter,
- +
+ +a_suite in ut_logical_suite
- +
+ +) is
- +
+ +begin
- + 6 +
+ +self.print_xml_fragment(xml_header);
- + 6 +
+ +self.print_start_node('event', 'type', 'post-suite');
- + 6 +
+ +self.print_start_node('suite', 'id', a_suite.path);
- + 6 +
+ +self.print_node('startTime', to_char(a_suite.start_time, 'YYYY-MM-DD"T"HH24:MI:SS.FF6'));
- + 6 +
+ +self.print_node('endTime', to_char(a_suite.end_time, 'YYYY-MM-DD"T"HH24:MI:SS.FF6'));
- + 6 +
+ +self.print_node('executionTime', ut_utils.to_xml_number_format(a_suite.execution_time()));
- + 6 +
+ +self.print_start_node('counter');
- + 6 +
+ +self.print_node('disabled', to_char(a_suite.results_count.disabled_count));
- + 6 +
+ +self.print_node('success', to_char(a_suite.results_count.success_count));
- + 6 +
+ +self.print_node('failure', to_char(a_suite.results_count.failure_count));
- + 6 +
+ +self.print_node('error', to_char(a_suite.results_count.errored_count));
- + 6 +
+ +self.print_node('warning', to_char(a_suite.results_count.warnings_count));
- + 6 +
+ +self.print_end_node('counter');
- + 6 +
+ +self.print_cdata_node('errorStack', ut_utils.table_to_clob(a_suite.get_error_stack_traces(), chr(10)||chr(10)));
- + 6 +
+ +self.print_cdata_node('serverOutput', a_suite.get_serveroutputs());
- + 6 +
+ +self.print_cdata_node('warnings', ut_utils.table_to_clob(a_suite.warnings, chr(10)||chr(10)));
- + 6 +
+ +self.print_end_node('suite');
- + 6 +
+ +self.print_end_node('event');
- + 6 +
+ +self.flush_print_buffer('post-suite');
- +
+ +end after_calling_suite;
- +
+ +- +
+ +overriding member procedure before_calling_test(
- +
+ +self in out nocopy ut_realtime_reporter,
- +
+ +a_test in ut_test
- +
+ +) is
- +
+ +begin
- + 8 +
+ +current_test_number := current_test_number + 1;
- + 8 +
+ +self.print_xml_fragment(xml_header);
- + 8 +
+ +self.print_start_node('event', 'type', 'pre-test');
- + 8 +
+ +self.print_start_node('test', 'id', a_test.path);
- + 8 +
+ +self.print_node('testNumber', to_char(current_test_number));
- + 8 +
+ +self.print_node('totalNumberOfTests', to_char(total_number_of_tests));
- + 8 +
+ +self.print_end_node('test');
- + 8 +
+ +self.print_end_node('event');
- + 8 +
+ +self.flush_print_buffer('pre-test');
- +
+ +end before_calling_test;
- +
+ +- +
+ +overriding member procedure after_calling_test(
- +
+ +self in out nocopy ut_realtime_reporter,
- +
+ +a_test in ut_test
- +
+ +) is
- +
+ +begin
- + 8 +
+ +self.print_xml_fragment(xml_header);
- + 8 +
+ +self.print_start_node('event', 'type', 'post-test');
- + 8 +
+ +self.print_start_node('test', 'id', a_test.path);
- + 8 +
+ +self.print_node('testNumber', to_char(current_test_number));
- + 8 +
+ +self.print_node('totalNumberOfTests', to_char(total_number_of_tests));
- + 8 +
+ +self.print_node('startTime', to_char(a_test.start_time, 'YYYY-MM-DD"T"HH24:MI:SS.FF6'));
- + 8 +
+ +self.print_node('endTime', to_char(a_test.end_time, 'YYYY-MM-DD"T"HH24:MI:SS.FF6'));
- + 8 +
+ +self.print_node('executionTime', ut_utils.to_xml_number_format(a_test.execution_time()));
- + 8 +
+ +self.print_start_node('counter');
- + 8 +
+ +self.print_node('disabled', to_char(a_test.results_count.disabled_count));
- + 8 +
+ +self.print_node('success', to_char(a_test.results_count.success_count));
- + 8 +
+ +self.print_node('failure', to_char(a_test.results_count.failure_count));
- + 8 +
+ +self.print_node('error', to_char(a_test.results_count.errored_count));
- + 8 +
+ +self.print_node('warning', to_char(a_test.results_count.warnings_count));
- + 8 +
+ +self.print_end_node('counter');
- + 8 +
+ +self.print_cdata_node('errorStack', ut_utils.table_to_clob(a_test.get_error_stack_traces(), chr(10)||chr(10)));
- + 8 +
+ +self.print_cdata_node('serverOutput', a_test.get_serveroutputs());
- + 8 +
+ +if a_test.failed_expectations.count > 0 then
- + 2 +
+ +self.print_start_node('failedExpectations');
- +
+ +<<expectations>>
- + 5 +
+ +for i in 1 .. a_test.failed_expectations.count loop
- + 3 +
+ +self.print_start_node('expectation');
- + 3 +
+ +self.print_node('description', a_test.failed_expectations(i).description);
- + 3 +
+ +self.print_cdata_node('message', a_test.failed_expectations(i).message);
- + 3 +
+ +self.print_cdata_node('caller', a_test.failed_expectations(i).caller_info);
- + 3 +
+ +self.print_end_node('expectation');
- +
+ +end loop expectations;
- + 2 +
+ +self.print_end_node('failedExpectations');
- +
+ +end if;
- + 8 +
+ +self.print_cdata_node('warnings', ut_utils.table_to_clob(a_test.warnings, chr(10)||chr(10)));
- + 8 +
+ +self.print_end_node('test');
- + 8 +
+ +self.print_end_node('event');
- + 8 +
+ +self.flush_print_buffer('post-test');
- +
+ +end after_calling_test;
- -
- -
-function get_coverage_json(
- -
-a_coverage_data ut_coverage.t_coverage
- -
-) return clob is
- -
-l_file_part varchar2(32767);
- -
-l_result clob;
- -
-l_unit ut_coverage.t_full_name;
- - 1 -
-c_coverage_header constant varchar2(30) := '{"source_files":['||chr(10);
- - 1 -
-c_coverage_footer constant varchar2(30) := ']}'||chr(10)||chr(10)||chr(10)||chr(10)||' ';
- -
-begin
- + +
- +
+ +overriding member function get_description return varchar2 is
- +
+ +begin
- 1 -
-dbms_lob.createtemporary(l_result,true);
- +
+ +return 'Provides test results in a XML format, for clients such as SQL Developer interested in showing progressing details.';
- +
+ +end get_description;
- -
- + +
- +
+ +member procedure print_start_node(
- +
+ +self in out nocopy ut_realtime_reporter,
- +
+ +a_node_name in varchar2,
- +
+ +a_attr_name in varchar2 default null,
- +
+ +a_attr_value in varchar2 default null
- +
+ +) is
- +
+ +begin
- + 100 +
+ +self.print_xml_fragment(
- +
+ +'<' || a_node_name
- 1 -
-ut_utils.append_to_clob(l_result, c_coverage_header);
- +
+ +|| case
- 1 -
-l_unit := a_coverage_data.objects.first;
- - 78 -
-while l_unit is not null loop
- - 78 -
-l_file_part := '{ "name": "'||l_unit||'",'||chr(10);
- - 78 -
-ut_utils.append_to_clob(l_result, l_file_part);
- -
-- - 78 -
-dbms_lob.append(l_result,get_lines_json(a_coverage_data.objects(l_unit)));
- +
+ +when a_attr_name is not null and a_attr_value is not null then
- +
+ +' ' || a_attr_name || '="' || dbms_xmlgen.convert(a_attr_value) || '"'
- +
+ +end
- +
+ +|| '>',
- +
+ +0, 1
- +
+ +);
- +
+ +end print_start_node;
- -
- - 78 -
-ut_utils.append_to_clob(l_result, '}');
- + +
- +
+ +member procedure print_end_node(
- +
+ +self in out nocopy ut_realtime_reporter,
- +
+ +a_name in varchar2
- +
+ +) is
- +
+ +begin
- + 100 +
+ +self.print_xml_fragment('</' || a_name || '>', -1);
- +
+ +end print_end_node;
- -
- - 78 -
-l_unit := a_coverage_data.objects.next(l_unit);
- - 78 -
-if l_unit is not null then
- - 77 -
-ut_utils.append_to_clob(l_result, ','||chr(10));
- -
-end if;
- -
-end loop;
- - 1 -
-ut_utils.append_to_clob(l_result, c_coverage_footer);
- - 1 -
-return l_result;
- -
-end;
- + +
- +
+ +member procedure print_node(
- +
+ +self in out nocopy ut_realtime_reporter,
- +
+ +a_name in varchar2,
- +
+ +a_content in clob
- +
+ +) is
- -
begin
- - 2 -
-ut_coverage.coverage_stop();
- + +
- + 232 +
+ +if a_content is not null then
- + 219 +
+ +self.print_xml_fragment('<' || a_name || '>' || dbms_xmlgen.convert(a_content) || '</' || a_name || '>');
- +
+ +end if;
- +
+ +end print_node;
- -
- - 1 -
-l_coverage_data := ut_coverage.get_coverage_data(a_run.coverage_options);
- + +
- +
+ +member procedure print_cdata_node(
- +
+ +self in out nocopy ut_realtime_reporter,
- +
+ +a_name in varchar2,
- +
+ +a_content in clob
- +
+ +) is
- +
+ +begin
- + 50 +
+ +if a_content is not null then
- + 13 +
+ +self.print_xml_fragment('<' || a_name || '><![CDATA[' || a_content || ']]></' || a_name || '>');
- +
+ +end if;
- +
+ +end print_cdata_node;
- -
- - 1 -
-self.print_clob( get_coverage_json( l_coverage_data ) );
- + +
- +
+ +member procedure print_xml_fragment(
- +
+ +self in out nocopy ut_realtime_reporter,
- +
+ +a_fragment in clob,
- +
+ +a_indent_summand_before in integer default 0,
- +
+ +a_indent_summand_after in integer default 0
- +
+ +) is
- +
+ +begin
- + 462 +
+ +current_indent := current_indent + a_indent_summand_before;
- + 462 +
+ +ut_utils.append_to_list(print_buffer, lpad(' ', 2 * current_indent) || a_fragment);
- + 462 +
+ +current_indent := current_indent + a_indent_summand_after;
- +
+ +end print_xml_fragment;
- -
- - 1 -
-(self as ut_reporter_base).after_calling_run(a_run);
- -
-end;
- + +
- +
+ +member procedure flush_print_buffer(
- +
+ +self in out nocopy ut_realtime_reporter,
- +
+ +a_item_type in varchar2
- +
+ +) is
- +
+ +l_doc clob;
- + 30 +
+ +l_rows integer := print_buffer.count;
- +
+ +begin
- + 513 +
+ +for i in 1 .. l_rows loop
- + 483 +
+ +ut_utils.append_to_clob(l_doc, print_buffer(i));
- + 483 +
+ +ut_utils.append_to_clob(l_doc, chr(10));
- +
+ +end loop;
- + 30 +
+ +self.print_clob(l_doc, a_item_type);
- + 30 +
+ +print_buffer.delete;
- +
+ +end flush_print_buffer;
- -
- -
end;
+UT3.UT_DOCUMENTATION_REPORTER
100 % covered
80 relevant lines. 80 lines covered and 0 lines missed+ +
- +
+end;
UT3.UT_SONAR_TEST_REPORTER
97.73 % lines covered
44 relevant lines. 43 lines covered and 1 lines missed+
- -
+type body ut_documentation_reporter is
type body ut_sonar_test_reporter is
+- +
/*
- -
+utPLSQL - Version X.X.X.X
utPLSQL - Version 3
+- -
+Copyright 2016 - 2017 utPLSQL Project
Copyright 2016 - 2019 utPLSQL Project
+- +
- +
Licensed under the Apache License, Version 2.0 (the "License"):
- +
you may not use this file except in compliance with the License.
- +
You may obtain a copy of the License at
- +
- +
http://www.apache.org/licenses/LICENSE-2.0
- +
- +
Unless required by applicable law or agreed to in writing, software
- +
distributed under the License is distributed on an "AS IS" BASIS,
- +
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
See the License for the specific language governing permissions and
- +
limitations under the License.
- +
*/
- +
- -
+constructor function ut_documentation_reporter(self in out nocopy ut_documentation_reporter) return self as result is
constructor function ut_sonar_test_reporter(
+- +
+ +self in out nocopy ut_sonar_test_reporter
- +
+ +) return self as result is
- -
begin
- - 31 + +
- + 10
-self.init($$plsql_unit);
- - 31 -
-self.lvl := 0;
- - 31 -
-self.failed_test_running_count := 0;
- - 31 + +
- + 10
+return;
- +
end;
- +
- -
+member function tab(self in ut_documentation_reporter) return varchar2 is
overriding member procedure after_calling_run(self in out nocopy ut_sonar_test_reporter, a_run in ut_run) is
+- -
-begin
- - 543 -
+return rpad(' ', self.lvl * 2);
+ +
- +
+function map_package_to_file(a_suite ut_suite, a_file_mappings ut_file_mappings) return varchar2 is
- -
+end tab;
l_file_name varchar2(4000);
+- -
-- -
-overriding member procedure print_text(self in out nocopy ut_documentation_reporter, a_text varchar2) is
- -
-l_lines ut_varchar2_list;
- -
-begin
- - 534 -
-if a_text is not null then
- - 494 -
-l_lines := ut_utils.string_to_table(a_text);
- - 1037 -
-for i in 1 .. l_lines.count loop
- - 543 -
-(self as ut_reporter_base).print_text(tab || l_lines(i));
- -
-end loop;
- -
-end if;
- -
-end;
- -
-- -
-overriding member procedure before_calling_suite(self in out nocopy ut_documentation_reporter, a_suite ut_logical_suite) as
- -
-begin
- - 63 -
-self.print_text(coalesce(a_suite.description, a_suite.name));
- - 63 -
-lvl := lvl + 1;
- -
-end;
- -
-- -
-overriding member procedure after_calling_test(self in out nocopy ut_documentation_reporter, a_test ut_test) as
- -
-l_message varchar2(4000);
- -
-- -
-begin
- - 95 -
-l_message := coalesce(a_test.description, a_test.name)||' ['||round(a_test.execution_time,3)||' sec]';
- -
---if test failed, then add it to the failures list, print failure with number
- - 95 -
-if a_test.result = ut_utils.tr_disabled then
- - 13 -
-self.print_yellow_text(l_message || ' (IGNORED)');
- - 82 -
-elsif a_test.result = ut_utils.tr_success then
- - 55 -
-self.print_green_text(l_message);
- - 27 -
-elsif a_test.result > ut_utils.tr_success then
- - 27 -
-failed_test_running_count := failed_test_running_count + 1;
- - 27 -
-self.print_red_text(l_message || ' (FAILED - ' || failed_test_running_count || ')');
- -
-end if;
- -
-- -
--- reproduce the output from before/after procedures and the test
- - 95 -
-self.print_clob(a_test.get_serveroutputs);
- -
-end;
- -
-- -
-overriding member procedure after_calling_before_all(self in out nocopy ut_documentation_reporter, a_suite in ut_logical_suite) is
- -
-begin
- - 11 -
-self.print_clob(treat(a_suite as ut_suite).before_all.serveroutput);
- -
-end;
- -
-- -
-overriding member procedure after_calling_after_all(self in out nocopy ut_documentation_reporter, a_suite in ut_logical_suite) is
- -
-begin
- - 9 -
-self.print_clob(treat(a_suite as ut_suite).after_all.serveroutput);
- -
-end;
- -
-- -
-overriding member procedure after_calling_suite(self in out nocopy ut_documentation_reporter, a_suite ut_logical_suite) as
- -
-begin
- - 63 -
-lvl := lvl - 1;
- - 63 -
-if lvl = 0 then
- - 39 -
-self.print_text(' ');
- -
-end if;
- -
-end;
- -
-- -
-overriding member procedure after_calling_run(self in out nocopy ut_documentation_reporter, a_run in ut_run) as
- -
-l_summary_text varchar2(4000);
- - 27 -
-l_warning_index pls_integer := 0;
- -
--- make all warning indexes uniformly indented
- - 27 -
-c_warnings_lpad constant integer := length(to_char(a_run.results_count.warnings_count));
- -
-- -
-procedure print_failure_for_expectation(a_expectation ut_expectation_result) is
- -
-l_lines ut_varchar2_list;
- -
begin
- - 13 -
-l_lines := a_expectation.get_result_lines();
- - 31 -
-for i in 1 .. l_lines.count loop
- + +
- + 20 +
+ +if a_file_mappings is not null then
- + 34 +
+ +for i in 1 .. a_file_mappings.count loop
- + 32 +
+ +if upper(a_file_mappings(i).object_name) = upper(a_suite.object_name)
- + 1 +
+ +and upper(a_file_mappings(i).object_owner) = upper(a_suite.object_owner)
- + 1 +
+ +and a_file_mappings(i).object_type = 'PACKAGE BODY' then
- 18 -
-self.print_red_text(l_lines(i));
- -
-end loop;
- - 13 -
-self.print_cyan_text(a_expectation.caller_info);
- - 13 -
-self.print_text(' ');
- -
-end;
- -
-- -
-procedure print_failures_for_test(a_test ut_test, a_failure_no in out nocopy integer) is
- -
-begin
- - 72 -
-if a_test.result > ut_utils.tr_success then
- - 27 -
-a_failure_no := a_failure_no + 1;
- - 27 -
-self.print_text(lpad(a_failure_no, length(failed_test_running_count) + 2, ' ') || ') ' ||
- -
-nvl(a_test.name, a_test.item.form_name));
- - 27 -
-self.lvl := self.lvl + 3;
- -
-- - 27 -
-self.print_red_text(ut_utils.table_to_clob(a_test.get_error_stack_traces()));
- -
-- - 40 -
-for j in 1 .. a_test.results.count loop
- - 13 -
-if a_test.results(j).status > ut_utils.tr_success then
- - 13 -
-print_failure_for_expectation(a_test.results(j));
- +
+ +l_file_name := a_file_mappings(i).file_name;
- + 18 +
+ +exit;
- -
end if;
- + +
- -
end loop;
- + +
- +
+ +end if;
- + 20 +
+ +return coalesce(l_file_name, a_suite.path);
- +
+ +end;
- -
- - 27 -
-self.lvl := self.lvl - 3;
- + +
- +
+ +procedure print_test_results(a_test ut_test) is
- + 43 +
+ +l_results ut_varchar2_rows := ut_varchar2_rows();
- +
+ +begin
- + 43 +
+ +ut_utils.append_to_list( l_results, '<testCase name="'||dbms_xmlgen.convert(a_test.name)||'" duration="'||round(a_test.execution_time()*1000,0)||'" >');
- + 43 +
+ +if a_test.result = ut_utils.gc_disabled then
- + 2 +
+ +ut_utils.append_to_list( l_results, '<skipped message="skipped"/>');
- + 41 +
+ +elsif a_test.result = ut_utils.gc_error then
- + 9 +
+ +ut_utils.append_to_list( l_results, '<error message="encountered errors">');
- + 9 +
+ +ut_utils.append_to_list( l_results, ut_utils.to_cdata( ut_utils.convert_collection( a_test.get_error_stack_traces() ) ) );
- + 9 +
+ +ut_utils.append_to_list( l_results, '</error>');
- + 32 +
+ +elsif a_test.result > ut_utils.gc_success then
- + 3 +
+ +ut_utils.append_to_list( l_results, '<failure message="some expectations have failed">');
- + 3 +
+ +ut_utils.append_to_list( l_results, ut_utils.to_cdata( a_test.get_failed_expectation_lines() ) );
- + 3 +
+ +ut_utils.append_to_list( l_results, '</failure>');
- -
end if;
- + +
- + 43 +
+ +ut_utils.append_to_list( l_results, '</testCase>');
- +
+ +- + 43 +
+ +self.print_text_lines(l_results);
- -
end;
- + +
- -
- -
-procedure print_failures_from_suite(a_suite ut_logical_suite, a_failure_no in out nocopy integer) is
- + +
- +
+ +procedure print_suite_results(a_suite ut_logical_suite, a_file_mappings ut_file_mappings) is
- -
begin
- - 124 + +
- +
+ +- + 113
-for i in 1 .. a_suite.items.count loop
- - 84 -
-if a_suite.items(i) is of(ut_logical_suite) then
- - 12 -
-print_failures_from_suite(treat(a_suite.items(i) as ut_logical_suite), a_failure_no);
- - 72 -
-elsif a_suite.items(i) is of(ut_test) then
- - 72 -
-print_failures_for_test(treat(a_suite.items(i) as ut_test), a_failure_no);
- + +
- + 71 +
+ +if a_suite.items(i) is of(ut_logical_suite) and a_suite.items(i) is not of(ut_suite_context) then
- + 26 +
+ +print_suite_results(treat(a_suite.items(i) as ut_logical_suite), a_file_mappings);
- -
end if;
- + +
- -
end loop;
- -
-end;
- -
-- -
-procedure print_failures_details(a_run in ut_run) is
- - 27 -
-l_failure_no integer := 0;
- -
-begin
- - 27 -
-if a_run.results_count.failure_count > 0 or a_run.results_count.errored_count > 0 then
- + +
- -
- - 16 -
-self.print_text('Failures:');
- - 16 -
-self.print_text(' ');
- - 44 -
-for i in 1 .. a_run.items.count loop
- - 28 -
-print_failures_from_suite(treat(a_run.items(i) as ut_logical_suite), l_failure_no);
- -
-end loop;
- + +
- + 42 +
+ +if a_suite is of(ut_suite) and a_suite is not of(ut_suite_context) then
- + 20 +
+ +self.print_text('<file path="'||dbms_xmlgen.convert(map_package_to_file(treat(a_suite as ut_suite), a_file_mappings))||'">');
- -
end if;
- -
-end;
- + +
- -
- -
-procedure print_item_warnings(a_item in ut_suite_item) is
- -
-l_items ut_suite_items;
- -
-begin
- - 8 -
-if a_item is of (ut_logical_suite) then
- - 3 -
-l_items := treat(a_item as ut_logical_suite).items;
- - 8 -
-for i in 1 .. l_items.count loop
- - 5 -
-if l_items(i) is of(ut_suite_item) then
- - 5 -
-print_item_warnings(l_items(i));
- + +
- + 113 +
+ +for i in 1 .. a_suite.items.count loop
- + 71 +
+ +if a_suite.items(i) is of(ut_suite_context) then
- + 2 +
+ +print_suite_results(treat(a_suite.items(i) as ut_suite_context), a_file_mappings);
- +
+ +end if;
- +
+ +end loop;
- +
+ +- + 42 +
+ +if a_suite is of(ut_suite) then
- + 73 +
+ +for i in 1 .. a_suite.items.count loop
- + 51 +
+ +if a_suite.items(i) is of(ut_test) then
- + 43 +
+ +print_test_results(treat(a_suite.items(i) as ut_test));
- -
end if;
- + +
- -
end loop;
- + +
- -
end if;
- + +
- -
- - 8 -
-if a_item.warnings is not null and a_item.warnings.count > 0 then
- - 10 -
-for i in 1 .. a_item.warnings.count loop
- - 5 -
-l_warning_index := l_warning_index + 1;
- - 5 -
-self.print_text(' ' || lpad(l_warning_index, c_warnings_lpad) || ') ' || a_item.path);
- - 5 -
-self.lvl := self.lvl + 3;
- - 5 -
-self.print_red_text(a_item.warnings(i));
- - 5 -
-self.lvl := self.lvl - 3;
- -
-end loop;
- - 5 -
-self.print_text(' ');
- + +
- + 42 +
+ +if a_suite is of(ut_suite) and a_suite is not of(ut_suite_context) then
- + 20 +
+ +self.print_text('</file>');
- -
end if;
- + +
- -
end;
- + +
- -
- -
-procedure print_warnings(a_run in ut_run) is
- -
-begin
- - 27 -
-if a_run.results_count.warnings_count > 0 then
- - 3 -
-self.print_text(' ');
- - 3 -
-self.print_text('Warnings:');
- - 3 -
-self.print_text(' ');
- - 6 -
-for i in 1 .. a_run.items.count loop
- - 3 -
-print_item_warnings(treat(a_run.items(i) as ut_suite_item));
- -
-end loop;
- -
-end if;
- -
-end;
- + +
- +
+ +begin
- + 10 +
+ +self.print_text(ut_utils.get_xml_header(a_run.client_character_set));
- + 10 +
+ +self.print_text('<testExecutions version="1">');
- + 24 +
+ +for i in 1 .. a_run.items.count loop
- + 14 +
+ +print_suite_results(treat(a_run.items(i) as ut_logical_suite), a_run.test_file_mappings);
- +
+ +end loop;
- +
+ +- + 10 +
+ +self.print_text('</testExecutions>');
- +
+ +end;
- -
- + +
- +
+ +overriding member function get_description return varchar2 as
- -
begin
- - 27 -
-print_failures_details(a_run);
- - 27 -
-print_warnings(a_run);
- - 27 -
-self.print_text('Finished in ' || a_run.execution_time || ' seconds');
- -
-- - 27 -
-l_summary_text :=
- -
-a_run.results_count.total_count || ' tests, '
- -
-|| a_run.results_count.failure_count || ' failed, ' || a_run.results_count.errored_count || ' errored, '
- -
-|| a_run.results_count.disabled_count ||' disabled, ' || a_run.results_count.warnings_count || ' warning(s)';
- - 27 -
-if a_run.results_count.failure_count + a_run.results_count.errored_count + a_run.results_count.warnings_count > 0 then
- - 18 -
-self.print_red_text(l_summary_text);
- -
-else
- - 9 -
-self.print_green_text(l_summary_text);
- -
-end if;
- - 27 -
-self.print_text(' ');
- - 27 -
-(self as ut_reporter_base).after_calling_run(a_run);
- + +
- +
+ +return 'Generates a JSON report providing detailed information on test execution.' || chr(10) ||
- +
+ +'Designed for [SonarQube](https://about.sonarqube.com/) to report test execution.' || chr(10) ||
- +
+ +'JSON format returned conforms with the Sonar specification: https://docs.sonarqube.org/display/SONAR/Generic+Test+Data';
- -
end;
- + +
- -
- -
end;
+UT3.UT_SONAR_TEST_REPORTER
100 % covered
31 relevant lines. 31 lines covered and 0 lines missed+ +
- +
+end;
UT3.UT_TEAMCITY_REPORTER
94.44 % lines covered
36 relevant lines. 34 lines covered (including 1 lines partially covered ) and 2 lines missed+
- -
+type body ut_sonar_test_reporter is
type body ut_teamcity_reporter is
+- +
/*
- -
+utPLSQL - Version X.X.X.X
utPLSQL - Version 3
+- -
+Copyright 2016 - 2017 utPLSQL Project
Copyright 2016 - 2019 utPLSQL Project
+- +
- +
Licensed under the Apache License, Version 2.0 (the "License"):
- +
you may not use this file except in compliance with the License.
- +
You may obtain a copy of the License at
- +
- +
http://www.apache.org/licenses/LICENSE-2.0
- +
- +
Unless required by applicable law or agreed to in writing, software
- +
distributed under the License is distributed on an "AS IS" BASIS,
- +
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
See the License for the specific language governing permissions and
- +
limitations under the License.
- +
*/
- +
- -
+constructor function ut_sonar_test_reporter(
constructor function ut_teamcity_reporter(self in out nocopy ut_teamcity_reporter) return self as result is
+- -
-self in out nocopy ut_sonar_test_reporter
- -
-) return self as result is
- -
begin
- - 6 + +
- + 3
-self.init($$plsql_unit);
- - 6 + +
- + 3
-return;
- + +
- -
end;
- + +
- -
- -
-overriding member procedure before_calling_run(self in out nocopy ut_sonar_test_reporter, a_run in ut_run) is
- + +
- +
+ +overriding member procedure before_calling_suite(self in out nocopy ut_teamcity_reporter, a_suite in ut_logical_suite) is
- -
begin
- - 6 -
-self.file_mappings := coalesce(a_run.test_file_mappings,ut_file_mappings());
- - 6 -
+ +self.print_text('<testExecutions version="1">');
- + 8 +
+ +self.print_text(
- +
+ +ut_teamcity_reporter_helper.test_suite_started(
- +
+ +a_suite_name => nvl(replace(trim(a_suite.description),'.'),a_suite.path)
- +
+)
- -
+end;
);
+- -
+end;
+- -
+overriding member procedure before_calling_suite(self in out nocopy ut_sonar_test_reporter, a_suite ut_logical_suite) is
+
- -
+l_file_name varchar2(4000);
overriding member procedure after_calling_suite(self in out nocopy ut_teamcity_reporter, a_suite in ut_logical_suite) is
+- -
begin
- - 74 -
-for i in 1 .. self.file_mappings.count loop
- - 62 -
+ +if upper(self.file_mappings(i).object_name) = upper(a_suite.object_name)
- + 8 +
+ +self.print_text(
- +
+ut_teamcity_reporter_helper.test_suite_finished(
- -
-and upper(self.file_mappings(i).object_owner) = upper(a_suite.object_owner) then
- - 14 -
-l_file_name := self.file_mappings(i).file_name;
- - 14 -
+exit;
a_suite_name => nvl(replace(trim(a_suite.description),'.'),a_suite.path)
+ +- +
+ +)
- +
+);
- -
+end if;
end;
+- -
-end loop;
- - 14 -
-l_file_name := coalesce(l_file_name, a_suite.path);
- - 26 -
+self.print_text('<file path="'||l_file_name||'">');
+ +
- +
+ +overriding member procedure before_calling_test(self in out nocopy ut_teamcity_reporter, a_test in ut_test) is
- +
+l_test_full_name varchar2(4000);
- -
+end;
begin
+- -
- -
+ +overriding member procedure after_calling_test(self in out nocopy ut_sonar_test_reporter, a_test ut_test) is
- + 6 +
+l_test_full_name := lower(a_test.item.owner_name) || '.' || lower(a_test.item.object_name) || '.' ||
- -
+l_message varchar2(32757);
lower(a_test.item.procedure_name);
+- -
-l_lines ut_varchar2_list;
- -
-begin
- - 46 -
-self.print_text('<testCase name="'||a_test.name||'" duration="'||round(a_test.execution_time()*1000,0)||'" >');
- - 46 -
-if a_test.result = ut_utils.tr_disabled then
- - 8 -
-self.print_text('<skipped message="skipped"/>');
- - 38 -
-elsif a_test.result = ut_utils.tr_error then
- - 4 -
-self.print_text('<error message="encountered errors">');
- - 4 -
-self.print_text('<![CDATA[');
- - 4 -
-self.print_clob(ut_utils.table_to_clob(a_test.get_error_stack_traces()));
- - 4 -
-self.print_text(']]>');
- - 4 -
-self.print_text('</error>');
- - 34 -
-elsif a_test.result > ut_utils.tr_success then
- - 4 -
-self.print_text('<failure message="some expectations have failed">');
- - 4 -
-self.print_text('<![CDATA[');
- - 8 -
-for i in 1 .. a_test.results.count loop
- +
+ +- + 6 +
+ +self.print_text(
- +
+ +ut_teamcity_reporter_helper.test_started(
- +
+ +a_test_name => l_test_full_name,
- +
+ +a_capture_standard_output => true
- +
+ +)
- +
+ +);
- +
+ +- +
+ +end;
- +
+ +- +
+ +overriding member procedure after_calling_test(self in out nocopy ut_teamcity_reporter, a_test in ut_test) is
- + 6 +
+ +l_results ut_varchar2_rows := ut_varchar2_rows();
- +
+ +l_test_full_name varchar2(4000);
- +
+ +l_std_err_msg varchar2(32767);
- +
+ +function add_error_message( a_message varchar2, a_message_name varchar2) return varchar2 is
- +
+ +begin
- + 3 +
+ +return
- + 1 +
+ +case
- + 1 +
+ +when a_message is not null
- +
+ +then a_message_name || chr(10) || a_message || chr(10)
- +
+ +end;
- +
+ +end;
- +
+ +function add_error_messages(a_executables ut_executables, a_message_name varchar2) return varchar2 is
- +
+ +l_message varchar2(32767);
- +
+ +l_idx binary_integer;
- +
+ +begin
- 4 -
-l_lines := a_test.results(i).get_result_lines();
- - 12 -
-for i in 1 .. l_lines.count loop
- - 8 -
-self.print_text(l_lines(i));
- -
-end loop;
- +
+ +l_idx := a_executables.first;
- + 6 +
+ +while l_idx is not null loop
- + 2 +
+ +l_message := l_message || add_error_message(a_executables(l_idx).error_backtrace, a_message_name);
- + 2 +
+ +l_idx := a_executables.next(l_idx);
- -
end loop;
- + +
- 4 -
-self.print_text(']]>');
- +
+ +return l_message;
- +
+ +end;
- +
+ +begin
- + 6 +
+ +l_test_full_name := lower(a_test.item.owner_name) || '.' || lower(a_test.item.object_name) || '.' ||
- +
+ +lower(a_test.item.procedure_name);
- +
+ +- + 7 +
+ +if a_test.result = ut_utils.gc_disabled then
- + 1 +
+ +ut_utils.append_to_list( l_results, ut_teamcity_reporter_helper.test_disabled(l_test_full_name));
- +
+ +else
- +
+ +- + 5 +
+ +ut_utils.append_to_list( l_results, a_test.get_serveroutputs());
- +
+ +- + 5 +
+ +if a_test.result = ut_utils.gc_error then
- + 1 +
+ +l_std_err_msg := l_std_err_msg || add_error_messages(a_test.before_each_list, 'Before each exception:');
- + 1 +
+ +l_std_err_msg := l_std_err_msg || add_error_messages(a_test.before_test_list, 'Before test exception:');
- + 1 +
+ +l_std_err_msg := l_std_err_msg || add_error_message(a_test.item.error_backtrace, 'Test exception:');
- + 1 +
+ +l_std_err_msg := l_std_err_msg || add_error_messages(a_test.after_test_list, 'After test exception:');
- + 1 +
+ +l_std_err_msg := l_std_err_msg || add_error_messages(a_test.after_each_list, 'After each exception:');
- +
+ +- + 1 +
+ +ut_utils.append_to_list(
- +
+ +l_results,
- +
+ +ut_teamcity_reporter_helper.test_std_err(
- +
+ +a_test_name => l_test_full_name,
- +
+ +a_out => trim(l_std_err_msg)
- +
+ +)
- +
+ +);
- + 1 +
+ +ut_utils.append_to_list(
- +
+ +l_results,
- +
+ +ut_teamcity_reporter_helper.test_failed(
- +
+ +a_test_name => l_test_full_name,
- +
+ +a_msg => 'Error occured',
- +
+ +a_details =>
- +
+ +trim(l_std_err_msg)
- + 2/3 + 1 +
+ +|| case when a_test.failed_expectations is not null
- + 1 +
+ +and a_test.failed_expectations.count>0
- +
+ +then a_test.failed_expectations(1).message end
- +
+ +)
- +
+ +);
- 4 -
-self.print_text('</failure>');
- -
-end if;
- - 46 -
-self.print_text('</testCase>');
- -
-end;
- +
+ +elsif a_test.failed_expectations is not null and a_test.failed_expectations.count > 0 then
- +
+ +-- Teamcity supports only a single failure message
- -
- -
-overriding member procedure after_calling_suite(self in out nocopy ut_sonar_test_reporter, a_suite ut_logical_suite) is
- -
-begin
- - 26 -
-self.print_text('</file>');
- + +
- + 3 +
+ +ut_utils.append_to_list(
- +
+ +l_results,
- +
+ +ut_teamcity_reporter_helper.test_failed(
- +
+ +a_test_name => l_test_full_name,
- +
+ +a_msg => a_test.failed_expectations(a_test.failed_expectations.first).description,
- +
+ +a_details => a_test.failed_expectations(a_test.failed_expectations.first).message )
- +
+ +);
- + 1 +
+ +elsif a_test.result = ut_utils.gc_failure then
- +
+ +ut_utils.append_to_list(
- +
+ +l_results,
- +
+ +ut_teamcity_reporter_helper.test_failed(
- +
+ +a_test_name => l_test_full_name,
- +
+ +a_msg => 'Test failed'
- +
+ +)
- +
+ +);
- +
+ +end if;
- +
+ +- + 5 +
+ +ut_utils.append_to_list(
- +
+ +l_results,
- +
+ +ut_teamcity_reporter_helper.test_finished(l_test_full_name, trunc(a_test.execution_time * 1e3))
- +
+ +);
- +
+ +- +
+ +end if;
- + 6 +
+ +self.print_text_lines(l_results);
- -
end;
- + +
- -
- -
-overriding member procedure after_calling_run(self in out nocopy ut_sonar_test_reporter, a_run in ut_run) is
- + +
- +
+ +overriding member function get_description return varchar2 as
- -
begin
- - 6 -
-self.print_text('</testExecutions>');
- + +
- +
+ +return 'Provides the TeamCity (a CI server by jetbrains) reporting-format that allows tracking of progress of a CI step/task as it executes.' || chr(10) ||
- +
+ +'https://confluence.jetbrains.com/display/TCD9/Build+Script+Interaction+with+TeamCity';
- -
end;
- + +
- -
- -
end;
+UT3.UT_TEAMCITY_REPORTER
81.82 % covered
33 relevant lines. 27 lines covered and 6 lines missed+ +
- +
+end;
UT3.UT_TEAMCITY_REPORTER_HELPER
93.18 % lines covered
44 relevant lines. 41 lines covered and 3 lines missed+
- -
+type body ut_teamcity_reporter is
package body ut_teamcity_reporter_helper is
+- +
/*
- -
+utPLSQL - Version X.X.X.X
utPLSQL - Version 3
+- -
+Copyright 2016 - 2017 utPLSQL Project
Copyright 2016 - 2019 utPLSQL Project
+- +
- +
Licensed under the Apache License, Version 2.0 (the "License"):
- +
you may not use this file except in compliance with the License.
- +
You may obtain a copy of the License at
- +
- +
http://www.apache.org/licenses/LICENSE-2.0
- +
- +
Unless required by applicable law or agreed to in writing, software
- +
distributed under the License is distributed on an "AS IS" BASIS,
- +
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
See the License for the specific language governing permissions and
- +
limitations under the License.
- +
*/
- +
- -
+constructor function ut_teamcity_reporter(self in out nocopy ut_teamcity_reporter) return self as result is
subtype t_prop_index is varchar2(2000 char);
+- -
-begin
- - 5 -
-self.init($$plsql_unit);
- - 5 -
-return;
- -
-end;
- +
+ +type t_props is table of varchar2(32767) index by t_prop_index;
- + +
- +
+ +function escape_value(a_value in varchar2) return varchar2 is
- +
+ +begin
- + 52 +
+return translate(regexp_replace(a_value, q'/(\'|\||\[|\]|/' || chr(13) || '|' || chr(10) || ')', '|\1'),chr(13)||chr(10),'rn');
- -
+overriding member procedure before_calling_suite(self in out nocopy ut_teamcity_reporter, a_suite in ut_logical_suite) is
end;
+- -
-begin
- - 25 -
+self.print_text(ut_teamcity_reporter_helper.test_suite_started(a_suite_name => nvl(replace(trim(a_suite.description)
+ +
- +
+function message(a_command in varchar2, a_props t_props default cast(null as t_props)) return varchar2 is
- -
+,'.')
l_message varchar2(32767);
+- -
+,a_suite.name)));
l_index t_prop_index;
+- -
-end;
- -
+l_value varchar2(32767);
+ +- + 33 +
+l_max_len binary_integer := 2000;
- -
-overriding member procedure after_calling_suite(self in out nocopy ut_teamcity_reporter, a_suite in ut_logical_suite) is
- -
begin
- - 25 -
+ +self.print_text(ut_teamcity_reporter_helper.test_suite_finished(a_suite_name => nvl(replace(trim(a_suite.description)
- + 33 +
+ +l_message := '##teamcity[' || a_command || ' timestamp=''' ||
- +
+regexp_replace(to_char(systimestamp, 'YYYY-MM-DD"T"HH24:MI:ss.FF3TZHTZM'), '(\.\d{3})\d+(\+)', '\1\2') || '''';
- -
-,'.')
- -
-,a_suite.name)));
- -
-end;
- -
- -
-overriding member procedure before_calling_test(self in out nocopy ut_teamcity_reporter, a_test in ut_test) is
- -
-l_test_full_name varchar2(4000);
- -
+ +begin
- + 33 +
+ +l_index := a_props.first;
- + 119 +
+ +while l_index is not null loop
- + 86 +
+ +if a_props(l_index) is not null then
- + 51 +
+ +l_value := escape_value(a_props(l_index));
- + 51 +
+ +if length(l_value) > l_max_len then
- + 1 +
+l_value := substr(l_value,1,l_max_len-7)||escape_value('[...]');
- -
-- - 42 -
+l_test_full_name := lower(a_test.item.owner_name) || '.' || lower(a_test.item.object_name) || '.' ||
end if;
+ +- + 51 +
+l_message := l_message || ' ' || l_index || '=''' || l_value || '''';
- -
-lower(a_test.item.procedure_name);
- -
-- - 42 -
-self.print_text(ut_teamcity_reporter_helper.test_started(a_test_name => l_test_full_name
- -
-,a_capture_standard_output => true));
- -
+end if;
+ +- + 86 +
+ +l_index := a_props.next(l_index);
- +
+ +end loop;
- + 33 +
+ +l_message := l_message || ']';
- + 33 +
+return l_message;
- -
-end;
- + +
- +
+end message;
- -
+overriding member procedure after_calling_test(self in out nocopy ut_teamcity_reporter, a_test in ut_test) is
+
- -
+l_expectation ut_expectation_result;
function test_suite_started(a_suite_name varchar2, a_flow_id varchar2 default null) return varchar2 is
+- -
+l_test_full_name varchar2(4000);
l_props t_props;
+- -
-l_std_err_msg varchar2(32767);
- -
begin
- -
--- l_test_full_name := self.suite_names_stack(self.suite_names_stack.last) || ':' ||
- -
--- nvl(replace(a_test.description, '.'), a_test.name);
- - 42 -
+ +l_test_full_name := lower(a_test.item.owner_name) || '.' || lower(a_test.item.object_name) || '.' ||
- + 8 +
+ +l_props('name') := a_suite_name;
- + 8 +
+ +l_props('flowId') := a_flow_id;
- + 8 +
+ +return message('testSuiteStarted', l_props);
- +
+end;
- -
+lower(a_test.item.procedure_name);
function test_suite_finished(a_suite_name varchar2, a_flow_id varchar2 default null) return varchar2 is
+- -
-- - 42 -
-if a_test.result = ut_utils.tr_disabled then
- - 7 -
-self.print_text(ut_teamcity_reporter_helper.test_disabled(l_test_full_name));
- -
-else
- -
-- - 35 -
+self.print_clob(a_test.get_serveroutputs());
l_props t_props;
+ +- +
+ +begin
- + 8 +
+ +l_props('name') := a_suite_name;
- + 8 +
+ +l_props('flowId') := a_flow_id;
- + 8 +
+ +return message('testSuiteFinished', l_props);
- +
+end;
- -
- - 35 -
-if a_test.result = ut_utils.tr_error then
- - 3 -
-if a_test.before_each.error_backtrace is not null then
- -
-l_std_err_msg := l_std_err_msg || 'Before each exception:' || chr(10) || a_test.before_each.error_backtrace || chr(10);
- -
-end if;
- -
-- - 3 -
-if a_test.before_test.error_backtrace is not null then
- -
-l_std_err_msg := l_std_err_msg || 'Before test exception:' || chr(10) || a_test.before_test.error_backtrace || chr(10);
- -
+ +end if;
- +
+ +function test_started(a_test_name varchar2, a_capture_standard_output boolean default null, a_flow_id varchar2 default null) return varchar2 is
- +
+ +l_props t_props;
- +
+ +begin
- + 6 +
+ +l_props('name') := a_test_name;
- + 6 +
+ +l_props('captureStandardOutput') := case a_capture_standard_output
- + 1 +
+ +when true then
- +
+ +'true'
- +
+when false then
- -
-- - 3 -
-if a_test.item.error_backtrace is not null then
- - 3 -
+l_std_err_msg := l_std_err_msg || 'Test exception:' || chr(10) || a_test.item.error_backtrace || chr(10);
'false'
+ +- +
+ +else
- +
+null
- -
-end if;
- -
-- - 3 -
-if a_test.after_test.error_backtrace is not null then
- -
+l_std_err_msg := l_std_err_msg || 'After test exception:' || chr(10) || a_test.after_test.error_backtrace || chr(10);
end;
+ +- + 6 +
+ +l_props('flowId') := a_flow_id;
- + 6 +
+ +return message('testStarted', l_props);
- +
+end;
- -
-end if;
- -
-- - 3 -
-if a_test.after_each.error_backtrace is not null then
- -
-l_std_err_msg := l_std_err_msg || 'After each exception:' || chr(10) || a_test.after_each.error_backtrace || chr(10);
- -
-end if;
- -
- - 3 -
-self.print_text(ut_teamcity_reporter_helper.test_std_err(a_test_name => l_test_full_name
- -
-,a_out => trim(l_std_err_msg)));
- - 3 -
+ +self.print_text(ut_teamcity_reporter_helper.test_failed(a_test_name => l_test_full_name
- +
+ +function test_finished(a_test_name varchar2, a_test_duration_milisec number default null, a_flow_id varchar2 default null) return varchar2 is
- +
+ +l_props t_props;
- +
+ +begin
- + 5 +
+ +l_props('name') := a_test_name;
- + 5 +
+ +l_props('duration') := a_test_duration_milisec;
- + 5 +
+ +l_props('flowId') := a_flow_id;
- + 5 +
+ +return message('testFinished', l_props);
- +
+end;
- -
-,a_msg => 'Error occured'
- - 1 -
-,a_details => trim(l_std_err_msg) || case when a_test.results is not null and a_test.results.count>0 then a_test.results(1)
- -
-.message end));
- - 32 -
-elsif a_test.results is not null and a_test.results.count > 0 then
- - 61 -
-for i in 1 .. a_test.results.count loop
- -
- - 32 -
+ +l_expectation := a_test.results(i);
- +
+ +function test_disabled(a_test_name varchar2, a_flow_id varchar2 default null) return varchar2 is
- +
+ +l_props t_props;
- +
+ +begin
- + 1 +
+ +l_props('name') := a_test_name;
- + 1 +
+ +l_props('flowId') := a_flow_id;
- + 1 +
+return message('testIgnored', l_props);
- -
-- - 32 -
-if l_expectation.status > ut_utils.tr_success then
- - 3 -
+self.print_text(ut_teamcity_reporter_helper.test_failed(a_test_name => l_test_full_name
end;
+ +- +
+ +function test_failed(a_test_name varchar2, a_msg in varchar2 default null, a_details varchar2 default null, a_flow_id varchar2 default null, a_actual varchar2 default null, a_expected varchar2 default null) return varchar2 is
- +
+l_props t_props;
- -
-,a_msg => l_expectation.description
- -
-,a_details => l_expectation.message ));
- -
--- Teamcity supports only a single failure message
- - 3 -
-exit;
- -
+end if;
begin
+ +- + 4 +
+ +l_props('name') := a_test_name;
- + 4 +
+ +l_props('message') := a_msg;
- + 4 +
+ +l_props('details') := a_details;
- + 4 +
+l_props('flowId') := a_flow_id;
- -
- -
+ +end loop;
- + 4 +
+if a_actual is not null and a_expected is not null then
- -
+elsif a_test.result = ut_utils.tr_failure then
l_props('actual') := a_actual;
+- -
+self.print_text(ut_teamcity_reporter_helper.test_failed(a_test_name => l_test_full_name
l_props('expected') := a_expected;
+- -
+,a_msg => 'Test failed'));
end if;
+- -
-end if;
- -
- - 35 -
+ +self.print_text(ut_teamcity_reporter_helper.test_finished(l_test_full_name, trunc(a_test.execution_time * 1e3)));
- + 4 +
+ +return message('testFailed', l_props);
- +
+end;
- +
- -
+end if;
function test_std_err(a_test_name varchar2, a_out in varchar2, a_flow_id in varchar2 default null) return varchar2 is
+- -
+l_props t_props;
+- +
+ +begin
- + 1 +
+ +l_props('name') := a_test_name;
- + 1 +
+ +l_props('out') := a_out;
- + 1 +
+ +l_props('flowId') := a_flow_id;
- + 1 +
+ +return message('testStdErr', l_props);
- -
end;
- + +
- -
- -
end;
+UT3.UT_TEAMCITY_REPORTER_HELPER
92.68 % covered
41 relevant lines. 38 lines covered and 3 lines missed+ +
- +
+end ut_teamcity_reporter_helper;
UT3.UT_TFS_JUNIT_REPORTER
92.45 % lines covered
53 relevant lines. 49 lines covered and 4 lines missed+
- -
+package body ut_teamcity_reporter_helper is
type body ut_tfs_junit_reporter is
+- +
/*
- -
+utPLSQL - Version X.X.X.X
utPLSQL - Version 3
+- -
+Copyright 2016 - 2017 utPLSQL Project
Copyright 2016 - 2019 utPLSQL Project
+- +
- +
Licensed under the Apache License, Version 2.0 (the "License"):
- +
you may not use this file except in compliance with the License.
- +
You may obtain a copy of the License at
- +
- +
http://www.apache.org/licenses/LICENSE-2.0
- +
- +
Unless required by applicable law or agreed to in writing, software
- +
distributed under the License is distributed on an "AS IS" BASIS,
- +
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
See the License for the specific language governing permissions and
- +
limitations under the License.
- +
*/
- +
- -
+subtype t_prop_index is varchar2(2000 char);
constructor function ut_tfs_junit_reporter(self in out nocopy ut_tfs_junit_reporter) return self as result is
+- -
-type t_props is table of varchar2(32767) index by t_prop_index;
- -
-- -
-function escape_value(a_value in varchar2) return varchar2 is
- -
begin
- - 235 -
-return translate(regexp_replace(a_value, '(''|"|[|]|' || chr(13) || '|' || chr(10) || ')', '|\1'),chr(13)||chr(10),'nr');
- + +
- + 8 +
+ +self.init($$plsql_unit);
- + 8 +
+ +return;
- -
end;
- + +
- -
- -
+ +function message(a_command in varchar2, a_props t_props default cast(null as t_props)) return varchar2 is
- +
+ +overriding member procedure after_calling_run(self in out nocopy ut_tfs_junit_reporter, a_run in ut_run) is
- +
+ +begin
- + 8 +
+junit_version_one(a_run);
- -
+l_message varchar2(32767);
end;
+- -
+l_index t_prop_index;
+
- -
-l_value varchar2(32767);
- -
-begin
- - 143 -
+l_message := '##teamcity[' || a_command || ' timestamp=''' ||
member procedure junit_version_one(self in out nocopy ut_tfs_junit_reporter,a_run in ut_run) is
+ +- + 8 +
+ +l_suite_id integer := 0;
- +
+- -
+regexp_replace(to_char(systimestamp, 'YYYY-MM-DD"T"HH24:MI:ss.FF3TZHTZM'), '(\.\d{3})\d+(\+)', '\1\2') || '''';
function get_common_suite_attributes(a_item ut_suite_item) return varchar2 is
+- -
-- - 143 -
-l_index := a_props.first;
- - 521 -
-while l_index is not null loop
- - 378 -
-if a_props(l_index) is not null then
- - 235 -
-l_value := escape_value(a_props(l_index));
- - 235 -
+l_message := l_message || ' ' || l_index || '=''' || l_value || '''';
begin
+ +- + 10 +
+ +return ' errors="' ||a_item.results_count.errored_count || '"' ||
- +
+ +' failures="' || a_item.results_count.failure_count ||
- +
+ +'" name="' || dbms_xmlgen.convert(nvl(a_item.description, a_item.name)) || '"' ||
- +
+ +' time="' || ut_utils.to_xml_number_format(a_item.execution_time()) || '" '||
- +
+' timestamp="' || to_char(sysdate,'RRRR-MM-DD"T"HH24:MI:SS') || '" '||
- -
-end if;
- - 378 -
+l_index := a_props.next(l_index);
' hostname="' || sys_context('USERENV','HOST') || '" ';
+ +- +
+end;
- -
-end loop;
- - 143 -
-l_message := l_message || ']';
- - 143 -
-return l_message;
- + +
- +
+ +function get_common_testcase_attributes(a_item ut_suite_item) return varchar2 is
- +
+ +begin
- + 10 +
+return ' name="' || dbms_xmlgen.convert(nvl(a_item.description, a_item.name)) || '"' ||
- -
+end message;
' time="' || ut_utils.to_xml_number_format(a_item.execution_time()) || '"';
+- -
+end;
+- -
+-- function block_opened(a_name varchar2, a_flow_id varchar2 default null) return varchar2 is
+
- -
+-- l_props t_props;
function get_path(a_path_with_name varchar2, a_name varchar2) return varchar2 is
+- -
--- begin
- -
+-- l_props('name') := a_name;
begin
+ +- + 10 +
+return regexp_substr(a_path_with_name, '(.*)\.' ||a_name||'$',subexpression=>1);
- -
+-- l_props('flowId') := a_flow_id;
end;
+- -
+-- return message('blockOpened', l_props);
+
- -
--- end;
- -
+--
procedure print_test_results(a_test ut_test) is
+ +- + 10 +
+l_results ut_varchar2_rows := ut_varchar2_rows();
- -
--- function block_closed(a_name varchar2, a_flow_id varchar2 default null) return varchar2 is
- -
+-- l_props t_props;
begin
+ +- + 10 +
+self.print_text('<testcase classname="' || dbms_xmlgen.convert(get_path(a_test.path, a_test.name)) || '" ' ||
- -
+-- begin
get_common_testcase_attributes(a_test) || '>');
+- -
+-- l_props('name') := a_name;
/*
+- -
+-- l_props('flowId') := a_flow_id;
According to specs :
+- -
+-- return message('blockClosed', l_props);
- A failure is a test which the code has explicitly failed by using the mechanisms for that purpose.
+- -
+-- end;
e.g., via an assertEquals
+- -
+--
- An errored test is one that had an unanticipated problem.
+- -
+function test_suite_started(a_suite_name varchar2, a_flow_id varchar2 default null) return varchar2 is
e.g., an unchecked throwable; or a problem with the implementation of the test.
+- -
+l_props t_props;
*/
+- -
-begin
- - 25 -
-l_props('name') := a_suite_name;
- - 25 -
-l_props('flowId') := a_flow_id;
- - 25 -
-return message('testSuiteStarted', l_props);
- -
+end;
+ +
- + 10 +
+ +if a_test.result = ut_utils.gc_error then
- + 1 +
+ +ut_utils.append_to_list( l_results, '<error type="error" message="Error while executing '||a_test.name||'">');
- + 1 +
+ +ut_utils.append_to_list( l_results, ut_utils.to_cdata( ut_utils.convert_collection( a_test.get_error_stack_traces() ) ) );
- + 1 +
+ut_utils.append_to_list( l_results, '</error>');
- -
-function test_suite_finished(a_suite_name varchar2, a_flow_id varchar2 default null) return varchar2 is
- -
-l_props t_props;
- -
-begin
- - 25 -
-l_props('name') := a_suite_name;
- - 25 -
-l_props('flowId') := a_flow_id;
- - 25 -
+return message('testSuiteFinished', l_props);
-- Do not count error as failure
+ +- + 9 +
+ +elsif a_test.result = ut_utils.gc_failure then
- + 6 +
+ +ut_utils.append_to_list( l_results, '<failure type="failure" message="Test '||a_test.name||' failed">');
- + 6 +
+ +ut_utils.append_to_list( l_results, ut_utils.to_cdata( a_test.get_failed_expectation_lines() ) );
- + 6 +
+ +ut_utils.append_to_list( l_results, '</failure>');
- +
+end if;
- -
-end;
- + +
- + 10 +
+ut_utils.append_to_list( l_results, '</testcase>');
- -
-function test_started(a_test_name varchar2, a_capture_standard_output boolean default null, a_flow_id varchar2 default null) return varchar2 is
- -
+l_props t_props;
+ +
- + 10 +
+self.print_text_lines(l_results);
- -
-begin
- - 42 -
-l_props('name') := a_test_name;
- - 42 -
-l_props('captureStandardOutput') := case a_capture_standard_output
- - 1 -
+when true then
end;
+ +- +
+ +- +
+ +procedure print_suite_results(a_suite ut_logical_suite, a_suite_id in out nocopy integer) is
- + 17 +
+l_tests_count integer := a_suite.results_count.disabled_count + a_suite.results_count.success_count +
- -
-'true'
- -
+when false then
a_suite.results_count.failure_count + a_suite.results_count.errored_count;
+ +- + 17 +
+l_results ut_varchar2_rows := ut_varchar2_rows();
- -
+'false'
l_suite ut_suite;
+- -
+else
l_outputs clob;
+- -
+null
l_errors ut_varchar2_list;
+- -
-end;
- - 42 -
-l_props('flowId') := a_flow_id;
- - 42 -
-return message('testStarted', l_props);
- -
-end;
- +
+ +begin
- + +
- + 36 +
+ +for i in 1 .. a_suite.items.count loop
- + 19 +
+ +if a_suite.items(i) is of(ut_logical_suite) then
- + 9 +
+print_suite_results(treat(a_suite.items(i) as ut_logical_suite), a_suite_id);
- -
+function test_finished(a_test_name varchar2, a_test_duration_milisec number default null, a_flow_id varchar2 default null) return varchar2 is
end if;
+- -
+l_props t_props;
end loop;
+- -
-begin
- - 35 -
-l_props('name') := a_test_name;
- - 35 -
-l_props('duration') := a_test_duration_milisec;
- - 35 -
-l_props('flowId') := a_flow_id;
- - 35 -
-return message('testFinished', l_props);
- -
-end;
- -
- -
-function test_disabled(a_test_name varchar2, a_flow_id varchar2 default null) return varchar2 is
- -
+ +l_props t_props;
- + 17 +
+ +if a_suite is of(ut_suite) then
- + 10 +
+ +a_suite_id := a_suite_id + 1;
- + 11 +
+ +self.print_text('<testsuite tests="' || l_tests_count || '"' || ' id="' || a_suite_id || '"' || ' package="' ||
- +
+ +dbms_xmlgen.convert(a_suite.path) || '" ' || get_common_suite_attributes(a_suite) || '>');
- + 10 +
+ +self.print_text('<properties/>');
- + 22 +
+ +for i in 1 .. a_suite.items.count loop
- + 12 +
+ +if a_suite.items(i) is of(ut_test) then
- + 10 +
+print_test_results(treat(a_suite.items(i) as ut_test));
- -
-begin
- - 7 -
-l_props('name') := a_test_name;
- - 7 -
-l_props('flowId') := a_flow_id;
- - 7 -
-return message('testIgnored', l_props);
- -
-end;
- -
-function test_failed(a_test_name varchar2, a_msg in varchar2 default null, a_details varchar2 default null, a_flow_id varchar2 default null, a_actual varchar2 default null, a_expected varchar2 default null) return varchar2 is
- -
-l_props t_props;
- -
-begin
- - 6 -
-l_props('name') := a_test_name;
- - 6 -
-l_props('message') := a_msg;
- - 6 -
-l_props('details') := a_details;
- - 6 -
-l_props('flowId') := a_flow_id;
- +
+ +end if;
- +
+ +end loop;
- + 10 +
+ +l_suite := treat(a_suite as ut_suite);
- + 10 +
+ +l_outputs := l_suite.get_serveroutputs();
- + 10 +
+ +if l_outputs is not null and l_outputs != empty_clob() then
- + 1 +
+ +ut_utils.append_to_list( l_results, '<system-out>');
- + 1 +
+ +ut_utils.append_to_list( l_results, ut_utils.to_cdata( l_suite.get_serveroutputs() ) );
- + 1 +
+ +ut_utils.append_to_list( l_results, '</system-out>');
- +
+ +else
- + 9 +
+ +ut_utils.append_to_list( l_results, '<system-out/>');
- +
+ +end if;
- -
- - 6 -
+ +if a_actual is not null and a_expected is not null then
- + 10 +
+ +l_errors := l_suite.get_error_stack_traces();
- + 10 +
+if l_errors is not empty then
- -
+l_props('actual') := a_actual;
ut_utils.append_to_list( l_results, '<system-err>');
+- -
-l_props('expected') := a_expected;
- -
+end if;
ut_utils.append_to_list( l_results, ut_utils.to_cdata( ut_utils.convert_collection( l_errors ) ) );
+ +- +
+ut_utils.append_to_list( l_results, '</system-err>');
- -
-- - 6 -
+return message('testFailed', l_props);
else
+ +- + 10 +
+ut_utils.append_to_list( l_results, '<system-err/>');
- -
-end;
- -
+-- function test_std_out(a_test_name varchar2, a_out in varchar2, a_flow_id in varchar2 default null) return varchar2 is
end if;
+ +- + 10 +
+ut_utils.append_to_list( l_results, '</testsuite>');
- -
--- l_props t_props;
- -
+-- begin
+ +
- + 10 +
+self.print_text_lines(l_results);
- -
+-- l_props('name') := a_test_name;
end if;
+- -
+-- l_props('out') := a_out;
end;
+- -
+-- l_props('flowId') := a_flow_id;
+
- -
--- return message('testStdOut', l_props);
- -
--- end;
- -
-function test_std_err(a_test_name varchar2, a_out in varchar2, a_flow_id in varchar2 default null) return varchar2 is
- -
-l_props t_props;
- -
begin
- - 3 -
-l_props('name') := a_test_name;
- - 3 -
-l_props('out') := a_out;
- - 3 -
-l_props('flowId') := a_flow_id;
- - 3 -
-return message('testStdErr', l_props);
- + +
- + 8 +
+ +l_suite_id := 0;
- + 8 +
+ +self.print_text(ut_utils.get_xml_header(a_run.client_character_set));
- + 8 +
+ +self.print_text('<testsuites>');
- + 16 +
+ +for i in 1 .. a_run.items.count loop
- + 8 +
+ +print_suite_results(treat(a_run.items(i) as ut_logical_suite), l_suite_id);
- +
+ +end loop;
- + 8 +
+ +self.print_text('</testsuites>');
- -
end;
- + +
- + +
- +
+overriding member function get_description return varchar2 as
- -
--- function custom_message(a_text in varchar2, a_status in varchar2, a_error_deatils in varchar2 default null, a_flow_id in varchar2 default null) return varchar2 is
- -
+-- l_props t_props;
begin
+ +- +
+return 'Provides outcomes in a format conforming with JUnit version for TFS / VSTS.
- -
+-- begin
As defined by specs :https://docs.microsoft.com/en-us/vsts/build-release/tasks/test/publish-test-results?view=vsts
+- -
+-- l_props('text') := a_text;
Version is based on windy road junit https://github.com/windyroad/JUnit-Schema/blob/master/JUnit.xsd.';
+- -
+-- l_props('status') := a_status;
end;
+- -
--- l_props('errorDetails') := a_error_deatils;
- -
--- l_props('flowId') := a_flow_id;
- -
--- return message('message', l_props);
- -
--- end;
- -
- -
end ut_teamcity_reporter_helper;
+UT3.UT_XUNIT_REPORTER
88.71 % covered
62 relevant lines. 55 lines covered and 7 lines missed+ +
- +
+end;
UT3.UT_XUNIT_REPORTER
66.67 % lines covered
3 relevant lines. 2 lines covered and 1 lines missed+
- +
type body ut_xunit_reporter is
- +
/*
- -
+utPLSQL - Version X.X.X.X
utPLSQL - Version 3
+- -
+Copyright 2016 - 2017 utPLSQL Project
Copyright 2016 - 2019 utPLSQL Project
+- +
- +
Licensed under the Apache License, Version 2.0 (the "License"):
- +
you may not use this file except in compliance with the License.
- +
You may obtain a copy of the License at
- +
- +
http://www.apache.org/licenses/LICENSE-2.0
- +
- +
Unless required by applicable law or agreed to in writing, software
- +
distributed under the License is distributed on an "AS IS" BASIS,
- +
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +
See the License for the specific language governing permissions and
- +
limitations under the License.
- +
*/
- +
- +
constructor function ut_xunit_reporter(self in out nocopy ut_xunit_reporter) return self as result is
- -
begin
- - 3 + +
- + 1
-self.init($$plsql_unit);
- - 3 + +
- + 1
+return;
- +
end;
- +
- -
-overriding member procedure after_calling_run(self in out nocopy ut_xunit_reporter, a_run in ut_run) is
- - 3 -
-l_suite_id integer := 0;
- - 3 -
+l_tests_count integer := a_run.results_count.disabled_count + a_run.results_count.success_count +
overriding member function get_description return varchar2 as
+ +- +
+ +begin
- +
+return 'Depracated reporter. Please use Junit.
- -
+a_run.results_count.failure_count + a_run.results_count.errored_count;
Provides outcomes in a format conforming with JUnit 4 and above as defined in: https://gist.github.com/kuzuha/232902acab1344d6b578';
+- -
-- -
-function get_path(a_path_with_name varchar2, a_name varchar2) return varchar2 is
- -
-begin
- - 7 -
-return substr(a_path_with_name, 1, instr(a_path_with_name, '.' || a_name) - 1);
- -
-end;
- -
-- -
-procedure print_test_elements(a_test ut_test) is
- -
-l_lines ut_varchar2_list;
- -
-l_output clob;
- -
-begin
- - 7 -
-self.print_text('<testcase classname="' || get_path(a_test.path, a_test.name) || '" ' || ' assertions="' ||
- - 1 -
-coalesce(cardinality(a_test.results), 0) || '"' || self.get_common_item_attributes(a_test) || case when
- -
-a_test.result != ut_utils.tr_success then
- -
-' status="' || ut_utils.test_result_to_char(a_test.result) || '"' end || '>');
- - 7 -
-if a_test.result = ut_utils.tr_disabled then
- - 1 -
-self.print_text('<skipped/>');
- -
-end if;
- - 1 -
-if a_test.result = ut_utils.tr_error then
- - 1 -
-self.print_text('<error>');
- - 1 -
-self.print_text('<![CDATA[');
- - 1 -
-self.print_clob(ut_utils.table_to_clob(a_test.get_error_stack_traces()));
- - 1 -
-self.print_text(']]>');
- - 1 -
-self.print_text('</error>');
- - 6 -
-elsif a_test.result > ut_utils.tr_success then
- - 1 -
-self.print_text('<failure>');
- - 1 -
-self.print_text('<![CDATA[');
- - 2 -
-for i in 1 .. a_test.results.count loop
- - 1 -
-l_lines := a_test.results(i).get_result_lines();
- - 3 -
-for i in 1 .. l_lines.count loop
- - 2 -
-self.print_text(l_lines(i));
- -
-end loop;
- -
-end loop;
- - 1 -
-self.print_text(']]>');
- - 1 -
-self.print_text('</failure>');
- -
-end if;
- -
--- TODO - decide if we need/want to use the <system-err/> tag too
- - 7 -
-l_output := a_test.get_serveroutputs();
- - 7 -
-if l_output is not null then
- - 3 -
-self.print_text('<system-out>');
- - 3 -
-self.print_text('<![CDATA[');
- - 3 -
-self.print_clob(l_output);
- - 3 -
-self.print_text(']]>');
- - 3 -
-self.print_text('</system-out>');
- -
-end if;
- - 7 -
-self.print_text('</testcase>');
- -
-end;
- -
-- -
-procedure print_suite_elements(a_suite ut_logical_suite, a_suite_id in out nocopy integer) is
- - 3 -
-l_tests_count integer := a_suite.results_count.disabled_count + a_suite.results_count.success_count +
- -
-a_suite.results_count.failure_count + a_suite.results_count.errored_count;
- -
-l_suite ut_suite;
- -
-begin
- - 3 -
-a_suite_id := a_suite_id + 1;
- - 3 -
-self.print_text('<testsuite tests="' || l_tests_count || '"' || ' id="' || a_suite_id || '"' || ' package="' ||
- -
-a_suite.path || '" ' || self.get_common_item_attributes(a_suite) || '>');
- - 3 -
-if a_suite is of(ut_suite) then
- - 3 -
-l_suite := treat(a_suite as ut_suite);
- -
-- - 3 -
-if l_suite.before_all.serveroutput is not null or l_suite.after_all.serveroutput is not null then
- - 1 -
-self.print_text('<system-out>');
- - 1 -
-self.print_text('<![CDATA[');
- - 1 -
-self.print_clob(l_suite.get_serveroutputs());
- - 1 -
-self.print_text(']]>');
- - 1 -
-self.print_text('</system-out>');
- -
-end if;
- -
-- - 3 -
-if l_suite.before_all.error_stack is not null or l_suite.after_all.error_stack is not null then
- -
-self.print_text('<system-err>');
- -
-self.print_text('<![CDATA[');
- -
-self.print_text(trim(l_suite.before_all.error_stack) || trim(chr(10) || chr(10) || l_suite.after_all.error_stack));
- -
-self.print_text(']]>');
- -
-self.print_text('</system-err>');
- -
-end if;
- -
-end if;
- -
-- - 10 -
-for i in 1 .. a_suite.items.count loop
- - 7 -
-if a_suite.items(i) is of(ut_test) then
- - 7 -
-print_test_elements(treat(a_suite.items(i) as ut_test));
- -
-elsif a_suite.items(i) is of(ut_logical_suite) then
- -
-print_suite_elements(treat(a_suite.items(i) as ut_logical_suite), a_suite_id);
- -
-end if;
- -
-end loop;
- - 3 -
-self.print_text('</testsuite>');
- -
-end;
- -
-begin
- - 3 -
-l_suite_id := 0;
- - 3 -
-self.print_text('<testsuites tests="' || l_tests_count || '"' || self.get_common_item_attributes(a_run) || '>');
- - 6 -
-for i in 1 .. a_run.items.count loop
- - 3 -
-print_suite_elements(treat(a_run.items(i) as ut_logical_suite), l_suite_id);
- -
-end loop;
- - 3 -
-self.print_text('</testsuites>');
- - 3 -
-(self as ut_reporter_base).after_calling_run(a_run);
- -
-end;
- -
-- -
-member function get_common_item_attributes(a_item ut_suite_item) return varchar2 is
- -
-begin
- - 13 -
-return ' skipped="' || a_item.results_count.disabled_count || '" error="' || a_item.results_count.errored_count || '"' || ' failure="' || a_item.results_count.failure_count || '" name="' || nvl(a_item.description, a_item.name) || '"' || ' time="' || a_item.execution_time() || '" ';
- -
end;
- + +
- -
- -
end;
- +
+end;