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

Skip to content

Commit e0ac97c

Browse files
committed
Adding test for double nested objects
1 parent c11aa24 commit e0ac97c

5 files changed

Lines changed: 48 additions & 28 deletions

File tree

source/expectations/data_values/ut_compound_data_helper.pkb

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,7 @@ create or replace package body ut_compound_data_helper is
144144
l_index := a_pk_table.next(l_index);
145145
end loop;
146146
end if;
147-
if a_data_info.column_type in ('OBJECT') then
148-
null;
149-
elsif not(l_exists) then
147+
if not(l_exists) then
150148
l_sql_stmt := ' (decode(a.'||a_data_info.transformed_name||','||' e.'||a_data_info.transformed_name||',1,0) = 0)';
151149
end if;
152150
return l_sql_stmt;
@@ -163,9 +161,7 @@ create or replace package body ut_compound_data_helper is
163161
if l_pk_tab.count <> 0 then
164162
l_index:= l_pk_tab.first;
165163
loop
166-
if a_data_info.column_type in ('OBJECT') then
167-
null;
168-
elsif l_pk_tab(l_index) in (a_data_info.access_path, a_data_info.parent_name) then
164+
if l_pk_tab(l_index) in (a_data_info.access_path, a_data_info.parent_name) then
169165
--When then table is nested and join is on whole table
170166
l_sql_stmt := l_sql_stmt ||' a.'||a_data_info.transformed_name||q'[ = ]'||' e.'||a_data_info.transformed_name;
171167
end if;
@@ -191,21 +187,15 @@ create or replace package body ut_compound_data_helper is
191187
if a_pk_table is not empty then
192188
l_index:= a_pk_table.first;
193189
loop
194-
if a_data_info.column_type in ('OBJECT') then
195-
null;
196-
elsif a_pk_table(l_index) in (a_data_info.access_path, a_data_info.parent_name) then
190+
if a_pk_table(l_index) in (a_data_info.access_path, a_data_info.parent_name) then
197191
--When then table is nested and join is on whole table
198192
l_sql_stmt := l_sql_stmt ||a_alias||a_data_info.transformed_name;
199193
end if;
200194
exit when (a_data_info.access_path = a_pk_table(l_index)) or l_index = a_pk_table.count;
201195
l_index := a_pk_table.next(l_index);
202196
end loop;
203197
else
204-
if a_data_info.column_type in ('OBJECT') then
205-
null;
206-
else
207-
l_sql_stmt := a_alias||a_data_info.transformed_name;
208-
end if;
198+
l_sql_stmt := a_alias||a_data_info.transformed_name;
209199
end if;
210200
return l_sql_stmt;
211201
end;
@@ -216,9 +206,7 @@ create or replace package body ut_compound_data_helper is
216206
l_alias varchar2(10) := a_alias;
217207
l_col_syntax varchar2(4000);
218208
begin
219-
if a_data_info.column_type in ('OBJECT') then
220-
null;
221-
elsif a_data_info.is_sql_diffable = 0 then
209+
if a_data_info.is_sql_diffable = 0 then
222210
l_col_syntax := 'ut_utils.get_hash('||l_alias||a_data_info.transformed_name||'.getClobVal()) as '||a_data_info.transformed_name ;
223211
elsif a_data_info.is_sql_diffable = 1 and a_data_info.column_type = 'DATE' then
224212
l_col_syntax := 'to_date('||l_alias||a_data_info.transformed_name||') as '|| a_data_info.transformed_name;
@@ -250,20 +238,14 @@ create or replace package body ut_compound_data_helper is
250238
--We cannot use a precision and scale as dbms_sql.describe_columns3 return precision 0 for dual table
251239
-- there is also no need for that as we not process data but only read and compare as they are stored
252240
l_col_type := a_data_info.column_type;
253-
elsif a_data_info.column_type in ('OBJECT') then
254-
null;
255241
else
256242
l_col_type := a_data_info.column_type
257243
||case when a_data_info.column_len is not null
258244
then '('||a_data_info.column_len||')'
259245
else null
260246
end;
261247
end if;
262-
if a_data_info.column_type in ('OBJECT') then
263-
return null;
264-
else
265-
return a_data_info.transformed_name||' '||l_col_type||q'[ PATH ']'||a_data_info.access_path||q'[']';
266-
end if;
248+
return a_data_info.transformed_name||' '||l_col_type||q'[ PATH ']'||a_data_info.access_path||q'[']';
267249
end;
268250

269251
procedure gen_sql_pieces_out_of_cursor(
@@ -296,7 +278,7 @@ create or replace package body ut_compound_data_helper is
296278
begin
297279
if a_data_info is not empty then
298280
for i in 1..a_data_info.count loop
299-
if a_data_info(i).has_nested_col = 0 then
281+
if a_data_info(i).has_nested_col = 0 and a_data_info(i).column_type <> 'OBJECT' then
300282
--Get XMLTABLE column list
301283
add_element_to_list(l_xmltab_list,generate_xmltab_stmt(a_data_info(i)));
302284
--Get Select statment list of columns

test/install_ut3_tester_helper.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ alter session set plsql_optimize_level=0;
77
@@ut3_tester_helper/test_dummy_object.tps
88
@@ut3_tester_helper/other_dummy_object.tps
99
@@ut3_tester_helper/test_dummy_nested_object.tps
10+
@@ut3_tester_helper/test_dummy_double_nested_object.tps
1011
@@ut3_tester_helper/test_dummy_object_list.tps
1112
@@ut3_tester_helper/test_tab_varchar2.tps
1213
@@ut3_tester_helper/test_tab_varray.tps
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
declare
2+
l_exists integer;
3+
begin
4+
select count(1) into l_exists from user_types where type_name = 'TEST_DUMMY_DOUBLE_NESTED_OBJECT';
5+
if l_exists > 0 then
6+
execute immediate 'drop type test_dummy_double_nested_object force';
7+
end if;
8+
end;
9+
/
10+
11+
create or replace type test_dummy_double_nested_object as object (
12+
first_double_nested_obj test_dummy_nested_object,
13+
"Value" varchar2(30)
14+
)
15+
/

test/ut3_user/expectations/test_expectation_anydata.pkb

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,16 +1000,35 @@ Rows: [ 60 differences, showing first 20 ]
10001000
g_test_expected := anydata.convertObject( ut3_tester_helper.test_dummy_nested_object(ut3_tester_helper.test_dummy_object(1, 'A', '0'),ut3_tester_helper.test_dummy_object(1, 'B', '0') ));
10011001
g_test_actual := anydata.convertObject( ut3_tester_helper.test_dummy_nested_object(ut3_tester_helper.test_dummy_object(1, 'A', '0'),ut3_tester_helper.test_dummy_object(1, 'C', '0') ));
10021002
--Act
1003-
l_expected_message := q'[%Actual: ut3_develop.some_item was expected to equal: ut3_develop.some_item
1003+
l_expected_message := q'[%Actual: ut3_tester_helper.test_dummy_nested_object was expected to equal: ut3_tester_helper.test_dummy_nested_object
10041004
%Diff:
10051005
%Rows: [ 1 differences ]
1006-
%Row No. 1 - Actual: <SEC_NESTED_OBJ><ID>1</ID><name>B</name><Value>0</Value></SEC_NESTED_OBJ>
1007-
%Row No. 1 - Expected: <SEC_NESTED_OBJ><ID>1</ID><name>C</name><Value>0</Value></SEC_NESTED_OBJ>]';
1006+
%Row No. 1 - Actual: <SEC_NESTED_OBJ><ID>1</ID><name>C</name><Value>0</Value></SEC_NESTED_OBJ>
1007+
%Row No. 1 - Expected: <SEC_NESTED_OBJ><ID>1</ID><name>B</name><Value>0</Value></SEC_NESTED_OBJ>]';
10081008
ut3_develop.ut.expect(g_test_actual).to_equal(g_test_expected);
10091009
l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1);
10101010
--Assert
10111011
ut.expect(l_actual_message).to_be_like(l_expected_message);
10121012
end;
10131013

