Modify ONAP PAP REST classes basic checkstyle
[policy/engine.git] / ONAP-PAP-REST / src / test / java / org / onap / policy / pap / xacml / rest / controller / MicroServiceDictionaryControllerTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP-PAP-REST
4  * ================================================================================
5  * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21
22 package org.onap.policy.pap.xacml.rest.controller;
23
24 import static org.junit.Assert.assertTrue;
25 import static org.junit.Assert.fail;
26 import static org.mockito.Mockito.doNothing;
27 import static org.mockito.Mockito.mock;
28 import static org.mockito.Mockito.when;
29
30 import java.io.BufferedReader;
31 import java.io.StringReader;
32 import java.io.UnsupportedEncodingException;
33 import java.util.ArrayList;
34 import java.util.List;
35
36 import javax.servlet.http.HttpServletRequest;
37
38 import org.junit.Before;
39 import org.junit.Test;
40 import org.mockito.Mockito;
41 import org.onap.policy.common.logging.flexlogger.FlexLogger;
42 import org.onap.policy.common.logging.flexlogger.Logger;
43 import org.onap.policy.pap.xacml.rest.util.DictionaryUtils;
44 import org.onap.policy.rest.dao.CommonClassDao;
45 import org.onap.policy.rest.jpa.DCAEuuid;
46 import org.onap.policy.rest.jpa.MicroServiceLocation;
47 import org.onap.policy.rest.jpa.MicroServiceModels;
48 import org.onap.policy.rest.jpa.UserInfo;
49 import org.springframework.mock.web.MockHttpServletResponse;
50
51 /**
52  * The class <code>MicroServiceDictionaryControllerTest</code> contains tests
53  * for the class {@link <code>MicroServiceDictionaryController</code>}*
54  *
55  * All JUnits are designed to run in the local development environment
56  * where they have write privileges and can execute time-sensitive
57  * tasks.
58  */
59
60 public class MicroServiceDictionaryControllerTest {
61
62     private static Logger logger = FlexLogger.getLogger(MicroServiceDictionaryControllerTest.class);
63     private static CommonClassDao commonClassDao;
64     private String jsonString = null;
65     private HttpServletRequest request = null;
66     private MicroServiceDictionaryController controller = null;
67      BufferedReader br = null;
68
69     @Before
70     public void setUp() throws Exception {
71         logger.info("setUp: Entering");
72         commonClassDao = Mockito.mock(CommonClassDao.class);
73         UserInfo userInfo = new UserInfo();
74         userInfo.setUserLoginId("testUserId");
75         userInfo.setUserName("John");
76         when(commonClassDao.getEntityItem(UserInfo.class, "userLoginId", "testing")).thenReturn(userInfo);
77         
78         List<String>  listIds = new ArrayList<String>();
79         listIds.add("Jack");
80         when(commonClassDao.getDataByColumn(DCAEuuid.class, "name")).thenReturn(listIds);
81         
82         List<String>  microList = new ArrayList<String>();
83         microList.add("MC-Model");
84         when(commonClassDao.getDataByColumn(MicroServiceLocation.class, "name")).thenReturn(microList);
85         
86         List<Object>  listId = new ArrayList<Object>();
87         listId.add("smith");
88         when(commonClassDao.getData(DCAEuuid.class)).thenReturn(listId);
89         MicroServiceModels microServiceModels = new MicroServiceModels();
90         
91         doNothing().when(commonClassDao).delete(microServiceModels);
92
93         MicroServiceDictionaryController.setCommonClassDao(commonClassDao);
94
95         controller = new MicroServiceDictionaryController();
96        
97         HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
98         
99         jsonString = "{\"microServiceModelsDictionaryData\": {\"modelName\": \"test\",  \"inprocess\": false,\"model\": {\"name\": \"testingdata\", "
100                 + " \"subScopename\": \"\",\"path\": [],\"type\": \"dir\",\"size\": 0,\"date\": \"2017-04-12T21:26:57.000Z\", "
101                 + " \"version\": \"\",\"createdBy\": \"someone\",       \"modifiedBy\": \"someone\",    \"content\": \"\",\"recursive\": false},"
102                 + " \"tempModel\": {\"name\": \"testingdata\",\"subScopename\": \"\"    },"
103                 + " \"policy\": {\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\",\"policyName\": \"may1501\", "
104                 + "     \"policyDescription\": \"testing input\", \"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\",\"riskLevel\": \"2\","
105                 + "     \"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\",\"version\": \"1707.41.02\",\"ruleGridData\": [ [\"fileId\"]],\"ttlDate\": null}}, "
106                 + "     \"policyJSON\": {\"pmTableName\": \"test\",     \"dmdTopic\": \"1\",\"fileId\": \"56\"} }";
107     
108         br = new BufferedReader(new StringReader(jsonString));
109         //--- mock the getReader() call
110         when(request.getReader()).thenReturn(br);   
111         new DictionaryUtils(commonClassDao);
112         DictionaryUtils.setDictionaryUtils(new DictionaryUtils());
113         mock(DictionaryUtils.class);        
114         logger.info("setUp: exit");
115     }
116
117
118     @Test
119     public void testSaveMicroServiceHeaderDefaultValues() {
120         logger.info("testSaveMicroServiceHeaderDefaultValues: Entering");
121
122         MockHttpServletResponse response =  new MockHttpServletResponse();
123         request = mock(HttpServletRequest.class);
124
125         try {
126             // mock the getReader() call
127             jsonString = "{\"modelAttributeDictionaryData\": {\"onapName\": \"test\",   \"guard\": false,\"priority\": \"3\","
128                     + " \"riskType\": \"test\", \"riskLevel\": \"7\", \"modelName\": \"testname\"}}";
129             BufferedReader br = new BufferedReader(new StringReader(jsonString));
130             when(request.getReader()).thenReturn(br);
131             controller.saveMicroServiceHeaderDefaultValues(request, response);
132             logger.info("response.getContentAsString(): " + response.getContentAsString());
133             assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceHeaderDefaultDatas"));
134
135         } catch (Exception e) {
136             fail("Exception: " + e);
137         }
138
139         logger.info("testSaveMicroServiceHeaderDefaultValues: exit");
140     }
141
142
143     @Test
144     public void testGetMicroServiceHeaderDefaultsEntityDataByName() {
145         logger.info("testGetMicroServiceHeaderDefaultsEntityDataByName: Entering");
146
147         MockHttpServletResponse response =  new MockHttpServletResponse();
148
149         controller.getMicroServiceHeaderDefaultsEntityDataByName(response);
150
151         try {
152             assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceHeaderDefaultDatas"));
153             logger.info("response.getContentAsString(): " + response.getContentAsString());
154         } catch (UnsupportedEncodingException e) {
155             fail("Exception: " + e);
156         }
157
158         logger.info("testGetMicroServiceHeaderDefaultsEntityDataByName: exit");
159     }
160
161     @Test
162     public void testGetMicroServiceHeaderDefaultsEntityData() {
163         logger.info("testGetMicroServiceHeaderDefaultsEntityData: Entering");
164
165         MockHttpServletResponse response =  new MockHttpServletResponse();
166
167         controller.getMicroServiceHeaderDefaultsEntityData(response);
168
169         try {
170             assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceHeaderDefaultDatas"));
171             logger.info("response.getContentAsString(): " + response.getContentAsString());
172         } catch (UnsupportedEncodingException e) {
173             fail("Exception: " + e);
174         }
175
176         logger.info("testGetMicroServiceHeaderDefaultsEntityData: exit");
177     }
178
179     @Test
180     public void testRemoveMicroServiceHeaderDefaults() {
181         logger.info("testRemoveMicroServiceHeaderDefaults: Entering");
182
183         MockHttpServletResponse response =  new MockHttpServletResponse();
184         request = mock(HttpServletRequest.class);
185
186         try {
187             // mock the getReader() call
188             jsonString = "{\"data\": {\"modelName\": \"test\",  \"inprocess\": false,\"model\": {\"name\": \"testingdata\", "
189                     + " \"subScopename\": \"\",\"path\": [],\"type\": \"dir\",\"size\": 0,\"date\": \"2017-04-12T21:26:57.000Z\", "
190                     + " \"version\": \"\",\"createdBy\": \"someone\",   \"modifiedBy\": \"someone\",    \"content\": \"\",\"recursive\": false},"
191                     + " \"tempModel\": {\"name\": \"testingdata\",\"subScopename\": \"\"        },"
192                     + " \"policy\": {\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\",\"policyName\": \"may1501\", "
193                     + " \"policyDescription\": \"testing input\", \"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\",\"riskLevel\": \"2\","
194                     + " \"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\",\"version\": \"1707.41.02\",\"ruleGridData\": [ [\"fileId\"]],\"ttlDate\": null}}, "
195                     + " \"policyJSON\": {\"pmTableName\": \"test\",     \"dmdTopic\": \"1\",\"fileId\": \"56\"} }";
196             BufferedReader br = new BufferedReader(new StringReader(jsonString));
197             when(request.getReader()).thenReturn(br);
198             controller.removeMicroServiceHeaderDefaults(request, response);
199             logger.info("response.getContentAsString(): " + response.getContentAsString());
200             assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceHeaderDefaultDatas"));
201
202         } catch (Exception e) {
203             fail("Exception: " + e);
204         }
205
206         logger.info("testRemoveMicroServiceHeaderDefaults: exit");
207     }
208
209
210     @Test
211     public void testGetDCAEUUIDDictionaryByNameEntityData() {
212
213         logger.info("testGetDCAEUUIDDictionaryByNameEntityData: Entering");
214
215         MockHttpServletResponse response =  new MockHttpServletResponse();
216
217         controller.getDCAEUUIDDictionaryByNameEntityData(response);
218
219         try {
220             assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("dcaeUUIDDictionaryDatas"));
221             logger.info("response.getContentAsString(): " + response.getContentAsString());
222         } catch (UnsupportedEncodingException e) {
223             fail("Exception: " + e);
224         }
225
226         logger.info("testGetDCAEUUIDDictionaryByNameEntityData: exit");
227     }
228
229     @Test
230     public void testGetDCAEUUIDDictionaryEntityData() {
231
232         logger.info("testGetDCAEUUIDDictionaryEntityData: Entering");
233
234         MockHttpServletResponse response =  new MockHttpServletResponse();
235
236         controller.getDCAEUUIDDictionaryEntityData(response);
237
238         try {
239             assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("dcaeUUIDDictionaryDatas"));
240             logger.info("response.getContentAsString(): " + response.getContentAsString());
241         } catch (UnsupportedEncodingException e) {
242             fail("Exception: " + e);
243         }
244
245         logger.info("testGetDCAEUUIDDictionaryEntityData: exit");
246     }
247
248     @Test
249     public void testSaveDCAEUUIDDictionary() {
250         logger.info("testSaveDCAEUUIDDictionary: Entering");
251
252         MockHttpServletResponse response =  new MockHttpServletResponse();
253         request = mock(HttpServletRequest.class);
254
255         try {
256             // mock the getReader() call
257             jsonString = "{\"dcaeUUIDDictionaryData\": {\"modelName\": \"test\",        \"inprocess\": false,\"model\": {\"name\": \"testingdata\", "
258                     + " \"subScopename\": \"\",\"path\": [],\"type\": \"dir\",\"size\": 0,\"date\": \"2017-04-12T21:26:57.000Z\", "
259                     + " \"version\": \"\",\"createdBy\": \"someone\",   \"modifiedBy\": \"someone\",    \"content\": \"\",\"recursive\": false},"
260                     + " \"tempModel\": {\"name\": \"testingdata\",\"subScopename\": \"\"        },"
261                     + " \"policy\": {\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\",\"policyName\": \"may1501\", "
262                     + " \"policyDescription\": \"testing input\", \"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\",\"riskLevel\": \"2\","
263                     + " \"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\",\"version\": \"1707.41.02\",\"ruleGridData\": [ [\"fileId\"]],\"ttlDate\": null}}, "
264                     + " \"policyJSON\": {\"pmTableName\": \"test\",     \"dmdTopic\": \"1\",\"fileId\": \"56\"} }";
265             BufferedReader br = new BufferedReader(new StringReader(jsonString));
266             when(request.getReader()).thenReturn(br);
267             controller.saveDCAEUUIDDictionary(request, response);
268             logger.info("response.getContentAsString(): " + response.getContentAsString());
269             assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("dcaeUUIDDictionaryDatas"));
270
271         } catch (Exception e) {
272             fail("Exception: " + e);
273         }
274
275         logger.info("testSaveDCAEUUIDDictionary: exit");
276     }
277
278     @Test
279     public void testRemoveDCAEUUIDDictionary() {
280         logger.info("testRemoveDCAEUUIDDictionary: Entering");
281
282         MockHttpServletResponse response =  new MockHttpServletResponse();
283         request = mock(HttpServletRequest.class);
284
285         try {
286             // mock the getReader() call
287             jsonString = "{\"data\": {\"modelName\": \"test\",  \"inprocess\": false,\"model\": {\"name\": \"testingdata\", "
288                     + " \"subScopename\": \"\",\"path\": [],\"type\": \"dir\",\"size\": 0,\"date\": \"2017-04-12T21:26:57.000Z\", "
289                     + " \"version\": \"\",\"createdBy\": \"someone\",   \"modifiedBy\": \"someone\",    \"content\": \"\",\"recursive\": false},"
290                     + " \"tempModel\": {\"name\": \"testingdata\",\"subScopename\": \"\"        },"
291                     + " \"policy\": {\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\",\"policyName\": \"may1501\", "
292                     + " \"policyDescription\": \"testing input\", \"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\",\"riskLevel\": \"2\","
293                     + " \"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\",\"version\": \"1707.41.02\",\"ruleGridData\": [ [\"fileId\"]],\"ttlDate\": null}}, "
294                     + " \"policyJSON\": {\"pmTableName\": \"test\",     \"dmdTopic\": \"1\",\"fileId\": \"56\"} }";
295             BufferedReader br = new BufferedReader(new StringReader(jsonString));
296             when(request.getReader()).thenReturn(br);
297             controller.removeMicroServiceConfigNameDictionary(request, response);
298             logger.info("response.getContentAsString(): " + response.getContentAsString());
299             assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceConfigNameDictionaryDatas"));
300
301         } catch (Exception e) {
302             fail("Exception: " + e);
303         }
304
305         logger.info("testRemoveDCAEUUIDDictionary: exit");
306     }
307
308     @Test
309     public void testGetMicroServiceConfigNameByNameDictionaryEntityData() {
310         logger.info("testGetMicroServiceConfigNameByNameDictionaryEntityData: Entering");
311
312         MockHttpServletResponse response =  new MockHttpServletResponse();
313
314         controller.getMicroServiceConfigNameByNameDictionaryEntityData(response);
315
316         try {
317             assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceConfigNameDictionaryDatas"));
318             logger.info("response.getContentAsString(): " + response.getContentAsString());
319         } catch (UnsupportedEncodingException e) {
320             fail("Exception: " + e);
321         }
322
323         logger.info("testGetMicroServiceConfigNameByNameDictionaryEntityData: exit");
324     }
325
326     @Test
327     public void testGetMicroServiceConfigNameDictionaryEntityData() {
328         logger.info("testGetMicroServiceConfigNameByNameDictionaryEntityData: Entering");
329
330         MockHttpServletResponse response =  new MockHttpServletResponse();
331
332         controller.getMicroServiceConfigNameDictionaryEntityData(response);
333
334         try {
335             assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceConfigNameDictionaryDatas"));
336             logger.info("response.getContentAsString(): " + response.getContentAsString());
337         } catch (UnsupportedEncodingException e) {
338             fail("Exception: " + e);
339         }
340
341         logger.info("testGetMicroServiceConfigNameDictionaryEntityData: exit");
342     }
343
344     @Test
345     public void testSaveMicroServiceConfigNameDictionary() {
346         logger.info("testSaveMicroServiceConfigNameDictionary: Entering");
347
348         MockHttpServletResponse response =  new MockHttpServletResponse();
349         request = mock(HttpServletRequest.class);
350
351         try {
352             // mock the getReader() call
353             jsonString = "{\"microServiceConfigNameDictionaryData\": {\"modelName\": \"test\",  \"inprocess\": false,\"model\": {\"name\": \"testingdata\", "
354                     + " \"subScopename\": \"\",\"path\": [],\"type\": \"dir\",\"size\": 0,\"date\": \"2017-04-12T21:26:57.000Z\", "
355                     + " \"version\": \"\",\"createdBy\": \"someone\",   \"modifiedBy\": \"someone\",    \"content\": \"\",\"recursive\": false},"
356                     + " \"tempModel\": {\"name\": \"testingdata\",\"subScopename\": \"\"        },"
357                     + " \"policy\": {\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\",\"policyName\": \"may1501\", "
358                     + " \"policyDescription\": \"testing input\", \"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\",\"riskLevel\": \"2\","
359                     + " \"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\",\"version\": \"1707.41.02\",\"ruleGridData\": [ [\"fileId\"]],\"ttlDate\": null}}, "
360                     + " \"policyJSON\": {\"pmTableName\": \"test\",     \"dmdTopic\": \"1\",\"fileId\": \"56\"} }";
361             BufferedReader br = new BufferedReader(new StringReader(jsonString));
362             when(request.getReader()).thenReturn(br);
363             controller.saveMicroServiceConfigNameDictionary(request, response);
364             logger.info("response.getContentAsString(): " + response.getContentAsString());
365             assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceConfigNameDictionaryDatas"));
366
367         } catch (Exception e) {
368             fail("Exception: " + e);
369         }
370
371         logger.info("testSaveMicroServiceConfigNameDictionary: exit");
372     }
373
374     @Test
375     public void testRemoveMicroServiceConfigNameDictionary() {
376         logger.info("testRemoveMicroServiceConfigNameDictionary: Entering");
377
378         MockHttpServletResponse response =  new MockHttpServletResponse();
379         request = mock(HttpServletRequest.class);
380
381         try {
382             // mock the getReader() call
383             jsonString = "{\"data\": {\"modelName\": \"test\",  \"inprocess\": false,\"model\": {\"name\": \"testingdata\", "
384                     + " \"subScopename\": \"\",\"path\": [],\"type\": \"dir\",\"size\": 0,\"date\": \"2017-04-12T21:26:57.000Z\", "
385                     + " \"version\": \"\",\"createdBy\": \"someone\",   \"modifiedBy\": \"someone\",    \"content\": \"\",\"recursive\": false},"
386                     + " \"tempModel\": {\"name\": \"testingdata\",\"subScopename\": \"\"        },"
387                     + " \"policy\": {\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\",\"policyName\": \"may1501\", "
388                     + " \"policyDescription\": \"testing input\", \"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\",\"riskLevel\": \"2\","
389                     + " \"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\",\"version\": \"1707.41.02\",\"ruleGridData\": [ [\"fileId\"]],\"ttlDate\": null}}, "
390                     + " \"policyJSON\": {\"pmTableName\": \"test\",     \"dmdTopic\": \"1\",\"fileId\": \"56\"} }";
391             BufferedReader br = new BufferedReader(new StringReader(jsonString));
392             when(request.getReader()).thenReturn(br);
393             controller.removeMicroServiceConfigNameDictionary(request, response);
394             logger.info("response.getContentAsString(): " + response.getContentAsString());
395             assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceConfigNameDictionaryDatas"));
396
397         } catch (Exception e) {
398             fail("Exception: " + e);
399         }
400
401         logger.info("testRemoveMicroServiceConfigNameDictionary: exit");
402     }
403
404     @Test
405     public void testGetMicroServiceLocationByNameDictionaryEntityData() {
406
407         logger.info("testGetMicroServiceLocationByNameDictionaryEntityData: Entering");
408
409         MockHttpServletResponse response =  new MockHttpServletResponse();
410
411         controller.getMicroServiceLocationByNameDictionaryEntityData(response);
412
413         try {
414             assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceLocationDictionaryDatas"));
415             logger.info("response.getContentAsString(): " + response.getContentAsString());
416         } catch (UnsupportedEncodingException e) {
417             fail("Exception: " + e);
418         }
419
420         logger.info("testGetMicroServiceLocationByNameDictionaryEntityData: exit");
421     }
422
423     @Test
424     public void testGetMicroServiceLocationDictionaryEntityData() {
425         logger.info("testGetMicroServiceLocationDictionaryEntityData: Entering");
426
427         MockHttpServletResponse response =  new MockHttpServletResponse();
428
429         controller.getMicroServiceLocationDictionaryEntityData(response);
430
431         try {
432             assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceLocationDictionaryDatas"));
433             logger.info("response.getContentAsString(): " + response.getContentAsString());
434         } catch (UnsupportedEncodingException e) {
435             fail("Exception: " + e);
436         }
437
438         logger.info("testGetMicroServiceLocationDictionaryEntityData: exit");
439     }
440
441     @Test
442     public void testSaveMicroServiceLocationDictionary() {
443         logger.info("testSaveMicroServiceLocationDictionary: Entering");
444
445         MockHttpServletResponse response =  new MockHttpServletResponse();
446         request = mock(HttpServletRequest.class);
447
448         try {
449             // mock the getReader() call
450             jsonString = "{\"microServiceLocationDictionaryData\": {\"modelName\": \"test\",    \"inprocess\": false,\"model\": {\"name\": \"testingdata\", "
451                     + " \"subScopename\": \"\",\"path\": [],\"type\": \"dir\",\"size\": 0,\"date\": \"2017-04-12T21:26:57.000Z\", "
452                     + " \"version\": \"\",\"createdBy\": \"someone\",   \"modifiedBy\": \"someone\",    \"content\": \"\",\"recursive\": false},"
453                     + " \"tempModel\": {\"name\": \"testingdata\",\"subScopename\": \"\"        },"
454                     + " \"policy\": {\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\",\"policyName\": \"may1501\", "
455                     + " \"policyDescription\": \"testing input\", \"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\",\"riskLevel\": \"2\","
456                     + " \"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\",\"version\": \"1707.41.02\",\"ruleGridData\": [ [\"fileId\"]],\"ttlDate\": null}}, "
457                     + " \"policyJSON\": {\"pmTableName\": \"test\",     \"dmdTopic\": \"1\",\"fileId\": \"56\"} }";
458             BufferedReader br = new BufferedReader(new StringReader(jsonString));
459             when(request.getReader()).thenReturn(br);
460             controller.saveMicroServiceLocationDictionary(request, response);
461             logger.info("response.getContentAsString(): " + response.getContentAsString());
462             assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceLocationDictionaryDatas"));
463
464         } catch (Exception e) {
465             fail("Exception: " + e);
466         }
467
468         logger.info("testSaveMicroServiceLocationDictionary: exit");
469     }
470
471     @Test
472     public void testRemoveMicroServiceLocationDictionary() {
473         logger.info("testRemoveMicroServiceLocationDictionary: Entering");
474
475         MockHttpServletResponse response =  new MockHttpServletResponse();
476         request = mock(HttpServletRequest.class);
477
478         try {
479             // mock the getReader() call
480             jsonString = "{\"data\": {\"modelName\": \"test\",  \"inprocess\": false,\"model\": {\"name\": \"testingdata\", "
481                     + " \"subScopename\": \"\",\"path\": [],\"type\": \"dir\",\"size\": 0,\"date\": \"2017-04-12T21:26:57.000Z\", "
482                     + " \"version\": \"\",\"createdBy\": \"someone\",   \"modifiedBy\": \"someone\",    \"content\": \"\",\"recursive\": false},"
483                     + " \"tempModel\": {\"name\": \"testingdata\",\"subScopename\": \"\"        },"
484                     + " \"policy\": {\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\",\"policyName\": \"may1501\", "
485                     + " \"policyDescription\": \"testing input\", \"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\",\"riskLevel\": \"2\","
486                     + " \"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\",\"version\": \"1707.41.02\",\"ruleGridData\": [ [\"fileId\"]],\"ttlDate\": null}}, "
487                     + " \"policyJSON\": {\"pmTableName\": \"test\",     \"dmdTopic\": \"1\",\"fileId\": \"56\"} }";
488             BufferedReader br = new BufferedReader(new StringReader(jsonString));
489
490             when(request.getReader()).thenReturn(br);
491             controller.removeMicroServiceLocationDictionary(request, response);
492             logger.info("response.getContentAsString(): " + response.getContentAsString());
493             assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceLocationDictionaryDatas"));
494
495         } catch (Exception e) {
496             fail("Exception: " + e);
497         }
498
499         logger.info("testRemoveMicroServiceLocationDictionary: exit");
500     }
501
502     @Test
503     public void testGetMicroServiceAttributeByNameDictionaryEntityData() {
504         logger.info("testGetMicroServiceAttributeByNameDictionaryEntityData: Entering");
505
506         MockHttpServletResponse response =  new MockHttpServletResponse();
507
508         controller.getMicroServiceAttributeByNameDictionaryEntityData(response);
509
510         try {
511             assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceAttributeDictionaryDatas"));
512             logger.info("response.getContentAsString(): " + response.getContentAsString());
513         } catch (UnsupportedEncodingException e) {
514             fail("Exception: " + e);
515         }
516
517         logger.info("testGetMicroServiceAttributeByNameDictionaryEntityData: exit");
518     }
519
520     @Test
521     public void testGetMicroServiceAttributeDictionaryEntityData() {
522         logger.info("testGetMicroServiceAttributeDictionaryEntityData: Entering");
523
524         MockHttpServletResponse response =  new MockHttpServletResponse();
525
526         controller.getMicroServiceAttributeDictionaryEntityData(response);
527
528         try {
529             assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceAttributeDictionaryDatas"));
530             logger.info("response.getContentAsString(): " + response.getContentAsString());
531         } catch (UnsupportedEncodingException e) {
532             fail("Exception: " + e);
533         }
534
535         logger.info("testGetMicroServiceAttributeDictionaryEntityData: exit");
536     }
537
538     @Test
539     public void testSaveMicroServiceAttributeDictionary() {
540         logger.info("testSaveMicroServiceAttributeDictionary: Entering");
541
542         MockHttpServletResponse response =  new MockHttpServletResponse();
543         request = mock(HttpServletRequest.class);
544
545         try {
546             // mock the getReader() call
547             jsonString = "{\"modelAttributeDictionaryData\": {\"modelName\": \"test\",  \"inprocess\": false,\"model\": {\"name\": \"testingdata\", "
548                     + " \"subScopename\": \"\",\"path\": [],\"type\": \"dir\",\"size\": 0,\"date\": \"2017-04-12T21:26:57.000Z\", "
549                     + " \"version\": \"\",\"createdBy\": \"someone\",   \"modifiedBy\": \"someone\",    \"content\": \"\",\"recursive\": false},"
550                     + " \"tempModel\": {\"name\": \"testingdata\",\"subScopename\": \"\"        },"
551                     + " \"policy\": {\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\",\"policyName\": \"may1501\", "
552                     + " \"policyDescription\": \"testing input\", \"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\",\"riskLevel\": \"2\","
553                     + " \"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\",\"version\": \"1707.41.02\",\"ruleGridData\": [ [\"fileId\"]],\"ttlDate\": null}}, "
554                     + " \"policyJSON\": {\"pmTableName\": \"test\",     \"dmdTopic\": \"1\",\"fileId\": \"56\"} }";
555             BufferedReader br = new BufferedReader(new StringReader(jsonString));
556             when(request.getReader()).thenReturn(br);
557             controller.saveMicroServiceAttributeDictionary(request, response);
558             logger.info("response.getContentAsString(): " + response.getContentAsString());
559             assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceAttributeDictionaryDatas"));
560
561         } catch (Exception e) {
562             fail("Exception: " + e);
563         }
564
565         logger.info("testSaveMicroServiceAttributeDictionary: exit");
566     }
567
568     @Test
569     public void testRemoveMicroServiceAttributeDictionary() {
570         logger.info("testRemoveMicroServiceAttributeDictionary: Entering");
571
572         MockHttpServletResponse response =  new MockHttpServletResponse();
573         request = mock(HttpServletRequest.class);
574
575         try {
576             // mock the getReader() call
577             jsonString = "{\"data\": {\"modelName\": \"test\",  \"inprocess\": false,\"model\": {\"name\": \"testingdata\", "
578                     + " \"subScopename\": \"\",\"path\": [],\"type\": \"dir\",\"size\": 0,\"date\": \"2017-04-12T21:26:57.000Z\", "
579                     + " \"version\": \"\",\"createdBy\": \"someone\",   \"modifiedBy\": \"someone\",    \"content\": \"\",\"recursive\": false},"
580                     + " \"tempModel\": {\"name\": \"testingdata\",\"subScopename\": \"\"        },"
581                     + " \"policy\": {\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\",\"policyName\": \"may1501\", "
582                     + " \"policyDescription\": \"testing input\", \"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\",\"riskLevel\": \"2\","
583                     + " \"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\",\"version\": \"1707.41.02\",\"ruleGridData\": [ [\"fileId\"]],\"ttlDate\": null}}, "
584                     + " \"policyJSON\": {\"pmTableName\": \"test\",     \"dmdTopic\": \"1\",\"fileId\": \"56\"} }";
585             BufferedReader br = new BufferedReader(new StringReader(jsonString));
586             when(request.getReader()).thenReturn(br);
587             controller.removeMicroServiceAttributeDictionary(request, response);
588             logger.info("response.getContentAsString(): " + response.getContentAsString());
589             assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceAttributeDictionaryDatas"));
590
591         } catch (Exception e) {
592             fail("Exception: " + e);
593         }
594
595         logger.info("testRemoveMicroServiceAttributeDictionary: exit");
596     }
597
598     @Test
599     public void testGetMicroServiceModelsDictionaryByNameEntityData() {
600         logger.info("testGetMicroServiceModelsDictionaryByNameEntityData: Entering");
601
602         MockHttpServletResponse response =  new MockHttpServletResponse();
603
604         controller.getMicroServiceModelsDictionaryByNameEntityData(response);
605
606         try {
607             assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceModelsDictionaryDatas"));
608             logger.info("response.getContentAsString(): " + response.getContentAsString());
609         } catch (UnsupportedEncodingException e) {
610             fail("Exception: " + e);
611         }
612
613         logger.info("testGetMicroServiceModelsDictionaryByNameEntityData: exit");
614     }
615
616     @Test
617     public void testGetMicroServiceModelsDictionaryByVersionEntityData() {
618         logger.info("testGetMicroServiceModelsDictionaryByVersionEntityData: Entering");
619
620         MockHttpServletResponse response =  new MockHttpServletResponse();
621         String msModelJson = "{\"microServiceModelsDictionaryData\":[\"modelName\"]}";
622
623         BufferedReader br = new BufferedReader(new StringReader(msModelJson));
624         request = mock(HttpServletRequest.class);
625
626         try {
627             // mock the getReader() call
628             when(request.getReader()).thenReturn(br);
629             controller.getMicroServiceModelsDictionaryByVersionEntityData(request, response);
630             logger.info("response.getContentAsString(): " + response.getContentAsString());
631             assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("No model name given"));
632
633         } catch (Exception e) {
634             fail("Exception: " + e);
635         }
636
637         logger.info("testGetMicroServiceModelsDictionaryByVersionEntityData: exit");
638     }
639
640     @Test
641     public void testGetMicroServiceModelsDictionaryEntityData() {
642         logger.info("testGetMicroServiceModelsDictionaryEntityData: Entering");
643
644         MockHttpServletResponse response =  new MockHttpServletResponse();
645         String msModelJson = "{\"microServiceModelsDictionaryData\":[\"modelName\"]}";
646
647         BufferedReader br = new BufferedReader(new StringReader(msModelJson));
648         request = mock(HttpServletRequest.class);
649
650         try {
651             // mock the getReader() call
652             when(request.getReader()).thenReturn(br);
653             controller.getMicroServiceModelsDictionaryEntityData(response);
654             logger.info("response.getContentAsString(): " + response.getContentAsString());
655             assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceModelsDictionaryDatas"));
656
657         } catch (Exception e) {
658             fail("Exception: " + e);
659         }
660
661         logger.info("testGetMicroServiceModelsDictionaryEntityData: exit");
662     }
663
664     @Test
665     public void testGetMicroServiceModelsDictionaryEntityDataServiceVersion() {
666         logger.info("testGetMicroServiceModelsDictionaryEntityDataServiceVersion: Entering");
667
668         MockHttpServletResponse response =  new MockHttpServletResponse();
669         String msModelJson = "{\"microServiceModelsDictionaryData\":[\"modelName\"]}";
670
671         BufferedReader br = new BufferedReader(new StringReader(msModelJson));
672         request = mock(HttpServletRequest.class);
673
674         try {
675             // mock the getReader() call
676             when(request.getReader()).thenReturn(br);
677             controller.getMicroServiceModelsDictionaryEntityDataServiceVersion(response);
678             logger.info("response.getContentAsString(): " + response.getContentAsString());
679             assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceModelsDictionaryDatas"));
680
681         } catch (Exception e) {
682             fail("Exception: " + e);
683         }
684
685         logger.info("testGetMicroServiceModelsDictionaryEntityDataServiceVersion: exit");
686     }
687
688     @Test
689     public void testGetMicroServiceModelsDictionaryClassEntityData() {
690         logger.info("testGetMicroServiceModelsDictionaryClassEntityData: Entering");
691
692         MockHttpServletResponse response =  new MockHttpServletResponse();
693         String msModelJson = "{\"microServiceModelsDictionaryData\":[\"modelName\"]}";
694
695         BufferedReader br = new BufferedReader(new StringReader(msModelJson));
696         request = mock(HttpServletRequest.class);
697
698         try {
699             // mock the getReader() call
700             when(request.getReader()).thenReturn(br);
701             controller.getMicroServiceModelsDictionaryClassEntityData(response);
702             logger.info("response.getContentAsString(): " + response.getContentAsString());
703             assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceModelsDictionaryClassDatas"));
704
705         } catch (Exception e) {
706             fail("Exception: " + e);
707         }
708
709         logger.info("testGetMicroServiceModelsDictionaryClassEntityData: exit");
710     }
711
712     @Test
713     public void testSaveMicroServiceModelsDictionary() {
714         logger.info("testSaveMicroServiceModelsDictionary: Entering");
715
716         MockHttpServletResponse response =  new MockHttpServletResponse();
717         request = mock(HttpServletRequest.class);
718
719         try {
720             // mock the getReader() call
721             when(request.getReader()).thenReturn(br);
722             controller.saveMicroServiceModelsDictionary(request, response);
723             logger.info("response.getContentAsString(): " + response.getContentAsString());
724             assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceModelsDictionaryDatas"));
725
726         } catch (Exception e) {
727             fail("Exception: " + e);
728         }
729
730         logger.info("testSaveMicroServiceModelsDictionary: exit");
731     }
732
733     @Test
734     public void testRemoveMicroServiceModelsDictionary() {
735         logger.info("testRemoveMicroServiceModelsDictionary: Entering");
736
737         MockHttpServletResponse response =  new MockHttpServletResponse();
738         request = mock(HttpServletRequest.class);
739
740         try {
741             // mock the getReader() call
742             jsonString = "{\"data\": {\"modelName\": \"test\",  \"inprocess\": false,\"model\": {\"name\": \"testingdata\", "
743                     + " \"subScopename\": \"\",\"path\": [],\"type\": \"dir\",\"size\": 0,\"date\": \"2017-04-12T21:26:57.000Z\", "
744                     + " \"version\": \"\",\"createdBy\": \"someone\",   \"modifiedBy\": \"someone\",    \"content\": \"\",\"recursive\": false},"
745                     + " \"tempModel\": {\"name\": \"testingdata\",\"subScopename\": \"\"        },"
746                     + " \"policy\": {\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\",\"policyName\": \"may1501\", "
747                     + " \"policyDescription\": \"testing input\", \"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\",\"riskLevel\": \"2\","
748                     + " \"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\",\"version\": \"1707.41.02\",\"ruleGridData\": [ [\"fileId\"]],\"ttlDate\": null}}, "
749                     + " \"policyJSON\": {\"pmTableName\": \"test\",     \"dmdTopic\": \"1\",\"fileId\": \"56\"} }";
750
751             BufferedReader br = new BufferedReader(new StringReader(jsonString));
752             when(request.getReader()).thenReturn(br);
753             controller.removeMicroServiceModelsDictionary(request, response);
754             logger.info("response.getContentAsString(): " + response.getContentAsString());
755             assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceModelsDictionaryDatas"));
756
757         } catch (Exception e) {
758             fail("Exception: " + e);
759         }
760
761         logger.info("testRemoveMicroServiceModelsDictionary: exit");
762     }
763
764 }