From f4231f30d53e192e15906245a8dd0e6ef42198e1 Mon Sep 17 00:00:00 2001 From: "Kotagiri, Ramprasad (rp5662)" Date: Thu, 21 Mar 2019 17:37:42 -0400 Subject: Java unit test code This change contains the following: 1) Added Junit classes for java unit testing and code coverage 2) Refactored code to use Spring autowiring of service class instances 3) Updated icons to match the available font icons library 4) Added back ccsdk-app-os module in the parent POM Change-Id: I545202357eb1c8257ee29e0f5a02aa37991b2673 Issue-ID: CCSDK-1011 Signed-off-by: ramprasad kotagiri --- .../app/ccsdk/consul/datacenter-health-service.js | 23 +- .../ccsdk/consul/datacenter-table-controller.js | 21 -- .../webapp/app/ccsdk/consul/datacenter_table.html | 2 +- .../webapp/app/ccsdk/consul/node-health-service.js | 56 +-- .../app/ccsdk/consul/node-services-controller.js | 31 +- .../app/ccsdk/consul/node-table-controller.js | 70 ++-- .../main/webapp/app/ccsdk/consul/node_popups.html | 5 +- .../main/webapp/app/ccsdk/consul/node_table.html | 17 +- .../webapp/app/ccsdk/consul/service-controllers.js | 87 +++-- .../app/ccsdk/consul/service-health-service.js | 51 +-- .../app/ccsdk/consul/service_health_table.html | 40 +- .../webapp/app/ccsdk/consul/service_popups.html | 14 +- .../app/ccsdk/home/executions-view-controller.js | 402 --------------------- .../ccsdk/inventory/inventory_blueprint_table.html | 32 +- .../inventory/inventory_deployment_table.html | 24 +- .../inventory/inventory_execution_popups.html | 4 +- 16 files changed, 238 insertions(+), 641 deletions(-) (limited to 'ccsdk-app-overlay') diff --git a/ccsdk-app-overlay/src/main/webapp/app/ccsdk/consul/datacenter-health-service.js b/ccsdk-app-overlay/src/main/webapp/app/ccsdk/consul/datacenter-health-service.js index 64618c1..20fe6d3 100644 --- a/ccsdk-app-overlay/src/main/webapp/app/ccsdk/consul/datacenter-health-service.js +++ b/ccsdk-app-overlay/src/main/webapp/app/ccsdk/consul/datacenter-health-service.js @@ -1,24 +1,3 @@ -/******************************************************************************* - * =============LICENSE_START========================================================= - * - * ================================================================================= - * Copyright (c) 2017 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========================================================= - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - *******************************************************************************/ appDS2.factory('DatacenterHealthService', function ($http, $q, $log) { return { /** @@ -45,7 +24,7 @@ appDS2.factory('DatacenterHealthService', function ($http, $q, $log) { $log.error('DatacenterService.getDatacentersHealth failed: ' + JSON.stringify(error)); return $q.reject(error.statusText); }); - } + }, }; }); diff --git a/ccsdk-app-overlay/src/main/webapp/app/ccsdk/consul/datacenter-table-controller.js b/ccsdk-app-overlay/src/main/webapp/app/ccsdk/consul/datacenter-table-controller.js index f1c8820..9ac13c2 100644 --- a/ccsdk-app-overlay/src/main/webapp/app/ccsdk/consul/datacenter-table-controller.js +++ b/ccsdk-app-overlay/src/main/webapp/app/ccsdk/consul/datacenter-table-controller.js @@ -1,24 +1,3 @@ -/******************************************************************************* - * =============LICENSE_START========================================================= - * - * ================================================================================= - * Copyright (c) 2017 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========================================================= - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - *******************************************************************************/ appDS2.controller('datacenterTableController', function($scope, $log, $modal, DatacenterHealthService) { 'use strict'; diff --git a/ccsdk-app-overlay/src/main/webapp/app/ccsdk/consul/datacenter_table.html b/ccsdk-app-overlay/src/main/webapp/app/ccsdk/consul/datacenter_table.html index 73a1b82..cb8e95a 100644 --- a/ccsdk-app-overlay/src/main/webapp/app/ccsdk/consul/datacenter_table.html +++ b/ccsdk-app-overlay/src/main/webapp/app/ccsdk/consul/datacenter_table.html @@ -5,7 +5,7 @@
- + Please wait while the content loads.
diff --git a/ccsdk-app-overlay/src/main/webapp/app/ccsdk/consul/node-health-service.js b/ccsdk-app-overlay/src/main/webapp/app/ccsdk/consul/node-health-service.js index 18fc30b..ae1dbb5 100644 --- a/ccsdk-app-overlay/src/main/webapp/app/ccsdk/consul/node-health-service.js +++ b/ccsdk-app-overlay/src/main/webapp/app/ccsdk/consul/node-health-service.js @@ -1,36 +1,38 @@ -/******************************************************************************* - * =============LICENSE_START========================================================= - * - * ================================================================================= - * Copyright (c) 2017 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========================================================= - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - *******************************************************************************/ appDS2.factory('NodeHealthService', function ($http, $q, $log) { return { + /** + * Get all the datacenter names + */ + getDatacentersHealth: function(pageNum,viewPerPage) { + // cache control for IE + var cc = "&cc=" + new Date().getTime().toString(); + return $http({ + method: 'GET', + url: 'healthservices/datacenters', + cache: false, + responseType: 'json' + }).then(function(response) { + if (response.data == null || typeof response.data != 'object') + return $q.reject('DatacentersService.getDatacentersHealth: response.data null or not object'); + else + return response.data; + }, + function(error) { + $log.error('DatacenterService.getDatacentersHealth failed: ' + JSON.stringify(error)); + return $q.reject(error.statusText); + }); + }, /** * Gets one page of objects. * @param {Number} pageNum - page number; e.g., 1 * @param {Number} viewPerPage - number of items per page; e.g., 25 * @return {JSON} Response object from remote side */ - getNodesHealth: function(pageNum,viewPerPage) { + getNodesHealth: function(pageNum,viewPerPage, dc) { // cache control for IE let cc = "&cc=" + new Date().getTime().toString(); - let url = 'healthservices/nodes?pageNum=' + pageNum + '&viewPerPage=' + viewPerPage + cc; + let url = 'healthservices/nodes?pageNum=' + pageNum + '&viewPerPage=' + viewPerPage + + '&dc=' + dc +cc; return $http({ method: 'GET', url: url, @@ -53,10 +55,8 @@ appDS2.factory('NodeHealthService', function ($http, $q, $log) { * @param {nodeName} node name (not the UUID) * @return {JSON} Response object from remote side */ - getNodeServicesHealth: function(nodeName) { - // cache control for IE - let cc = "?cc=" + new Date().getTime().toString(); - let url = 'healthservices/nodes/' + nodeName + cc; + getNodeServicesHealth: function(nodeName, dc) { + let url = 'healthservices/nodes/' + nodeName + '?dc=' + dc; return $http({ method: 'GET', url: url, @@ -72,7 +72,7 @@ appDS2.factory('NodeHealthService', function ($http, $q, $log) { $log.error('serviceHealthService.getNodeServicesHealth failed: ' + JSON.stringify(error)); return $q.reject(error.statusText); }); - } + }, }; }); diff --git a/ccsdk-app-overlay/src/main/webapp/app/ccsdk/consul/node-services-controller.js b/ccsdk-app-overlay/src/main/webapp/app/ccsdk/consul/node-services-controller.js index b82ba40..f0820be 100644 --- a/ccsdk-app-overlay/src/main/webapp/app/ccsdk/consul/node-services-controller.js +++ b/ccsdk-app-overlay/src/main/webapp/app/ccsdk/consul/node-services-controller.js @@ -1,24 +1,3 @@ -/******************************************************************************* - * =============LICENSE_START========================================================= - * - * ================================================================================= - * Copyright (c) 2017 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========================================================= - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - *******************************************************************************/ appDS2.controller('nodeServicesCtrl', function($scope, $log, message, NodeHealthService) { 'use strict'; @@ -32,15 +11,16 @@ appDS2.controller('nodeServicesCtrl', function($scope, $log, message, NodeHealth // this object holds all app data and functions $scope.ecdapp = {}; $scope.ecdapp.label = 'Services on Node ' + message.node; - + $scope.ecdapp.activeImg = "static/fusion/images/active.png"; + $scope.ecdapp.inactiveImg = "static/fusion/images/inactive.png"; /** * Loads the table of services for the specified node. */ - $scope.ecdapp.loadTable = function(nodeName) { + $scope.ecdapp.loadTable = function(nodeName, dc) { $scope.ecdapp.isDataLoading = true; if (debug) $log.debug('nodeServicesCtrl: loading data for ' + nodeName); - NodeHealthService.getNodeServicesHealth(nodeName).then( + NodeHealthService.getNodeServicesHealth(nodeName, dc).then( function(jsonObj) { if (debug) $log.debug('nodeServicesCtrl: response is ' + JSON.stringify(jsonObj)); @@ -72,6 +52,7 @@ appDS2.controller('nodeServicesCtrl', function($scope, $log, message, NodeHealth // Show services for the requested node if (debug) $log.debug('nodeServicesCtrl: requesting services for node ' + message.node); - $scope.ecdapp.loadTable(message.node); + $scope.ecdapp.loadTable(message.node, message.dc); + }); diff --git a/ccsdk-app-overlay/src/main/webapp/app/ccsdk/consul/node-table-controller.js b/ccsdk-app-overlay/src/main/webapp/app/ccsdk/consul/node-table-controller.js index 61ececb..992caeb 100644 --- a/ccsdk-app-overlay/src/main/webapp/app/ccsdk/consul/node-table-controller.js +++ b/ccsdk-app-overlay/src/main/webapp/app/ccsdk/consul/node-table-controller.js @@ -1,24 +1,3 @@ -/******************************************************************************* - * =============LICENSE_START========================================================= - * - * ================================================================================= - * Copyright (c) 2017 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========================================================= - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - *******************************************************************************/ appDS2.controller('nodeTableController', function($scope, $log, $modal, NodeHealthService) { 'use strict'; @@ -31,9 +10,42 @@ appDS2.controller('nodeTableController', function($scope, $log, $modal, NodeHeal $scope.ecdapp.viewPerPage = 10; // other $scope.ecdapp.errMsg = null; - $scope.ecdapp.isDataLoading = true; + $scope.ecdapp.isDataLoading = false; $scope.ecdapp.isRequestFailed = false; + $scope.ecdapp.isDcLoaded = false; + $scope.ecdapp.activeImg = "static/fusion/images/active.png"; + $scope.ecdapp.inactiveImg = "static/fusion/images/inactive.png"; + $scope.ecdapp.datacenter = ""; + $scope.ecdapp.datacenters = []; + var getDataCenters = function() { + NodeHealthService.getDatacentersHealth().then( + function(jsonObj) { + if (jsonObj.error) { + $log.error("datacentersController.loadTable failed: " + + jsonObj.error); + $scope.ecdapp.isRequestFailed = true; + $scope.ecdapp.errMsg = jsonObj.error; + $scope.ecdapp.tableData = []; + } else { + // $log.debug("datacentersController.loadTable + // succeeded, size " + jsonObj.data.length); + $scope.ecdapp.errMsg = null; + $scope.ecdapp.datacenters = jsonObj.items; + $scope.ecdapp.datacenter = $scope.ecdapp.datacenters[0].name; + $scope.ecdapp.isDcLoaded = true; + $scope.ecdapp.isRequestFailed = false; + $scope.pageChangeHandler(1); + } + }, + function(error) { + $log.error("datacentersController.loadTable failed: " + + error); + $scope.ecdapp.isRequestFailed = true; + $scope.ecdapp.errMsg = error; + $scope.ecdapp.tableData = []; + }); + }; /** * Answers an array of the specified size - makes Angular iteration easy. */ @@ -48,9 +60,10 @@ appDS2.controller('nodeTableController', function($scope, $log, $modal, NodeHeal * tableData, or an error to be shown. */ $scope.ecdapp.loadTable = function() { + if ($scope.ecdapp.datacenter != 'Select Datacenter') { $scope.ecdapp.isDataLoading = true; NodeHealthService.getNodesHealth($scope.ecdapp.currentPageNum, - $scope.ecdapp.viewPerPage).then( + $scope.ecdapp.viewPerPage, $scope.ecdapp.datacenter).then( function(jsonObj) { if (jsonObj.error) { $log.error("nodeHealthController.loadTable failed: " @@ -76,6 +89,7 @@ appDS2.controller('nodeTableController', function($scope, $log, $modal, NodeHeal $scope.ecdapp.tableData = []; $scope.ecdapp.isDataLoading = false; }); + } }; /** @@ -86,19 +100,22 @@ appDS2.controller('nodeTableController', function($scope, $log, $modal, NodeHeal // console.log('pageChangeHandler: current is ' + // $scope.ecdapp.currentPageNum + ' new is ' + page); $scope.ecdapp.currentPageNum = page; - $scope.ecdapp.loadTable(); + if ($scope.ecdapp.isDcLoaded) { + $scope.ecdapp.loadTable(); + } } /** * Shows a modal pop-up with services on this node. */ - $scope.ecdapp.viewServicesModalPopup = function(nodeInfo) { + $scope.ecdapp.viewServicesModalPopup = function(nodeInfo, dc) { + nodeInfo.dc = dc; var modalInstance = $modal.open({ templateUrl : 'node_services_popup.html', controller : 'nodeServicesCtrl', windowClass: 'modal-docked', - sizeClass: 'modal-large', + sizeClass: 'modal-jumbo', resolve : { message : function() { return nodeInfo ; @@ -115,4 +132,5 @@ appDS2.controller('nodeTableController', function($scope, $log, $modal, NodeHeal // Do not call this here to avoid double load: // $scope.ecdapp.loadTable(); + getDataCenters(); }); diff --git a/ccsdk-app-overlay/src/main/webapp/app/ccsdk/consul/node_popups.html b/ccsdk-app-overlay/src/main/webapp/app/ccsdk/consul/node_popups.html index 63b5e5f..6148f8c 100644 --- a/ccsdk-app-overlay/src/main/webapp/app/ccsdk/consul/node_popups.html +++ b/ccsdk-app-overlay/src/main/webapp/app/ccsdk/consul/node_popups.html @@ -7,11 +7,13 @@ ng-click="$dismiss('cancel')"> +
- Please wait while the content loads.
@@ -54,6 +56,7 @@
+