@@ -64,6 +64,39 @@ create or replace package body test_annotation_manager is
6464 commit;
6565 end;
6666
67+ procedure setup_cache is
68+ pragma autonomous_transaction;
69+ begin
70+ create_dummy_test_package();
71+ execute immediate q'[create or replace procedure dummy_test_procedure as
72+ --%some_annotation(some_text)
73+ --%rollback(manual)
74+ begin
75+ null;
76+ end;]';
77+ execute immediate q'[create or replace procedure ut3.dummy_test_procedure as
78+ --%some_annotation(some_text)
79+ --%rollback(manual)
80+ begin
81+ null;
82+ end;]';
83+ ut3.ut_annotation_manager.rebuild_annotation_cache(user,'PACKAGE');
84+ ut3.ut_annotation_manager.rebuild_annotation_cache(user,'PROCEDURE');
85+ ut3.ut_annotation_manager.rebuild_annotation_cache('UT3','PROCEDURE');
86+ end;
87+
88+ procedure cleanup_cache is
89+ pragma autonomous_transaction;
90+ begin
91+ delete from ut3.ut_annotation_cache_info
92+ where object_type = 'PROCEDURE' and object_owner in ('UT3',user)
93+ or object_type = 'PACKAGE' and object_owner = user and object_name = 'DUMMY_TEST_PACKAGE';
94+ drop_dummy_test_package();
95+ execute immediate q'[drop procedure dummy_test_procedure]';
96+ execute immediate q'[drop procedure ut3.dummy_test_procedure]';
97+ end;
98+
99+
67100
68101 procedure add_new_package is
69102 l_actual_cache_id integer;
@@ -143,7 +176,8 @@ create or replace package body test_annotation_manager is
143176
144177 open l_actual for
145178 select annotation_position, annotation_name, annotation_text, subobject_name
146- from ut3.ut_annotation_cache where cache_id = l_actual_cache_id;
179+ from ut3.ut_annotation_cache where cache_id = l_actual_cache_id
180+ order by annotation_position;
147181
148182 open l_expected for
149183 select 1 as annotation_position, 'suite' as annotation_name,
@@ -183,7 +217,8 @@ create or replace package body test_annotation_manager is
183217
184218 open l_actual for
185219 select annotation_position, annotation_name, annotation_text, subobject_name
186- from ut3.ut_annotation_cache where cache_id = l_actual_cache_id;
220+ from ut3.ut_annotation_cache where cache_id = l_actual_cache_id
221+ order by annotation_position;
187222
188223 open l_expected for
189224 select 1 as annotation_position, 'suite' as annotation_name,
@@ -219,7 +254,8 @@ create or replace package body test_annotation_manager is
219254
220255 open l_actual for
221256 select annotation_position, annotation_name, annotation_text, subobject_name
222- from ut3.ut_annotation_cache where cache_id = l_actual_cache_id;
257+ from ut3.ut_annotation_cache where cache_id = l_actual_cache_id
258+ order by annotation_position;
223259
224260 open l_expected for
225261 select 1 as annotation_position, 'suite' as annotation_name,
@@ -249,5 +285,36 @@ create or replace package body test_annotation_manager is
249285 ut.expect(l_actual).to_be_empty();
250286 end;
251287
288+ procedure test_purge_schema_type is
289+ l_actual sys_refcursor;
290+ begin
291+
292+ open l_actual for
293+ select * from ut3.ut_annotation_cache_info
294+ where object_owner = user and object_type = 'PROCEDURE';
295+ ut.expect(l_actual).not_to_be_empty();
296+
297+ --Act
298+ ut3.ut_annotation_cache_manager.purge_cache(user,'PROCEDURE');
299+
300+ --Assert
301+ open l_actual for
302+ select * from ut3.ut_annotation_cache_info
303+ where object_owner = user and object_type = 'PROCEDURE';
304+ --Cache purged for object owner/type
305+ ut.expect(l_actual).to_be_empty();
306+ open l_actual for
307+ select * from ut3.ut_annotation_cache_info
308+ where object_owner = user and object_type = 'PACKAGE';
309+ --Cache not purged for other types
310+ ut.expect(l_actual).not_to_be_empty();
311+ open l_actual for
312+ select * from ut3.ut_annotation_cache_info
313+ where object_owner != user and object_type = 'PROCEDURE';
314+ --Cache not purged for other owners
315+ ut.expect(l_actual).not_to_be_empty();
316+
317+ end;
318+
252319end test_annotation_manager;
253320/
0 commit comments