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

Skip to content

Commit 1642f47

Browse files
committed
Adding test:
unary/test_expect_to_be_not_null
1 parent 858a675 commit 1642f47

3 files changed

Lines changed: 363 additions & 0 deletions

File tree

test/install_ut3_user_tests.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ prompt Install user tests
1010
@@ut3_user/expectations/unary/test_expect_to_be_empty.pks
1111
@@ut3_user/expectations/unary/test_expect_to_have_count.pks
1212
@@ut3_user/expectations/unary/test_expect_to_be_true_false.pks
13+
@@ut3_user/expectations/unary/test_expect_to_be_not_null.pks
1314
@@ut3_user/expectations/binary/test_equal.pks
1415
@@ut3_user/expectations/binary/test_expect_to_be_less_than.pks
1516
@@ut3_user/expectations/binary/test_be_less_or_equal.pks
@@ -47,6 +48,7 @@ set define off
4748
@@ut3_user/expectations/unary/test_expect_to_be_empty.pkb
4849
@@ut3_user/expectations/unary/test_expect_to_have_count.pkb
4950
@@ut3_user/expectations/unary/test_expect_to_be_true_false.pkb
51+
@@ut3_user/expectations/unary/test_expect_to_be_not_null.pkb
5052
@@ut3_user/expectations/binary/test_equal.pkb
5153
@@ut3_user/expectations/binary/test_expect_to_be_less_than.pkb
5254
@@ut3_user/expectations/binary/test_be_less_or_equal.pkb
Lines changed: 264 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,264 @@
1+
create or replace package body test_expect_to_be_not_null
2+
is
3+
gc_object_name constant varchar2(30) := 't_to_be_not_null_test';
4+
gc_nested_table_name constant varchar2(30) := 'tt_to_be_not_null_test';
5+
gc_varray_name constant varchar2(30) := 'tv_to_be_not_null_test';
6+
7+
procedure cleanup_expectations is
8+
begin
9+
ut3_tester_helper.main_helper.clear_expectations( );
10+
end;
11+
12+
procedure create_types is
13+
pragma autonomous_transaction;
14+
begin
15+
execute immediate 'create type '||gc_object_name||' is object (dummy number)';
16+
execute immediate 'create type '||gc_nested_table_name||' is table of number';
17+
execute immediate 'create type '||gc_varray_name||' is varray(1) of number';
18+
end;
19+
20+
procedure drop_types is
21+
pragma autonomous_transaction;
22+
begin
23+
execute immediate 'drop type '||gc_object_name;
24+
execute immediate 'drop type '||gc_nested_table_name;
25+
execute immediate 'drop type '||gc_varray_name;
26+
end;
27+
28+
procedure blob_not_null is
29+
begin
30+
--Act
31+
execute immediate ut3_tester_helper.expectations_helper.unary_expectation_block('to_be_not_null', 'blob', 'to_blob(''abc'')');
32+
--Assert
33+
ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0);
34+
end;
35+
36+
procedure empty_blob is
37+
begin
38+
--Act
39+
execute immediate ut3_tester_helper.expectations_helper.unary_expectation_block('to_be_not_null', 'blob', 'empty_blob()');
40+
--Assert
41+
ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0);
42+
end;
43+
44+
procedure boolean_not_null is
45+
begin
46+
--Act
47+
execute immediate ut3_tester_helper.expectations_helper.unary_expectation_block('to_be_not_null', 'boolean', 'true');
48+
--Assert
49+
ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0);
50+
end;
51+
52+
procedure clob_not_null is
53+
begin
54+
--Act
55+
execute immediate ut3_tester_helper.expectations_helper.unary_expectation_block('to_be_not_null', 'clob', 'to_clob(''abc'')');
56+
--Assert
57+
ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0);
58+
end;
59+
60+
procedure empty_clob is
61+
begin
62+
--Act
63+
execute immediate ut3_tester_helper.expectations_helper.unary_expectation_block('to_be_not_null', 'clob', 'empty_clob()');
64+
--Assert
65+
ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0);
66+
end;
67+
68+
procedure date_not_null is
69+
begin
70+
--Act
71+
execute immediate ut3_tester_helper.expectations_helper.unary_expectation_block('to_be_not_null', 'date', 'sysdate');
72+
--Assert
73+
ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0);
74+
end;
75+
76+
procedure number_not_null is
77+
begin
78+
--Act
79+
execute immediate ut3_tester_helper.expectations_helper.unary_expectation_block('to_be_not_null', 'number', '1234');
80+
--Assert
81+
ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0);
82+
end;
83+
84+
procedure timestamp_not_null is
85+
begin
86+
--Act
87+
execute immediate ut3_tester_helper.expectations_helper.unary_expectation_block('to_be_not_null', 'timestamp', 'systimestamp');
88+
--Assert
89+
ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0);
90+
end;
91+
92+
procedure timestamp_with_ltz_not_null is
93+
begin
94+
--Act
95+
execute immediate ut3_tester_helper.expectations_helper.unary_expectation_block('to_be_not_null', 'timestamp with local time zone', 'systimestamp');
96+
--Assert
97+
ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0);
98+
end;
99+
100+
procedure timestamp_with_tz_not_null is
101+
begin
102+
--Act
103+
execute immediate ut3_tester_helper.expectations_helper.unary_expectation_block('to_be_not_null', 'timestamp with time zone', 'systimestamp');
104+
--Assert
105+
ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0);
106+
end;
107+
108+
procedure varchar2_not_null is
109+
begin
110+
--Act
111+
execute immediate ut3_tester_helper.expectations_helper.unary_expectation_block('to_be_not_null', 'varchar2(4000)', '''abc''');
112+
--Assert
113+
ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0);
114+
end;
115+
116+
procedure initialized_object is
117+
begin
118+
--Act
119+
execute immediate ut3_tester_helper.expectations_helper.unary_expectation_object_block(
120+
'to_be_not_null', gc_object_name, gc_object_name||'(1)', 'object'
121+
);
122+
--Assert
123+
ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0);
124+
end;
125+
126+
procedure initialized_nested_table is
127+
begin
128+
--Act
129+
execute immediate ut3_tester_helper.expectations_helper.unary_expectation_object_block(
130+
'to_be_not_null', gc_nested_table_name, gc_nested_table_name||'()', 'collection'
131+
);
132+
--Assert
133+
ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0);
134+
end;
135+
136+
procedure initialized_varray is
137+
begin
138+
--Act
139+
execute immediate ut3_tester_helper.expectations_helper.unary_expectation_object_block(
140+
'to_be_not_null', gc_varray_name, gc_varray_name||'()', 'collection'
141+
);
142+
--Assert
143+
ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0);
144+
end;
145+
146+
procedure null_blob is
147+
begin
148+
--Act
149+
execute immediate ut3_tester_helper.expectations_helper.unary_expectation_block('to_be_not_null', 'blob', 'null');
150+
--Assert
151+
ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0);
152+
end;
153+
154+
procedure null_boolean is
155+
begin
156+
--Act
157+
execute immediate ut3_tester_helper.expectations_helper.unary_expectation_block('to_be_not_null', 'boolean', 'null');
158+
--Assert
159+
ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0);
160+
end;
161+
162+
163+
procedure null_clob is
164+
begin
165+
--Act
166+
execute immediate ut3_tester_helper.expectations_helper.unary_expectation_block('to_be_not_null', 'clob', 'null');
167+
--Assert
168+
ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0);
169+
end;
170+
171+
172+
procedure null_date is
173+
begin
174+
--Act
175+
execute immediate ut3_tester_helper.expectations_helper.unary_expectation_block('to_be_not_null', 'date', 'null');
176+
--Assert
177+
ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0);
178+
end;
179+
180+
181+
procedure null_number is
182+
begin
183+
--Act
184+
execute immediate ut3_tester_helper.expectations_helper.unary_expectation_block('to_be_not_null', 'number', 'null');
185+
--Assert
186+
ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0);
187+
end;
188+
189+
190+
procedure null_timestamp is
191+
begin
192+
--Act
193+
execute immediate ut3_tester_helper.expectations_helper.unary_expectation_block('to_be_not_null', 'timestamp', 'null');
194+
--Assert
195+
ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0);
196+
end;
197+
198+
199+
procedure null_timestamp_with_ltz is
200+
begin
201+
--Act
202+
execute immediate ut3_tester_helper.expectations_helper.unary_expectation_block('to_be_not_null', 'timestamp with local time zone', 'null');
203+
--Assert
204+
ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0);
205+
end;
206+
207+
208+
procedure null_timestamp_with_tz is
209+
begin
210+
--Act
211+
execute immediate ut3_tester_helper.expectations_helper.unary_expectation_block('to_be_not_null', 'timestamp with time zone', 'null');
212+
--Assert
213+
ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0);
214+
end;
215+
216+
217+
procedure null_varchar2 is
218+
begin
219+
--Act
220+
execute immediate ut3_tester_helper.expectations_helper.unary_expectation_block('to_be_not_null', 'varchar2(4000)', 'null');
221+
--Assert
222+
ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0);
223+
end;
224+
225+
procedure null_anydata is
226+
begin
227+
--Act
228+
execute immediate ut3_tester_helper.expectations_helper.unary_expectation_block('to_be_not_null', 'anydata', 'null');
229+
--Assert
230+
ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0);
231+
end;
232+
233+
procedure uninit_object_in_anydata is
234+
begin
235+
--Act
236+
execute immediate ut3_tester_helper.expectations_helper.unary_expectation_object_block(
237+
'to_be_not_null', gc_object_name, 'null', 'object'
238+
);
239+
--Assert
240+
ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0);
241+
end;
242+
243+
procedure uninit_nested_table_in_anydata is
244+
begin
245+
--Act
246+
execute immediate ut3_tester_helper.expectations_helper.unary_expectation_object_block(
247+
'to_be_not_null', gc_nested_table_name, 'null', 'collection'
248+
);
249+
--Assert
250+
ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0);
251+
end;
252+
253+
procedure uninit_varray_in_anydata is
254+
begin
255+
--Act
256+
execute immediate ut3_tester_helper.expectations_helper.unary_expectation_object_block(
257+
'to_be_not_null', gc_varray_name, 'null', 'collection'
258+
);
259+
--Assert
260+
ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0);
261+
end;
262+
263+
end test_expect_to_be_not_null;
264+
/
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
create or replace package test_expect_to_be_not_null
2+
is
3+
--%suite(to_be_not_null)
4+
--%suitepath(utplsql.test_user.expectations.unary)
5+
6+
--%aftereach
7+
procedure cleanup_expectations;
8+
9+
--%beforeall
10+
procedure create_types;
11+
12+
--%afterall
13+
procedure drop_types;
14+
15+
--%test(Gives success for not null blob)
16+
procedure blob_not_null;
17+
18+
--%test(Gives success for empty blob)
19+
procedure empty_blob;
20+
21+
--%test(Gives success for not null boolean)
22+
procedure boolean_not_null;
23+
24+
--%test(Gives success for not null clob)
25+
procedure clob_not_null;
26+
27+
--%test(Gives success for empty clob)
28+
procedure empty_clob;
29+
30+
--%test(Gives success for not null date)
31+
procedure date_not_null;
32+
33+
--%test(Gives success for not null number)
34+
procedure number_not_null;
35+
36+
--%test(Gives success for not null timestamp)
37+
procedure timestamp_not_null;
38+
39+
--%test(Gives success for not null timestamp with local time zone)
40+
procedure timestamp_with_ltz_not_null;
41+
42+
--%test(Gives success for not null timestamp with time zone)
43+
procedure timestamp_with_tz_not_null;
44+
45+
--%test(Gives success for not null varchar2)
46+
procedure varchar2_not_null;
47+
48+
--%test(Gives success for initialized object within anydata)
49+
procedure initialized_object;
50+
51+
--%test(Gives success for initialized nested table within anydata)
52+
procedure initialized_nested_table;
53+
54+
--%test(Gives success for initialized varray within anydata)
55+
procedure initialized_varray;
56+
57+
--%test(Gives failure with null blob)
58+
procedure null_blob;
59+
60+
--%test(Gives failure with null boolean)
61+
procedure null_boolean;
62+
63+
--%test(Gives failure with null clob)
64+
procedure null_clob;
65+
66+
--%test(Gives failure with null date)
67+
procedure null_date;
68+
69+
--%test(Gives failure with null number)
70+
procedure null_number;
71+
72+
--%test(Gives failure null timestamp)
73+
procedure null_timestamp;
74+
75+
--%test(Gives failure with null timestamp with local time zone)
76+
procedure null_timestamp_with_ltz;
77+
78+
--%test(Gives failure with null timestamp with time zone)
79+
procedure null_timestamp_with_tz;
80+
81+
--%test(Gives failure with null varchar2)
82+
procedure null_varchar2;
83+
84+
--%test(Gives failure with null anydata)
85+
procedure null_anydata;
86+
87+
--%test(Gives failure with uninitialized object within anydata)
88+
procedure uninit_object_in_anydata;
89+
90+
--%test(Gives failure with uninitialized nested table within anydata)
91+
procedure uninit_nested_table_in_anydata;
92+
93+
--%test(Gives failure with uninitialized varray within anydata)
94+
procedure uninit_varray_in_anydata;
95+
96+
end test_expect_to_be_not_null;
97+
/

0 commit comments

Comments
 (0)