|
| 1 | +create or replace package body test_expec_not_to_be_null |
| 2 | +is |
| 3 | + |
| 4 | + procedure execute_expectation(a_data_type in varchar2, |
| 5 | + a_data_value in varchar2) |
| 6 | + is |
| 7 | + l_execute varchar2(32000); |
| 8 | + begin |
| 9 | + -- arrange |
| 10 | + l_execute := ' declare |
| 11 | + l_expected '||a_data_type||' := '||a_data_value||'; |
| 12 | + begin |
| 13 | + --act - execute the expectation |
| 14 | + ut3.ut.expect(l_expected).not_to_be_null(); |
| 15 | + end;'; |
| 16 | + |
| 17 | + execute immediate l_execute; |
| 18 | + end; |
| 19 | + |
| 20 | + procedure test_success_expectacion(a_data_type in varchar2, |
| 21 | + a_data_value in varchar2) |
| 22 | + is |
| 23 | + begin |
| 24 | + execute_expectation(a_data_type, a_data_value); |
| 25 | + |
| 26 | + --assert - check that expectation was executed successfully |
| 27 | + ut3_latest_release.ut.expect(ut3.ut_expectation_processor.get_status()).to_equal(ut3.ut_utils.tr_success); |
| 28 | + |
| 29 | + -- cleanup |
| 30 | + ut3.ut_expectation_processor.clear_expectations(); |
| 31 | + end; |
| 32 | + |
| 33 | + procedure test_failure_expectacion(a_data_type in varchar2, |
| 34 | + a_data_value in varchar2) |
| 35 | + is |
| 36 | + begin |
| 37 | + execute_expectation(a_data_type, a_data_value); |
| 38 | + |
| 39 | + --assert - check that expectation was a failure |
| 40 | + ut3_latest_release.ut.expect(ut3.ut_expectation_processor.get_status()).to_equal(ut3.ut_utils.tr_failure); |
| 41 | + |
| 42 | + -- cleanup |
| 43 | + ut3.ut_expectation_processor.clear_expectations(); |
| 44 | + end; |
| 45 | + |
| 46 | + procedure blob_not_null |
| 47 | + is |
| 48 | + begin |
| 49 | + test_success_expectacion('blob', 'to_blob(''abc'')'); |
| 50 | + end; |
| 51 | + |
| 52 | + procedure blob_0_lengt |
| 53 | + is |
| 54 | + begin |
| 55 | + test_success_expectacion('blob', 'empty_blob()'); |
| 56 | + end; |
| 57 | + |
| 58 | + procedure boolean_not_null |
| 59 | + is |
| 60 | + begin |
| 61 | + test_success_expectacion('boolean', 'true'); |
| 62 | + end; |
| 63 | + |
| 64 | + procedure clob_not_null |
| 65 | + is |
| 66 | + begin |
| 67 | + test_success_expectacion('clob', 'to_clob(''abc'')'); |
| 68 | + end; |
| 69 | + |
| 70 | + |
| 71 | + procedure clob_0_lengt |
| 72 | + is |
| 73 | + begin |
| 74 | + test_success_expectacion('clob', 'empty_clob()'); |
| 75 | + end; |
| 76 | + |
| 77 | + procedure date_not_null |
| 78 | + is |
| 79 | + begin |
| 80 | + test_success_expectacion('date', 'sysdate'); |
| 81 | + end; |
| 82 | + |
| 83 | + procedure number_not_null |
| 84 | + is |
| 85 | + begin |
| 86 | + test_success_expectacion('number', '1234'); |
| 87 | + end; |
| 88 | + |
| 89 | + procedure timestamp_not_null |
| 90 | + is |
| 91 | + begin |
| 92 | + test_success_expectacion('timestamp', 'systimestamp'); |
| 93 | + end; |
| 94 | + |
| 95 | + procedure timestamp_with_ltz_not_null |
| 96 | + is |
| 97 | + begin |
| 98 | + test_success_expectacion('timestamp with local time zone', 'systimestamp'); |
| 99 | + end; |
| 100 | + |
| 101 | + procedure timestamp_with_tz_not_null |
| 102 | + is |
| 103 | + begin |
| 104 | + test_success_expectacion('timestamp with time zone', 'systimestamp'); |
| 105 | + end; |
| 106 | + |
| 107 | + procedure varchar2_not_null |
| 108 | + is |
| 109 | + begin |
| 110 | + test_success_expectacion('varchar2(4000)', '''abc'''); |
| 111 | + end; |
| 112 | + |
| 113 | + procedure null_blob |
| 114 | + is |
| 115 | + begin |
| 116 | + test_failure_expectacion('blob', 'null'); |
| 117 | + end; |
| 118 | + |
| 119 | + |
| 120 | + procedure null_boolean |
| 121 | + is |
| 122 | + begin |
| 123 | + test_failure_expectacion('boolean', 'null'); |
| 124 | + end; |
| 125 | + |
| 126 | + |
| 127 | + procedure null_clob |
| 128 | + is |
| 129 | + begin |
| 130 | + test_failure_expectacion('clob', 'null'); |
| 131 | + end; |
| 132 | + |
| 133 | + |
| 134 | + procedure null_date |
| 135 | + is |
| 136 | + begin |
| 137 | + test_failure_expectacion('date', 'null'); |
| 138 | + end; |
| 139 | + |
| 140 | + |
| 141 | + procedure null_number |
| 142 | + is |
| 143 | + begin |
| 144 | + test_failure_expectacion('number', 'null'); |
| 145 | + end; |
| 146 | + |
| 147 | + |
| 148 | + procedure null_timestamp |
| 149 | + is |
| 150 | + begin |
| 151 | + test_failure_expectacion('timestamp', 'null'); |
| 152 | + end; |
| 153 | + |
| 154 | + |
| 155 | + procedure null_timestamp_with_ltz |
| 156 | + is |
| 157 | + begin |
| 158 | + test_failure_expectacion('timestamp with local time zone', 'null'); |
| 159 | + end; |
| 160 | + |
| 161 | + |
| 162 | + procedure null_timestamp_with_tz |
| 163 | + is |
| 164 | + begin |
| 165 | + test_failure_expectacion('timestamp with time zone', 'null'); |
| 166 | + end; |
| 167 | + |
| 168 | + |
| 169 | + procedure null_varchar2 |
| 170 | + is |
| 171 | + begin |
| 172 | + test_failure_expectacion('varchar2(4000)', 'null'); |
| 173 | + end; |
| 174 | + |
| 175 | +end test_expec_not_to_be_null; |
0 commit comments