diff options
Diffstat (limited to 'POLICY-SDK-APP')
6 files changed, 92 insertions, 33 deletions
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateDcaeMicroServiceController.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateDcaeMicroServiceController.java index d1043f709..ab4ea6d2d 100644 --- a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateDcaeMicroServiceController.java +++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateDcaeMicroServiceController.java @@ -989,9 +989,9 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController { LOGGER.info("allkeys : " + allkeys); } - String allManyTrueKeys = ""; + String nameOfTrueKey = ""; if(allkeys != null){ - allManyTrueKeys = allkeys.toString(); + nameOfTrueKey = allkeys.toString(); } String jsonModel = createMicroSeriveJson(returnModel, allkeys); @@ -1035,10 +1035,10 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController { PrintWriter out = response.getWriter(); String responseString = mapper.writeValueAsString(returnModel); JSONObject j; - if("".equals(allManyTrueKeys)){ + if("".equals(nameOfTrueKey)){ j = new JSONObject("{dcaeModelData: " + responseString + ",jsonValue: " + jsonModel + "}"); }else{ - j = new JSONObject("{dcaeModelData: " + responseString + ",jsonValue: " + jsonModel + ",allManyTrueKeys: " + allManyTrueKeys+ "}"); + j = new JSONObject("{dcaeModelData: " + responseString + ",jsonValue: " + jsonModel + ",allManyTrueKeys: " + nameOfTrueKey+ "}"); } list.add(j); out.write(list.toString()); @@ -1716,9 +1716,9 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController { } private List<File> listModelFiles(String directoryName) { - File directory = new File(directoryName); + File fileDirectory = new File(directoryName); List<File> resultList = new ArrayList<>(); - File[] fList = directory.listFiles(); + File[] fList = fileDirectory.listFiles(); for (File file : fList) { if (file.isFile()) { resultList.add(file); diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/MSConfigNameDictController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/MSConfigNameDictController.js index 1065da508..a1b703880 100644 --- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/MSConfigNameDictController.js +++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryController/MSConfigNameDictController.js @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP Policy Engine * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-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. @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ app.controller('editMSConfigController' , function ($scope, $modalInstance, message, UserInfoServiceDS2, Notification){ - if(message.microServiceCongigNameDictionaryData==null) + if(message.microServiceConfigNameDictionaryData==null) $scope.label='Add Config Name' else{ $scope.label='Edit Config Name' @@ -33,15 +33,15 @@ app.controller('editMSConfigController' , function ($scope, $modalInstance, mes userid = response.userid; }); - $scope.editMSConfig = message.microServiceCongigNameDictionaryData; + $scope.editMSConfig = message.microServiceConfigNameDictionaryData; - $scope.saveMSConfig = function(microServiceCongigNameDictionaryData) { + $scope.saveMSConfig = function(microServiceConfigNameDictionaryData) { var regex = new RegExp("^[a-zA-Z0-9_]*$"); - if(!regex.test(microServiceCongigNameDictionaryData.name)) { + if(!regex.test(microServiceConfigNameDictionaryData.name)) { Notification.error("Enter Valid Config Name without spaces or special characters"); }else{ var uuu = "saveDictionary/ms_dictionary/save_configName"; - var postData={microServiceCongigNameDictionaryData: microServiceCongigNameDictionaryData, userid: userid}; + var postData={microServiceConfigNameDictionaryData: microServiceConfigNameDictionaryData, userid: userid}; $.ajax({ type : 'POST', url : uuu, @@ -50,12 +50,12 @@ app.controller('editMSConfigController' , function ($scope, $modalInstance, mes data: JSON.stringify(postData), success : function(data){ $scope.$apply(function(){ - $scope.microServiceCongigNameDictionaryDatas=data.microServiceCongigNameDictionaryDatas;}); - if($scope.microServiceCongigNameDictionaryDatas == "Duplicate"){ + $scope.microServiceConfigNameDictionaryDatas=data.microServiceConfigNameDictionaryDatas;}); + if($scope.microServiceConfigNameDictionaryDatas == "Duplicate"){ Notification.error("MS ConfigName Dictionary exists with Same Config Name.") }else{ - console.log($scope.microServiceCongigNameDictionaryDatas); - $modalInstance.close({microServiceCongigNameDictionaryDatas:$scope.microServiceCongigNameDictionaryDatas}); + console.log($scope.microServiceConfigNameDictionaryDatas); + $modalInstance.close({microServiceConfigNameDictionaryDatas:$scope.microServiceConfigNameDictionaryDatas}); } }, error : function(data){ diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryGridController/MSConfigNameDictGridController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryGridController/MSConfigNameDictGridController.js index 8b4d014f1..295d1b803 100644 --- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryGridController/MSConfigNameDictGridController.js +++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/controller/dictionaryGridController/MSConfigNameDictGridController.js @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP Policy Engine * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-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. @@ -24,8 +24,8 @@ app.controller('msConfigNameDictGridController', function ($scope, PolicyAppServ var j = data; $scope.data = JSON.parse(j.data); console.log($scope.data); - $scope.microServiceCongigNameDictionaryDatas = JSON.parse($scope.data.microServiceCongigNameDictionaryDatas); - console.log($scope.microServiceCongigNameDictionaryDatas); + $scope.microServiceConfigNameDictionaryDatas = JSON.parse($scope.data.microServiceConfigNameDictionaryDatas); + console.log($scope.microServiceConfigNameDictionaryDatas); }, function (error) { console.log("failed"); }); @@ -69,7 +69,7 @@ app.controller('msConfigNameDictGridController', function ($scope, PolicyAppServ resolve: { message: function () { var message = { - microServiceCongigNameDictionaryDatas: $scope.editMSConfig + microServiceConfigNameDictionaryDatas: $scope.editMSConfig }; return message; } @@ -77,12 +77,12 @@ app.controller('msConfigNameDictGridController', function ($scope, PolicyAppServ }); modalInstance.result.then(function(response){ console.log('response', response); - $scope.microServiceCongigNameDictionaryDatas=response.microServiceCongigNameDictionaryDatas; + $scope.microServiceConfigNameDictionaryDatas=response.microServiceConfigNameDictionaryDatas; }); }; - $scope.editMSConfigNameWindow = function(microServiceCongigNameDictionaryData) { - $scope.editMSConfig = microServiceCongigNameDictionaryData; + $scope.editMSConfigNameWindow = function(microServiceConfigNameDictionaryData) { + $scope.editMSConfig = microServiceConfigNameDictionaryData; var modalInstance = $modal.open({ backdrop: 'static', keyboard: false, templateUrl : 'add_msConfigName_popup.html', @@ -90,7 +90,7 @@ app.controller('msConfigNameDictGridController', function ($scope, PolicyAppServ resolve: { message: function () { var message = { - microServiceCongigNameDictionaryData: $scope.editMSConfig + microServiceConfigNameDictionaryData: $scope.editMSConfig }; return message; } @@ -98,7 +98,7 @@ app.controller('msConfigNameDictGridController', function ($scope, PolicyAppServ }); modalInstance.result.then(function(response){ console.log('response', response); - $scope.microServiceCongigNameDictionaryDatas = response.microServiceCongigNameDictionaryDatas; + $scope.microServiceConfigNameDictionaryDatas = response.microServiceConfigNameDictionaryDatas; }); }; @@ -114,7 +114,7 @@ app.controller('msConfigNameDictGridController', function ($scope, PolicyAppServ contentType: 'application/json', data: JSON.stringify(postData), success : function(data){ - $scope.$apply(function(){$scope.microServiceCongigNameDictionaryDatas=data.microServiceCongigNameDictionaryDatas;}); + $scope.$apply(function(){$scope.microServiceConfigNameDictionaryDatas=data.microServiceConfigNameDictionaryDatas;}); }, error : function(data){ console.log(data); diff --git a/POLICY-SDK-APP/src/test/java/org/onap/policy/admin/PolicyManagerServletTest.java b/POLICY-SDK-APP/src/test/java/org/onap/policy/admin/PolicyManagerServletTest.java index 7ca788995..be0a92e55 100644 --- a/POLICY-SDK-APP/src/test/java/org/onap/policy/admin/PolicyManagerServletTest.java +++ b/POLICY-SDK-APP/src/test/java/org/onap/policy/admin/PolicyManagerServletTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP Policy Engine * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-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. @@ -21,7 +21,6 @@ package org.onap.policy.admin; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; -import static org.mockito.Mockito.mock; import java.io.BufferedReader; import java.io.File; diff --git a/POLICY-SDK-APP/src/test/java/org/onap/policy/controller/AutoPushControllerTest.java b/POLICY-SDK-APP/src/test/java/org/onap/policy/controller/AutoPushControllerTest.java new file mode 100644 index 000000000..0c85e7116 --- /dev/null +++ b/POLICY-SDK-APP/src/test/java/org/onap/policy/controller/AutoPushControllerTest.java @@ -0,0 +1,64 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP Policy Engine + * ================================================================================ + * 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.controller; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; +import java.io.IOException; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; + +public class AutoPushControllerTest { + private PolicyController controller = new PolicyController();; + private AutoPushController apController = new AutoPushController(); + + @Rule + public ExpectedException thrown = ExpectedException.none(); + + @Test + public void testAutoPushSetGet() throws IOException { + // Get and set tests + apController.setPolicyController(controller); + assertEquals(apController.getPolicyController(), controller); + } + + @Test + public void testNegativeCase1() { + try { + apController.getPolicyGroupContainerData(null, null); + } + catch (Exception ex) { + fail("No exceptions expected, received: " + ex); + } + } + + @Test + public void testNegativeCase2() throws IOException { + thrown.expect(NullPointerException.class); + apController.pushPolicyToPDPGroup(null, null); + } + + @Test + public void testNegativeCase3() throws IOException { + thrown.expect(NullPointerException.class); + apController.removePDPGroup(null, null); + } +} diff --git a/POLICY-SDK-APP/src/test/java/org/onap/policy/controller/CreateDcaeMicroServiceControllerTest.java b/POLICY-SDK-APP/src/test/java/org/onap/policy/controller/CreateDcaeMicroServiceControllerTest.java index a2f24ebe1..8d8f57b0d 100644 --- a/POLICY-SDK-APP/src/test/java/org/onap/policy/controller/CreateDcaeMicroServiceControllerTest.java +++ b/POLICY-SDK-APP/src/test/java/org/onap/policy/controller/CreateDcaeMicroServiceControllerTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP Policy Engine * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-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. @@ -558,10 +558,6 @@ public class CreateDcaeMicroServiceControllerTest { public void testSetMSModelData() { logger.debug("testSetMSModelData: enter"); - - CreateDcaeMicroServiceController controller = new CreateDcaeMicroServiceController(); - - MockHttpServletResponse response = new MockHttpServletResponse(); HttpServletRequest request = createMock(HttpServletRequest.class); expect(request.getContentType()).andReturn("multipart/form-data; boundary=----WebKitFormBoundaryWcRUaIbC8kXgjr3p"); |