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

Skip to content

Commit f39b96a

Browse files
committed
Update not to include
1 parent add5ed8 commit f39b96a

6 files changed

Lines changed: 187 additions & 67 deletions

File tree

source/expectations/data_values/ut_compound_data_helper.pkb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ create or replace package body ut_compound_data_helper is
544544
l_sql varchar2(32767);
545545
begin
546546
l_sql := 'with source_data as
547-
( select t.data_id,t.item_hash,row_number() over (partition by t.pk_hash,t.item_hash,t.data_id order by 1,2) duplicate_no,
547+
( select t.data_id,t.item_hash,t.duplicate_no,
548548
pk_hash
549549
from ' || a_owner || '.ut_compound_data_tmp t
550550
where data_id = :self_guid or data_id = :other_guid
@@ -577,7 +577,7 @@ create or replace package body ut_compound_data_helper is
577577
l_sql varchar2(32767);
578578
begin
579579
l_sql := 'with source_data as
580-
( select t.data_id,t.item_hash,row_number() over (partition by t.pk_hash,t.item_hash,t.data_id order by 1,2) duplicate_no,
580+
( select t.data_id,t.item_hash,t.duplicate_no,
581581
pk_hash
582582
from ' || a_owner || '.ut_compound_data_tmp t
583583
where data_id = :self_guid or data_id = :other_guid
@@ -613,7 +613,7 @@ create or replace package body ut_compound_data_helper is
613613
begin
614614
/* Self set does not contain any values from other set */
615615
l_sql := 'with source_data as
616-
( select t.data_id,t.item_hash,row_number() over (partition by t.pk_hash,t.item_hash,t.data_id order by 1,2) duplicate_no,
616+
( select t.data_id,t.item_hash,t.duplicate_no,
617617
pk_hash
618618
from ' || a_owner || '.ut_compound_data_tmp t
619619
where data_id = :self_guid or data_id = :other_guid

source/expectations/ut_expectation.tpb

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,13 @@ create or replace type body ut_expectation as
3232
l_matcher ut_matcher := a_matcher;
3333
l_message varchar2(32767);
3434
begin
35-
l_expectation_result := l_matcher.run_matcher_negated( self.actual_data );
36-
l_expectation_result := coalesce(l_expectation_result,false);
37-
l_message := coalesce( l_matcher.error_message( self.actual_data ), l_matcher.failure_message_when_negated( self.actual_data ) );
38-
ut_expectation_processor.add_expectation_result( ut_expectation_result( ut_utils.to_test_result( l_expectation_result ), self.description, l_message ) );
39-
end;
40-
41-
member procedure not_include(self in ut_expectation, a_matcher ut_matcher) is
42-
l_expectation_result boolean;
43-
l_matcher ut_matcher := a_matcher;
44-
l_message varchar2(32767);
45-
begin
46-
l_expectation_result := l_matcher.run_matcher( self.actual_data );
35+
--Negated matcher for include option.
36+
if (l_matcher is of (ut_include)) then
37+
l_expectation_result := l_matcher.run_matcher( self.actual_data );
38+
else
39+
l_expectation_result := l_matcher.run_matcher_negated( self.actual_data );
40+
end if;
41+
4742
l_expectation_result := coalesce(l_expectation_result,false);
4843
l_message := coalesce( l_matcher.error_message( self.actual_data ), l_matcher.failure_message_when_negated( self.actual_data ) );
4944
ut_expectation_processor.add_expectation_result( ut_expectation_result( ut_utils.to_test_result( l_expectation_result ), self.description, l_message ) );
@@ -701,12 +696,12 @@ create or replace type body ut_expectation as
701696

702697
member procedure not_to_include(self in ut_expectation, a_expected sys_refcursor) is
703698
begin
704-
self.not_include( ut_include(a_expected).negated );
699+
self.not_to( ut_include(a_expected).negated );
705700
end;
706701

707702
member procedure not_to_contain(self in ut_expectation, a_expected sys_refcursor) is
708703
begin
709-
self.not_include( ut_include(a_expected).negated );
704+
self.not_to( ut_include(a_expected).negated );
710705
end;
711706

712707
end;

source/expectations/ut_expectation.tps

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ create or replace type ut_expectation authid current_user as object(
2121
--base matcher executors
2222
member procedure to_(self in ut_expectation, a_matcher ut_matcher),
2323
member procedure not_to(self in ut_expectation, a_matcher ut_matcher),
24-
member procedure not_include(self in ut_expectation, a_matcher ut_matcher),
25-
24+
2625
--shortcuts
2726
member procedure to_be_null(self in ut_expectation),
2827
member procedure to_be_not_null(self in ut_expectation),

source/expectations/ut_expectation_compound.tpb

Lines changed: 6 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,7 @@ create or replace type body ut_expectation_compound as
124124
member procedure include(self in ut_expectation_compound, a_items varchar2) is
125125
begin
126126
if ut_utils.int_to_boolean(negated) then
127-
if (matcher is of (ut_include)) then
128-
self.not_include( treat(matcher as ut_equal).include(a_items) );
129-
else
130-
self.not_to( treat(matcher as ut_equal).include(a_items) );
131-
end if;
127+
self.not_to( treat(matcher as ut_equal).include(a_items) );
132128
else
133129
self.to_( treat(matcher as ut_equal).include(a_items) );
134130
end if;
@@ -137,11 +133,7 @@ create or replace type body ut_expectation_compound as
137133
member procedure include(self in ut_expectation_compound, a_items ut_varchar2_list) is
138134
begin
139135
if ut_utils.int_to_boolean(negated) then
140-
if (matcher is of (ut_include)) then
141-
self.not_include( treat(matcher as ut_equal).include(a_items) );
142-
else
143-
self.not_to( treat(matcher as ut_equal).include(a_items) );
144-
end if;
136+
self.not_to( treat(matcher as ut_equal).include(a_items) );
145137
else
146138
self.to_( treat(matcher as ut_equal).include(a_items) );
147139
end if;
@@ -168,11 +160,7 @@ create or replace type body ut_expectation_compound as
168160
member procedure exclude(self in ut_expectation_compound, a_items varchar2) is
169161
begin
170162
if ut_utils.int_to_boolean(negated) then
171-
if (matcher is of (ut_include)) then
172-
self.not_include( treat(matcher as ut_equal).exclude(a_items) );
173-
else
174-
self.not_to( treat(matcher as ut_equal).exclude(a_items) );
175-
end if;
163+
self.not_to( treat(matcher as ut_equal).exclude(a_items) );
176164
else
177165
self.to_( treat(matcher as ut_equal).exclude(a_items) );
178166
end if;
@@ -181,11 +169,7 @@ create or replace type body ut_expectation_compound as
181169
member procedure exclude(self in ut_expectation_compound, a_items ut_varchar2_list) is
182170
begin
183171
if ut_utils.int_to_boolean(negated) then
184-
if (matcher is of (ut_include)) then
185-
self.not_include( treat(matcher as ut_equal).exclude(a_items) );
186-
else
187-
self.not_to( treat(matcher as ut_equal).exclude(a_items) );
188-
end if;
172+
self.not_to( treat(matcher as ut_equal).exclude(a_items) );
189173
else
190174
self.to_( treat(matcher as ut_equal).exclude(a_items) );
191175
end if;
@@ -228,11 +212,7 @@ create or replace type body ut_expectation_compound as
228212
member procedure join_by(self in ut_expectation_compound, a_columns varchar2) is
229213
begin
230214
if ut_utils.int_to_boolean(negated) then
231-
if (matcher is of (ut_include)) then
232-
self.not_include( treat(matcher as ut_equal).join_by(a_columns) );
233-
else
234-
self.not_to( treat(matcher as ut_equal).join_by(a_columns) );
235-
end if;
215+
self.not_to( treat(matcher as ut_equal).join_by(a_columns) );
236216
else
237217
self.to_( treat(matcher as ut_equal).join_by(a_columns) );
238218
end if;
@@ -241,11 +221,7 @@ create or replace type body ut_expectation_compound as
241221
member procedure join_by(self in ut_expectation_compound, a_columns ut_varchar2_list) is
242222
begin
243223
if ut_utils.int_to_boolean(negated) then
244-
if (matcher is of (ut_include)) then
245-
self.not_include( treat(matcher as ut_equal).join_by(a_columns) );
246-
else
247-
self.not_to( treat(matcher as ut_equal).join_by(a_columns) );
248-
end if;
224+
self.not_to( treat(matcher as ut_equal).join_by(a_columns) );
249225
else
250226
self.to_( treat(matcher as ut_equal).join_by(a_columns) );
251227
end if;

test/core/expectations/test_expectations_cursor.pkb

Lines changed: 136 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2019,7 +2019,7 @@ Diff:%
20192019

20202020
end;
20212021

2022-
procedure cursor_contain is
2022+
procedure cursor_to_include is
20232023
l_actual SYS_REFCURSOR;
20242024
l_expected SYS_REFCURSOR;
20252025
begin
@@ -2035,7 +2035,7 @@ Diff:%
20352035
ut.expect(expectations.failed_expectations_data()).to_be_empty();
20362036
end;
20372037

2038-
procedure cursor_contain_fail is
2038+
procedure cursor_to_include_fail is
20392039
l_actual SYS_REFCURSOR;
20402040
l_expected SYS_REFCURSOR;
20412041
l_expected_message varchar2(32767);
@@ -2107,7 +2107,7 @@ Diff:%
21072107
ut.expect(l_actual_message).to_be_like(l_expected_message);
21082108
end;
21092109

2110-
procedure cursor_contain_joinby is
2110+
procedure cursor_to_include_joinby is
21112111
l_actual SYS_REFCURSOR;
21122112
l_expected SYS_REFCURSOR;
21132113
begin
@@ -2121,7 +2121,7 @@ Diff:%
21212121
ut.expect(expectations.failed_expectations_data()).to_be_empty();
21222122
end;
21232123

2124-
procedure cursor_contain_joinby_fail is
2124+
procedure cursor_to_include_joinby_fail is
21252125
l_actual SYS_REFCURSOR;
21262126
l_expected SYS_REFCURSOR;
21272127
l_expected_message varchar2(32767);
@@ -2151,7 +2151,51 @@ Diff:%
21512151

21522152
end;
21532153

2154-
procedure contain_incl_cols_as_list
2154+
procedure cursor_contain_joinby is
2155+
l_actual SYS_REFCURSOR;
2156+
l_expected SYS_REFCURSOR;
2157+
begin
2158+
--Arrange
2159+
open l_actual for select username,user_id from all_users;
2160+
open l_expected for select username ,user_id from all_users where rownum < 5;
2161+
2162+
--Act
2163+
ut3.ut.expect(l_actual).to_contain(l_expected).join_by('USERNAME');
2164+
--Assert
2165+
ut.expect(expectations.failed_expectations_data()).to_be_empty();
2166+
end;
2167+
2168+
procedure cursor_contain_joinby_fail is
2169+
l_actual SYS_REFCURSOR;
2170+
l_expected SYS_REFCURSOR;
2171+
l_expected_message varchar2(32767);
2172+
l_actual_message varchar2(32767);
2173+
begin
2174+
--Arrange
2175+
open l_actual for select username, user_id from all_users
2176+
union all
2177+
select 'TEST' username, -600 user_id from dual
2178+
order by 1 desc;
2179+
open l_expected for select username, user_id from all_users
2180+
union all
2181+
select 'TEST' username, -601 user_id from dual
2182+
order by 1 asc;
2183+
2184+
--Act
2185+
ut3.ut.expect(l_actual).to_contain(l_expected).join_by('USERNAME');
2186+
--Assert
2187+
l_expected_message := q'[%Actual: refcursor [ count = % ] was expected to include: refcursor [ count = % ]
2188+
%Diff:
2189+
%Rows: [ 1 differences ]
2190+
%PK <USERNAME>TEST</USERNAME> - Actual: <USER_ID>-600</USER_ID>
2191+
%PK <USERNAME>TEST</USERNAME> - Expected: <USER_ID>-601</USER_ID>%]';
2192+
l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message;
2193+
--Assert
2194+
ut.expect(l_actual_message).to_be_like(l_expected_message);
2195+
2196+
end;
2197+
2198+
procedure to_include_incl_cols_as_list
21552199
as
21562200
l_actual sys_refcursor;
21572201
l_expected sys_refcursor;
@@ -2164,8 +2208,22 @@ Diff:%
21642208
--Assert
21652209
ut.expect(expectations.failed_expectations_data()).to_be_empty();
21662210
end;
2211+
2212+
procedure to_contain_cont_cols_as_list
2213+
as
2214+
l_actual sys_refcursor;
2215+
l_expected sys_refcursor;
2216+
begin
2217+
--Arrange
2218+
open l_actual for select rownum as rn, 'a' as "A_Column", 'c' as A_COLUMN, 'x' SOME_COL, 'd' "Some_Col" from dual a connect by level < 6;
2219+
open l_expected for select rownum as rn, 'a' as "A_Column", 'd' as A_COLUMN, 'x' SOME_COL, 'c' "Some_Col" from dual a connect by level < 4;
2220+
--Act
2221+
ut3.ut.expect(l_actual).to_contain(l_expected).include(ut3.ut_varchar2_list('RN','//A_Column','SOME_COL'));
2222+
--Assert
2223+
ut.expect(expectations.failed_expectations_data()).to_be_empty();
2224+
end;
21672225

2168-
procedure contain_join_incl_cols_as_lst
2226+
procedure to_inc_join_incl_cols_as_lst
21692227
as
21702228
l_actual sys_refcursor;
21712229
l_expected sys_refcursor;
@@ -2179,7 +2237,21 @@ Diff:%
21792237
ut.expect(expectations.failed_expectations_data()).to_be_empty();
21802238
end;
21812239

2182-
procedure contain_join_excl_cols_as_lst
2240+
procedure to_cont_join_incl_cols_as_lst
2241+
as
2242+
l_actual sys_refcursor;
2243+
l_expected sys_refcursor;
2244+
begin
2245+
--Arrange
2246+
open l_actual for select rownum as rn, 'a' as "A_Column", 'c' as A_COLUMN, 'x' SOME_COL, 'd' "Some_Col" from dual a connect by level < 10;
2247+
open l_expected for select rownum as rn, 'a' as "A_Column", 'd' as A_COLUMN, 'x' SOME_COL, 'c' "Some_Col" from dual a connect by level < 4;
2248+
--Act
2249+
ut3.ut.expect(l_actual).to_contain(l_expected).include(ut3.ut_varchar2_list('RN','//A_Column','SOME_COL')).join_by('RN');
2250+
--Assert
2251+
ut.expect(expectations.failed_expectations_data()).to_be_empty();
2252+
end;
2253+
2254+
procedure include_join_excl_cols_as_lst
21832255
as
21842256
l_actual sys_refcursor;
21852257
l_expected sys_refcursor;
@@ -2193,7 +2265,21 @@ Diff:%
21932265
ut.expect(expectations.failed_expectations_data()).to_be_empty();
21942266
end;
21952267

2196-
procedure contain_excl_cols_as_list
2268+
procedure contain_join_excl_cols_as_lst
2269+
as
2270+
l_actual sys_refcursor;
2271+
l_expected sys_refcursor;
2272+
begin
2273+
--Arrange
2274+
open l_actual for select rownum as rn, 'a' as "A_Column", 'c' as A_COLUMN, 'x' SOME_COL, 'd' "Some_Col" from dual a connect by level < 10;
2275+
open l_expected for select rownum as rn, 'a' as "A_Column", 'd' as A_COLUMN, 'x' SOME_COL, 'c' "Some_Col" from dual a connect by level < 4;
2276+
--Act
2277+
ut3.ut.expect(l_actual).to_contain(l_expected).exclude(ut3.ut_varchar2_list('//Some_Col','A_COLUMN')).join_by('RN');
2278+
--Assert
2279+
ut.expect(expectations.failed_expectations_data()).to_be_empty();
2280+
end;
2281+
2282+
procedure include_excl_cols_as_list
21972283
as
21982284
l_actual sys_refcursor;
21992285
l_expected sys_refcursor;
@@ -2205,6 +2291,20 @@ Diff:%
22052291
ut3.ut.expect(l_actual).to_include(l_expected).exclude(ut3.ut_varchar2_list('A_COLUMN|//Some_Col'));
22062292
--Assert
22072293
ut.expect(expectations.failed_expectations_data()).to_be_empty();
2294+
end;
2295+
2296+
procedure contain_excl_cols_as_list
2297+
as
2298+
l_actual sys_refcursor;
2299+
l_expected sys_refcursor;
2300+
begin
2301+
--Arrange
2302+
open l_actual for select rownum as rn, 'a' as "A_Column", 'c' as A_COLUMN, 'x' SOME_COL, 'd' "Some_Col" from dual a connect by level < 10;
2303+
open l_expected for select rownum as rn, 'a' as "A_Column", 'd' as A_COLUMN, 'x' SOME_COL, 'c' "Some_Col" from dual a connect by level < 4;
2304+
--Act
2305+
ut3.ut.expect(l_actual).to_contain(l_expected).exclude(ut3.ut_varchar2_list('A_COLUMN|//Some_Col'));
2306+
--Assert
2307+
ut.expect(expectations.failed_expectations_data()).to_be_empty();
22082308
end;
22092309

22102310
procedure cursor_not_to_contain is
@@ -2268,6 +2368,19 @@ Diff:%
22682368
--Assert
22692369
ut.expect(expectations.failed_expectations_data()).to_be_empty();
22702370
end;
2371+
2372+
procedure not_inc_join_incl_cols_as_lst is
2373+
l_actual sys_refcursor;
2374+
l_expected sys_refcursor;
2375+
begin
2376+
--Arrange
2377+
open l_actual for select rownum as rn, 'b' as "A_Column", 'c' as A_COLUMN, 'x' SOME_COL, 'd' "Some_Col" from dual a connect by level < 10;
2378+
open l_expected for select rownum as rn, 'a' as "A_Column", 'd' as A_COLUMN, 'x' SOME_COL, 'c' "Some_Col" from dual a connect by level < 4;
2379+
--Act
2380+
ut3.ut.expect(l_actual).not_to_include(l_expected).include(ut3.ut_varchar2_list('RN','//A_Column','SOME_COL')).join_by('RN');
2381+
--Assert
2382+
ut.expect(expectations.failed_expectations_data()).to_be_empty();
2383+
end;
22712384

22722385
procedure not_cont_join_incl_cols_as_lst is
22732386
l_actual sys_refcursor;
@@ -2277,7 +2390,20 @@ Diff:%
22772390
open l_actual for select rownum as rn, 'b' as "A_Column", 'c' as A_COLUMN, 'x' SOME_COL, 'd' "Some_Col" from dual a connect by level < 10;
22782391
open l_expected for select rownum as rn, 'a' as "A_Column", 'd' as A_COLUMN, 'x' SOME_COL, 'c' "Some_Col" from dual a connect by level < 4;
22792392
--Act
2280-
ut3.ut.expect(l_actual).to_include(l_expected).include(ut3.ut_varchar2_list('RN','//A_Column','SOME_COL')).join_by('RN');
2393+
ut3.ut.expect(l_actual).not_to_contain(l_expected).include(ut3.ut_varchar2_list('RN','//A_Column','SOME_COL')).join_by('RN');
2394+
--Assert
2395+
ut.expect(expectations.failed_expectations_data()).to_be_empty();
2396+
end;
2397+
2398+
procedure not_inc_join_excl_cols_as_lst is
2399+
l_actual sys_refcursor;
2400+
l_expected sys_refcursor;
2401+
begin
2402+
--Arrange
2403+
open l_actual for select rownum as rn, 'a' as "A_Column", 'c' as A_COLUMN, 'y' SOME_COL, 'd' "Some_Col" from dual a connect by level < 10;
2404+
open l_expected for select rownum as rn, 'a' as "A_Column", 'd' as A_COLUMN, 'x' SOME_COL, 'c' "Some_Col" from dual a connect by level < 4;
2405+
--Act
2406+
ut3.ut.expect(l_actual).not_to_include(l_expected).exclude(ut3.ut_varchar2_list('//Some_Col','A_COLUMN')).join_by('RN');
22812407
--Assert
22822408
ut.expect(expectations.failed_expectations_data()).to_be_empty();
22832409
end;
@@ -2290,7 +2416,7 @@ Diff:%
22902416
open l_actual for select rownum as rn, 'a' as "A_Column", 'c' as A_COLUMN, 'y' SOME_COL, 'd' "Some_Col" from dual a connect by level < 10;
22912417
open l_expected for select rownum as rn, 'a' as "A_Column", 'd' as A_COLUMN, 'x' SOME_COL, 'c' "Some_Col" from dual a connect by level < 4;
22922418
--Act
2293-
ut3.ut.expect(l_actual).to_include(l_expected).exclude(ut3.ut_varchar2_list('//Some_Col','A_COLUMN')).join_by('RN');
2419+
ut3.ut.expect(l_actual).not_to_contain(l_expected).exclude(ut3.ut_varchar2_list('//Some_Col','A_COLUMN')).join_by('RN');
22942420
--Assert
22952421
ut.expect(expectations.failed_expectations_data()).to_be_empty();
22962422
end;

0 commit comments

Comments
 (0)