Skip to content

Commit 1e71c99

Browse files
committed
Adding a new expectation type to specialize unordered_columns only to sys_refcursor
1 parent 45643e0 commit 1e71c99

11 files changed

+216
-90
lines changed

source/api/ut.pkb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ create or replace package body ut is
7575
return ut_expectation(ut_data_value_varchar2(a_actual), a_message);
7676
end;
7777

78-
function expect(a_actual in sys_refcursor, a_message varchar2 := null) return ut_expectation_compound is
78+
function expect(a_actual in sys_refcursor, a_message varchar2 := null) return ut_expectation_refcursor is
7979
begin
80-
return ut_expectation_compound(ut_data_value_refcursor(a_actual), a_message);
80+
return ut_expectation_refcursor(ut_data_value_refcursor(a_actual), a_message);
8181
end;
8282

8383
function expect(a_actual in yminterval_unconstrained, a_message varchar2 := null) return ut_expectation is

source/api/ut.pks

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ create or replace package ut authid current_user as
3131

3232
function expect(a_actual in number, a_message varchar2 := null) return ut_expectation;
3333

34-
function expect(a_actual in sys_refcursor, a_message varchar2 := null) return ut_expectation_compound;
34+
function expect(a_actual in sys_refcursor, a_message varchar2 := null) return ut_expectation_refcursor;
3535

3636
function expect(a_actual in timestamp_unconstrained, a_message varchar2 := null) return ut_expectation;
3737

source/create_synonyms_and_grants_for_public.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ alter session set current_schema = &&ut3_owner;
3333

3434
grant execute on &&ut3_owner..ut_expectation to public;
3535
grant execute on &&ut3_owner..ut_expectation_compound to public;
36+
grant execute on &&ut3_owner..ut_expectation_refcursor to public;
3637
grant execute on &&ut3_owner..ut_be_between to public;
3738
grant execute on &&ut3_owner..ut_be_empty to public;
3839
grant execute on &&ut3_owner..ut_be_false to public;
@@ -112,6 +113,7 @@ prompt Creating synonyms for UTPLSQL objects in &&ut3_owner schema to PUBLIC
112113

113114
create public synonym ut_expectation for &&ut3_owner..ut_expectation;
114115
create public synonym ut_expectation_compound for &&ut3_owner..ut_expectation_compound;
116+
create public synonym ut_expectation_refcursor for &&ut3_owner..ut_expectation_refcursor;
115117

116118
create public synonym be_between for &&ut3_owner..be_between;
117119
create public synonym be_empty for &&ut3_owner..be_empty;

source/create_user_grants.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ alter session set current_schema = &&ut3_owner;
5353

5454
grant execute on &&ut3_owner..ut_expectation to &ut3_user;
5555
grant execute on &&ut3_owner..ut_expectation_compound to &ut3_user;
56+
grant execute on &&ut3_owner..ut_expectation_refcursor to &ut3_user;
57+
5658
grant execute on &&ut3_owner..ut_be_between to &ut3_user;
5759
grant execute on &&ut3_owner..ut_be_empty to &ut3_user;
5860
grant execute on &&ut3_owner..ut_be_false to &ut3_user;

source/create_user_synonyms.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ prompt Creating synonyms for UTPLSQL objects in &&ut3_owner schema to user &&ut3
5555

5656
create or replace synonym &ut3_user..ut_expectation for &&ut3_owner..ut_expectation;
5757
create or replace synonym &ut3_user..ut_expectation_compound for &&ut3_owner..ut_expectation_compound;
58+
create or replace synonym &ut3_user..ut_expectation_refcursor for &&ut3_owner..ut_expectation_refcursor;
5859

5960
create or replace synonym &ut3_user..be_between for &&ut3_owner..be_between;
6061
create or replace synonym &ut3_user..be_empty for &&ut3_owner..be_empty;

source/expectations/ut_expectation_compound.tpb

Lines changed: 0 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -52,57 +52,13 @@ create or replace type body ut_expectation_compound as
5252
return l_result;
5353
end;
5454

