summaryrefslogtreecommitdiffstats
path: root/ONAP-PAP-REST/src/test
diff options
context:
space:
mode:
authorMichael Mokry <mm117s@att.com>2018-03-16 20:50:41 -0500
committerMichael Mokry <mm117s@att.com>2018-03-26 09:43:24 -0500
commitb6d9063e06ab8cdf2d97fc75810792659344e4a8 (patch)
tree189c47e59cef6650ba0d39bbee31dcdaaa3ddbc7 /ONAP-PAP-REST/src/test
parentc8bed1e392b935ec50aaeeb5fb82d25a9568b790 (diff)
New Optimization Policy
This is the new Optimization Policy to support the Integration of the OOF Policy Model into the Policy Platform. Added changes from Frank Wang to fix the following issues with existing Model Parser: 1. TOSCA Rendering issues 2. Matching Attributes support 3. ImportModelAPI to support TOSCA model upload via REST API Running local Sonar tonight to start fixing Sonar issues Added changes per review comments and fixed Sonar issues Change-Id: Ia8ce09c28a718ce4460475e76a750caef774bd6b Issue-ID: POLICY-622 Signed-off-by: Michael Mokry <mm117s@att.com>
Diffstat (limited to 'ONAP-PAP-REST/src/test')
-rw-r--r--ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/components/MicroServicePolicyTest.java2
-rw-r--r--ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/components/OptimizationConfigPolicyTest.java105
-rw-r--r--ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/DictionaryImportControllerTest.java13
-rw-r--r--ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/MicroServiceDictionaryControllerTest.java92
-rw-r--r--ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/OptimizationDictionaryControllerTest.java173
-rw-r--r--ONAP-PAP-REST/src/test/resources/dictionaryImport/OptimizationPolicyDictionary.csv2
6 files changed, 380 insertions, 7 deletions
diff --git a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/components/MicroServicePolicyTest.java b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/components/MicroServicePolicyTest.java
index 39b21f184..a47c2be58 100644
--- a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/components/MicroServicePolicyTest.java
+++ b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/components/MicroServicePolicyTest.java
@@ -105,7 +105,7 @@ public class MicroServicePolicyTest {
String testFileName = "testFile.zip";
String testVal = "testVal";
CreateNewMicroServiceModel model = new CreateNewMicroServiceModel(testFileName, testVal, testVal, testVal, testVal);
- model.addValuesToNewModel();
+ model.addValuesToNewModel(".xmi");
model.saveImportService();
}
}
diff --git a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/components/OptimizationConfigPolicyTest.java b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/components/OptimizationConfigPolicyTest.java
new file mode 100644
index 000000000..7b9be6891
--- /dev/null
+++ b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/components/OptimizationConfigPolicyTest.java
@@ -0,0 +1,105 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP-PAP-REST
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.policy.pap.xacml.rest.components;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.fail;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.when;
+import static org.mockito.Matchers.any;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.junit.runner.RunWith;
+import org.mockito.Mockito;
+import org.onap.policy.pap.xacml.rest.daoimpl.CommonClassDaoImpl;
+import org.onap.policy.rest.adapter.PolicyRestAdapter;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+import java.io.File;
+import java.util.Collections;
+
+@RunWith(PowerMockRunner.class)
+public class OptimizationConfigPolicyTest {
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ @Test
+ public void testConstructor1() {
+ thrown.expect(NullPointerException.class);
+ OptimizationConfigPolicy policy = new OptimizationConfigPolicy();
+ policy.getCorrectPolicyDataObject();
+ fail("Expected an exception");
+ }
+
+ @Test
+ public void testConstructor2() {
+ PolicyRestAdapter policyAdapter = new PolicyRestAdapter();
+ OptimizationConfigPolicy policy = new OptimizationConfigPolicy(policyAdapter);
+ assertNull(policy.getCorrectPolicyDataObject());
+ }
+
+ @PrepareForTest({OptimizationConfigPolicy.class})
+ @Test
+ public void testPrepareToSave() throws Exception {
+ // Need to mock internal dictionary retrieval
+ CommonClassDaoImpl impl = Mockito.mock(CommonClassDaoImpl.class);
+ PowerMockito.whenNew(CommonClassDaoImpl.class).withNoArguments().thenReturn(impl);
+ when(impl.getDataById(any(), anyString(), anyString())).thenReturn(null);
+
+ PolicyRestAdapter policyAdapter = new PolicyRestAdapter();
+ OptimizationConfigPolicy policy = new OptimizationConfigPolicy(policyAdapter);
+ policyAdapter.setHighestVersion(1);
+ policyAdapter.setPolicyType("Config");
+ policyAdapter.setNewFileName("foo.xml");
+ policyAdapter.setJsonBody("{ \"version\": \"1.0\"}");
+ policyAdapter.setServiceType("foo");
+ policy.prepareToSave();
+ assertEquals(true, policy.isPreparedToSave());
+ }
+
+ @PrepareForTest({CreateNewOptimizationModel.class})
+ @Test
+ public void testCreateModel() throws Exception {
+ // Mock file retrieval
+ File testFile = new File("testFile");
+ File[] testList = new File[1];
+ testList[0] = testFile;
+ File impl = Mockito.mock(File.class);
+ PowerMockito.whenNew(File.class).withAnyArguments().thenReturn(impl);
+ when(impl.listFiles()).thenReturn(testList);
+ when(impl.isFile()).thenReturn(true);
+
+ // Mock internal dictionary retrieval
+ CommonClassDaoImpl daoImpl = Mockito.mock(CommonClassDaoImpl.class);
+ PowerMockito.whenNew(CommonClassDaoImpl.class).withNoArguments().thenReturn(daoImpl);
+ when(daoImpl.getDataById(any(), anyString(), anyString())).thenReturn(Collections.emptyList());
+
+ // Test create methods
+ String testFileName = "testFile.zip";
+ String testVal = "testVal";
+ CreateNewOptimizationModel model = new CreateNewOptimizationModel(testFileName, testVal, testVal, testVal, testVal);
+ model.addValuesToNewModel();
+ model.saveImportService();
+ }
+}
diff --git a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/DictionaryImportControllerTest.java b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/DictionaryImportControllerTest.java
index 7c1c507c2..6a28c271a 100644
--- a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/DictionaryImportControllerTest.java
+++ b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/DictionaryImportControllerTest.java
@@ -42,15 +42,15 @@ import org.onap.policy.common.logging.flexlogger.Logger;
import org.onap.policy.rest.dao.CommonClassDao;
import org.springframework.mock.web.MockHttpServletResponse;
-public class DictionaryImportControllerTest extends Mockito{
+public class DictionaryImportControllerTest extends Mockito{
private static Logger logger = FlexLogger.getLogger(DictionaryImportController.class);
-
+
private static CommonClassDao commonClassDao;
private HttpServletRequest request = null;
private HttpServletResponse response = null;
private DictionaryImportController controller = null;
-
+
@Before
public void setUp() throws Exception {
logger.info("setUp: Entering");
@@ -59,7 +59,7 @@ public class DictionaryImportControllerTest extends Mockito{
controller = new DictionaryImportController();
new DictionaryImportController(commonClassDao);
request = Mockito.mock(HttpServletRequest.class);
- response = new MockHttpServletResponse();
+ response = new MockHttpServletResponse();
}
@Test
@@ -70,7 +70,7 @@ public class DictionaryImportControllerTest extends Mockito{
//test valid name
assertTrue(cotroller.isValidDictionaryName("ActionList"));
}
-
+
@Test
public void testImportDictionaryData() throws ServletException, IOException{
List<String> fileNames = new ArrayList<>();
@@ -78,6 +78,7 @@ public class DictionaryImportControllerTest extends Mockito{
fileNames.add("ActionPolicyDictionary.csv");
fileNames.add("OnapName.csv");
fileNames.add("MSPolicyDictionary.csv");
+ fileNames.add("OptimizationPolicyDictionary.csv");
fileNames.add("ClosedLoopService.csv");
fileNames.add("ClosedLoopSite.csv");
fileNames.add("VarbindDictionary.csv");
@@ -113,7 +114,7 @@ public class DictionaryImportControllerTest extends Mockito{
}
when(request.getParameter("dictionaryName")).thenReturn("WrongName");
controller.importDictionaryData(request, response);
- assertTrue(HttpServletResponse.SC_OK == response.getStatus());
+ assertTrue(HttpServletResponse.SC_BAD_REQUEST == response.getStatus());
when(request.getParameter("dictionaryName")).thenReturn("");
controller.importDictionaryData(request, response);
diff --git a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/MicroServiceDictionaryControllerTest.java b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/MicroServiceDictionaryControllerTest.java
index 36335ae5e..ae71692c1 100644
--- a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/MicroServiceDictionaryControllerTest.java
+++ b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/MicroServiceDictionaryControllerTest.java
@@ -114,6 +114,98 @@ public class MicroServiceDictionaryControllerTest {
logger.info("setUp: exit");
}
+
+ @Test
+ public void testSaveMicroServiceHeaderDefaultValues() {
+ logger.info("testSaveMicroServiceHeaderDefaultValues: Entering");
+
+ MockHttpServletResponse response = new MockHttpServletResponse();
+ request = mock(HttpServletRequest.class);
+
+ try {
+ // mock the getReader() call
+ jsonString = "{\"modelAttributeDictionaryData\": {\"onapName\": \"test\", \"guard\": false,\"priority\": \"3\","
+ + " \"riskType\": \"test\", \"riskLevel\": \"7\", \"modelName\": \"testname\"}}";
+ BufferedReader br = new BufferedReader(new StringReader(jsonString));
+ when(request.getReader()).thenReturn(br);
+ controller.saveMicroServiceHeaderDefaultValues(request, response);
+ logger.info("response.getContentAsString(): " + response.getContentAsString());
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceHeaderDefaultDatas"));
+
+ } catch (Exception e) {
+ fail("Exception: " + e);
+ }
+
+ logger.info("testSaveMicroServiceHeaderDefaultValues: exit");
+ }
+
+
+ @Test
+ public void testGetMicroServiceHeaderDefaultsEntityDataByName() {
+ logger.info("testGetMicroServiceHeaderDefaultsEntityDataByName: Entering");
+
+ MockHttpServletResponse response = new MockHttpServletResponse();
+
+ controller.getMicroServiceHeaderDefaultsEntityDataByName(response);
+
+ try {
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceHeaderDefaultDatas"));
+ logger.info("response.getContentAsString(): " + response.getContentAsString());
+ } catch (UnsupportedEncodingException e) {
+ fail("Exception: " + e);
+ }
+
+ logger.info("testGetMicroServiceHeaderDefaultsEntityDataByName: exit");
+ }
+
+ @Test
+ public void testGetMicroServiceHeaderDefaultsEntityData() {
+ logger.info("testGetMicroServiceHeaderDefaultsEntityData: Entering");
+
+ MockHttpServletResponse response = new MockHttpServletResponse();
+
+ controller.getMicroServiceHeaderDefaultsEntityData(response);
+
+ try {
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceHeaderDefaultDatas"));
+ logger.info("response.getContentAsString(): " + response.getContentAsString());
+ } catch (UnsupportedEncodingException e) {
+ fail("Exception: " + e);
+ }
+
+ logger.info("testGetMicroServiceHeaderDefaultsEntityData: exit");
+ }
+
+ @Test
+ public void testRemoveMicroServiceHeaderDefaults() {
+ logger.info("testRemoveMicroServiceHeaderDefaults: Entering");
+
+ MockHttpServletResponse response = new MockHttpServletResponse();
+ request = mock(HttpServletRequest.class);
+
+ try {
+ // mock the getReader() call
+ jsonString = "{\"data\": {\"modelName\": \"test\", \"inprocess\": false,\"model\": {\"name\": \"testingdata\", "
+ + " \"subScopename\": \"\",\"path\": [],\"type\": \"dir\",\"size\": 0,\"date\": \"2017-04-12T21:26:57.000Z\", "
+ + " \"version\": \"\",\"createdBy\": \"someone\", \"modifiedBy\": \"someone\", \"content\": \"\",\"recursive\": false},"
+ + " \"tempModel\": {\"name\": \"testingdata\",\"subScopename\": \"\" },"
+ + " \"policy\": {\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\",\"policyName\": \"may1501\", "
+ + " \"policyDescription\": \"testing input\", \"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\",\"riskLevel\": \"2\","
+ + " \"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\",\"version\": \"1707.41.02\",\"ruleGridData\": [ [\"fileId\"]],\"ttlDate\": null}}, "
+ + " \"policyJSON\": {\"pmTableName\": \"test\", \"dmdTopic\": \"1\",\"fileId\": \"56\"} }";
+ BufferedReader br = new BufferedReader(new StringReader(jsonString));
+ when(request.getReader()).thenReturn(br);
+ controller.removeMicroServiceHeaderDefaults(request, response);
+ logger.info("response.getContentAsString(): " + response.getContentAsString());
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("microServiceHeaderDefaultDatas"));
+
+ } catch (Exception e) {
+ fail("Exception: " + e);
+ }
+
+ logger.info("testRemoveMicroServiceHeaderDefaults: exit");
+ }
+
@Test
public void testGetDCAEUUIDDictionaryByNameEntityData() {
diff --git a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/OptimizationDictionaryControllerTest.java b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/OptimizationDictionaryControllerTest.java
new file mode 100644
index 000000000..edc08f31b
--- /dev/null
+++ b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/OptimizationDictionaryControllerTest.java
@@ -0,0 +1,173 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP-PAP-REST
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.policy.pap.xacml.rest.controller;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.io.BufferedReader;
+import java.io.StringReader;
+import java.io.UnsupportedEncodingException;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.onap.policy.common.logging.flexlogger.FlexLogger;
+import org.onap.policy.common.logging.flexlogger.Logger;
+import org.onap.policy.pap.xacml.rest.util.DictionaryUtils;
+import org.onap.policy.rest.dao.CommonClassDao;
+import org.onap.policy.rest.jpa.DCAEuuid;
+import org.onap.policy.rest.jpa.MicroServiceLocation;
+import org.onap.policy.rest.jpa.MicroServiceModels;
+import org.onap.policy.rest.jpa.OptimizationModels;
+import org.onap.policy.rest.jpa.UserInfo;
+import org.springframework.mock.web.MockHttpServletResponse;
+
+
+public class OptimizationDictionaryControllerTest {
+
+ private static Logger logger = FlexLogger.getLogger(OptimizationDictionaryControllerTest.class);
+ private static CommonClassDao commonClassDao;
+ private String jsonString = null;
+ private HttpServletRequest request = null;
+ private OptimizationDictionaryController controller = null;
+ BufferedReader br = null;
+
+ @Before
+ public void setUp() throws Exception {
+ logger.info("setUp: Entering");
+ commonClassDao = Mockito.mock(CommonClassDao.class);
+ UserInfo userInfo = new UserInfo();
+ userInfo.setUserLoginId("testUserId");
+ userInfo.setUserName("John");
+ when(commonClassDao.getEntityItem(UserInfo.class, "userLoginId", "testing")).thenReturn(userInfo);
+
+ OptimizationModels optimziationModels = new OptimizationModels();
+
+ doNothing().when(commonClassDao).delete(optimziationModels);
+
+ OptimizationDictionaryController.setCommonClassDao(commonClassDao);
+
+ controller = new OptimizationDictionaryController();
+
+ HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
+
+ jsonString = "{\"optimizationModelsDictionaryData\": {\"modelName\": \"test\", \"inprocess\": false,\"model\": {\"name\": \"testingdata\", "
+ + " \"subScopename\": \"\",\"path\": [],\"type\": \"dir\",\"size\": 0,\"date\": \"2017-04-12T21:26:57.000Z\", "
+ + " \"version\": \"\",\"createdBy\": \"someone\", \"modifiedBy\": \"someone\", \"content\": \"\",\"recursive\": false},"
+ + " \"tempModel\": {\"name\": \"testingdata\",\"subScopename\": \"\" },"
+ + " \"policy\": {\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\",\"policyName\": \"may1501\", "
+ + " \"policyDescription\": \"testing input\", \"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\",\"riskLevel\": \"2\","
+ + " \"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\",\"version\": \"1707.41.02\",\"ruleGridData\": [ [\"fileId\"]],\"ttlDate\": null}}, "
+ + " \"policyJSON\": {\"pmTableName\": \"test\", \"dmdTopic\": \"1\",\"fileId\": \"56\"} }";
+
+ br = new BufferedReader(new StringReader(jsonString));
+ //--- mock the getReader() call
+ when(request.getReader()).thenReturn(br);
+ new DictionaryUtils(commonClassDao);
+ DictionaryUtils.setDictionaryUtils(new DictionaryUtils());
+ mock(DictionaryUtils.class);
+ logger.info("setUp: exit");
+ }
+
+ @Test
+ public void testGetOptimizationModelsDictionaryEntityData() {
+ logger.info("testGetOptimizationModelsDictionaryEntityData: Entering");
+
+ MockHttpServletResponse response = new MockHttpServletResponse();
+ String modelJson = "{\"optimizationModelsDictionaryData\":[\"modelName\"]}";
+
+ BufferedReader br = new BufferedReader(new StringReader(modelJson));
+ request = mock(HttpServletRequest.class);
+
+ try {
+ // mock the getReader() call
+ when(request.getReader()).thenReturn(br);
+ controller.getOptimizationModelsDictionaryEntityData(response);
+ logger.info("response.getContentAsString(): " + response.getContentAsString());
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("optimizationModelsDictionaryDatas"));
+
+ } catch (Exception e) {
+ fail("Exception: " + e);
+ }
+
+ logger.info("testGetOptimizationModelsDictionaryEntityData: exit");
+ }
+
+ @Test
+ public void testSaveOptimizationModelsDictionary() {
+ logger.info("testSaveOptimizationModelsDictionary: Entering");
+
+ MockHttpServletResponse response = new MockHttpServletResponse();
+ request = mock(HttpServletRequest.class);
+
+ try {
+ // mock the getReader() call
+ when(request.getReader()).thenReturn(br);
+ controller.saveOptimizationModelsDictionary(request, response);
+ logger.info("response.getContentAsString(): " + response.getContentAsString());
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("optimizationModelsDictionaryDatas"));
+
+ } catch (Exception e) {
+ fail("Exception: " + e);
+ }
+
+ logger.info("testSaveOptimizationModelsDictionary: exit");
+ }
+
+ @Test
+ public void testRemoveOptimizationModelsDictionary() {
+ logger.info("testRemoveOptimizationModelsDictionary: Entering");
+
+ MockHttpServletResponse response = new MockHttpServletResponse();
+ request = mock(HttpServletRequest.class);
+
+ try {
+ // mock the getReader() call
+ jsonString = "{\"data\": {\"modelName\": \"test\", \"inprocess\": false,\"model\": {\"name\": \"testingdata\", "
+ + " \"subScopename\": \"\",\"path\": [],\"type\": \"dir\",\"size\": 0,\"date\": \"2017-04-12T21:26:57.000Z\", "
+ + " \"version\": \"\",\"createdBy\": \"someone\", \"modifiedBy\": \"someone\", \"content\": \"\",\"recursive\": false},"
+ + " \"tempModel\": {\"name\": \"testingdata\",\"subScopename\": \"\" },"
+ + " \"policy\": {\"policyType\": \"Config\",\"configPolicyType\": \"Micro Service\",\"policyName\": \"may1501\", "
+ + " \"policyDescription\": \"testing input\", \"onapName\": \"RaviTest\",\"guard\": \"False\",\"riskType\": \"Risk12345\",\"riskLevel\": \"2\","
+ + " \"priority\": \"6\",\"serviceType\": \"DkatPolicyBody\",\"version\": \"1707.41.02\",\"ruleGridData\": [ [\"fileId\"]],\"ttlDate\": null}}, "
+ + " \"policyJSON\": {\"pmTableName\": \"test\", \"dmdTopic\": \"1\",\"fileId\": \"56\"} }";
+
+ BufferedReader br = new BufferedReader(new StringReader(jsonString));
+ when(request.getReader()).thenReturn(br);
+ controller.removeOptimizationModelsDictionary(request, response);
+ logger.info("response.getContentAsString(): " + response.getContentAsString());
+ assertTrue( response.getContentAsString() != null && response.getContentAsString().contains("optimizationModelsDictionaryDatas"));
+
+ } catch (Exception e) {
+ fail("Exception: " + e);
+ }
+
+ logger.info("testRemoveOptimizationModelsDictionary: exit");
+ }
+
+}
diff --git a/ONAP-PAP-REST/src/test/resources/dictionaryImport/OptimizationPolicyDictionary.csv b/ONAP-PAP-REST/src/test/resources/dictionaryImport/OptimizationPolicyDictionary.csv
new file mode 100644
index 000000000..722f31595
--- /dev/null
+++ b/ONAP-PAP-REST/src/test/resources/dictionaryImport/OptimizationPolicyDictionary.csv
@@ -0,0 +1,2 @@
+Id,Optimization Model,Description,Model Version,Imported By,dependency,attributes,enumValues,Ref Attributes,Sub Attributes
+16857,PolicyBody,PolicyBody,0.1.0-SNAPSHOT,demo,test,test,test,test,test