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

Skip to content

Commit 002ae12

Browse files
refactoring with the new design
1 parent 7f5f775 commit 002ae12

4 files changed

Lines changed: 111 additions & 82 deletions

File tree

test/core/expectations/test_expect_not_to_be_null.pkb

Lines changed: 86 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,152 +1,198 @@
11
create or replace package body test_expect_not_to_be_null
22
is
3+
procedure cleanup_expectations
4+
is
5+
begin
6+
ut3.ut_expectation_processor.clear_expectations();
7+
end;
8+
39
procedure blob_not_null
410
is
511
begin
6-
expectations_helpers.execute_unary_expectation('not_to_be_null', 'blob', 'to_blob(''abc'')');
7-
expectations_helpers.test_success_expectacion;
12+
--Act
13+
execute immediate expectations_helpers.unary_expectation_block('not_to_be_null', 'blob', 'to_blob(''abc'')');
14+
--Assert
15+
ut.expect(anydata.convertCollection(ut3.ut_expectation_processor.get_failed_expectations())).to_be_empty();
816
end;
917

1018
procedure blob_0_lengt
1119
is
1220
begin
13-
expectations_helpers.execute_unary_expectation('not_to_be_null', 'blob', 'empty_blob()');
14-
expectations_helpers.test_success_expectacion;
21+
--Act
22+
execute immediate expectations_helpers.unary_expectation_block('not_to_be_null', 'blob', 'empty_blob()');
23+
--Assert
24+
ut.expect(anydata.convertCollection(ut3.ut_expectation_processor.get_failed_expectations())).to_be_empty();
1525
end;
1626

1727
procedure boolean_not_null
1828
is
1929
begin
20-
expectations_helpers.execute_unary_expectation('not_to_be_null', 'boolean', 'true');
21-
expectations_helpers.test_success_expectacion;
30+
--Act
31+
execute immediate expectations_helpers.unary_expectation_block('not_to_be_null', 'boolean', 'true');
32+
--Assert
33+
ut.expect(anydata.convertCollection(ut3.ut_expectation_processor.get_failed_expectations())).to_be_empty();
2234
end;
2335

2436
procedure clob_not_null
2537
is
2638
begin
27-
expectations_helpers.execute_unary_expectation('not_to_be_null', 'clob', 'to_clob(''abc'')');
28-
expectations_helpers.test_success_expectacion;
39+
--Act
40+
execute immediate expectations_helpers.unary_expectation_block('not_to_be_null', 'clob', 'to_clob(''abc'')');
41+
--Assert
42+
ut.expect(anydata.convertCollection(ut3.ut_expectation_processor.get_failed_expectations())).to_be_empty();
2943
end;
3044

3145

3246
procedure clob_0_lengt
3347
is
3448
begin
35-
expectations_helpers.execute_unary_expectation('not_to_be_null', 'clob', 'empty_clob()');
36-
expectations_helpers.test_success_expectacion;
49+
--Act
50+
execute immediate expectations_helpers.unary_expectation_block('not_to_be_null', 'clob', 'empty_clob()');
51+
--Assert
52+
ut.expect(anydata.convertCollection(ut3.ut_expectation_processor.get_failed_expectations())).to_be_empty();
3753
end;
3854

3955
procedure date_not_null
4056
is
4157
begin
42-
expectations_helpers.execute_unary_expectation('not_to_be_null', 'date', 'sysdate');
43-
expectations_helpers.test_success_expectacion;
58+
--Act
59+
execute immediate expectations_helpers.unary_expectation_block('not_to_be_null', 'date', 'sysdate');
60+
--Assert
61+
ut.expect(anydata.convertCollection(ut3.ut_expectation_processor.get_failed_expectations())).to_be_empty();
4462
end;
4563

4664
procedure number_not_null
4765
is
4866
begin
49-
expectations_helpers.execute_unary_expectation('not_to_be_null', 'number', '1234');
50-
expectations_helpers.test_success_expectacion;
67+
--Act
68+
execute immediate expectations_helpers.unary_expectation_block('not_to_be_null', 'number', '1234');
69+
--Assert
70+
ut.expect(anydata.convertCollection(ut3.ut_expectation_processor.get_failed_expectations())).to_be_empty();
5171
end;
5272

5373
procedure timestamp_not_null
5474
is
5575
begin
56-
expectations_helpers.execute_unary_expectation('not_to_be_null', 'timestamp', 'systimestamp');
57-
expectations_helpers.test_success_expectacion;
76+
--Act
77+
execute immediate expectations_helpers.unary_expectation_block('not_to_be_null', 'timestamp', 'systimestamp');
78+
--Assert
79+
ut.expect(anydata.convertCollection(ut3.ut_expectation_processor.get_failed_expectations())).to_be_empty();
5880
end;
5981

