|
| 1 | +create or replace type body ut_include as |
| 2 | + /* |
| 3 | + utPLSQL - Version 3 |
| 4 | + Copyright 2016 - 2018 utPLSQL Project |
| 5 | + |
| 6 | + Licensed under the Apache License, Version 2.0 (the "License"): |
| 7 | + you may not use this file except in compliance with the License. |
| 8 | + You may obtain a copy of the License at |
| 9 | + |
| 10 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | + |
| 12 | + Unless required by applicable law or agreed to in writing, software |
| 13 | + distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | + See the License for the specific language governing permissions and |
| 16 | + limitations under the License. |
| 17 | + */ |
| 18 | + |
| 19 | + member procedure init(self in out nocopy ut_include, a_expected ut_data_value) is |
| 20 | + begin |
| 21 | + self.self_type := $$plsql_unit; |
| 22 | + self.expected := a_expected; |
| 23 | + self.include_list := ut_varchar2_list(); |
| 24 | + self.exclude_list := ut_varchar2_list(); |
| 25 | + self.join_columns := ut_varchar2_list(); |
| 26 | + end; |
| 27 | + |
| 28 | + constructor function ut_include(self in out nocopy ut_include, a_expected sys_refcursor) return self as result is |
| 29 | + begin |
| 30 | + init(ut_data_value_refcursor(a_expected)); |
| 31 | + return; |
| 32 | + end; |
| 33 | + |
| 34 | + member function get_inclusion_compare return boolean is |
| 35 | + begin |
| 36 | + return true; |
| 37 | + end; |
| 38 | + |
| 39 | + overriding member function run_matcher(self in out nocopy ut_include, a_actual ut_data_value) return boolean is |
| 40 | + l_result boolean; |
| 41 | + begin |
| 42 | + if self.expected.data_type = a_actual.data_type then |
| 43 | + l_result := 0 = treat(self.expected as ut_data_value_refcursor).compare_implementation(a_actual, self.get_exclude_xpath(), self.get_include_xpath(), self.get_join_by_xpath(), |
| 44 | + true,get_inclusion_compare()); |
| 45 | + else |
| 46 | + l_result := (self as ut_matcher).run_matcher(a_actual); |
| 47 | + end if; |
| 48 | + return l_result; |
| 49 | + end; |
| 50 | + |
| 51 | + overriding member function failure_message(a_actual ut_data_value) return varchar2 is |
| 52 | + l_result varchar2(32767); |
| 53 | + begin |
| 54 | + if self.expected.data_type = a_actual.data_type and self.expected.is_diffable then |
| 55 | + l_result := |
| 56 | + 'Actual: '||a_actual.get_object_info()||' '||self.description()||': '||self.expected.get_object_info() |
| 57 | + || chr(10) || 'Diff:' || expected.diff(a_actual, self.get_exclude_xpath(), self.get_include_xpath(), self.get_join_by_xpath(), true); |
| 58 | + else |
| 59 | + l_result := (self as ut_matcher).failure_message(a_actual) || ': '|| self.expected.to_string_report(); |
| 60 | + end if; |
| 61 | + return l_result; |
| 62 | + end; |
| 63 | + |
| 64 | +end; |
| 65 | +/ |
0 commit comments