summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--gui-clamp/ui-react/src/components/dialogs/Policy/PolicyDeploymentEditor.js2
-rw-r--r--gui-clamp/ui-react/src/components/dialogs/Policy/PolicyDeploymentEditor.test.js93
-rw-r--r--gui-clamp/ui-react/src/components/dialogs/Policy/ViewAllPolicies.js2
-rw-r--r--gui-clamp/ui-react/src/components/dialogs/Policy/ViewAllPolicies.test.js29
-rw-r--r--gui-clamp/ui-react/src/components/dialogs/Policy/__snapshots__/PolicyDeploymentEditor.test.js.snap71
-rw-r--r--gui-clamp/ui-react/src/components/dialogs/Policy/toscaPolicyDeploymentEditor.test.json90
-rw-r--r--gui-editors/gui-editor-apex/pom.xml41
-rw-r--r--gui-editors/pom.xml7
-rw-r--r--pom.xml21
9 files changed, 291 insertions, 65 deletions
diff --git a/gui-clamp/ui-react/src/components/dialogs/Policy/PolicyDeploymentEditor.js b/gui-clamp/ui-react/src/components/dialogs/Policy/PolicyDeploymentEditor.js
index de29947..27eed22 100644
--- a/gui-clamp/ui-react/src/components/dialogs/Policy/PolicyDeploymentEditor.js
+++ b/gui-clamp/ui-react/src/components/dialogs/Policy/PolicyDeploymentEditor.js
@@ -72,6 +72,7 @@ export default class PolicyDeploymentEditor extends React.Component {
}
createPdpGroupOperations(initialStates, newStates) {
+ console.log('createPdpGroupOperations called');
let commandsArray = [];
initialStates.forEach(initElem => {
let newStateFound = newStates.find(newElement => newElement.name === initElem.name);
@@ -89,6 +90,7 @@ export default class PolicyDeploymentEditor extends React.Component {
}
handleUpdatePdpDeployment() {
+ console.log('handleUpdatePdpDeployment called');
let operationsList = this.createPdpGroupOperations(this.state.checkboxesInitialState,
this.state.checkboxesState);
if (typeof (operationsList) !== "undefined") {
diff --git a/gui-clamp/ui-react/src/components/dialogs/Policy/PolicyDeploymentEditor.test.js b/gui-clamp/ui-react/src/components/dialogs/Policy/PolicyDeploymentEditor.test.js
new file mode 100644
index 0000000..1ae73a2
--- /dev/null
+++ b/gui-clamp/ui-react/src/components/dialogs/Policy/PolicyDeploymentEditor.test.js
@@ -0,0 +1,93 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2022 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+import {shallow} from "enzyme";
+import toJson from "enzyme-to-json";
+import React from "react";
+import PolicyDeploymentEditor from "./PolicyDeploymentEditor";
+import fs from "fs";
+import LoopService from "../../../api/LoopService";
+
+describe('Verify PolicyDeploymentEditor', () => {
+ const toscaPolicyDeploymentEditor = fs.readFileSync('src/components/dialogs/Policy/toscaPolicyDeploymentEditor.test.json', {
+ encoding: 'utf8',
+ flag: 'r'
+ });
+
+ const toscaPolicyDeploymentEditorArray = JSON.parse(toscaPolicyDeploymentEditor);
+
+ const initialStateTrue = [
+ {
+ "name": "monitoring/xacml",
+ "value": true
+ }
+ ];
+
+ const initialStateFalse = [
+ {
+ "name": "monitoring/xacml",
+ "value": false
+ }
+ ];
+
+ const logSpy = jest.spyOn(console, 'log');
+
+ it("renders correctly", () => {
+ const component = shallow(<PolicyDeploymentEditor policyData={toscaPolicyDeploymentEditorArray}/>);
+ expect(toJson(component)).toMatchSnapshot();
+ });
+
+ it('Test createPdpGroupOperations', () => {
+ const component = shallow(<PolicyDeploymentEditor policyData={toscaPolicyDeploymentEditorArray} />);
+
+ const instance = component.instance();
+
+ instance.createPdpGroupOperations(initialStateTrue, initialStateTrue);
+
+ component.update();
+
+ expect(logSpy).toHaveBeenCalledWith('createPdpGroupOperations called');
+ });
+
+ it('Test handleUpdatePdpDeployment', () => {
+ LoopService.updatePdpDeployment = jest.fn().mockImplementation(() => {
+ return Promise.resolve(undefined);
+ });
+
+ const component = shallow(<PolicyDeploymentEditor policyData={toscaPolicyDeploymentEditorArray} />);
+ component.setState({checkboxesInitialState: initialStateTrue});
+ component.setState({checkboxesState: initialStateFalse});
+
+ const instance = component.instance();
+ instance.handleUpdatePdpDeployment();
+
+ expect(component.state('showFailAlert')).toEqual(false);
+ expect(component.state('showMessage')).toEqual(undefined);
+
+ component.update();
+
+ component.setState({showFailAlert: true});
+ component.setState({showMessage: 'Pdp Deployment update Failure'});
+
+ expect(logSpy).toHaveBeenCalledWith('handleUpdatePdpDeployment called');
+ expect(component.state('showFailAlert')).toEqual(true);
+ expect(component.state('showMessage')).toEqual('Pdp Deployment update Failure');
+ });
+
+}); \ No newline at end of file
diff --git a/gui-clamp/ui-react/src/components/dialogs/Policy/ViewAllPolicies.js b/gui-clamp/ui-react/src/components/dialogs/Policy/ViewAllPolicies.js
index 0aed5f4..8f8bd51 100644
--- a/gui-clamp/ui-react/src/components/dialogs/Policy/ViewAllPolicies.js
+++ b/gui-clamp/ui-react/src/components/dialogs/Policy/ViewAllPolicies.js
@@ -203,6 +203,8 @@ export default class ViewAllPolicies extends React.Component {
}
generateAdditionalPolicyColumns(policiesData) {
+ console.log('generateAdditionalPolicyColumns called');
+
policiesData.forEach(policy => {
let supportedPdpGroupsString = "";
if (typeof policy.supportedPdpGroups !== "undefined") {
diff --git a/gui-clamp/ui-react/src/components/dialogs/Policy/ViewAllPolicies.test.js b/gui-clamp/ui-react/src/components/dialogs/Policy/ViewAllPolicies.test.js
index d4a3fd9..c2ce731 100644
--- a/gui-clamp/ui-react/src/components/dialogs/Policy/ViewAllPolicies.test.js
+++ b/gui-clamp/ui-react/src/components/dialogs/Policy/ViewAllPolicies.test.js
@@ -23,7 +23,6 @@ import ViewAllPolicies from "./ViewAllPolicies";
import fs from "fs";
import PolicyToscaService from "../../../api/PolicyToscaService";
import PolicyService from "../../../api/PolicyService";
-import CreateLoopModal from "../Loop/CreateLoopModal";
import toJson from "enzyme-to-json";
describe('Verify ViewAllPolicies', () => {
@@ -36,6 +35,12 @@ describe('Verify ViewAllPolicies', () => {
flag: 'r'
});
+ const toscaPolicyModelsArray = JSON.parse(toscaPolicyModels);
+
+ const toscaPoliciesListArray = JSON.parse(toscaPoliciesList);
+
+ const logSpy = jest.spyOn(console, 'log');
+
it("renders correctly", () => {
const component = shallow(<ViewAllPolicies />);
expect(toJson(component)).toMatchSnapshot();
@@ -127,15 +132,33 @@ describe('Verify ViewAllPolicies', () => {
});
const event = { target: {value: 'event'}}
- const component = shallow(<CreateLoopModal/>);
+ const renderPoliciesTab = jest.spyOn(ViewAllPolicies.prototype, 'renderPoliciesTab');
+
+ const component = shallow(<ViewAllPolicies />);
component.setState({showSuccessAlert: true});
component.setState({showMessage: 'Policy successfully Deleted'});
+ component.setState({policiesListDataFiltered: toscaPolicyModelsArray});
- component.find('input').simulate('click', event, rowData);
component.update();
+ const instance = component.instance();
+
+ instance.handleDeletePolicy(event, rowData);
+
+ expect(renderPoliciesTab).toHaveBeenCalledTimes(4);
expect(component.state('showSuccessAlert')).toEqual(true);
expect(component.state('showMessage')).toEqual('Policy successfully Deleted');
});
+
+ it('Test generateAdditionalPolicyColumns policiesData', async () => {
+ const component = shallow(<ViewAllPolicies />);
+
+ const instance = component.instance();
+ instance.generateAdditionalPolicyColumns(toscaPoliciesListArray.policies);
+
+ component.update();
+
+ expect(logSpy).toHaveBeenCalledWith('generateAdditionalPolicyColumns called');
+ });
});
diff --git a/gui-clamp/ui-react/src/components/dialogs/Policy/__snapshots__/PolicyDeploymentEditor.test.js.snap b/gui-clamp/ui-react/src/components/dialogs/Policy/__snapshots__/PolicyDeploymentEditor.test.js.snap
new file mode 100644
index 0000000..7bf297a
--- /dev/null
+++ b/gui-clamp/ui-react/src/components/dialogs/Policy/__snapshots__/PolicyDeploymentEditor.test.js.snap
@@ -0,0 +1,71 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`Verify PolicyDeploymentEditor renders correctly 1`] = `
+<styled.div>
+ <Alert
+ closeLabel="Close alert"
+ dismissible={true}
+ onClose={[Function]}
+ show={false}
+ transition={
+ Object {
+ "$$typeof": Symbol(react.forward_ref),
+ "defaultProps": Object {
+ "appear": false,
+ "in": false,
+ "mountOnEnter": false,
+ "timeout": 300,
+ "unmountOnExit": false,
+ },
+ "render": [Function],
+ }
+ }
+ variant="success"
+ >
+ <styled.div />
+ </Alert>
+ <Alert
+ closeLabel="Close alert"
+ dismissible={true}
+ onClose={[Function]}
+ show={false}
+ transition={
+ Object {
+ "$$typeof": Symbol(react.forward_ref),
+ "defaultProps": Object {
+ "appear": false,
+ "in": false,
+ "mountOnEnter": false,
+ "timeout": 300,
+ "unmountOnExit": false,
+ },
+ "render": [Function],
+ }
+ }
+ variant="danger"
+ >
+ <styled.div />
+ </Alert>
+ <Button
+ active={false}
+ disabled={false}
+ onClick={[Function]}
+ title="Update the policy to the specified PDP Groups/Subgroups"
+ variant="secondary"
+ >
+ Update PDP
+ </Button>
+ <WithStyles(ForwardRef(FormGroup))>
+ <WithStyles(ForwardRef(FormControlLabel))
+ control={
+ <WithStyles(ForwardRef(Checkbox))
+ checked={true}
+ name="monitoring/xacml"
+ onChange={[Function]}
+ />
+ }
+ label="monitoring/xacml"
+ />
+ </WithStyles(ForwardRef(FormGroup))>
+</styled.div>
+`;
diff --git a/gui-clamp/ui-react/src/components/dialogs/Policy/toscaPolicyDeploymentEditor.test.json b/gui-clamp/ui-react/src/components/dialogs/Policy/toscaPolicyDeploymentEditor.test.json
new file mode 100644
index 0000000..f6907e5
--- /dev/null
+++ b/gui-clamp/ui-react/src/components/dialogs/Policy/toscaPolicyDeploymentEditor.test.json
@@ -0,0 +1,90 @@
+{
+ "type": "onap.policies.monitoring.tcagen2",
+ "type_version": "1.0.0",
+ "properties": {
+ "tca.policy": {
+ "domain": "measurementsForVfScaling",
+ "metricsPerEventName": [
+ {
+ "policyScope": "DCAE",
+ "thresholds": [
+ {
+ "version": "1.0.2",
+ "severity": "MAJOR",
+ "thresholdValue": 200,
+ "closedLoopEventStatus": "ONSET",
+ "closedLoopControlName": "LOOP_test",
+ "direction": "LESS_OR_EQUAL",
+ "fieldPath": "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedTotalPacketsDelta"
+ }
+ ],
+ "eventName": "vLoadBalancer",
+ "policyVersion": "v0.0.1",
+ "controlLoopSchemaType": "VM",
+ "policyName": "DCAE.Config_tca-hi-lo"
+ }
+ ]
+ }
+ },
+ "name": "MICROSERVICE_vLoadBalancerMS_v1_0_tcagen2_1_0_0_AV0",
+ "version": "1.0.0",
+ "metadata": {
+ "policy-id": "MICROSERVICE_vLoadBalancerMS_v1_0_tcagen2_1_0_0_AV0",
+ "policy-version": "1.0.0"
+ },
+ "pdpGroupInfo": [
+ {
+ "monitoring": {
+ "name": "monitoring",
+ "description": "This group should be used for managing all monitoring related policies and pdps",
+ "pdpGroupState": "ACTIVE",
+ "properties": {},
+ "pdpSubgroups": [
+ {
+ "pdpType": "xacml",
+ "supportedPolicyTypes": [
+ {
+ "name": "onap.policies.monitoring.*",
+ "version": "1.0.0"
+ },
+ {
+ "name": "onap.policies.Naming",
+ "version": "1.0.0"
+ }
+ ],
+ "policies": [
+ {
+ "name": "MICROSERVICE_vLoadBalancerMS_v1_0_tcagen2_1_0_0_AV0",
+ "version": "1.0.0"
+ }
+ ],
+ "currentInstanceCount": 0,
+ "desiredInstanceCount": 1,
+ "properties": {},
+ "pdpInstances": [
+ {
+ "instanceId": "monitoring-f8287777-5f3e-4f0f-b21b-d8829c93f57b",
+ "pdpState": "ACTIVE",
+ "healthy": "HEALTHY",
+ "message": "Pdp Heartbeat",
+ "lastUpdate": "2021-09-29T02:51:21Z"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ ],
+ "supportedPdpGroups": [
+ {
+ "monitoring": [
+ "xacml"
+ ]
+ }
+ ],
+ "supportedPdpGroupsString": "monitoring/xacml\r\n",
+ "pdpGroupInfoString": "monitoring/xacml (ACTIVE)\r\n",
+ "tableData": {
+ "id": 0
+ }
+} \ No newline at end of file
diff --git a/gui-editors/gui-editor-apex/pom.xml b/gui-editors/gui-editor-apex/pom.xml
index 3a49df7..1095e14 100644
--- a/gui-editors/gui-editor-apex/pom.xml
+++ b/gui-editors/gui-editor-apex/pom.xml
@@ -1,7 +1,7 @@
<!--
============LICENSE_START=======================================================
Copyright (C) 2018 Ericsson. All rights reserved.
- Modifications Copyright (C) 2019-2021 Nordix Foundation.
+ Modifications Copyright (C) 2019-2022 Nordix Foundation.
Modifications Copyright (C) 2020 Bell Canada.
Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
================================================================================
@@ -35,6 +35,8 @@
<properties>
<policy.apex-pdp.version>2.4.0</policy.apex-pdp.version>
+ <policy.common.version>1.10.1-SNAPSHOT</policy.common.version>
+ <policy.models.version>2.6.1-SNAPSHOT</policy.models.version>
<webapp.dir>src/main/resources/webapp</webapp.dir>
<sonar.nodejs.executable>${project.basedir}/src/main/resources/webapp/node/node</sonar.nodejs.executable>
<sonar.sources>${project.basedir}/src/main/java,${project.basedir}/src/main/resources/webapp/js</sonar.sources>
@@ -44,25 +46,8 @@
<dependencies>
<dependency>
<groupId>org.onap.policy.common</groupId>
- <artifactId>policy-endpoints</artifactId>
- <exclusions>
- <exclusion>
- <groupId>org.onap.aaf.authz</groupId>
- <artifactId>aaf-cadi-aaf</artifactId>
- </exclusion>
- <exclusion>
- <groupId>com.att.nsa</groupId>
- <artifactId>cambriaClient</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.onap.dmaap.messagerouter.dmaapclient</groupId>
- <artifactId>dmaapClient</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.onap.policy.common</groupId>
<artifactId>utils</artifactId>
+ <version>${policy.common.version}</version>
<exclusions>
<exclusion>
<groupId>com.worldturner.medeia</groupId>
@@ -104,19 +89,6 @@
<artifactId>commons-cli</artifactId>
</dependency>
<dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-text</artifactId>
- <version>1.9</version>
- </dependency>
- <dependency>
- <groupId>org.onap.policy.apex-pdp.client</groupId>
- <artifactId>apex-client-common</artifactId>
- <version>${policy.apex-pdp.version}</version>
- <classifier>resources</classifier>
- <type>zip</type>
- <scope>provided</scope>
- </dependency>
- <dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-multipart</artifactId>
</dependency>
@@ -126,11 +98,6 @@
<version>3.10.0</version>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>commons-io</groupId>
- <artifactId>commons-io</artifactId>
- </dependency>
-
</dependencies>
<build>
diff --git a/gui-editors/pom.xml b/gui-editors/pom.xml
index 7deee2d..3810af5 100644
--- a/gui-editors/pom.xml
+++ b/gui-editors/pom.xml
@@ -1,6 +1,6 @@
<!--
============LICENSE_START=======================================================
- Copyright (C) 2020 Nordix Foundation.
+ Copyright (C) 2020-2022 Nordix Foundation.
================================================================================
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -32,11 +32,6 @@
<name>${project.artifactId}</name>
<description>Web Client editors for PDP policies</description>
- <properties>
- <sonar.sources>${project.basedir}/src/main</sonar.sources>
- <sonar.exclusions>src/main/resources/webapp/js/edit_area/**/*,src/main/resources/webapp/js/jquery/**/*,src/main/resources/webapp/js/jquery-ui-1.12.1/**/*,src/main/resources/webapp/js/lib/**/*</sonar.exclusions>
- </properties>
-
<modules>
<module>gui-editor-apex</module>
</modules>
diff --git a/pom.xml b/pom.xml
index 4be0a92..d1f833c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -3,7 +3,7 @@
ONAP Policy GUI
================================================================================
Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
- Modifications Copyright (C) 2020-2021 Nordix Foundation.
+ Modifications Copyright (C) 2020-2022 Nordix Foundation.
================================================================================
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -20,7 +20,7 @@
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
@@ -40,8 +40,6 @@
<description>Code for all the Policy GUI's.</description>
<properties>
- <policy.common.version>1.10.1-SNAPSHOT</policy.common.version>
- <policy.models.version>2.6.1-SNAPSHOT</policy.models.version>
<jacoco.dataFile>${project.basedir}/../../target/code-coverage/jacoco-ut.exec</jacoco.dataFile>
<sonar.javascript.lcov.reportPaths>${project.basedir}/target/code-coverage/lcov.info</sonar.javascript.lcov.reportPaths>
</properties>
@@ -78,21 +76,6 @@
</site>
</distributionManagement>
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.onap.policy.common</groupId>
- <artifactId>utils</artifactId>
- <version>${policy.common.version}</version>
- </dependency>
- <dependency>
- <groupId>org.onap.policy.common</groupId>
- <artifactId>policy-endpoints</artifactId>
- <version>${policy.common.version}</version>
- </dependency>
- </dependencies>
- </dependencyManagement>
-
<profiles>
<profile>
<!--This profile is used to store Eclipse m2e settings only. It has no