2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
22 package org.openecomp.policy.pap.xacml.rest.controller;
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.*;
46 * The class <code>MicroServiceDictionaryControllerTest</code> contains tests
47 * for the class {@link <code>MicroServiceDictionaryController</code>}*
49 * All JUnits are designed to run in the local development environment
50 * where they have write privileges and can execute time-sensitive
53 public class MicroServiceDictionaryControllerTest {
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;
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);
72 List<String> listIds = new ArrayList<String>();
74 when(commonClassDao.getDataByColumn(DCAEuuid.class, "name")).thenReturn(listIds);
76 List<String> microList = new ArrayList<String>();
77 microList.add("MC-Model");
78 when(commonClassDao.getDataByColumn(MicroServiceLocation.class, "name")).thenReturn(microList);
80 List<Object> listId = new ArrayList<Object>();
82 when(commonClassDao.getData(DCAEuuid.class)).thenReturn(listId);
83 MicroServiceModels microServiceModels = new MicroServiceModels();
85 doNothing().when(commonClassDao).delete(microServiceModels);
88 controller = new MicroServiceDictionaryController(commonClassDao);
90 HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
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\"} }";
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\"}}";
105 br = new BufferedReader(new StringReader(jsonString));
106 //--- mock the getReader() call
107 when(request.getReader()).thenReturn(br);
109 logger.info("setUp: exit");
113 public void tearDown() throws Exception {
118 public void testGetUserInfo() {
120 logger.info("testGetUserInfo: Entering");
122 UserInfo userInfo = controller.getUserInfo("testing");
123 logger.info("userInfo.getUserName() : " + userInfo.getUserName());
125 assertEquals("John", userInfo.getUserName());
127 logger.info("testGetUserInfo: exit");
131 public void testGetDCAEUUIDDictionaryByNameEntityData() {
133 logger.info("testGetDCAEUUIDDictionaryByNameEntityData: Entering");
135 MockHttpServletResponse response = new MockHttpServletResponse();
137 controller.getDCAEUUIDDictionaryByNameEntityData(request, response);
140 assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("dcaeUUIDDictionaryDatas"));
141 logger.info("response.getContentAsString(): " + response.getContentAsString());
142 } catch (UnsupportedEncodingException e) {
143 fail("Exception: " + e);
146 logger.info("testGetDCAEUUIDDictionaryByNameEntityData: exit");
150 public void testGetDCAEUUIDDictionaryEntityData() {
152 logger.info("testGetDCAEUUIDDictionaryEntityData: Entering");
154 MockHttpServletResponse response = new MockHttpServletResponse();
156 controller.getDCAEUUIDDictionaryEntityData(request, response);
159 assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("dcaeUUIDDictionaryDatas"));
160 logger.info("response.getContentAsString(): " + response.getContentAsString());
161 } catch (UnsupportedEncodingException e) {
162 fail("Exception: " + e);
165 logger.info("testGetDCAEUUIDDictionaryEntityData: exit");
169 public void testSaveDCAEUUIDDictionary() {
170 logger.info("testSaveDCAEUUIDDictionary: Entering");
172 MockHttpServletResponse response = new MockHttpServletResponse();
173 request = mock(HttpServletRequest.class);
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"));
191 } catch (Exception e) {
192 fail("Exception: " + e);
195 logger.info("testSaveDCAEUUIDDictionary: exit");
199 public void testRemoveDCAEUUIDDictionary() {
200 logger.info("testRemoveDCAEUUIDDictionary: Entering");
202 MockHttpServletResponse response = new MockHttpServletResponse();
203 request = mock(HttpServletRequest.class);
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"));
221 } catch (Exception e) {
222 fail("Exception: " + e);
225 logger.info("testRemoveDCAEUUIDDictionary: exit");
229 public void testGetMicroServiceConfigNameByNameDictionaryEntityData() {
230 logger.info("testGetMicroServiceConfigNameByNameDictionaryEntityData: Entering");
232 MockHttpServletResponse response = new MockHttpServletResponse();
234 controller.getMicroServiceConfigNameByNameDictionaryEntityData(request, response);
237 assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceCongigNameDictionaryDatas"));
238 logger.info("response.getContentAsString(): " + response.getContentAsString());
239 } catch (UnsupportedEncodingException e) {
240 fail("Exception: " + e);
243 logger.info("testGetMicroServiceConfigNameByNameDictionaryEntityData: exit");
247 public void testGetMicroServiceConfigNameDictionaryEntityData() {
248 logger.info("testGetMicroServiceConfigNameByNameDictionaryEntityData: Entering");
250 MockHttpServletResponse response = new MockHttpServletResponse();
252 controller.getMicroServiceConfigNameDictionaryEntityData(request, response);
255 assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceCongigNameDictionaryDatas"));
256 logger.info("response.getContentAsString(): " + response.getContentAsString());
257 } catch (UnsupportedEncodingException e) {
258 fail("Exception: " + e);
261 logger.info("testGetMicroServiceConfigNameDictionaryEntityData: exit");
265 public void testSaveMicroServiceConfigNameDictionary() {
266 logger.info("testSaveMicroServiceConfigNameDictionary: Entering");
268 MockHttpServletResponse response = new MockHttpServletResponse();
269 request = mock(HttpServletRequest.class);
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"));
287 } catch (Exception e) {
288 fail("Exception: " + e);
291 logger.info("testSaveMicroServiceConfigNameDictionary: exit");
295 public void testRemoveMicroServiceConfigNameDictionary() {
296 logger.info("testRemoveMicroServiceConfigNameDictionary: Entering");
298 MockHttpServletResponse response = new MockHttpServletResponse();
299 request = mock(HttpServletRequest.class);
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"));
317 } catch (Exception e) {
318 fail("Exception: " + e);
321 logger.info("testRemoveMicroServiceConfigNameDictionary: exit");
325 public void testGetMicroServiceLocationByNameDictionaryEntityData() {
327 logger.info("testGetMicroServiceLocationByNameDictionaryEntityData: Entering");
329 MockHttpServletResponse response = new MockHttpServletResponse();
331 controller.getMicroServiceLocationByNameDictionaryEntityData(request, response);
334 assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceLocationDictionaryDatas"));
335 logger.info("response.getContentAsString(): " + response.getContentAsString());
336 } catch (UnsupportedEncodingException e) {
337 fail("Exception: " + e);
340 logger.info("testGetMicroServiceLocationByNameDictionaryEntityData: exit");
344 public void testGetMicroServiceLocationDictionaryEntityData() {
345 logger.info("testGetMicroServiceLocationDictionaryEntityData: Entering");
347 MockHttpServletResponse response = new MockHttpServletResponse();
349 controller.getMicroServiceLocationDictionaryEntityData(request, response);
352 assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceLocationDictionaryDatas"));
353 logger.info("response.getContentAsString(): " + response.getContentAsString());
354 } catch (UnsupportedEncodingException e) {
355 fail("Exception: " + e);
358 logger.info("testGetMicroServiceLocationDictionaryEntityData: exit");
362 public void testSaveMicroServiceLocationDictionary() {
363 logger.info("testSaveMicroServiceLocationDictionary: Entering");
365 MockHttpServletResponse response = new MockHttpServletResponse();
366 request = mock(HttpServletRequest.class);
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"));
384 } catch (Exception e) {
385 fail("Exception: " + e);
388 logger.info("testSaveMicroServiceLocationDictionary: exit");
392 public void testRemoveMicroServiceLocationDictionary() {
393 logger.info("testRemoveMicroServiceLocationDictionary: Entering");
395 MockHttpServletResponse response = new MockHttpServletResponse();
396 request = mock(HttpServletRequest.class);
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));
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"));
415 } catch (Exception e) {
416 fail("Exception: " + e);
419 logger.info("testRemoveMicroServiceLocationDictionary: exit");
423 public void testGetMicroServiceAttributeByNameDictionaryEntityData() {
424 logger.info("testGetMicroServiceAttributeByNameDictionaryEntityData: Entering");
426 MockHttpServletResponse response = new MockHttpServletResponse();
428 controller.getMicroServiceAttributeByNameDictionaryEntityData(request, response);
431 assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceAttributeDictionaryDatas"));
432 logger.info("response.getContentAsString(): " + response.getContentAsString());
433 } catch (UnsupportedEncodingException e) {
434 fail("Exception: " + e);
437 logger.info("testGetMicroServiceAttributeByNameDictionaryEntityData: exit");
441 public void testGetMicroServiceAttributeDictionaryEntityData() {
442 logger.info("testGetMicroServiceAttributeDictionaryEntityData: Entering");
444 MockHttpServletResponse response = new MockHttpServletResponse();
446 controller.getMicroServiceAttributeDictionaryEntityData(request, response);
449 assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceAttributeDictionaryDatas"));
450 logger.info("response.getContentAsString(): " + response.getContentAsString());
451 } catch (UnsupportedEncodingException e) {
452 fail("Exception: " + e);
455 logger.info("testGetMicroServiceAttributeDictionaryEntityData: exit");
459 public void testSaveMicroServiceAttributeDictionary() {
460 logger.info("testSaveMicroServiceAttributeDictionary: Entering");
462 MockHttpServletResponse response = new MockHttpServletResponse();
463 request = mock(HttpServletRequest.class);
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"));
481 } catch (Exception e) {
482 fail("Exception: " + e);
485 logger.info("testSaveMicroServiceAttributeDictionary: exit");
489 public void testRemoveMicroServiceAttributeDictionary() {
490 logger.info("testRemoveMicroServiceAttributeDictionary: Entering");
492 MockHttpServletResponse response = new MockHttpServletResponse();
493 request = mock(HttpServletRequest.class);
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"));
511 } catch (Exception e) {
512 fail("Exception: " + e);
515 logger.info("testRemoveMicroServiceAttributeDictionary: exit");
519 public void testGetMicroServiceModelsDictionaryByNameEntityData() {
520 logger.info("testGetMicroServiceModelsDictionaryByNameEntityData: Entering");
522 MockHttpServletResponse response = new MockHttpServletResponse();
524 controller.getMicroServiceModelsDictionaryByNameEntityData(request, response);
527 assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceModelsDictionaryDatas"));
528 logger.info("response.getContentAsString(): " + response.getContentAsString());
529 } catch (UnsupportedEncodingException e) {
530 fail("Exception: " + e);
533 logger.info("testGetMicroServiceModelsDictionaryByNameEntityData: exit");
537 public void testGetMicroServiceModelsDictionaryByVersionEntityData() {
538 logger.info("testGetMicroServiceModelsDictionaryByVersionEntityData: Entering");
540 MockHttpServletResponse response = new MockHttpServletResponse();
541 String msModelJson = "{\"microServiceModelsDictionaryData\":[\"modelName\"]}";
543 BufferedReader br = new BufferedReader(new StringReader(msModelJson));
544 request = mock(HttpServletRequest.class);
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"));
553 } catch (Exception e) {
554 fail("Exception: " + e);
557 logger.info("testGetMicroServiceModelsDictionaryByVersionEntityData: exit");
561 public void testGetMicroServiceModelsDictionaryEntityData() {
562 logger.info("testGetMicroServiceModelsDictionaryEntityData: Entering");
564 MockHttpServletResponse response = new MockHttpServletResponse();
565 String msModelJson = "{\"microServiceModelsDictionaryData\":[\"modelName\"]}";
567 BufferedReader br = new BufferedReader(new StringReader(msModelJson));
568 request = mock(HttpServletRequest.class);
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"));
577 } catch (Exception e) {
578 fail("Exception: " + e);
581 logger.info("testGetMicroServiceModelsDictionaryEntityData: exit");
585 public void testGetMicroServiceModelsDictionaryEntityDataServiceVersion() {
586 logger.info("testGetMicroServiceModelsDictionaryEntityDataServiceVersion: Entering");
588 MockHttpServletResponse response = new MockHttpServletResponse();
589 String msModelJson = "{\"microServiceModelsDictionaryData\":[\"modelName\"]}";
591 BufferedReader br = new BufferedReader(new StringReader(msModelJson));
592 request = mock(HttpServletRequest.class);
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"));
601 } catch (Exception e) {
602 fail("Exception: " + e);
605 logger.info("testGetMicroServiceModelsDictionaryEntityDataServiceVersion: exit");
609 public void testGetMicroServiceModelsDictionaryClassEntityData() {
610 logger.info("testGetMicroServiceModelsDictionaryClassEntityData: Entering");
612 MockHttpServletResponse response = new MockHttpServletResponse();
613 String msModelJson = "{\"microServiceModelsDictionaryData\":[\"modelName\"]}";
615 BufferedReader br = new BufferedReader(new StringReader(msModelJson));
616 request = mock(HttpServletRequest.class);
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"));
625 } catch (Exception e) {
626 fail("Exception: " + e);
629 logger.info("testGetMicroServiceModelsDictionaryClassEntityData: exit");
633 public void testSaveMicroServiceModelsDictionary() {
634 logger.info("testSaveMicroServiceModelsDictionary: Entering");
636 MockHttpServletResponse response = new MockHttpServletResponse();
637 request = mock(HttpServletRequest.class);
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"));
646 } catch (Exception e) {
647 fail("Exception: " + e);
650 logger.info("testSaveMicroServiceModelsDictionary: exit");
654 public void testRemoveMicroServiceModelsDictionary() {
655 logger.info("testRemoveMicroServiceModelsDictionary: Entering");
657 MockHttpServletResponse response = new MockHttpServletResponse();
658 request = mock(HttpServletRequest.class);
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\"} }";
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"));
677 } catch (Exception e) {
678 fail("Exception: " + e);
681 logger.info("testRemoveMicroServiceModelsDictionary: exit");