55-
member function to_equal(a_expected sys_refcursor, a_nulls_are_equal boolean := null) return ut_expectation_compound is
56-
l_result ut_expectation_compound := self;
57-
begin
58-
l_result.matcher := ut_equal(a_expected, a_nulls_are_equal);
59-
return l_result;
60-
end;
61-
6255
member function not_to_equal(a_expected anydata, a_nulls_are_equal boolean := null) return ut_expectation_compound is
6356
l_result ut_expectation_compound := self;
6457
begin
6558
l_result.matcher := ut_equal(a_expected, a_nulls_are_equal);
6659
l_result.negated := ut_utils.boolean_to_int(true);
6760
return l_result;
68-
end;
69-
70-
member function not_to_equal(a_expected sys_refcursor, a_nulls_are_equal boolean := null) return ut_expectation_compound is
71-
l_result ut_expectation_compound := self;
72-
begin
73-
l_result.matcher := ut_equal(a_expected, a_nulls_are_equal);
74-
l_result.negated := ut_utils.boolean_to_int(true);
75-
return l_result;
76-
end;
77-
78-
member function to_include(a_expected sys_refcursor) return ut_expectation_compound is
79-
l_result ut_expectation_compound := self;
80-
begin
81-
l_result.matcher := ut_include(a_expected);
82-
return l_result;
83-
end;
84-
85-
member function to_contain(a_expected sys_refcursor) return ut_expectation_compound is
86-
l_result ut_expectation_compound := self;
87-
begin
88-
l_result.matcher := ut_include(a_expected);
89-
return l_result;
90-
end;
91-
92-
member function not_to_include(a_expected sys_refcursor) return ut_expectation_compound is
93-
l_result ut_expectation_compound := self;
94-
begin
95-
l_result.matcher := ut_include(a_expected).negated;
96-
l_result.negated := ut_utils.boolean_to_int(true);
97-
return l_result;
98-
end;
9961

100-
member function not_to_contain(a_expected sys_refcursor) return ut_expectation_compound is
101-
l_result ut_expectation_compound := self;
102-
begin
103-
l_result.matcher := ut_include(a_expected).negated;
104-
l_result.negated := ut_utils.boolean_to_int(true);
105-
return l_result;
10662
end;
10763

10864
member function include(a_items varchar2) return ut_expectation_compound is
@@ -226,34 +182,5 @@ create or replace type body ut_expectation_compound as
226182
end if;
227183
end;
228184

229-
member function unordered_columns return ut_expectation_compound is
230-
l_result ut_expectation_compound;
231-
begin
232-
l_result := self;
233-
l_result.matcher := treat(l_result.matcher as ut_equal).unordered_columns;
234-
return l_result;
235-
end;
236-
237-
member procedure unordered_columns(self in ut_expectation_compound) is
238-
begin
239-
240-
if ut_utils.int_to_boolean(negated) then
241-
self.not_to( treat(matcher as ut_equal).unordered_columns );
242-
else
243-
self.to_( treat(matcher as ut_equal).unordered_columns );
244-
end if;
245-
end;
246-
247-
member function uc return ut_expectation_compound is
248-
l_result ut_expectation_compound;
249-
begin
250-
return unordered_columns;
251-
end;
252-
253-
member procedure uc(self in ut_expectation_compound) is
254-
begin
255-
unordered_columns;
256-
end;
257-
258185
end;
259186
/

