From 9f31fcf44b25076f33ec6315ae1bac56d82dcc31 Mon Sep 17 00:00:00 2001 From: Walter Alexis Castro Date: Mon, 15 Jan 2018 20:02:40 -0600 Subject: [PATCH] Test refactored for the expectation to_be_null --- old_tests/RunAll.sql | 1 - ...expect.unuary_comparator.scalar.common.sql | 16 - .../ut_expectations/ut.expect.to_be_null.sql | 19 -- .../expectations/test_expect_to_be_null.pkb | 289 ++++++++++++++++++ .../expectations/test_expect_to_be_null.pks | 97 ++++++ test/install_tests.sql | 2 + 6 files changed, 388 insertions(+), 36 deletions(-) delete mode 100644 old_tests/ut_expectations/common/ut.expect.unuary_comparator.scalar.common.sql delete mode 100644 old_tests/ut_expectations/ut.expect.to_be_null.sql create mode 100644 test/core/expectations/test_expect_to_be_null.pkb create mode 100644 test/core/expectations/test_expect_to_be_null.pks diff --git a/old_tests/RunAll.sql b/old_tests/RunAll.sql index a7b2da3a1..2ce07b801 100644 --- a/old_tests/RunAll.sql +++ b/old_tests/RunAll.sql @@ -46,7 +46,6 @@ exec ut_coverage.coverage_start_develop(); @@lib/RunTest.sql ut_expectations/ut.expect.to_be_null.anydata.GivesSuccessWhenAnydataIsNull.sql @@lib/RunTest.sql ut_expectations/ut.expect.to_be_null.anydata.GivesSuccessWhenCollectionPassedIsNull.sql @@lib/RunTest.sql ut_expectations/ut.expect.to_be_null.anydata.GivesSuccessWhenObjectPassedIsNull.sql -@@ut_expectations/ut.expect.to_be_null.sql @@lib/RunTest.sql ut_expectations/ut.expect.to_be_true.GivesFailureWhenExpessionIsFalse.sql @@lib/RunTest.sql ut_expectations/ut.expect.to_be_true.GivesFailureWhenExpessionIsNotBoolean.sql @@lib/RunTest.sql ut_expectations/ut.expect.to_be_true.GivesFailureWhenExpessionIsNull.sql diff --git a/old_tests/ut_expectations/common/ut.expect.unuary_comparator.scalar.common.sql b/old_tests/ut_expectations/common/ut.expect.unuary_comparator.scalar.common.sql deleted file mode 100644 index 0cd8554d5..000000000 --- a/old_tests/ut_expectations/common/ut.expect.unuary_comparator.scalar.common.sql +++ /dev/null @@ -1,16 +0,0 @@ ---Arrange -declare - l_actual &&1 := &&2; - l_result integer; -begin ---Act - ut.expect(l_actual).&&3(); - l_result := ut_expectation_processor.get_status(); ---Assert - if nvl(:test_result, ut_utils.tr_success) = ut_utils.tr_success and l_result = &&4 then - :test_result := ut_utils.tr_success; - else - dbms_output.put_line(q'[expected: &&2 &&3]' ); - end if; -end; -/ diff --git a/old_tests/ut_expectations/ut.expect.to_be_null.sql b/old_tests/ut_expectations/ut.expect.to_be_null.sql deleted file mode 100644 index 707a1f166..000000000 --- a/old_tests/ut_expectations/ut.expect.to_be_null.sql +++ /dev/null @@ -1,19 +0,0 @@ -@@lib/RunTest.sql "ut_expectations/common/ut.expect.unuary_comparator.scalar.common.sql 'blob' 'to_blob(''abc'')' 'to_be_null' 'ut_utils.tr_failure'" -@@lib/RunTest.sql "ut_expectations/common/ut.expect.unuary_comparator.scalar.common.sql 'boolean' 'true' 'to_be_null' 'ut_utils.tr_failure'" -@@lib/RunTest.sql "ut_expectations/common/ut.expect.unuary_comparator.scalar.common.sql 'clob' '''abc''' 'to_be_null' 'ut_utils.tr_failure'" -@@lib/RunTest.sql "ut_expectations/common/ut.expect.unuary_comparator.scalar.common.sql 'date' 'sysdate' 'to_be_null' 'ut_utils.tr_failure'" -@@lib/RunTest.sql "ut_expectations/common/ut.expect.unuary_comparator.scalar.common.sql 'number' '1234' 'to_be_null' 'ut_utils.tr_failure'" -@@lib/RunTest.sql "ut_expectations/common/ut.expect.unuary_comparator.scalar.common.sql 'timestamp' 'systimestamp' 'to_be_null' 'ut_utils.tr_failure'" -@@lib/RunTest.sql "ut_expectations/common/ut.expect.unuary_comparator.scalar.common.sql 'timestamp with local time zone' 'systimestamp' 'to_be_null' 'ut_utils.tr_failure'" -@@lib/RunTest.sql "ut_expectations/common/ut.expect.unuary_comparator.scalar.common.sql 'timestamp with time zone' 'systimestamp' 'to_be_null' 'ut_utils.tr_failure'" -@@lib/RunTest.sql "ut_expectations/common/ut.expect.unuary_comparator.scalar.common.sql 'varchar2(4000)' '''abc''' 'to_be_null' 'ut_utils.tr_failure'" - -@@lib/RunTest.sql "ut_expectations/common/ut.expect.unuary_comparator.scalar.common.sql 'blob' 'NULL' 'to_be_null' 'ut_utils.tr_success'" -@@lib/RunTest.sql "ut_expectations/common/ut.expect.unuary_comparator.scalar.common.sql 'boolean' 'NULL' 'to_be_null' 'ut_utils.tr_success'" -@@lib/RunTest.sql "ut_expectations/common/ut.expect.unuary_comparator.scalar.common.sql 'clob' 'NULL' 'to_be_null' 'ut_utils.tr_success'" -@@lib/RunTest.sql "ut_expectations/common/ut.expect.unuary_comparator.scalar.common.sql 'date' 'NULL' 'to_be_null' 'ut_utils.tr_success'" -@@lib/RunTest.sql "ut_expectations/common/ut.expect.unuary_comparator.scalar.common.sql 'number' 'NULL' 'to_be_null' 'ut_utils.tr_success'" -@@lib/RunTest.sql "ut_expectations/common/ut.expect.unuary_comparator.scalar.common.sql 'timestamp' 'NULL' 'to_be_null' 'ut_utils.tr_success'" -@@lib/RunTest.sql "ut_expectations/common/ut.expect.unuary_comparator.scalar.common.sql 'timestamp with local time zone' 'NULL' 'to_be_null' 'ut_utils.tr_success'" -@@lib/RunTest.sql "ut_expectations/common/ut.expect.unuary_comparator.scalar.common.sql 'timestamp with time zone' 'NULL' 'to_be_null' 'ut_utils.tr_success'" -@@lib/RunTest.sql "ut_expectations/common/ut.expect.unuary_comparator.scalar.common.sql 'varchar2(4000)' 'NULL' 'to_be_null' 'ut_utils.tr_success'" diff --git a/test/core/expectations/test_expect_to_be_null.pkb b/test/core/expectations/test_expect_to_be_null.pkb new file mode 100644 index 000000000..47dbb4714 --- /dev/null +++ b/test/core/expectations/test_expect_to_be_null.pkb @@ -0,0 +1,289 @@ +create or replace package body test_expect_to_be_null +is + gc_object_name constant varchar2(30) := 't_to_be_null_test'; + gc_nested_table_name constant varchar2(30) := 'tt_to_be_null_test'; + gc_varray_name constant varchar2(30) := 'tv_to_be_null_test'; + + procedure cleanup_expectations + is + begin + ut3.ut_expectation_processor.clear_expectations(); + end; + + procedure create_types + is + pragma autonomous_transaction; + begin + execute immediate 'create type '||gc_object_name||' is object (dummy number)'; + execute immediate 'create type '||gc_nested_table_name||' is table of number'; + execute immediate 'create type '||gc_varray_name||' is varray(1) of number'; + end; + + procedure drop_types + is + pragma autonomous_transaction; + begin + execute immediate 'drop type '||gc_object_name; + execute immediate 'drop type '||gc_nested_table_name; + execute immediate 'drop type '||gc_varray_name; + end; + + procedure null_blob + is + begin + --Act + execute immediate expectations_helpers.unary_expectation_block('to_be_null', 'blob', 'null'); + --Assert + ut.expect(anydata.convertCollection(ut3.ut_expectation_processor.get_failed_expectations())).to_be_empty(); + end; + + procedure null_boolean + is + begin + --Act + execute immediate expectations_helpers.unary_expectation_block('to_be_null', 'boolean', 'null'); + --Assert + ut.expect(anydata.convertCollection(ut3.ut_expectation_processor.get_failed_expectations())).to_be_empty(); + end; + + + procedure null_clob + is + begin + --Act + execute immediate expectations_helpers.unary_expectation_block('to_be_null', 'clob', 'null'); + --Assert + ut.expect(anydata.convertCollection(ut3.ut_expectation_processor.get_failed_expectations())).to_be_empty(); + end; + + + procedure null_date + is + begin + --Act + execute immediate expectations_helpers.unary_expectation_block('to_be_null', 'date', 'null'); + --Assert + ut.expect(anydata.convertCollection(ut3.ut_expectation_processor.get_failed_expectations())).to_be_empty(); + end; + + + procedure null_number + is + begin + --Act + execute immediate expectations_helpers.unary_expectation_block('to_be_null', 'number', 'null'); + --Assert + ut.expect(anydata.convertCollection(ut3.ut_expectation_processor.get_failed_expectations())).to_be_empty(); + end; + + + procedure null_timestamp + is + begin + --Act + execute immediate expectations_helpers.unary_expectation_block('to_be_null', 'timestamp', 'null'); + --Assert + ut.expect(anydata.convertCollection(ut3.ut_expectation_processor.get_failed_expectations())).to_be_empty(); + end; + + + procedure null_timestamp_with_ltz + is + begin + --Act + execute immediate expectations_helpers.unary_expectation_block('to_be_null', 'timestamp with local time zone', 'null'); + --Assert + ut.expect(anydata.convertCollection(ut3.ut_expectation_processor.get_failed_expectations())).to_be_empty(); + end; + + + procedure null_timestamp_with_tz + is + begin + --Act + execute immediate expectations_helpers.unary_expectation_block('to_be_null', 'timestamp with time zone', 'null'); + --Assert + ut.expect(anydata.convertCollection(ut3.ut_expectation_processor.get_failed_expectations())).to_be_empty(); + end; + + + procedure null_varchar2 + is + begin + --Act + execute immediate expectations_helpers.unary_expectation_block('to_be_null', 'varchar2(4000)', 'null'); + --Assert + ut.expect(anydata.convertCollection(ut3.ut_expectation_processor.get_failed_expectations())).to_be_empty(); + end; + + procedure null_anydata + is + begin + --Act + execute immediate expectations_helpers.unary_expectation_block('to_be_null', 'anydata', 'null'); + --Assert + ut.expect(anydata.convertCollection(ut3.ut_expectation_processor.get_failed_expectations())).to_be_empty(); + end; + + procedure uninit_object_in_anydata + is + begin + --Act + execute immediate expectations_helpers.unary_expectation_object_block('to_be_null', gc_object_name, + 'null', 'object'); + --Assert + ut.expect(anydata.convertCollection(ut3.ut_expectation_processor.get_failed_expectations())).to_be_empty(); + end; + + procedure uninit_nested_table_in_anydata + is + begin + --Act + execute immediate expectations_helpers.unary_expectation_object_block('to_be_null', gc_nested_table_name, + 'null', 'collection'); + --Assert + ut.expect(anydata.convertCollection(ut3.ut_expectation_processor.get_failed_expectations())).to_be_empty(); + end; + + procedure uninit_varray_in_anydata + is + begin + --Act + execute immediate expectations_helpers.unary_expectation_object_block('to_be_null', gc_varray_name, + 'null', 'collection'); + --Assert + ut.expect(anydata.convertCollection(ut3.ut_expectation_processor.get_failed_expectations())).to_be_empty(); + end; + + procedure blob_not_null + is + begin + --Act + execute immediate expectations_helpers.unary_expectation_block('to_be_null', 'blob', 'to_blob(''abc'')'); + --Assert + ut.expect(anydata.convertCollection(ut3.ut_expectation_processor.get_failed_expectations())).not_to_be_empty(); + end; + + procedure blob_0_length + is + begin + --Act + execute immediate expectations_helpers.unary_expectation_block('to_be_null', 'blob', 'empty_blob()'); + --Assert + ut.expect(anydata.convertCollection(ut3.ut_expectation_processor.get_failed_expectations())).not_to_be_empty(); + end; + + procedure boolean_not_null + is + begin + --Act + execute immediate expectations_helpers.unary_expectation_block('to_be_null', 'boolean', 'true'); + --Assert + ut.expect(anydata.convertCollection(ut3.ut_expectation_processor.get_failed_expectations())).not_to_be_empty(); + end; + + procedure clob_not_null + is + begin + --Act + execute immediate expectations_helpers.unary_expectation_block('to_be_null', 'clob', 'to_clob(''abc'')'); + --Assert + ut.expect(anydata.convertCollection(ut3.ut_expectation_processor.get_failed_expectations())).not_to_be_empty(); + end; + + + procedure clob_0_length + is + begin + --Act + execute immediate expectations_helpers.unary_expectation_block('to_be_null', 'clob', 'empty_clob()'); + --Assert + ut.expect(anydata.convertCollection(ut3.ut_expectation_processor.get_failed_expectations())).not_to_be_empty(); + end; + + procedure date_not_null + is + begin + --Act + execute immediate expectations_helpers.unary_expectation_block('to_be_null', 'date', 'sysdate'); + --Assert + ut.expect(anydata.convertCollection(ut3.ut_expectation_processor.get_failed_expectations())).not_to_be_empty(); + end; + + procedure number_not_null + is + begin + --Act + execute immediate expectations_helpers.unary_expectation_block('to_be_null', 'number', '1234'); + --Assert + ut.expect(anydata.convertCollection(ut3.ut_expectation_processor.get_failed_expectations())).not_to_be_empty(); + end; + + procedure timestamp_not_null + is + begin + --Act + execute immediate expectations_helpers.unary_expectation_block('to_be_null', 'timestamp', 'systimestamp'); + --Assert + ut.expect(anydata.convertCollection(ut3.ut_expectation_processor.get_failed_expectations())).not_to_be_empty(); + end; + + procedure timestamp_with_ltz_not_null + is + begin + --Act + execute immediate expectations_helpers.unary_expectation_block('to_be_null', 'timestamp with local time zone', 'systimestamp'); + --Assert + ut.expect(anydata.convertCollection(ut3.ut_expectation_processor.get_failed_expectations())).not_to_be_empty(); + end; + + procedure timestamp_with_tz_not_null + is + begin + --Act + execute immediate expectations_helpers.unary_expectation_block('to_be_null', 'timestamp with time zone', 'systimestamp'); + --Assert + ut.expect(anydata.convertCollection(ut3.ut_expectation_processor.get_failed_expectations())).not_to_be_empty(); + end; + + procedure varchar2_not_null + is + begin + --Act + execute immediate expectations_helpers.unary_expectation_block('to_be_null', 'varchar2(4000)', '''abc'''); + --Assert + ut.expect(anydata.convertCollection(ut3.ut_expectation_processor.get_failed_expectations())).not_to_be_empty(); + end; + + procedure initialized_object + is + begin + --Act + execute immediate expectations_helpers.unary_expectation_object_block('to_be_null', gc_object_name, + gc_object_name||'(1)', 'object'); + --Assert + ut.expect(anydata.convertCollection(ut3.ut_expectation_processor.get_failed_expectations())).not_to_be_empty(); + end; + + procedure initialized_nested_table + is + begin + --Act + execute immediate expectations_helpers.unary_expectation_object_block('to_be_null', gc_nested_table_name, + gc_nested_table_name||'()', 'collection'); + --Assert + ut.expect(anydata.convertCollection(ut3.ut_expectation_processor.get_failed_expectations())).not_to_be_empty(); + end; + + procedure initialized_varray + is + begin + --Act + execute immediate expectations_helpers.unary_expectation_object_block('to_be_null', gc_varray_name, + gc_varray_name||'()', 'collection'); + --Assert + ut.expect(anydata.convertCollection(ut3.ut_expectation_processor.get_failed_expectations())).not_to_be_empty(); + end; + +end test_expect_to_be_null; +/ diff --git a/test/core/expectations/test_expect_to_be_null.pks b/test/core/expectations/test_expect_to_be_null.pks new file mode 100644 index 000000000..6b625ec28 --- /dev/null +++ b/test/core/expectations/test_expect_to_be_null.pks @@ -0,0 +1,97 @@ +create or replace package test_expect_to_be_null +is + --%suite(expectations - to_be_null) + --%suitepath(utplsql.core.expectations.unary) + + --%aftereach + procedure cleanup_expectations; + + --%beforeall + procedure create_types; + + --%afterall + procedure drop_types; + + --%test(Gives success with null blob) + procedure null_blob; + + --%test(Gives success with null boolean) + procedure null_boolean; + + --%test(Gives success with null clob) + procedure null_clob; + + --%test(Gives success with null date) + procedure null_date; + + --%test(Gives success with null number) + procedure null_number; + + --%test(Gives success null timestamp) + procedure null_timestamp; + + --%test(Gives success with null timestamp with local time zone) + procedure null_timestamp_with_ltz; + + --%test(Gives success with null timestamp with time zone) + procedure null_timestamp_with_tz; + + --%test(Gives success with null varchar2) + procedure null_varchar2; + + --%test(Gives success with null anydata) + procedure null_anydata; + + --%test(Gives success with uninitialized object within anydata) + procedure uninit_object_in_anydata; + + --%test(Gives success with uninitialized nested table within anydata) + procedure uninit_nested_table_in_anydata; + + --%test(Gives success with uninitialized varray within anydata) + procedure uninit_varray_in_anydata; + + --%test(Gives failure for not null blob) + procedure blob_not_null; + + --%test(Gives failure for blob with length 0) + procedure blob_0_length; + + --%test(Gives failure for not null boolean) + procedure boolean_not_null; + + --%test(Gives failure for not null clob) + procedure clob_not_null; + + --%test(Gives failure for clob with length 0) + procedure clob_0_length; + + --%test(Gives failure for not null date) + procedure date_not_null; + + --%test(Gives failure for not null number) + procedure number_not_null; + + --%test(Gives failure for not null timestamp) + procedure timestamp_not_null; + + --%test(Gives failure for not null timestamp with local time zone) + procedure timestamp_with_ltz_not_null; + + --%test(Gives failure for not null timestamp with time zone) + procedure timestamp_with_tz_not_null; + + --%test(Gives failure for not null varchar2) + procedure varchar2_not_null; + + --%test(Gives failure for initialized object within anydata) + procedure initialized_object; + + --%test(Gives failure for initialized nested table within anydata) + procedure initialized_nested_table; + + --%test(Gives failure for initialized varray within anydata) + procedure initialized_varray; + +end test_expect_to_be_null; +/ diff --git a/test/install_tests.sql b/test/install_tests.sql index 422d20ad2..faf00775a 100644 --- a/test/install_tests.sql +++ b/test/install_tests.sql @@ -26,6 +26,7 @@ whenever oserror exit failure rollback @@core/expectations/test_expectations_cursor.pks @@core/expectations/test_expect_not_to_be_null.pks @@core/expectations/test_expect_to_be_not_null.pks +@@core/expectations/test_expect_to_be_null.pks @@test_ut_runner.pks @@core/annotations/test_annotation_manager.pks @@core/test_ut_suite.pks @@ -44,6 +45,7 @@ whenever oserror exit failure rollback @@core/expectations/test_expectations_cursor.pkb @@core/expectations/test_expect_not_to_be_null.pkb @@core/expectations/test_expect_to_be_not_null.pkb +@@core/expectations/test_expect_to_be_null.pkb @@test_ut_runner.pkb @@core/annotations/test_annotation_manager.pkb @@core/test_ut_suite.pkb