DBA Data[Home] [Help]

PACKAGE BODY: APPS.CSK_DIAG_SOLUTION_PVT

Source


1 PACKAGE BODY CSK_DIAG_SOLUTION_PVT AS
2   /* $Header: csktsolb.pls 120.1 2005/06/22 12:33:58 appldev noship $ */
3 
4     --CHANGE_PARENT_CATEGORY_TEST
5     g_move_solutions_test_c1ID NUMBER;
6     g_move_solutions_test_c2ID NUMBER;
7     g_move_solutions_test_s1_aID NUMBER;
8     g_move_solutions_test_s1_bID NUMBER;
9 ------------------
10 -- init
11 ------------------
12 --This procedure does not take any parameters and is always called prior to the
13 --runTest procedure being executed. In this procedure, implement the code for any
14 --data structures that need to be set up before the test runs.
15 --
16 PROCEDURE init
17 IS
18   l_return_status varchar2(1) := '';
19   l_msg_count number := 0;
20   l_msg_data varchar2(4000) := '';
21 
22   l_P_SET_DEF_REC   CSK_SETUP_UTILITY_PKG.Soln_rec_type;
23   l_P_ELE_DEF_TBL   CSK_SETUP_UTILITY_PKG.Stmt_tbl_type;
24   l_P_CAT_DEF_TBL   CSK_SETUP_UTILITY_PKG.Cat_tbl_type;
25 BEGIN
26     FND_GLOBAL.APPS_initialize(1000667,21782,170,null,null);
27     CSK_SETUP_UTILITY_PKG.validate_seeded_setups(p_api_version => 1.0,
28                                                  x_return_status => l_return_status,
29                                                  x_msg_count => l_msg_count,
30                                                  x_msg_data => l_msg_data);
31     --MOVE_SOLUTIONS_TEST
32     g_move_solutions_test_c1ID := CSK_SETUP_UTILITY_PKG.get_next_category_id();
33     CSK_SETUP_UTILITY_PKG.Create_Category (
34         p_api_version        => 1.0,
35         x_return_status      => l_return_status,
36         x_msg_count          => l_msg_count,
37         x_msg_data           => l_msg_data,
38         P_PARENT_CATEGORY_ID => 1,
39         P_CATEGORY_ID        => g_move_solutions_test_c1ID,
40         P_CATEGORY_NAME      => 'Move Solutions Test Category c1',
41         P_VISIBILITY_ID      => CSK_SETUP_UTILITY_PKG.VISIBILITY_EXTERNAL_API_TEST);
42 
43     g_move_solutions_test_c2ID := CSK_SETUP_UTILITY_PKG.get_next_category_id();
44     CSK_SETUP_UTILITY_PKG.Create_Category (
45         p_api_version        => 1.0,
46         x_return_status      => l_return_status,
47         x_msg_count          => l_msg_count,
48         x_msg_data           => l_msg_data,
49         P_PARENT_CATEGORY_ID => 1,
50         P_CATEGORY_ID        => g_move_solutions_test_c2ID,
51         P_CATEGORY_NAME      => 'Move Solutions Test Category c2',
52         P_VISIBILITY_ID      => CSK_SETUP_UTILITY_PKG.VISIBILITY_EXTERNAL_API_TEST);
53 
54 
55     g_move_solutions_test_s1_aID := CSK_SETUP_UTILITY_PKG.get_next_set_id();
56     l_P_SET_DEF_REC.SET_ID :=   g_move_solutions_test_s1_aID;
57     l_P_SET_DEF_REC.SET_NUMBER :=   CSK_SETUP_UTILITY_PKG.get_next_set_number();
58     l_P_SET_DEF_REC.SET_TYPE_ID :=   CSK_SETUP_UTILITY_PKG.SOLN_TYPE_FAQ_API_TEST;
59     l_P_SET_DEF_REC.NAME :=   'Move Solution Test s1_a';
60     l_P_SET_DEF_REC.visibility_id :=   CSK_SETUP_UTILITY_PKG.VISIBILITY_EXTERNAL_API_TEST;
61 
62     l_P_ELE_DEF_TBL := CSK_SETUP_UTILITY_PKG.Stmt_tbl_type();
63 
64     l_P_CAT_DEF_TBL := CSK_SETUP_UTILITY_PKG.Cat_tbl_type();
65     l_P_CAT_DEF_TBL.EXTEND;
66     l_P_CAT_DEF_TBL(1) := g_move_solutions_test_c1ID;
67 
68     CSK_SETUP_UTILITY_PKG.Create_Solution(
69         p_api_version        => 1.0,
70         x_return_status      => l_return_status,
71         x_msg_count          => l_msg_count,
72         x_msg_data           => l_msg_data,
73         P_SOLN_REC => l_P_SET_DEF_REC
74         ,P_STMT_TBL => l_P_ELE_DEF_TBL
75         ,P_CAT_TBL  => l_P_CAT_DEF_TBL
76         ,P_PUBLISH => true );
77 
78     g_move_solutions_test_s1_bID := CSK_SETUP_UTILITY_PKG.get_next_set_id();
79     l_P_SET_DEF_REC.SET_ID :=   g_move_solutions_test_s1_bID;
80     l_P_SET_DEF_REC.NAME :=   'Move Solution Test Solution s1_b';
81     CSK_SETUP_UTILITY_PKG.Create_Solution(
82         p_api_version        => 1.0,
83         x_return_status      => l_return_status,
84         x_msg_count          => l_msg_count,
85         x_msg_data           => l_msg_data,
86         P_SOLN_REC => l_P_SET_DEF_REC
87         ,P_STMT_TBL => l_P_ELE_DEF_TBL
88         ,P_CAT_TBL  => l_P_CAT_DEF_TBL
89         ,P_PUBLISH => false );
90 
91     commit;
92 END init;
93 
94 ------------------
95 -- cleanup
96 ------------------
97 PROCEDURE cleanup
98 IS
99     l_return_status varchar2(200);
100     l_msg_count number;
101     l_msg_data  varchar2(200);
102 begin
103 
104     CSK_SETUP_UTILITY_PKG.delete_solution(
105         p_api_version        => 1.0,
106         x_return_status      => l_return_status,
107         x_msg_count          => l_msg_count,
108         x_msg_data           => l_msg_data,
109         P_set_ID        => g_move_solutions_test_s1_aID);
110     CSK_SETUP_UTILITY_PKG.delete_solution(
111         p_api_version        => 1.0,
112         x_return_status      => l_return_status,
113         x_msg_count          => l_msg_count,
114         x_msg_data           => l_msg_data,
115         P_set_ID        => g_move_solutions_test_s1_bID);
116     CSK_SETUP_UTILITY_PKG.Delete_Category (
117         p_api_version        => 1.0,
118         x_return_status      => l_return_status,
119         x_msg_count          => l_msg_count,
120         x_msg_data           => l_msg_data,
121         P_CATEGORY_ID        => g_move_solutions_test_c1ID);
122     CSK_SETUP_UTILITY_PKG.Delete_Category (
123         p_api_version        => 1.0,
124         x_return_status      => l_return_status,
125         x_msg_count          => l_msg_count,
126         x_msg_data           => l_msg_data,
127         P_CATEGORY_ID        => g_move_solutions_test_c2ID);
128 
129     commit;
130 END cleanup;
131 
132 ------------------
133 -- getComponentName
134 ------------------
135 PROCEDURE getComponentName(name  OUT NOCOPY VARCHAR2)
136 IS
137 BEGIN
138 name := 'cs_kb_solution_pvt';
139 END getComponentName;
140 
141 ------------------
142 -- getTestName
143 ------------------
144 PROCEDURE getTestName(name OUT NOCOPY VARCHAR2)
145 IS
146 BEGIN
147 name := 'cs_kb_solution_pvt Test';
148 END getTestName;
149 
150 ------------------
151 -- getTestDesc
152 ------------------
153 PROCEDURE getTestDesc(descStr OUT NOCOPY VARCHAR2)
154 IS
155 BEGIN
156 descStr := 'This test will test functions in cs_kb_solution_pvt';
157 END getTestDesc;
158 
159 ------------------
160 -- getDefaultTestParams
161 ------------------
162 -- procedure to provide the default parameters for the test case.
163 -- please note the paramters have to be registered through the UI
164 -- before basic tests can be run.
165 --
166 PROCEDURE getDefaultTestParams(defaultInputValues OUT NOCOPY JTF_DIAG_INPUTTBL)
167 IS
168 tempInput JTF_DIAG_INPUTTBL;
169 BEGIN
170 -- If the Unit Test requires Input Parameters the defaults can be set up as follows:
171 tempInput := JTF_DIAGNOSTIC_ADAPTUTIL.initinputtable;
172 --tempInput := JTF_DIAGNOSTIC_ADAPTUTIL.addInput(tempInput,'DEMO VALUE','1');
173 defaultInputValues := tempInput;
174 EXCEPTION
175 when others then
176 defaultInputValues := JTF_DIAGNOSTIC_ADAPTUTIL.initinputtable;
177 END getDefaultTestParams;
178 
179 ------------------
180 -- currentUser
181 ------------------
182 --
183 PROCEDURE currentUser
184 IS
185  sqltxt VARCHAR2(2000);
186  dummy_num NUMBER;
187 BEGIN
188  -- If you want to display the output of a Simple SQL query it can be achieved as follows:
189  sqltxt := ' select fnd_global.user_id, fnd_global.USER_NAME '||
190            ' , fnd_global.APPLICATION_SHORT_NAME '||
191            ' , fnd_global.APPLICATION_NAME '||
192            ' , fnd_global.RESP_NAME '||
193            ' from dual ';
194  dummy_num:= JTF_DIAGNOSTIC_COREAPI.display_sql(sqltxt,'Current User Information');
195 END currentUser;
196 ------------------
197 -- cascadeDeleteTest
198 ------------------
199 --
200 PROCEDURE moveSolutionsTest IS
201   l_STATUS   VARCHAR2(2000);
202   l_RETURN_STATUS   VARCHAR2(2000);
203   l_MSG_DATA   VARCHAR2(2000);
204   l_MSG_COUNT   NUMBER;
205   l_value NUMBER;
206   l_count NUMBER;
207   l_count_1 NUMBER;
208   l_count_2 NUMBER;
209   l_success varchar2(1) := 'N';
210   l_soln_ids JTF_NUMBER_TABLE := JTF_NUMBER_TABLE();
211 
212   l_index_content varchar2(4000) := '';
213   l_start_tag number;
214   l_end_tag number;
215   l_categories_section varchar2(4000) := '';
216 
217 BEGIN
218  JTF_DIAGNOSTIC_COREAPI.line_out('<br><font color=blue> <b> Test Name </b></font> Move Solutions Test  ');
219  JTF_DIAGNOSTIC_COREAPI.line_out('<br><font color=blue> <b> Test Ref </b></font>  CS_KB_SOLN_CATEGORIES_PVT_MOVE_SOLUTIONS_TEST');
220  -- step 10
221     l_soln_ids.EXTEND;
222     l_soln_ids(1) := g_move_solutions_test_s1_aID;
223     l_soln_ids.EXTEND;
224     l_soln_ids(2) := g_move_solutions_test_s1_bID;
225 
226    cs_kb_solution_pvt.move_solutions(1.0,
227                                      x_return_status => l_RETURN_STATUS,
228                                      x_msg_count => l_MSG_COUNT,
229                                      x_msg_data => l_MSG_DATA,
230                                      p_set_ids => l_soln_ids,
231                                      p_src_cat_id => g_move_solutions_test_c1ID,
232                                      p_dest_cat_id => g_move_solutions_test_c2ID );
233    IF (l_RETURN_STATUS = 'E') THEN
234      l_success := 'N';
235    ELSE
236      l_success := 'Y';
237    END IF;
238 
239    IF l_success = 'Y' THEN
240     JTF_DIAGNOSTIC_COREAPI.line_out('<br><b>' ||'SUCCESS: [ 10] moveSolutions() execution </b>');
241         --Step 20
242         select count(1) into l_count_1
243         from cs_kb_set_categories
244         where set_id = g_move_solutions_test_s1_aID and category_id = g_move_solutions_test_c2ID;
245         select count(1) into l_count_2
246         from cs_kb_set_categories
247         where set_id = g_move_solutions_test_s1_bID and category_id = g_move_solutions_test_c2ID;
248         if l_count_1 = 1 and l_count_2 = 1 then
249             JTF_DIAGNOSTIC_COREAPI.line_out('<br><b>' ||'SUCCESS: [ 20] solutions have been moved into c2</b>');
250             --step 30
251             select count(1) into l_count_1
252             from cs_kb_set_categories
253             where set_id = g_move_solutions_test_s1_aID and category_id = g_move_solutions_test_c1ID;
254             select count(1) into l_count_2
255             from cs_kb_set_categories
256             where set_id = g_move_solutions_test_s1_bID and category_id = g_move_solutions_test_c1ID;
257             if l_count_1 = 0 and l_count_2 = 0 then
258                 JTF_DIAGNOSTIC_COREAPI.line_out('<br><b>' ||'SUCCESS: [ 30] solutions have been moved out of c1</b>');
259                 --step 40
260                 l_index_content := CSK_SETUP_UTILITY_PKG.Calculate_Set_Index_Content(g_move_solutions_test_s1_aID);
261                 select INSTR(l_index_content,'</CATEGORIES>') into l_end_tag from dual;
262                 if (l_end_tag > 0) then
263                     select INSTR(l_index_content,'<CATEGORIES>') into l_start_tag from dual;
264                     l_categories_section := substr(l_index_content,l_start_tag+12,l_end_tag-l_start_tag-12);
265                     select INSTR(l_categories_section,'a'||g_move_solutions_test_c2ID||'a') into l_count from dual;
266                     if(l_count > 0) then
267                         JTF_DIAGNOSTIC_COREAPI.line_out('<br><b>' ||'SUCCESS: [ 40] text index of child solution updated. </b>');
268                     else
269                         l_success := 'N';
270                         JTF_DIAGNOSTIC_COREAPI.ActionErrorPrint('<br><b>' ||'FAILED : [ 40] text index of child solution updated. </b>');
271                         l_statusStr := 'FAILURE';
272                         l_errStr := l_errStr||'<BR> text index of child solution was not updated correctly';
273                         l_fixInfo := '.';
274                         l_isFatal := 'TRUE';
275                     end if;
276                 else
277                     JTF_DIAGNOSTIC_COREAPI.ActionErrorPrint('<br><b>' ||'WARNING: [ 50] Cannot fetch the whole <CATEGORIES> section.</b>');
278                 end if;
279             else
280                 JTF_DIAGNOSTIC_COREAPI.ActionErrorPrint('<br><b>' ||'FAILED : [ 30] solutions have been moved out of c1 </b>');
281                 l_statusStr := 'FAILURE';
285             end if;
282                 l_errStr := l_errStr||'<BR> solutions have not been moved into c2';
283                 l_fixInfo := '.';
284                 l_isFatal := 'TRUE';
286 
287         else
288             JTF_DIAGNOSTIC_COREAPI.ActionErrorPrint('<br><b>' ||'FAILED : [ 20] solutions have been moved into c2 </b>');
289             l_statusStr := 'FAILURE';
290             l_errStr := l_errStr||'<BR> solutions have not been moved into c2';
291             l_fixInfo := '.';
292             l_isFatal := 'TRUE';
293         end if;
294    ELSE
295     JTF_DIAGNOSTIC_COREAPI.ActionErrorPrint('<br><b>' ||'FAILED : [ 10] moveSolutions() execution </b>');
296     l_statusStr := 'FAILURE';
297     l_errStr := l_errStr||'<BR> moveSolutions() execution failed';
298     l_fixInfo := '.';
299     l_isFatal := 'TRUE';
300    END IF;
301 END moveSolutionsTest;
302 ------------------
303 -- runtest
304 ------------------
305 -- procedure to execute the PLSQL test
306 -- the inputs needed for the test are passed in and a report object and CLOB are
307 -- returned.
308 PROCEDURE runtest(inputs     IN  JTF_DIAG_INPUTTBL,
309                   report     OUT NOCOPY JTF_DIAG_REPORT,
310                   reportClob OUT NOCOPY CLOB)
311 IS
312 BEGIN
313  -- The Report for the Unit Test is represented by a CLOB
314  -- This CLOB must be initialized before it can be used
315  JTF_DIAGNOSTIC_ADAPTUTIL.setUpVars;
316  -- if the report is HTML-based, then the first string added to
317  -- the report must be "@html".
318  -- addStringToReport writes to the Report CLOB
319  JTF_DIAGNOSTIC_ADAPTUTIL.addStringToReport('@html');
320  JTF_DIAGNOSTIC_COREAPI.insert_style_sheet;
321  -- line_out writes to the Report CLOB
322  JTF_DIAGNOSTIC_COREAPI.line_out('======================================================');
323  -- BRPrint Adds a New Line to the Report CLOB
324  JTF_DIAGNOSTIC_COREAPI.BRPrint;
325  JTF_DIAGNOSTIC_COREAPI.line_out('=== Knowledge Management Diagnostics - cs_kb_solution_pvt');
326  JTF_DIAGNOSTIC_COREAPI.BRPrint;
327  JTF_DIAGNOSTIC_COREAPI.line_out('======================================================');
328  l_statusStr := 'SUCCESS';
329  ----------------------------------------------
330  -- Add Product Specific Tests Here:
331  ----------------------------------------------
332  currentUser;
333  moveSolutionsTest;
334  ----------------------------------------------
335 -- Construct the Report with the corresponding Report Status information:
336  report := JTF_DIAGNOSTIC_ADAPTUTIL.constructReport(l_statusStr, -- SUCCESS, FAILURE, WARNING
337                                                     l_errStr,    -- The Error Message
338                                                     l_fixInfo,   -- fix suggestions
339                                                     l_isFatal    -- Fatal Error: "TRUE" or "FALSE"
340                                                     );
341  -- Return the clob output report
342  reportClob := JTF_DIAGNOSTIC_ADAPTUTIL.getReportClob;
343 END runTest;
344 
345 END CSK_DIAG_SOLUTION_PVT;