source/expectations/ut_expectation_compound.tps

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,8 @@ create or replace type ut_expectation_compound under ut_expectation(
2626
member procedure not_to_have_count(self in ut_expectation_compound, a_expected integer),
2727

2828
member function to_equal(a_expected anydata, a_nulls_are_equal boolean := null) return ut_expectation_compound,
29-
member function to_equal(a_expected sys_refcursor, a_nulls_are_equal boolean := null) return ut_expectation_compound,
3029
member function not_to_equal(a_expected anydata, a_nulls_are_equal boolean := null) return ut_expectation_compound,
31-
member function not_to_equal(a_expected sys_refcursor, a_nulls_are_equal boolean := null) return ut_expectation_compound,
32-
33-
member function to_include(a_expected sys_refcursor) return ut_expectation_compound,
34-
member function to_contain(a_expected sys_refcursor) return ut_expectation_compound,
35-
member function not_to_include(a_expected sys_refcursor) return ut_expectation_compound,
36-
member function not_to_contain(a_expected sys_refcursor) return ut_expectation_compound,
37-
30+
3831
member function include(a_items varchar2) return ut_expectation_compound,
3932
member function include(a_items ut_varchar2_list) return ut_expectation_compound,
4033
member procedure include(self in ut_expectation_compound, a_items varchar2),
@@ -48,11 +41,7 @@ create or replace type ut_expectation_compound under ut_expectation(
4841
member function join_by(a_columns varchar2) return ut_expectation_compound,
4942
member function join_by(a_columns ut_varchar2_list) return ut_expectation_compound,
5043
member procedure join_by(self in ut_expectation_compound, a_columns varchar2),
51-
member procedure join_by(self in ut_expectation_compound, a_columns ut_varchar2_list),
52-
member function unordered_columns return ut_expectation_compound,
53-
member procedure unordered_columns(self in ut_expectation_compound),
54-
member function uc return ut_expectation_compound,
55-
member procedure uc(self in ut_expectation_compound)
44+
member procedure join_by(self in ut_expectation_compound, a_columns ut_varchar2_list)
5645
)
57-
final
46+
not final
5847
/
Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
create or replace type body ut_expectation_refcursor 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+
constructor function ut_expectation_refcursor(self in out nocopy ut_expectation_refcursor, a_actual_data ut_data_value, a_description varchar2) return self as result is
20+
begin
21+
self.actual_data := a_actual_data;
22+
self.description := a_description;
23+
negated := ut_utils.boolean_to_int(false);
24+
return;
25+
end;
26+
27+
member function to_equal(a_expected sys_refcursor, a_nulls_are_equal boolean := null) return ut_expectation_refcursor is
28+
l_result ut_expectation_refcursor := self;
29+
begin
30+
l_result.matcher := ut_equal(a_expected, a_nulls_are_equal);
31+
return l_result;
32+
end;
33+
34+
member function not_to_equal(a_expected sys_refcursor, a_nulls_are_equal boolean := null) return ut_expectation_refcursor is
35+
l_result ut_expectation_refcursor := self;
36+
begin
37+
l_result.matcher := ut_equal(a_expected, a_nulls_are_equal);
38+
l_result.negated := ut_utils.boolean_to_int(true);
39+
return l_result;
40+
end;
41+
42+
member function to_include(a_expected sys_refcursor) return ut_expectation_refcursor is
43+
l_result ut_expectation_refcursor := self;
44+
begin
45+
l_result.matcher := ut_include(a_expected);
46+
return l_result;
47+
end;
48+
49+
member function to_contain(a_expected sys_refcursor) return ut_expectation_refcursor is
50+
l_result ut_expectation_refcursor := self;
51+
begin
52+
l_result.matcher := ut_include(a_expected);
53+
return l_result;
54+
end;
55+
56+
member function not_to_include(a_expected sys_refcursor) return ut_expectation_refcursor is
57+
l_result ut_expectation_refcursor := self;
58+
begin
59+
l_result.matcher := ut_include(a_expected).negated;
60+
l_result.negated := ut_utils.boolean_to_int(true);
61+
return l_result;
62+
end;
63+
64+
member function not_to_contain(a_expected sys_refcursor) return ut_expectation_refcursor is
65+
l_result ut_expectation_refcursor := self;
66+
begin
67+
l_result.matcher := ut_include(a_expected).negated;
68+
l_result.negated := ut_utils.boolean_to_int(true);
69+
return l_result;
70+
end;
71+
72+
overriding member function include(a_items varchar2) return ut_expectation_refcursor is
73+
l_result ut_expectation_refcursor;
74+
begin
75+
l_result := self;
76+
l_result.matcher := treat(l_result.matcher as ut_equal).include(a_items);
77+
return l_result;
78+
end;
79+
80+
overriding member function include(a_items ut_varchar2_list) return ut_expectation_refcursor is
81+
l_result ut_expectation_refcursor;
82+
begin
83+
l_result := self;
84+
l_result.matcher := treat(l_result.matcher as ut_equal).include(a_items);
85+
return l_result;
86+
end;
87+
88+
overriding member function exclude(a_items varchar2) return ut_expectation_refcursor is
89+
l_result ut_expectation_refcursor;
90+
begin
91+
l_result := self;
92+
l_result.matcher := treat(l_result.matcher as ut_equal).exclude(a_items);
93+
return l_result;
94+
end;
95+
96+
overriding member function exclude(a_items ut_varchar2_list) return ut_expectation_refcursor is
97+
l_result ut_expectation_refcursor;
98+
begin
99+
l_result := self;
100+
l_result.matcher := treat(l_result.matcher as ut_equal).exclude(a_items);
101+
return l_result;
102+
end;
103+
104+
overriding member function unordered return ut_expectation_refcursor is
105+
l_result ut_expectation_refcursor;
106+
begin
107+
l_result := self;
108+
l_result.matcher := treat(l_result.matcher as ut_equal).unordered;
109+
return l_result;
110+
end;
111+
112+
overriding member function join_by(a_columns varchar2) return ut_expectation_refcursor is
113+
l_result ut_expectation_refcursor;
114+
begin
115+
l_result := self;
116+
l_result.matcher := treat(l_result.matcher as ut_equal).join_by(a_columns);
117+
return l_result;
118+
end;
119+
120+
overriding member function join_by(a_columns ut_varchar2_list) return ut_expectation_refcursor is
121+
l_result ut_expectation_refcursor;
122+
begin
123+
l_result := self;
124+
l_result.matcher := treat(l_result.matcher as ut_equal).join_by(a_columns);
125+
return l_result;
126+
end;
127+
128+
member function unordered_columns return ut_expectation_refcursor is
129+
l_result ut_expectation_refcursor;
130+
begin
131+
l_result := self;
132+
l_result.matcher := treat(l_result.matcher as ut_equal).unordered_columns;
133+
return l_result;
134+
end;
135+
136+
member procedure unordered_columns(self in ut_expectation_refcursor) is
137+
begin
138+
139+
if ut_utils.int_to_boolean(negated) then
140+
self.not_to( treat(matcher as ut_equal).unordered_columns );
141+
else
142+
self.to_( treat(matcher as ut_equal).unordered_columns );
143+
end if;
144+
end;
145+
146+
member function uc return ut_expectation_refcursor is
147+
l_result ut_expectation_refcursor;
148+
begin
149+
return unordered_columns;
150+
end;
151+
152+
member procedure uc(self in ut_expectation_refcursor) is
153+
begin
154+
unordered_columns;
155+
end;
156+
157+
end;
158+
/
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
create or replace type ut_expectation_refcursor under ut_expectation_compound(
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+
constructor function ut_expectation_refcursor(
20+
self in out nocopy ut_expectation_refcursor, a_actual_data ut_data_value, a_description varchar2
21+
) return self as result,
22+
23+
member function to_equal(a_expected sys_refcursor, a_nulls_are_equal boolean := null) return ut_expectation_refcursor,
24+
member function to_include(a_expected sys_refcursor) return ut_expectation_refcursor,
25+
member function not_to_equal(a_expected sys_refcursor, a_nulls_are_equal boolean := null) return ut_expectation_refcursor,
26+
member function to_contain(a_expected sys_refcursor) return ut_expectation_refcursor,
27+
member function not_to_include(a_expected sys_refcursor) return ut_expectation_refcursor,
28+
member function not_to_contain(a_expected sys_refcursor) return ut_expectation_refcursor,
29+
30+
overriding member function include(a_items varchar2) return ut_expectation_refcursor,
31+
overriding member function include(a_items ut_varchar2_list) return ut_expectation_refcursor,
32+
overriding member function exclude(a_items varchar2) return ut_expectation_refcursor,
33+
overriding member function exclude(a_items ut_varchar2_list) return ut_expectation_refcursor,
34+
overriding member function unordered return ut_expectation_refcursor,
35+
overriding member function join_by(a_columns varchar2) return ut_expectation_refcursor,
36+
overriding member function join_by(a_columns ut_varchar2_list) return ut_expectation_refcursor,
37+
member function unordered_columns return ut_expectation_refcursor,
38+
member procedure unordered_columns(self in ut_expectation_refcursor),
39+
member function uc return ut_expectation_refcursor,
40+
member procedure uc(self in ut_expectation_refcursor)
41+
)
42+
final
43+
/

source/install.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ prompt Installing DBMSPLSQL Tables objects into &&ut3_owner schema
220220
@@install_component.sql 'expectations/data_values/ut_cursor_column.tpb'
221221
@@install_component.sql 'expectations/data_values/ut_cursor_details.tpb'
222222
@@install_component.sql 'expectations/ut_expectation_compound.tps'
223+
@@install_component.sql 'expectations/ut_expectation_refcursor.tps'
223224
@@install_component.sql 'expectations/data_values/ut_data_value.tpb'
224225
@@install_component.sql 'expectations/data_values/ut_compound_data_value.tpb'
225226
@@install_component.sql 'expectations/data_values/ut_compound_data_helper.pkb'
@@ -258,6 +259,7 @@ prompt Installing DBMSPLSQL Tables objects into &&ut3_owner schema
258259
@@install_component.sql 'expectations/matchers/ut_match.tpb'
259260
@@install_component.sql 'expectations/ut_expectation.tpb'
260261
@@install_component.sql 'expectations/ut_expectation_compound.tpb'
262+
@@install_component.sql 'expectations/ut_expectation_refcursor.tpb'
261263

262264
--core reporter
263265
@@install_component.sql 'reporters/ut_documentation_reporter.tps'

0 commit comments

Comments
 (0)