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

Skip to content

Commit 42d8d45

Browse files
committed
Initial check in
1 parent a6e4e6a commit 42d8d45

8 files changed

Lines changed: 107 additions & 18 deletions

source/expectations/data_values/ut_compound_data_value.tpb

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,8 @@ create or replace type body ut_compound_data_value as
194194
return l_result;
195195
end;
196196

197-
member function compare_implementation(a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2, a_join_by_xpath varchar2, a_unordered boolean ) return integer is
197+
member function compare_implementation(a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2, a_join_by_xpath varchar2,
198+
a_unordered boolean , a_inclusion_compare boolean := false ) return integer is
198199
l_other ut_compound_data_value;
199200
l_ut_owner varchar2(250) := ut_utils.ut_owner;
200201
l_column_filter varchar2(32767);
@@ -249,7 +250,11 @@ create or replace type body ut_compound_data_value as
249250
tgt.pk_hash = src.pk_hash ]'
250251
using a_exclude_xpath, a_include_xpath,a_join_by_xpath,self.data_id, l_other.data_id;
251252

252-
/* Peform minus on two sets two get diffrences that will be used later on to print results */
253+
/*!*
254+
* Comparision is based on type of search, for inclusion based search we will look for left join only.
255+
* For normal two side diff we will peform minus on two sets two get diffrences.
256+
* SELF is expected
257+
*/
253258
execute immediate 'insert into ' || l_ut_owner || '.ut_compound_data_diff_tmp ( diff_id,item_hash,pk_hash,duplicate_no)
254259
with source_data as
255260
( 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,
@@ -258,30 +263,47 @@ create or replace type body ut_compound_data_value as
258263
where data_id = :self_guid or data_id = :other_guid
259264
)
260265
select distinct :diff_id,tmp.item_hash,tmp.pk_hash,tmp.duplicate_no
261-
from(
266+
from(
262267
(
263268
select t.item_hash,t. duplicate_no,t.pk_hash
264269
from source_data t
265-
where t.data_id = :self_guid
270+
where t.data_id = :other_guid
266271
minus
267272
select t.item_hash,t. duplicate_no,t.pk_hash
268273
from source_data t
269-
where t.data_id = :other_guid
274+
where t.data_id = :self_guid
270275
)
271276
union all
272277
(
273278
select t.item_hash,t. duplicate_no,t.pk_hash
274279
from source_data t
275-
where t.data_id = :other_guid
280+
where t.data_id = :self_guid '
281+
||
282+
case when a_inclusion_compare then
283+
' and 1 = 2 '
284+
else
285+
null
286+
end ||
287+
'
276288
minus
277289
select t.item_hash,t. duplicate_no,t.pk_hash
278290
from source_data t
279-
where t.data_id = :self_guid
280-
))tmp'
291+
where t.data_id = :other_guid '
292+
||
293+
case when a_inclusion_compare then
294+
' and 1 = 2 '
295+
else
296+
null
297+
end ||
298+
'
299+
)
300+
)
301+
tmp'
281302
using self.data_id, l_other.data_id,
282303
l_diff_id,
283-
self.data_id, l_other.data_id,
284-
l_other.data_id,self.data_id;
304+
l_other.data_id,self.data_id,
305+
self.data_id, l_other.data_id;
306+
285307
--result is OK only if both are same
286308
if sql%rowcount = 0 and self.elements_count = l_other.elements_count then
287309
l_result := 0;

source/expectations/data_values/ut_compound_data_value.tps

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ create or replace type ut_compound_data_value force under ut_data_value(
4444
overriding member function diff( a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2, a_join_by_xpath varchar2, a_unordered boolean := false ) return varchar2,
4545
member function get_data_diff(a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2, a_join_by_xpath varchar2, a_unordered boolean) return clob,
4646
member function compare_implementation(a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2) return integer,
47-
member function compare_implementation(a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2, a_join_by_xpath varchar2, a_unordered boolean ) return integer
47+
member function compare_implementation(a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2, a_join_by_xpath varchar2,
48+
a_unordered boolean , a_inclusion_compare boolean := false) return integer
4849
) not final not instantiable
4950
/

source/expectations/data_values/ut_data_value_refcursor.tpb

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,8 @@ create or replace type body ut_data_value_refcursor as
220220
return l_result_string;
221221
end;
222222

223-
overriding member function compare_implementation (a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2, a_join_by_xpath varchar2, a_unordered boolean) return integer is
223+
overriding member function compare_implementation (a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2, a_join_by_xpath varchar2,
224+
a_unordered boolean, a_inclusion_compare boolean := false) return integer is
224225
l_result integer := 0;
225226
l_other ut_data_value_refcursor;
226227
function is_pk_missing (a_pk_missing_tab ut_compound_data_helper.tt_missing_pk) return integer is
@@ -236,7 +237,8 @@ create or replace type body ut_data_value_refcursor as
236237

237238
--if we join by key and key is missing fail and report error
238239
if a_join_by_xpath is not null then
239-
l_result := is_pk_missing(ut_compound_data_helper.is_pk_exists(self.key_info, l_other.key_info, a_exclude_xpath, a_include_xpath,a_join_by_xpath));
240+
l_result := is_pk_missing(ut_compound_data_helper.is_pk_exists(self.key_info, l_other.key_info, a_exclude_xpath,
241+
a_include_xpath,a_join_by_xpath));
240242
end if;
241243

