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