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