Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 47eb4a0

Browse files
committed
Fixed warnings. Refactored warnings.
Added tests for depreciation.
1 parent 528808b commit 47eb4a0

9 files changed

Lines changed: 241 additions & 58 deletions

File tree

source/core/types/ut_test.tpb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ create or replace type body ut_test as
120120
--expectation results need to be part of test results
121121
self.all_expectations := ut_expectation_processor.get_all_expectations();
122122
self.failed_expectations := ut_expectation_processor.get_failed_expectations();
123-
self.warnings := ut_expectation_processor.get_warnings();
123+
self.warnings := self.warnings multiset union all ut_expectation_processor.get_warnings();
124124
ut_expectation_processor.clear_expectations();
125125
self.results_count.set_counter_values(self.result);
126126
end;

source/core/ut_utils.pkb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,13 @@ procedure append_to_clob(a_src_clob in out nocopy clob, a_clob_table t_clob_tab,
480480
return nvl(trunc(power(10,(floor(log(10,a_cardinality))+1))/3),0);
481481
end;
482482

483+
function build_depreciation_warning(a_old_syntax varchar2, a_new_syntax varchar2) return varchar2 is
484+
begin
485+
return 'The syntax: "'||a_old_syntax||'" is depreciated.' ||chr(10)||
486+
'Please use the new syntax: "'||a_new_syntax||'".' ||chr(10)||
487+
'The depreciated syntax will not be supported in future releases.';
488+
end;
489+
483490
function to_xml_number_format(a_value number) return varchar2 is
484491
begin
485492
return to_char(a_value, gc_number_format, 'NLS_NUMERIC_CHARACTERS=''. ''');

source/core/ut_utils.pks

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,8 @@ create or replace package ut_utils authid definer is
285285
*/
286286
function scale_cardinality(a_cardinality natural) return natural;
287287

288+
function build_depreciation_warning(a_old_syntax varchar2, a_new_syntax varchar2) return varchar2;
289+
288290
/**
289291
* Returns number as string. The value is represented as decimal according to XML standard:
290292
* https://www.w3.org/TR/xmlschema-2/#decimal

source/expectations/matchers/ut_equal.tpb

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,27 @@ create or replace type body ut_equal as
3838
end;
3939

4040
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
41-
begin
42-
ut_expectation_processor.add_warning('The syntax: "equal( a_expected, a_exclude)" is DEPRECATED.' ||chr(10)||
43-
'Please use the new syntax: "equal( a_expected).exclude( a_items )".' ||chr(10)||
44-
'The DEPRECIATED syntax will not be supported in future releases.');
41+
l_depreciated integer;
42+
begin
43+
ut_expectation_processor.add_warning(
44+
ut_utils.build_depreciation_warning(
45+
'equal( a_expected anydata, a_exclude varchar2 )',
46+
'equal( a_expected anydata ).exclude( a_exclude varchar2 )'
47+
)
48+
);
4549
init(ut_data_value_anydata.get_instance(a_expected), a_nulls_are_equal);
4650
exclude_list := ut_varchar2_list(a_exclude);
4751
return;
4852
end;
4953

5054
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
5155
begin
52-
ut_expectation_processor.add_warning('The syntax: "equal( a_expected, a_exclude)" is DEPRECATED.' ||chr(10)||
53-
'Please use the new syntax: "equal( a_expected).exclude( a_items )".' ||chr(10)||
54-
'The DEPRECIATED syntax will not be supported in future releases.');
56+
ut_expectation_processor.add_warning(
57+
ut_utils.build_depreciation_warning(
58+
'equal( a_expected anydata, a_exclude ut_varchar2_list )',
59+
'equal( a_expected anydata ).exclude( a_exclude ut_varchar2_list )'
60+
)
61+
);
5562
init(ut_data_value_anydata.get_instance(a_expected), a_nulls_are_equal);
5663
exclude_list := coalesce(a_exclude, ut_varchar2_list());
5764
return;
@@ -95,19 +102,25 @@ create or replace type body ut_equal as
95102

96103
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
97104
begin
98-
ut_expectation_processor.add_warning('The syntax: "equal( a_expected, a_exclude)" is DEPRECATED.' ||chr(10)||
99-
'Please use the new syntax: "equal( a_expected).exclude( a_items )".' ||chr(10)||
100-
'The DEPRECIATED syntax will not be supported in future releases.');
105+
ut_expectation_processor.add_warning(
106+
ut_utils.build_depreciation_warning(
107+
'equal( a_expected sys_refcursor, a_exclude varchar2 )',
108+
'equal( a_expected sys_refcursor ).exclude( a_exclude varchar2 )'
109+
)
110+
);
101111
init(ut_data_value_refcursor(a_expected), a_nulls_are_equal);
102112
exclude_list := ut_varchar2_list(a_exclude);
103113
return;
104114
end;
105115

106116
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
107117
begin
108-
ut_expectation_processor.add_warning('The syntax: "equal( a_expected, a_exclude)" is DEPRECATED.' ||chr(10)||
109-
'Please use the new syntax: "equal( a_expected).exclude( a_items )".' ||chr(10)||
110-
'The DEPRECIATED syntax will not be supported in future releases.');
118+
ut_expectation_processor.add_warning(
119+
ut_utils.build_depreciation_warning(
120+
'equal( a_expected sys_refcursor, a_exclude ut_varchar2_list )',
121+
'equal( a_expected sys_refcursor ).exclude( a_exclude ut_varchar2_list )'
122+
)
123+
);
111124
init(ut_data_value_refcursor(a_expected), a_nulls_are_equal);
112125
exclude_list := coalesce(a_exclude, ut_varchar2_list());
113126
return;

source/expectations/ut_expectation.tpb

Lines changed: 48 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -97,17 +97,23 @@ create or replace type body ut_expectation as
9797

9898
member procedure to_equal(self in ut_expectation, a_expected anydata, a_exclude varchar2, a_nulls_are_equal boolean := null) is
9999
begin
100-
ut_expectation_processor.add_warning('The syntax: "to_equal( a_expected, a_exclude)" is DEPRECATED.' ||chr(10)||
101-
'Please use the new syntax: "to_equal( a_expected).exclude( a_items )".' ||chr(10)||
102-
'The DEPRECIATED syntax will not be supported in future releases.');
100+
ut_expectation_processor.add_warning(
101+
ut_utils.build_depreciation_warning(
102+
'to_equal( a_expected anydata, a_exclude varchar2 )',
103+
'to_equal( a_expected anydata ).exclude( a_exclude varchar2 )'
104+
)
105+
);
103106
self.to_( ut_equal(a_expected, a_nulls_are_equal).exclude(a_exclude) );
104107
end;
105108

106109
member procedure to_equal(self in ut_expectation, a_expected anydata, a_exclude ut_varchar2_list, a_nulls_are_equal boolean := null) is
107110
begin
108-
ut_expectation_processor.add_warning('The syntax: "to_equal( a_expected, a_exclude)" is DEPRECATED.' ||chr(10)||
109-
'Please use the new syntax: "to_equal( a_expected).exclude( a_items )".' ||chr(10)||
110-
'The DEPRECIATED syntax will not be supported in future releases.');
111+
ut_expectation_processor.add_warning(
112+
ut_utils.build_depreciation_warning(
113+
'to_equal( a_expected anydata, a_exclude ut_varchar2_list )',
114+
'to_equal( a_expected anydata ).exclude( a_exclude ut_varchar2_list )'
115+
)
116+
);
111117
self.to_( ut_equal(a_expected, a_nulls_are_equal).exclude(a_exclude) );
112118
end;
113119

@@ -143,17 +149,23 @@ create or replace type body ut_expectation as
143149

144150
member procedure to_equal(self in ut_expectation, a_expected sys_refcursor, a_exclude varchar2, a_nulls_are_equal boolean := null) is
145151
begin
146-
ut_expectation_processor.add_warning('The syntax: "to_equal( a_expected, a_exclude)" is DEPRECATED.' ||chr(10)||
147-
'Please use the new syntax: "to_equal( a_expected).exclude( a_items )".' ||chr(10)||
148-
'The DEPRECIATED syntax will not be supported in future releases.');
152+
ut_expectation_processor.add_warning(
153+
ut_utils.build_depreciation_warning(
154+
'to_equal( a_expected sys_refcursor, a_exclude varchar2 )',
155+
'to_equal( a_expected sys_refcursor ).exclude( a_exclude varchar2 )'
156+
)
157+
);
149158
self.to_( ut_equal(a_expected, a_nulls_are_equal).exclude(a_exclude) );
150159
end;
151160

152161
member procedure to_equal(self in ut_expectation, a_expected sys_refcursor, a_exclude ut_varchar2_list, a_nulls_are_equal boolean := null) is
153162
begin
154-
ut_expectation_processor.add_warning('The syntax: "to_equal( a_expected, a_exclude)" is DEPRECATED.' ||chr(10)||
155-
'Please use the new syntax: "to_equal( a_expected).exclude( a_items )".' ||chr(10)||
156-
'The DEPRECIATED syntax will not be supported in future releases.');
163+
ut_expectation_processor.add_warning(
164+
ut_utils.build_depreciation_warning(
165+
'to_equal( a_expected sys_refcursor, a_exclude ut_varchar2_list )',
166+
'to_equal( a_expected sys_refcursor ).exclude( a_exclude ut_varchar2_list )'
167+
)
168+
);
157169
self.to_( ut_equal(a_expected, a_nulls_are_equal).exclude(a_exclude) );
158170
end;
159171

@@ -195,17 +207,23 @@ create or replace type body ut_expectation as
195207

196208
member procedure not_to_equal(self in ut_expectation, a_expected anydata, a_exclude varchar2, a_nulls_are_equal boolean := null) is
197209
begin
198-
ut_expectation_processor.add_warning('The syntax: "not_to_equal( a_expected, a_exclude)" is DEPRECATED.' ||chr(10)||
199-
'Please use the new syntax: "not_to_equal( a_expected).exclude( a_items )".' ||chr(10)||
200-
'The DEPRECIATED syntax will not be supported in future releases.');
210+
ut_expectation_processor.add_warning(
211+
ut_utils.build_depreciation_warning(
212+
'not_to_equal( a_expected anydata, a_exclude varchar2 )',
213+
'not_to_equal( a_expected anydata ).exclude( a_exclude varchar2 )'
214+
)
215+
);
201216
self.not_to( ut_equal(a_expected, a_nulls_are_equal).exclude(a_exclude) );
202217
end;
203218

204219
member procedure not_to_equal(self in ut_expectation, a_expected anydata, a_exclude ut_varchar2_list, a_nulls_are_equal boolean := null) is
205220
begin
206-
ut_expectation_processor.add_warning('The syntax: "not_to_equal( a_expected, a_exclude)" is DEPRECATED.' ||chr(10)||
207-
'Please use the new syntax: "not_to_equal( a_expected).exclude( a_items )".' ||chr(10)||
208-
'The DEPRECIATED syntax will not be supported in future releases.');
221+
ut_expectation_processor.add_warning(
222+
ut_utils.build_depreciation_warning(
223+
'not_to_equal( a_expected anydata, a_exclude ut_varchar2_list )',
224+
'not_to_equal( a_expected anydata ).exclude( a_exclude ut_varchar2_list )'
225+
)
226+
);
209227
self.not_to( ut_equal(a_expected, a_nulls_are_equal).exclude(a_exclude) );
210228
end;
211229

@@ -241,17 +259,23 @@ create or replace type body ut_expectation as
241259

242260
member procedure not_to_equal(self in ut_expectation, a_expected sys_refcursor, a_exclude varchar2, a_nulls_are_equal boolean := null) is
243261
begin
244-
ut_expectation_processor.add_warning('The syntax: "not_to_equal( a_expected, a_exclude)" is DEPRECATED.' ||chr(10)||
245-
'Please use the new syntax: "not_to_equal( a_expected).exclude( a_items )".' ||chr(10)||
246-
'The DEPRECIATED syntax will not be supported in future releases.');
262+
ut_expectation_processor.add_warning(
263+
ut_utils.build_depreciation_warning(
264+
'not_to_equal( a_expected sys_refcursor, a_exclude varchar2 )',
265+
'not_to_equal( a_expected sys_refcursor ).exclude( a_exclude varchar2 )'
266+
)
267+
);
247268
self.not_to( ut_equal(a_expected, a_nulls_are_equal).exclude(a_exclude) );
248269
end;
249270

250271
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
251272
begin
252-
ut_expectation_processor.add_warning('The syntax: "not_to_equal( a_expected, a_exclude)" is DEPRECATED.' ||chr(10)||
253-
'Please use the new syntax: "not_to_equal( a_expected).exclude( a_items )".' ||chr(10)||
254-
'The DEPRECIATED syntax will not be supported in future releases.');
273+
ut_expectation_processor.add_warning(
274+
ut_utils.build_depreciation_warning(
275+
'not_to_equal( a_expected sys_refcursor, a_exclude ut_varchar2_list )',
276+
'not_to_equal( a_expected sys_refcursor ).exclude( a_exclude ut_varchar2_list )'
277+
)
278+
);
255279
self.not_to( ut_equal(a_expected, a_nulls_are_equal).exclude(a_exclude) );
256280
end;
257281

test/core/expectations/compound_data/test_expectation_anydata.pkb

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,5 +414,64 @@ was expected to equal:%[ count = % ])
414414
ut.expect(l_actual).to_be_like(l_expected);
415415
end;
416416

417+
function get_anydata return anydata is
418+
begin
419+
return anydata.convertObject( test_dummy_object(1, 'B', '0') );
420+
end;
421+
422+
procedure deprec_to_equal_excl_varch is
423+
begin
424+
--Act
425+
ut3.ut.expect(get_anydata()).to_equal(get_anydata(), a_exclude => 'A_COLUMN,Some_Col');
426+
--Assert
427+
ut.expect(cardinality(ut3.ut_expectation_processor.get_warnings())).to_equal(1);
428+
ut.expect(ut3.ut_expectation_processor.get_warnings()(1)).to_be_like('The syntax: "%" is depreciated.%');
429+
end;
430+
431+
procedure deprec_to_equal_excl_list is
432+
begin
433+
--Act
434+
ut3.ut.expect(get_anydata()).to_equal(get_anydata(), a_exclude => ut3.ut_varchar2_list('A_COLUMN','Some_Col'));
435+
--Assert
436+
ut.expect(cardinality(ut3.ut_expectation_processor.get_warnings())).to_equal(1);
437+
ut.expect(ut3.ut_expectation_processor.get_warnings()(1)).to_be_like('The syntax: "%" is depreciated.%');
438+
end;
439+
440+
procedure deprec_not_to_equal_excl_varch is
441+
begin
442+
--Act
443+
ut3.ut.expect(get_anydata()).not_to_equal(get_anydata(), a_exclude => 'A_COLUMN,Some_Col');
444+
--Assert
445+
ut.expect(cardinality(ut3.ut_expectation_processor.get_warnings())).to_equal(1);
446+
ut.expect(ut3.ut_expectation_processor.get_warnings()(1)).to_be_like('The syntax: "%" is depreciated.%');
447+
end;
448+
449+
procedure deprec_not_to_equal_excl_list is
450+
begin
451+
--Act
452+
ut3.ut.expect(get_anydata()).not_to_equal(get_anydata(), a_exclude => ut3.ut_varchar2_list('A_COLUMN','Some_Col'));
453+
--Assert
454+
ut.expect(cardinality(ut3.ut_expectation_processor.get_warnings())).to_equal(1);
455+
ut.expect(ut3.ut_expectation_processor.get_warnings()(1)).to_be_like('The syntax: "%" is depreciated.%');
456+
end;
457+
458+
procedure deprec_equal_excl_varch is
459+
begin
460+
--Act
461+
ut3.ut.expect(get_anydata()).to_(ut3.equal(get_anydata(), a_exclude => 'A_COLUMN,Some_Col'));
462+
--Assert
463+
ut.expect(cardinality(ut3.ut_expectation_processor.get_warnings())).to_equal(1);
464+
ut.expect(ut3.ut_expectation_processor.get_warnings()(1)).to_be_like('The syntax: "%" is depreciated.%');
465+
end;
466+
467+
procedure deprec_equal_excl_list is
468+
begin
469+
--Act
470+
ut3.ut.expect(get_anydata()).to_(ut3.equal(get_anydata(), a_exclude => ut3.ut_varchar2_list('A_COLUMN','Some_Col')));
471+
--Assert
472+
ut.expect(cardinality(ut3.ut_expectation_processor.get_warnings())).to_equal(1);
473+
ut.expect(ut3.ut_expectation_processor.get_warnings()(1)).to_be_like('The syntax: "%" is depreciated.%');
474+
end;
475+
417476
end;
418477
/

test/core/expectations/compound_data/test_expectation_anydata.pks

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,5 +93,23 @@ create or replace package test_expectation_anydata is
9393
--%test(Gives information about collections content in report)
9494
procedure reports_collection_structre;
9595

96+
--%test(Adds a warning when using depreciated syntax to_equal( a_expected anydata, a_exclude varchar2 ))
97+
procedure deprec_to_equal_excl_varch;
98+
99+
--%test(Adds a warning when using depreciated syntax to_equal( a_expected anydata, a_exclude ut_varchar2_list ))
100+
procedure deprec_to_equal_excl_list;
101+
102+
--%test(Adds a warning when using depreciated syntax not_to_equal( a_expected anydata, a_exclude varchar2 ))
103+
procedure deprec_not_to_equal_excl_varch;
104+
105+
--%test(Adds a warning when using depreciated syntax not_to_equal( a_expected anydata, a_exclude ut_varchar2_list ))
106+
procedure deprec_not_to_equal_excl_list;
107+
108+
--%test(Adds a warning when using depreciated syntax to_( equal( a_expected anydata, a_exclude varchar2 ) ))
109+
procedure deprec_equal_excl_varch;
110+
111+
--%test(Adds a warning when using depreciated syntax to_( equal( a_expected anydata, a_exclude ut_varchar2_list )) )
112+
procedure deprec_equal_excl_list;
113+
96114
end;
97115
/

0 commit comments

Comments
 (0)