2  * ============LICENSE_START=======================================================
 
   4  * ================================================================================
 
   5  * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
 
   6  * ================================================================================
 
   7  * Licensed under the Apache License, Version 2.0 (the "License");
 
   8  * you may not use this file except in compliance with the License.
 
   9  * You may obtain a copy of the License at
 
  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.onap.policy.pap.xacml.rest.controller;
 
  24 import static org.junit.Assert.assertTrue;
 
  25 import static org.junit.Assert.fail;
 
  26 import static org.mockito.Mockito.doNothing;
 
  27 import static org.mockito.Mockito.mock;
 
  28 import static org.mockito.Mockito.when;
 
  30 import java.io.BufferedReader;
 
  31 import java.io.StringReader;
 
  32 import java.io.UnsupportedEncodingException;
 
  33 import java.util.ArrayList;
 
  34 import java.util.List;
 
  36 import javax.servlet.http.HttpServletRequest;
 
  38 import org.junit.Before;
 
  39 import org.junit.Test;
 
  40 import org.mockito.Mockito;
 
  41 import org.onap.policy.common.logging.flexlogger.FlexLogger;
 
  42 import org.onap.policy.common.logging.flexlogger.Logger;
 
  43 import org.onap.policy.pap.xacml.rest.util.DictionaryUtils;
 
  44 import org.onap.policy.rest.dao.CommonClassDao;
 
  45 import org.onap.policy.rest.jpa.DCAEuuid;
 
  46 import org.onap.policy.rest.jpa.MicroServiceLocation;
 
  47 import org.onap.policy.rest.jpa.MicroServiceModels;
 
  48 import org.onap.policy.rest.jpa.UserInfo;
 
  49 import org.springframework.mock.web.MockHttpServletResponse;
 
  52  * The class <code>MicroServiceDictionaryControllerTest</code> contains tests
 
  53  * for the class {@link <code>MicroServiceDictionaryController</code>}*
 
  55  * All JUnits are designed to run in the local development environment
 
  56  * where they have write privileges and can execute time-sensitive
 
  60 public class MicroServiceDictionaryControllerTest {
 
  62         private static Logger logger = FlexLogger.getLogger(MicroServiceDictionaryControllerTest.class);
 
  63         private static CommonClassDao commonClassDao;
 
  64         private String jsonString = null;
 
  65         private HttpServletRequest request = null;
 
  66         private MicroServiceDictionaryController controller = null;
 
  67          BufferedReader br = null;
 
  70         public void setUp() throws Exception {
 
  71                 logger.info("setUp: Entering");
 
  72         commonClassDao = Mockito.mock(CommonClassDao.class);
 
  73         UserInfo userInfo = new UserInfo();
 
  74         userInfo.setUserLoginId("testUserId");
 
  75         userInfo.setUserName("John");
 
  76         when(commonClassDao.getEntityItem(UserInfo.class, "userLoginId", "testing")).thenReturn(userInfo);
 
  78         List<String>  listIds = new ArrayList<String>();
 
  80         when(commonClassDao.getDataByColumn(DCAEuuid.class, "name")).thenReturn(listIds);
 
  82         List<String>  microList = new ArrayList<String>();
 
  83         microList.add("MC-Model");
 
  84         when(commonClassDao.getDataByColumn(MicroServiceLocation.class, "name")).thenReturn(microList);
 
  86         List<Object>  listId = new ArrayList<Object>();
 
  88         when(commonClassDao.getData(DCAEuuid.class)).thenReturn(listId);
 
  89         MicroServiceModels microServiceModels = new MicroServiceModels();
 
  91         doNothing().when(commonClassDao).delete(microServiceModels);
 
  93                 MicroServiceDictionaryController.setCommonClassDao(commonClassDao);     
 
  95                 controller = new MicroServiceDictionaryController();
 
  97         HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
 
  99                 jsonString = "{\"microServiceModelsDictionaryData\": {\"modelName\": \"test\",  \"inprocess\": false,\"model\": {\"name\": \"testingdata\", "
 
 100                                 + " \"subScopename\": \"\",\"path\": [],\"type\": \"dir\",\"size\": 0,\"date\": \"2017-04-12T21:26:57.000Z\", "
 
 101                                 + " \"version\": \"\",\"createdBy\": \"someone\",       \"modifiedBy\": \"someone\",    \"content\": \"\",\"recursive\": false},"
 
 102                                 + " \"tempModel\": {\"name\": \"testingdata\",\"subScopename\": \"\"    },"
 
 103                                 + " \"policy\": {\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\",\"policyName\": \"may1501\", "
 
 104                                 + "     \"policyDescription\": \"testing input\", \"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\",\"riskLevel\": \"2\","
 
 105                                 + "     \"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\",\"version\": \"1707.41.02\",\"ruleGridData\": [ [\"fileId\"]],\"ttlDate\": null}}, "
 
 106                                 + "     \"policyJSON\": {\"pmTableName\": \"test\",     \"dmdTopic\": \"1\",\"fileId\": \"56\"} }";
 
 108         br = new BufferedReader(new StringReader(jsonString));
 
 109         //--- mock the getReader() call
 
 110         when(request.getReader()).thenReturn(br);   
 
 111         new DictionaryUtils(commonClassDao);
 
 112         DictionaryUtils.setDictionaryUtils(new DictionaryUtils());
 
 113         mock(DictionaryUtils.class);        
 
 114         logger.info("setUp: exit");
 
 119         public void testGetDCAEUUIDDictionaryByNameEntityData() {
 
 121                 logger.info("testGetDCAEUUIDDictionaryByNameEntityData: Entering");
 
 123                 MockHttpServletResponse response =  new MockHttpServletResponse();
 
 125                 controller.getDCAEUUIDDictionaryByNameEntityData(response);
 
 128                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("dcaeUUIDDictionaryDatas"));
 
 129                         logger.info("response.getContentAsString(): " + response.getContentAsString());
 
 130                 } catch (UnsupportedEncodingException e) {
 
 131                         fail("Exception: " + e);
 
 134                 logger.info("testGetDCAEUUIDDictionaryByNameEntityData: exit");
 
 138         public void testGetDCAEUUIDDictionaryEntityData() {
 
 140                 logger.info("testGetDCAEUUIDDictionaryEntityData: Entering");
 
 142                 MockHttpServletResponse response =  new MockHttpServletResponse();
 
 144                 controller.getDCAEUUIDDictionaryEntityData(response);
 
 147                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("dcaeUUIDDictionaryDatas"));
 
 148                         logger.info("response.getContentAsString(): " + response.getContentAsString());
 
 149                 } catch (UnsupportedEncodingException e) {
 
 150                         fail("Exception: " + e);
 
 153                 logger.info("testGetDCAEUUIDDictionaryEntityData: exit");
 
 157         public void testSaveDCAEUUIDDictionary() {
 
 158                 logger.info("testSaveDCAEUUIDDictionary: Entering");
 
 160                 MockHttpServletResponse response =  new MockHttpServletResponse();
 
 161             request = mock(HttpServletRequest.class);   
 
 164                     // mock the getReader() call
 
 165                         jsonString = "{\"dcaeUUIDDictionaryData\": {\"modelName\": \"test\",    \"inprocess\": false,\"model\": {\"name\": \"testingdata\", "
 
 166                                         + " \"subScopename\": \"\",\"path\": [],\"type\": \"dir\",\"size\": 0,\"date\": \"2017-04-12T21:26:57.000Z\", "
 
 167                                         + " \"version\": \"\",\"createdBy\": \"someone\",       \"modifiedBy\": \"someone\",    \"content\": \"\",\"recursive\": false},"
 
 168                                         + " \"tempModel\": {\"name\": \"testingdata\",\"subScopename\": \"\"    },"
 
 169                                         + " \"policy\": {\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\",\"policyName\": \"may1501\", "
 
 170                                         + "     \"policyDescription\": \"testing input\", \"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\",\"riskLevel\": \"2\","
 
 171                                         + "     \"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\",\"version\": \"1707.41.02\",\"ruleGridData\": [ [\"fileId\"]],\"ttlDate\": null}}, "
 
 172                                         + "     \"policyJSON\": {\"pmTableName\": \"test\",     \"dmdTopic\": \"1\",\"fileId\": \"56\"} }";
 
 173                         BufferedReader br = new BufferedReader(new StringReader(jsonString));
 
 174                         when(request.getReader()).thenReturn(br);                   
 
 175                         controller.saveDCAEUUIDDictionary(request, response);
 
 176                         logger.info("response.getContentAsString(): " + response.getContentAsString());
 
 177                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("dcaeUUIDDictionaryDatas"));
 
 179                 } catch (Exception e) {
 
 180                         fail("Exception: " + e);
 
 183                 logger.info("testSaveDCAEUUIDDictionary: exit");
 
 187         public void testRemoveDCAEUUIDDictionary() {
 
 188                 logger.info("testRemoveDCAEUUIDDictionary: Entering");
 
 190                 MockHttpServletResponse response =  new MockHttpServletResponse();
 
 191             request = mock(HttpServletRequest.class);   
 
 194                     // mock the getReader() call
 
 195                         jsonString = "{\"data\": {\"modelName\": \"test\",      \"inprocess\": false,\"model\": {\"name\": \"testingdata\", "
 
 196                                         + " \"subScopename\": \"\",\"path\": [],\"type\": \"dir\",\"size\": 0,\"date\": \"2017-04-12T21:26:57.000Z\", "
 
 197                                         + " \"version\": \"\",\"createdBy\": \"someone\",       \"modifiedBy\": \"someone\",    \"content\": \"\",\"recursive\": false},"
 
 198                                         + " \"tempModel\": {\"name\": \"testingdata\",\"subScopename\": \"\"    },"
 
 199                                         + " \"policy\": {\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\",\"policyName\": \"may1501\", "
 
 200                                         + "     \"policyDescription\": \"testing input\", \"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\",\"riskLevel\": \"2\","
 
 201                                         + "     \"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\",\"version\": \"1707.41.02\",\"ruleGridData\": [ [\"fileId\"]],\"ttlDate\": null}}, "
 
 202                                         + "     \"policyJSON\": {\"pmTableName\": \"test\",     \"dmdTopic\": \"1\",\"fileId\": \"56\"} }";
 
 203                         BufferedReader br = new BufferedReader(new StringReader(jsonString));
 
 204                         when(request.getReader()).thenReturn(br);                   
 
 205                         controller.removeMicroServiceConfigNameDictionary(request, response);
 
 206                         logger.info("response.getContentAsString(): " + response.getContentAsString());
 
 207                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceConfigNameDictionaryDatas"));
 
 209                 } catch (Exception e) {
 
 210                         fail("Exception: " + e);
 
 213                 logger.info("testRemoveDCAEUUIDDictionary: exit");
 
 217         public void testGetMicroServiceConfigNameByNameDictionaryEntityData() {
 
 218                 logger.info("testGetMicroServiceConfigNameByNameDictionaryEntityData: Entering");
 
 220                 MockHttpServletResponse response =  new MockHttpServletResponse();
 
 222                 controller.getMicroServiceConfigNameByNameDictionaryEntityData(response);
 
 225                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceConfigNameDictionaryDatas"));
 
 226                         logger.info("response.getContentAsString(): " + response.getContentAsString());
 
 227                 } catch (UnsupportedEncodingException e) {
 
 228                         fail("Exception: " + e);
 
 231                 logger.info("testGetMicroServiceConfigNameByNameDictionaryEntityData: exit");
 
 235         public void testGetMicroServiceConfigNameDictionaryEntityData() {
 
 236                 logger.info("testGetMicroServiceConfigNameByNameDictionaryEntityData: Entering");
 
 238                 MockHttpServletResponse response =  new MockHttpServletResponse();
 
 240                 controller.getMicroServiceConfigNameDictionaryEntityData(response);
 
 243                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceConfigNameDictionaryDatas"));
 
 244                         logger.info("response.getContentAsString(): " + response.getContentAsString());
 
 245                 } catch (UnsupportedEncodingException e) {
 
 246                         fail("Exception: " + e);
 
 249                 logger.info("testGetMicroServiceConfigNameDictionaryEntityData: exit");
 
 253         public void testSaveMicroServiceConfigNameDictionary() {
 
 254                 logger.info("testSaveMicroServiceConfigNameDictionary: Entering");
 
 256                 MockHttpServletResponse response =  new MockHttpServletResponse();
 
 257             request = mock(HttpServletRequest.class);   
 
 260                     // mock the getReader() call
 
 261                         jsonString = "{\"microServiceConfigNameDictionaryData\": {\"modelName\": \"test\",      \"inprocess\": false,\"model\": {\"name\": \"testingdata\", "
 
 262                                         + " \"subScopename\": \"\",\"path\": [],\"type\": \"dir\",\"size\": 0,\"date\": \"2017-04-12T21:26:57.000Z\", "
 
 263                                         + " \"version\": \"\",\"createdBy\": \"someone\",       \"modifiedBy\": \"someone\",    \"content\": \"\",\"recursive\": false},"
 
 264                                         + " \"tempModel\": {\"name\": \"testingdata\",\"subScopename\": \"\"    },"
 
 265                                         + " \"policy\": {\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\",\"policyName\": \"may1501\", "
 
 266                                         + "     \"policyDescription\": \"testing input\", \"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\",\"riskLevel\": \"2\","
 
 267                                         + "     \"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\",\"version\": \"1707.41.02\",\"ruleGridData\": [ [\"fileId\"]],\"ttlDate\": null}}, "
 
 268                                         + "     \"policyJSON\": {\"pmTableName\": \"test\",     \"dmdTopic\": \"1\",\"fileId\": \"56\"} }";
 
 269                         BufferedReader br = new BufferedReader(new StringReader(jsonString));
 
 270                         when(request.getReader()).thenReturn(br);                   
 
 271                         controller.saveMicroServiceConfigNameDictionary(request, response);
 
 272                         logger.info("response.getContentAsString(): " + response.getContentAsString());
 
 273                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceConfigNameDictionaryDatas"));
 
 275                 } catch (Exception e) {
 
 276                         fail("Exception: " + e);
 
 279                 logger.info("testSaveMicroServiceConfigNameDictionary: exit");
 
 283         public void testRemoveMicroServiceConfigNameDictionary() {
 
 284                 logger.info("testRemoveMicroServiceConfigNameDictionary: Entering");
 
 286                 MockHttpServletResponse response =  new MockHttpServletResponse();
 
 287             request = mock(HttpServletRequest.class);   
 
 290                     // mock the getReader() call
 
 291                         jsonString = "{\"data\": {\"modelName\": \"test\",      \"inprocess\": false,\"model\": {\"name\": \"testingdata\", "
 
 292                                         + " \"subScopename\": \"\",\"path\": [],\"type\": \"dir\",\"size\": 0,\"date\": \"2017-04-12T21:26:57.000Z\", "
 
 293                                         + " \"version\": \"\",\"createdBy\": \"someone\",       \"modifiedBy\": \"someone\",    \"content\": \"\",\"recursive\": false},"
 
 294                                         + " \"tempModel\": {\"name\": \"testingdata\",\"subScopename\": \"\"    },"
 
 295                                         + " \"policy\": {\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\",\"policyName\": \"may1501\", "
 
 296                                         + "     \"policyDescription\": \"testing input\", \"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\",\"riskLevel\": \"2\","
 
 297                                         + "     \"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\",\"version\": \"1707.41.02\",\"ruleGridData\": [ [\"fileId\"]],\"ttlDate\": null}}, "
 
 298                                         + "     \"policyJSON\": {\"pmTableName\": \"test\",     \"dmdTopic\": \"1\",\"fileId\": \"56\"} }";
 
 299                         BufferedReader br = new BufferedReader(new StringReader(jsonString));
 
 300                         when(request.getReader()).thenReturn(br);                   
 
 301                         controller.removeMicroServiceConfigNameDictionary(request, response);
 
 302                         logger.info("response.getContentAsString(): " + response.getContentAsString());
 
 303                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceConfigNameDictionaryDatas"));
 
 305                 } catch (Exception e) {
 
 306                         fail("Exception: " + e);
 
 309                 logger.info("testRemoveMicroServiceConfigNameDictionary: exit");
 
 313         public void testGetMicroServiceLocationByNameDictionaryEntityData() {
 
 315                 logger.info("testGetMicroServiceLocationByNameDictionaryEntityData: Entering");
 
 317                 MockHttpServletResponse response =  new MockHttpServletResponse();
 
 319                 controller.getMicroServiceLocationByNameDictionaryEntityData(response);
 
 322                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceLocationDictionaryDatas"));
 
 323                         logger.info("response.getContentAsString(): " + response.getContentAsString());
 
 324                 } catch (UnsupportedEncodingException e) {
 
 325                         fail("Exception: " + e);
 
 328                 logger.info("testGetMicroServiceLocationByNameDictionaryEntityData: exit");
 
 332         public void testGetMicroServiceLocationDictionaryEntityData() {
 
 333                 logger.info("testGetMicroServiceLocationDictionaryEntityData: Entering");
 
 335                 MockHttpServletResponse response =  new MockHttpServletResponse();
 
 337                 controller.getMicroServiceLocationDictionaryEntityData(response);
 
 340                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceLocationDictionaryDatas"));
 
 341                         logger.info("response.getContentAsString(): " + response.getContentAsString());
 
 342                 } catch (UnsupportedEncodingException e) {
 
 343                         fail("Exception: " + e);
 
 346                 logger.info("testGetMicroServiceLocationDictionaryEntityData: exit");
 
 350         public void testSaveMicroServiceLocationDictionary() {
 
 351                 logger.info("testSaveMicroServiceLocationDictionary: Entering");
 
 353                 MockHttpServletResponse response =  new MockHttpServletResponse();
 
 354             request = mock(HttpServletRequest.class);   
 
 357                     // mock the getReader() call
 
 358                         jsonString = "{\"microServiceLocationDictionaryData\": {\"modelName\": \"test\",        \"inprocess\": false,\"model\": {\"name\": \"testingdata\", "
 
 359                                         + " \"subScopename\": \"\",\"path\": [],\"type\": \"dir\",\"size\": 0,\"date\": \"2017-04-12T21:26:57.000Z\", "
 
 360                                         + " \"version\": \"\",\"createdBy\": \"someone\",       \"modifiedBy\": \"someone\",    \"content\": \"\",\"recursive\": false},"
 
 361                                         + " \"tempModel\": {\"name\": \"testingdata\",\"subScopename\": \"\"    },"
 
 362                                         + " \"policy\": {\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\",\"policyName\": \"may1501\", "
 
 363                                         + "     \"policyDescription\": \"testing input\", \"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\",\"riskLevel\": \"2\","
 
 364                                         + "     \"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\",\"version\": \"1707.41.02\",\"ruleGridData\": [ [\"fileId\"]],\"ttlDate\": null}}, "
 
 365                                         + "     \"policyJSON\": {\"pmTableName\": \"test\",     \"dmdTopic\": \"1\",\"fileId\": \"56\"} }";
 
 366                         BufferedReader br = new BufferedReader(new StringReader(jsonString));
 
 367                         when(request.getReader()).thenReturn(br);                   
 
 368                         controller.saveMicroServiceLocationDictionary(request, response);
 
 369                         logger.info("response.getContentAsString(): " + response.getContentAsString());
 
 370                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceLocationDictionaryDatas"));
 
 372                 } catch (Exception e) {
 
 373                         fail("Exception: " + e);
 
 376                 logger.info("testSaveMicroServiceLocationDictionary: exit");
 
 380         public void testRemoveMicroServiceLocationDictionary() {
 
 381                 logger.info("testRemoveMicroServiceLocationDictionary: Entering");
 
 383                 MockHttpServletResponse response =  new MockHttpServletResponse();
 
 384             request = mock(HttpServletRequest.class);   
 
 387                     // mock the getReader() call
 
 388                         jsonString = "{\"data\": {\"modelName\": \"test\",      \"inprocess\": false,\"model\": {\"name\": \"testingdata\", "
 
 389                                         + " \"subScopename\": \"\",\"path\": [],\"type\": \"dir\",\"size\": 0,\"date\": \"2017-04-12T21:26:57.000Z\", "
 
 390                                         + " \"version\": \"\",\"createdBy\": \"someone\",       \"modifiedBy\": \"someone\",    \"content\": \"\",\"recursive\": false},"
 
 391                                         + " \"tempModel\": {\"name\": \"testingdata\",\"subScopename\": \"\"    },"
 
 392                                         + " \"policy\": {\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\",\"policyName\": \"may1501\", "
 
 393                                         + "     \"policyDescription\": \"testing input\", \"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\",\"riskLevel\": \"2\","
 
 394                                         + "     \"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\",\"version\": \"1707.41.02\",\"ruleGridData\": [ [\"fileId\"]],\"ttlDate\": null}}, "
 
 395                                         + "     \"policyJSON\": {\"pmTableName\": \"test\",     \"dmdTopic\": \"1\",\"fileId\": \"56\"} }";
 
 396                         BufferedReader br = new BufferedReader(new StringReader(jsonString));
 
 398                         when(request.getReader()).thenReturn(br);                   
 
 399                         controller.removeMicroServiceLocationDictionary(request, response);
 
 400                         logger.info("response.getContentAsString(): " + response.getContentAsString());
 
 401                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceLocationDictionaryDatas"));
 
 403                 } catch (Exception e) {
 
 404                         fail("Exception: " + e);
 
 407                 logger.info("testRemoveMicroServiceLocationDictionary: exit");
 
 411         public void testGetMicroServiceAttributeByNameDictionaryEntityData() {
 
 412                 logger.info("testGetMicroServiceAttributeByNameDictionaryEntityData: Entering");
 
 414                 MockHttpServletResponse response =  new MockHttpServletResponse();
 
 416                 controller.getMicroServiceAttributeByNameDictionaryEntityData(response);
 
 419                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceAttributeDictionaryDatas"));
 
 420                         logger.info("response.getContentAsString(): " + response.getContentAsString());
 
 421                 } catch (UnsupportedEncodingException e) {
 
 422                         fail("Exception: " + e);
 
 425                 logger.info("testGetMicroServiceAttributeByNameDictionaryEntityData: exit");
 
 429         public void testGetMicroServiceAttributeDictionaryEntityData() {
 
 430                 logger.info("testGetMicroServiceAttributeDictionaryEntityData: Entering");
 
 432                 MockHttpServletResponse response =  new MockHttpServletResponse();
 
 434                 controller.getMicroServiceAttributeDictionaryEntityData(response);
 
 437                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceAttributeDictionaryDatas"));
 
 438                         logger.info("response.getContentAsString(): " + response.getContentAsString());
 
 439                 } catch (UnsupportedEncodingException e) {
 
 440                         fail("Exception: " + e);
 
 443                 logger.info("testGetMicroServiceAttributeDictionaryEntityData: exit");
 
 447         public void testSaveMicroServiceAttributeDictionary() {
 
 448                 logger.info("testSaveMicroServiceAttributeDictionary: Entering");
 
 450                 MockHttpServletResponse response =  new MockHttpServletResponse();
 
 451             request = mock(HttpServletRequest.class);   
 
 454                     // mock the getReader() call
 
 455                         jsonString = "{\"modelAttributeDictionaryData\": {\"modelName\": \"test\",      \"inprocess\": false,\"model\": {\"name\": \"testingdata\", "
 
 456                                         + " \"subScopename\": \"\",\"path\": [],\"type\": \"dir\",\"size\": 0,\"date\": \"2017-04-12T21:26:57.000Z\", "
 
 457                                         + " \"version\": \"\",\"createdBy\": \"someone\",       \"modifiedBy\": \"someone\",    \"content\": \"\",\"recursive\": false},"
 
 458                                         + " \"tempModel\": {\"name\": \"testingdata\",\"subScopename\": \"\"    },"
 
 459                                         + " \"policy\": {\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\",\"policyName\": \"may1501\", "
 
 460                                         + "     \"policyDescription\": \"testing input\", \"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\",\"riskLevel\": \"2\","
 
 461                                         + "     \"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\",\"version\": \"1707.41.02\",\"ruleGridData\": [ [\"fileId\"]],\"ttlDate\": null}}, "
 
 462                                         + "     \"policyJSON\": {\"pmTableName\": \"test\",     \"dmdTopic\": \"1\",\"fileId\": \"56\"} }";
 
 463                         BufferedReader br = new BufferedReader(new StringReader(jsonString));
 
 464                         when(request.getReader()).thenReturn(br);                   
 
 465                         controller.saveMicroServiceAttributeDictionary(request, response);
 
 466                         logger.info("response.getContentAsString(): " + response.getContentAsString());
 
 467                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceAttributeDictionaryDatas"));
 
 469                 } catch (Exception e) {
 
 470                         fail("Exception: " + e);
 
 473                 logger.info("testSaveMicroServiceAttributeDictionary: exit");
 
 477         public void testRemoveMicroServiceAttributeDictionary() {
 
 478                 logger.info("testRemoveMicroServiceAttributeDictionary: Entering");
 
 480                 MockHttpServletResponse response =  new MockHttpServletResponse();
 
 481             request = mock(HttpServletRequest.class);   
 
 484                     // mock the getReader() call
 
 485                         jsonString = "{\"data\": {\"modelName\": \"test\",      \"inprocess\": false,\"model\": {\"name\": \"testingdata\", "
 
 486                                         + " \"subScopename\": \"\",\"path\": [],\"type\": \"dir\",\"size\": 0,\"date\": \"2017-04-12T21:26:57.000Z\", "
 
 487                                         + " \"version\": \"\",\"createdBy\": \"someone\",       \"modifiedBy\": \"someone\",    \"content\": \"\",\"recursive\": false},"
 
 488                                         + " \"tempModel\": {\"name\": \"testingdata\",\"subScopename\": \"\"    },"
 
 489                                         + " \"policy\": {\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\",\"policyName\": \"may1501\", "
 
 490                                         + "     \"policyDescription\": \"testing input\", \"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\",\"riskLevel\": \"2\","
 
 491                                         + "     \"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\",\"version\": \"1707.41.02\",\"ruleGridData\": [ [\"fileId\"]],\"ttlDate\": null}}, "
 
 492                                         + "     \"policyJSON\": {\"pmTableName\": \"test\",     \"dmdTopic\": \"1\",\"fileId\": \"56\"} }";
 
 493                         BufferedReader br = new BufferedReader(new StringReader(jsonString));
 
 494                         when(request.getReader()).thenReturn(br);                   
 
 495                         controller.removeMicroServiceAttributeDictionary(request, response);
 
 496                         logger.info("response.getContentAsString(): " + response.getContentAsString());
 
 497                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceAttributeDictionaryDatas"));
 
 499                 } catch (Exception e) {
 
 500                         fail("Exception: " + e);
 
 503                 logger.info("testRemoveMicroServiceAttributeDictionary: exit");
 
 507         public void testGetMicroServiceModelsDictionaryByNameEntityData() {
 
 508                 logger.info("testGetMicroServiceModelsDictionaryByNameEntityData: Entering");
 
 510                 MockHttpServletResponse response =  new MockHttpServletResponse();
 
 512                 controller.getMicroServiceModelsDictionaryByNameEntityData(response);
 
 515                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceModelsDictionaryDatas"));
 
 516                         logger.info("response.getContentAsString(): " + response.getContentAsString());
 
 517                 } catch (UnsupportedEncodingException e) {
 
 518                         fail("Exception: " + e);
 
 521                 logger.info("testGetMicroServiceModelsDictionaryByNameEntityData: exit");
 
 525         public void testGetMicroServiceModelsDictionaryByVersionEntityData() {
 
 526                 logger.info("testGetMicroServiceModelsDictionaryByVersionEntityData: Entering");
 
 528                 MockHttpServletResponse response =  new MockHttpServletResponse();
 
 529                 String msModelJson = "{\"microServiceModelsDictionaryData\":[\"modelName\"]}";
 
 531             BufferedReader br = new BufferedReader(new StringReader(msModelJson));
 
 532             request = mock(HttpServletRequest.class);   
 
 535                     // mock the getReader() call
 
 536                         when(request.getReader()).thenReturn(br);                   
 
 537                         controller.getMicroServiceModelsDictionaryByVersionEntityData(request, response);
 
 538                         logger.info("response.getContentAsString(): " + response.getContentAsString());
 
 539                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("No model name given"));
 
 541                 } catch (Exception e) {
 
 542                         fail("Exception: " + e);
 
 545                 logger.info("testGetMicroServiceModelsDictionaryByVersionEntityData: exit");
 
 549         public void testGetMicroServiceModelsDictionaryEntityData() {
 
 550                 logger.info("testGetMicroServiceModelsDictionaryEntityData: Entering");
 
 552                 MockHttpServletResponse response =  new MockHttpServletResponse();
 
 553                 String msModelJson = "{\"microServiceModelsDictionaryData\":[\"modelName\"]}";
 
 555             BufferedReader br = new BufferedReader(new StringReader(msModelJson));
 
 556             request = mock(HttpServletRequest.class);   
 
 559                     // mock the getReader() call
 
 560                         when(request.getReader()).thenReturn(br);                   
 
 561                         controller.getMicroServiceModelsDictionaryEntityData(response);
 
 562                         logger.info("response.getContentAsString(): " + response.getContentAsString());
 
 563                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceModelsDictionaryDatas"));
 
 565                 } catch (Exception e) {
 
 566                         fail("Exception: " + e);
 
 569                 logger.info("testGetMicroServiceModelsDictionaryEntityData: exit");
 
 573         public void testGetMicroServiceModelsDictionaryEntityDataServiceVersion() {
 
 574                 logger.info("testGetMicroServiceModelsDictionaryEntityDataServiceVersion: Entering");
 
 576                 MockHttpServletResponse response =  new MockHttpServletResponse();
 
 577                 String msModelJson = "{\"microServiceModelsDictionaryData\":[\"modelName\"]}";
 
 579             BufferedReader br = new BufferedReader(new StringReader(msModelJson));
 
 580             request = mock(HttpServletRequest.class);   
 
 583                     // mock the getReader() call
 
 584                         when(request.getReader()).thenReturn(br);                   
 
 585                         controller.getMicroServiceModelsDictionaryEntityDataServiceVersion(response);
 
 586                         logger.info("response.getContentAsString(): " + response.getContentAsString());
 
 587                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceModelsDictionaryDatas"));
 
 589                 } catch (Exception e) {
 
 590                         fail("Exception: " + e);
 
 593                 logger.info("testGetMicroServiceModelsDictionaryEntityDataServiceVersion: exit");
 
 597         public void testGetMicroServiceModelsDictionaryClassEntityData() {
 
 598                 logger.info("testGetMicroServiceModelsDictionaryClassEntityData: Entering");
 
 600                 MockHttpServletResponse response =  new MockHttpServletResponse();
 
 601                 String msModelJson = "{\"microServiceModelsDictionaryData\":[\"modelName\"]}";
 
 603             BufferedReader br = new BufferedReader(new StringReader(msModelJson));
 
 604             request = mock(HttpServletRequest.class);   
 
 607                     // mock the getReader() call
 
 608                         when(request.getReader()).thenReturn(br);                   
 
 609                         controller.getMicroServiceModelsDictionaryClassEntityData(response);
 
 610                         logger.info("response.getContentAsString(): " + response.getContentAsString());
 
 611                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceModelsDictionaryClassDatas"));
 
 613                 } catch (Exception e) {
 
 614                         fail("Exception: " + e);
 
 617                 logger.info("testGetMicroServiceModelsDictionaryClassEntityData: exit");
 
 621         public void testSaveMicroServiceModelsDictionary() {
 
 622                 logger.info("testSaveMicroServiceModelsDictionary: Entering");
 
 624                 MockHttpServletResponse response =  new MockHttpServletResponse();
 
 625             request = mock(HttpServletRequest.class);   
 
 628                     // mock the getReader() call
 
 629                         when(request.getReader()).thenReturn(br);                   
 
 630                         controller.saveMicroServiceModelsDictionary(request, response);
 
 631                         logger.info("response.getContentAsString(): " + response.getContentAsString());
 
 632                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceModelsDictionaryDatas"));
 
 634                 } catch (Exception e) {
 
 635                         fail("Exception: " + e);
 
 638                 logger.info("testSaveMicroServiceModelsDictionary: exit");
 
 642         public void testRemoveMicroServiceModelsDictionary() {
 
 643                 logger.info("testRemoveMicroServiceModelsDictionary: Entering");
 
 645                 MockHttpServletResponse response =  new MockHttpServletResponse();
 
 646             request = mock(HttpServletRequest.class);   
 
 649                     // mock the getReader() call
 
 650                         jsonString = "{\"data\": {\"modelName\": \"test\",      \"inprocess\": false,\"model\": {\"name\": \"testingdata\", "
 
 651                                         + " \"subScopename\": \"\",\"path\": [],\"type\": \"dir\",\"size\": 0,\"date\": \"2017-04-12T21:26:57.000Z\", "
 
 652                                         + " \"version\": \"\",\"createdBy\": \"someone\",       \"modifiedBy\": \"someone\",    \"content\": \"\",\"recursive\": false},"
 
 653                                         + " \"tempModel\": {\"name\": \"testingdata\",\"subScopename\": \"\"    },"
 
 654                                         + " \"policy\": {\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\",\"policyName\": \"may1501\", "
 
 655                                         + "     \"policyDescription\": \"testing input\", \"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\",\"riskLevel\": \"2\","
 
 656                                         + "     \"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\",\"version\": \"1707.41.02\",\"ruleGridData\": [ [\"fileId\"]],\"ttlDate\": null}}, "
 
 657                                         + "     \"policyJSON\": {\"pmTableName\": \"test\",     \"dmdTopic\": \"1\",\"fileId\": \"56\"} }";
 
 659                         BufferedReader br = new BufferedReader(new StringReader(jsonString));
 
 660                         when(request.getReader()).thenReturn(br);                   
 
 661                         controller.removeMicroServiceModelsDictionary(request, response);
 
 662                         logger.info("response.getContentAsString(): " + response.getContentAsString());
 
 663                         assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceModelsDictionaryDatas"));
 
 665                 } catch (Exception e) {
 
 666                         fail("Exception: " + e);
 
 669                 logger.info("testRemoveMicroServiceModelsDictionary: exit");