242244
if l_result = 0 then
@@ -246,9 +248,10 @@ create or replace type body ut_data_value_refcursor as
246248
then
247249
l_result := 1;
248250
end if;
249-
251+
250252
if a_unordered then
251-
l_result := l_result + (self as ut_compound_data_value).compare_implementation(a_other, a_exclude_xpath, a_include_xpath, a_join_by_xpath, a_unordered);
253+
l_result := l_result + (self as ut_compound_data_value).compare_implementation(a_other, a_exclude_xpath, a_include_xpath,
254+
a_join_by_xpath, a_unordered, a_inclusion_compare);
252255
else
253256
l_result := l_result + (self as ut_compound_data_value).compare_implementation(a_other, a_exclude_xpath, a_include_xpath);
254257
end if;

source/expectations/data_values/ut_data_value_refcursor.tps

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ create or replace type ut_data_value_refcursor under ut_compound_data_value(
4444
member procedure init(self in out nocopy ut_data_value_refcursor, a_value sys_refcursor),
4545
overriding member function to_string return varchar2,
4646
overriding member function diff( a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2, a_join_by_xpath varchar2, a_unordered boolean := false ) return varchar2,
47-
overriding member function compare_implementation(a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2, a_join_by_xpath varchar2, a_unordered boolean) return integer,
47+
overriding member function compare_implementation(a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2, a_join_by_xpath varchar2,
48+
a_unordered boolean, a_inclusion_compare boolean := false) return integer,
4849
overriding member function is_empty return boolean
4950

5051
)

source/expectations/ut_expectation.tpb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -679,5 +679,25 @@ create or replace type body ut_expectation as
679679
self.not_to( ut_be_less_than (a_expected) );
680680
end;
681681

682+
member procedure to_include(self in ut_expectation, a_expected sys_refcursor) is
683+
begin
684+
self.to_( ut_include(a_expected) );
685+
end;
686+
687+
member procedure to_contain(self in ut_expectation, a_expected sys_refcursor) is
688+
begin
689+
self.to_( ut_include(a_expected) );
690+
end;
691+
692+
member procedure not_to_include(self in ut_expectation, a_expected sys_refcursor) is
693+
begin
694+
self.not_to( ut_include(a_expected) );
695+
end;
696+
697+
member procedure not_to_contain(self in ut_expectation, a_expected sys_refcursor) is
698+
begin
699+
self.not_to( ut_include(a_expected) );
700+
end;
701+
682702
end;
683703
/

source/expectations/ut_expectation.tps

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,14 @@ create or replace type ut_expectation authid current_user as object(
158158
member procedure not_to_be_less_than(self in ut_expectation, a_expected timestamp_unconstrained),
159159
member procedure not_to_be_less_than(self in ut_expectation, a_expected timestamp_ltz_unconstrained),
160160
member procedure not_to_be_less_than(self in ut_expectation, a_expected timestamp_tz_unconstrained),
161-
member procedure not_to_be_less_than(self in ut_expectation, a_expected yminterval_unconstrained)
161+
member procedure not_to_be_less_than(self in ut_expectation, a_expected yminterval_unconstrained),
162+
163+
member procedure to_include(self in ut_expectation, a_expected sys_refcursor),
164+
member procedure to_contain(self in ut_expectation, a_expected sys_refcursor),
165+
166+
member procedure not_to_include(self in ut_expectation, a_expected sys_refcursor),
167+
member procedure not_to_contain(self in ut_expectation, a_expected sys_refcursor)
168+
162169
)
163170
not final
164171
/

source/expectations/ut_expectation_compound.tpb

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ create or replace type body ut_expectation_compound as
3434
self.not_to( ut_be_empty() );
3535
end;
3636

37-
3837
member procedure to_have_count(self in ut_expectation_compound, a_expected integer) is
3938
begin
4039
self.to_( ut_have_count(a_expected) );
@@ -76,6 +75,36 @@ create or replace type body ut_expectation_compound as
7675
return l_result;
7776
end;
7877

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);
96+
l_result.negated := ut_utils.boolean_to_int(true);
97+
return l_result;
98+
end;
99+
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);
104+
l_result.negated := ut_utils.boolean_to_int(true);
105+
return l_result;
106+
end;
107+
79108
member function include(a_items varchar2) return ut_expectation_compound is
80109
l_result ut_expectation_compound;
81110
begin

source/expectations/ut_expectation_compound.tps

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ create or replace type ut_expectation_compound under ut_expectation(
2929
member function to_equal(a_expected sys_refcursor, a_nulls_are_equal boolean := null) return ut_expectation_compound,
3030
member function not_to_equal(a_expected anydata, a_nulls_are_equal boolean := null) return ut_expectation_compound,
3131
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+
3238
member function include(a_items varchar2) return ut_expectation_compound,
3339
member function include(a_items ut_varchar2_list) return ut_expectation_compound,
3440
member procedure include(self in ut_expectation_compound, a_items varchar2),

0 commit comments

Comments
 (0)