6082
procedure timestamp_with_ltz_not_null
6183
is
6284
begin
63-
expectations_helpers.execute_unary_expectation('not_to_be_null', 'timestamp with local time zone', 'systimestamp');
64-
expectations_helpers.test_success_expectacion;
85+
--Act
86+
execute immediate expectations_helpers.unary_expectation_block('not_to_be_null', 'timestamp with local time zone', 'systimestamp');
87+
--Assert
88+
ut.expect(anydata.convertCollection(ut3.ut_expectation_processor.get_failed_expectations())).to_be_empty();
6589
end;
6690

6791
procedure timestamp_with_tz_not_null
6892
is
6993
begin
70-
expectations_helpers.execute_unary_expectation('not_to_be_null', 'timestamp with time zone', 'systimestamp');
71-
expectations_helpers.test_success_expectacion;
94+
--Act
95+
execute immediate expectations_helpers.unary_expectation_block('not_to_be_null', 'timestamp with time zone', 'systimestamp');
96+
--Assert
97+
ut.expect(anydata.convertCollection(ut3.ut_expectation_processor.get_failed_expectations())).to_be_empty();
7298
end;
7399

74100
procedure varchar2_not_null
75101
is
76102
begin
77-
expectations_helpers.execute_unary_expectation('not_to_be_null', 'varchar2(4000)', '''abc''');
78-
expectations_helpers.test_success_expectacion;
103+
--Act
104+
execute immediate expectations_helpers.unary_expectation_block('not_to_be_null', 'varchar2(4000)', '''abc''');
105+
--Assert
106+
ut.expect(anydata.convertCollection(ut3.ut_expectation_processor.get_failed_expectations())).to_be_empty();
79107
end;
80108

81109
procedure null_blob
82110
is
83111
begin
84-
expectations_helpers.execute_unary_expectation('not_to_be_null', 'blob', 'null');
85-
expectations_helpers.test_failure_expectacion;
112+
--Act
113+
execute immediate expectations_helpers.unary_expectation_block('not_to_be_null', 'blob', 'null');
114+
--Assert
115+
ut.expect(anydata.convertCollection(ut3.ut_expectation_processor.get_failed_expectations())).not_to_be_empty();
86116
end;
87117

88118

89119
procedure null_boolean
90120
is
91121
begin
92-
expectations_helpers.execute_unary_expectation('not_to_be_null', 'boolean', 'null');
93-
expectations_helpers.test_failure_expectacion;
122+
--Act
123+
execute immediate expectations_helpers.unary_expectation_block('not_to_be_null', 'boolean', 'null');
124+
--Assert
125+
ut.expect(anydata.convertCollection(ut3.ut_expectation_processor.get_failed_expectations())).not_to_be_empty();
94126
end;
95127

96128

97129
procedure null_clob
98130
is
99131
begin
100-
expectations_helpers.execute_unary_expectation('not_to_be_null', 'clob', 'null');
101-
expectations_helpers.test_failure_expectacion;
132+
--Act
133+
execute immediate expectations_helpers.unary_expectation_block('not_to_be_null', 'clob', 'null');
134+
--Assert
135+
ut.expect(anydata.convertCollection(ut3.ut_expectation_processor.get_failed_expectations())).not_to_be_empty();
102136
end;
103137

104138

105139
procedure null_date
106140
is
107141
begin
108-
expectations_helpers.execute_unary_expectation('not_to_be_null', 'date', 'null');
109-
expectations_helpers.test_failure_expectacion;
142+
--Act
143+
execute immediate expectations_helpers.unary_expectation_block('not_to_be_null', 'date', 'null');
144+
--Assert
145+
ut.expect(anydata.convertCollection(ut3.ut_expectation_processor.get_failed_expectations())).not_to_be_empty();
110146
end;
111147

112148

113149
procedure null_number
114150
is
115151
begin
116-
expectations_helpers.execute_unary_expectation('not_to_be_null', 'number', 'null');
117-
expectations_helpers.test_failure_expectacion;
152+
--Act
153+
execute immediate expectations_helpers.unary_expectation_block('not_to_be_null', 'number', 'null');
154+
--Assert
155+
ut.expect(anydata.convertCollection(ut3.ut_expectation_processor.get_failed_expectations())).not_to_be_empty();
118156
end;
119157

120158

121159
procedure null_timestamp
122160
is
123161
begin
124-
expectations_helpers.execute_unary_expectation('not_to_be_null', 'timestamp', 'null');
125-
expectations_helpers.test_failure_expectacion;
162+
--Act
163+
execute immediate expectations_helpers.unary_expectation_block('not_to_be_null', 'timestamp', 'null');
164+
--Assert
165+
ut.expect(anydata.convertCollection(ut3.ut_expectation_processor.get_failed_expectations())).not_to_be_empty();
126166
end;
127167

128168

129169
procedure null_timestamp_with_ltz
130170
is
131171
begin
132-
expectations_helpers.execute_unary_expectation('not_to_be_null', 'timestamp with local time zone', 'null');
133-
expectations_helpers.test_failure_expectacion;
172+
--Act
173+
execute immediate expectations_helpers.unary_expectation_block('not_to_be_null', 'timestamp with local time zone', 'null');
174+
--Assert
175+
ut.expect(anydata.convertCollection(ut3.ut_expectation_processor.get_failed_expectations())).not_to_be_empty();
134176
end;
135177