1014+
procedure failure_double_nested_objects is
1015+
l_actual_message varchar2(32767);
1016+
l_expected_message varchar2(32767);
1017+
begin
1018+
--Arrange
1019+
g_test_expected := anydata.convertObject( ut3_tester_helper.test_dummy_double_nested_object(ut3_tester_helper.test_dummy_nested_object(ut3_tester_helper.test_dummy_object(1, 'A', '0'),ut3_tester_helper.test_dummy_object(1, 'B', '0') ),'Test'));
1020+
g_test_actual := anydata.convertObject( ut3_tester_helper.test_dummy_double_nested_object(ut3_tester_helper.test_dummy_nested_object(ut3_tester_helper.test_dummy_object(1, 'A', '0'),ut3_tester_helper.test_dummy_object(1, 'C', '0') ),'Test'));
1021+
--Act
1022+
l_expected_message := q'[%Actual: ut3_tester_helper.test_dummy_double_nested_object was expected to equal: ut3_tester_helper.test_dummy_double_nested_object
1023+
%Diff:
1024+
%Rows: [ 1 differences ]
1025+
%Row No. 1 - Actual: <FIRST_DOUBLE_NESTED_OBJ><FIRST_NESTED_OBJ><ID>1</ID><name>A</name><Value>0</Value></FIRST_NESTED_OBJ><SEC_NESTED_OBJ><ID>1</ID><name>C</name><Value>0</Value></SEC_NESTED_OBJ></FIRST_DOUBLE_NESTED_OBJ>
1026+
%Row No. 1 - Expected: <FIRST_DOUBLE_NESTED_OBJ><FIRST_NESTED_OBJ><ID>1</ID><name>A</name><Value>0</Value></FIRST_NESTED_OBJ><SEC_NESTED_OBJ><ID>1</ID><name>B</name><Value>0</Value></SEC_NESTED_OBJ></FIRST_DOUBLE_NESTED_OBJ>]';
1027+
ut3_develop.ut.expect(g_test_actual).to_equal(g_test_expected);
1028+
l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1);
1029+
--Assert
1030+
ut.expect(l_actual_message).to_be_like(l_expected_message);
1031+
end;
1032+
10141033
end;
10151034
/

test/ut3_user/expectations/test_expectation_anydata.pks

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,9 @@ create or replace package test_expectation_anydata is
206206

207207
--%test ( Failure of comparing nesting objects )
208208
procedure failure_nesting_objects;
209+
210+
--%test ( Failure of comparing double nested objects )
211+
procedure failure_double_nested_objects;
209212

210213
end;
211214
/

0 commit comments

Comments
 (0)