136178

137179
procedure null_timestamp_with_tz
138180
is
139181
begin
140-
expectations_helpers.execute_unary_expectation('not_to_be_null', 'timestamp with time zone', 'null');
141-
expectations_helpers.test_failure_expectacion;
182+
--Act
183+
execute immediate expectations_helpers.unary_expectation_block('not_to_be_null', 'timestamp with time zone', 'null');
184+
--Assert
185+
ut.expect(anydata.convertCollection(ut3.ut_expectation_processor.get_failed_expectations())).not_to_be_empty();
142186
end;
143187

144188

145189
procedure null_varchar2
146190
is
147191
begin
148-
expectations_helpers.execute_unary_expectation('not_to_be_null', 'varchar2(4000)', 'null');
149-
expectations_helpers.test_failure_expectacion;
192+
--Act
193+
execute immediate expectations_helpers.unary_expectation_block('not_to_be_null', 'varchar2(4000)', 'null');
194+
--Assert
195+
ut.expect(anydata.convertCollection(ut3.ut_expectation_processor.get_failed_expectations())).not_to_be_empty();
150196
end;
151197

152198
end test_expect_not_to_be_null;

test/core/expectations/test_expect_not_to_be_null.pks

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ is
33
--%suite(expectations - not_to_be_null)
44
--%suitepath(utplsql.core.expectations.unary)
55

6+
--%aftereach
7+
procedure cleanup_expectations;
8+
69
--%test(Gives success for not null blob)
710
procedure blob_not_null;
811

Lines changed: 12 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
create or replace package body expectations_helpers
22
is
3-
procedure execute_unary_expectation(a_matcher_name in varchar2,
4-
a_data_type in varchar2,
5-
a_data_value in varchar2)
3+
function unary_expectation_block(a_matcher_name in varchar2,
4+
a_data_type in varchar2,
5+
a_data_value in varchar2)
6+
return varchar2
67
is
78
l_execute varchar2(32000);
89
begin
@@ -13,14 +14,15 @@ is
1314
ut3.ut.expect(l_expected).'||a_matcher_name||'();
1415
end;';
1516

16-
execute immediate l_execute;
17+
return l_execute;
1718
end;
1819

19-
procedure execute_binary_expectation(a_matcher_name in varchar2,
20-
a_data_type_1 in varchar2,
21-
a_data_value_1 in varchar2,
22-
a_data_type_2 in varchar2,
23-
a_data_value_2 in varchar2)
20+
function binary_expectation_block(a_matcher_name in varchar2,
21+
a_data_type_1 in varchar2,
22+
a_data_value_1 in varchar2,
23+
a_data_type_2 in varchar2,
24+
a_data_value_2 in varchar2)
25+
return varchar2
2426
is
2527
l_execute varchar2(32000);
2628
begin
@@ -32,27 +34,7 @@ is
3234
ut3.ut.expect(l_expected_1).'||a_matcher_name||'(l_expected_2);
3335
end;';
3436

35-
execute immediate l_execute;
36-
end;
37-
38-
procedure test_success_expectacion
39-
is
40-
begin
41-
--assert - check that expectation was a success
42-
ut.expect(ut3.ut_expectation_processor.get_status()).to_equal(ut3.ut_utils.tr_success);
43-
44-
-- cleanup
45-
ut3.ut_expectation_processor.clear_expectations();
46-
end;
47-
48-
procedure test_failure_expectacion
49-
is
50-
begin
51-
--assert - check that expectation was a failure
52-
ut.expect(ut3.ut_expectation_processor.get_status()).to_equal(ut3.ut_utils.tr_failure);
53-
54-
-- cleanup
55-
ut3.ut_expectation_processor.clear_expectations();
37+
return l_execute;
5638
end;
5739
end expectations_helpers;
5840
/
Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
create or replace package expectations_helpers
22
is
3-
procedure execute_unary_expectation(a_matcher_name in varchar2,
4-
a_data_type in varchar2,
5-
a_data_value in varchar2);
3+
function unary_expectation_block(a_matcher_name in varchar2,
4+
a_data_type in varchar2,
5+
a_data_value in varchar2)
6+
return varchar2;
67

7-
procedure execute_binary_expectation(a_matcher_name in varchar2,
8-
a_data_type_1 in varchar2,
9-
a_data_value_1 in varchar2,
10-
a_data_type_2 in varchar2,
11-
a_data_value_2 in varchar2);
12-
13-
procedure test_success_expectacion;
14-
15-
procedure test_failure_expectacion;
8+
function binary_expectation_block(a_matcher_name in varchar2,
9+
a_data_type_1 in varchar2,
10+
a_data_value_1 in varchar2,
11+
a_data_type_2 in varchar2,
12+
a_data_value_2 in varchar2)
13+
return varchar2;
1614
end expectations_helpers;
1715
/

0 commit comments

Comments
 (0)