2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2019 AT&T Intellectual Property. All rights
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END============================================
20 * ===================================================================
23 import React from 'react';
24 import LoopCache from '../api/LoopCache';
26 const json = require('./LoopCache_mokeLoopJsonCache.json');
28 describe('Verify LoopCache functions', () => {
29 const loopCache = new LoopCache(json);
30 it('getLoopName', () => {
31 expect(loopCache.getLoopName()).toBe("LOOP_Jbv1z_v1_0_ResourceInstanceName1_tca");
34 it('getOperationalPolicyConfigurationJson', () => {
35 const opPolicyConfig = {
37 "operational_policy": {
42 expect(loopCache.getOperationalPolicyConfigurationJson()).toStrictEqual(opPolicyConfig);
45 it('getOperationalPolicies', () => {
47 "name": "OPERATIONAL_h2NMX_v1_0_ResourceInstanceName1_tca",
48 "configurationsJson": {
50 "operational_policy": {
57 expect(loopCache.getOperationalPolicies()).toStrictEqual(opPolicy);
60 it('getGlobalProperties', () => {
62 "dcaeDeployParameters": {
65 "policy_id": "TCA_h2NMX_v1_0_ResourceInstanceName1_tca"
68 expect(loopCache.getGlobalProperties()).toStrictEqual(globelProp);
71 it('getDcaeDeploymentProperties', () => {
72 const deploymentProp = {
75 "policy_id": "TCA_h2NMX_v1_0_ResourceInstanceName1_tca"
77 expect(loopCache.getDcaeDeploymentProperties()).toStrictEqual(deploymentProp);
80 it('getMicroServiceForName', () => {
82 "name": "TCA_h2NMX_v1_0_ResourceInstanceName1_tca",
83 "modelType": "onap.policies.monitoring.cdap.tca.hi.lo.app",
84 "properties": {"domain": "measurementsForVfScaling"},
86 "jsonRepresentation": {"schema": {}}
88 expect(loopCache.getMicroServiceForName("TCA_h2NMX_v1_0_ResourceInstanceName1_tca")).toStrictEqual(msJson);
89 expect(loopCache.getMicroServiceForName("TCA_h2NMX_v1_0_ResourceInstanceName1_tca_2")).toBeNull();
92 it('getMicroServicePropertiesForName', () => {
93 const msProp = {"domain": "measurementsForVfScaling"};
94 expect(loopCache.getMicroServicePropertiesForName("TCA_h2NMX_v1_0_ResourceInstanceName1_tca")).toStrictEqual(msProp);
95 expect(loopCache.getMicroServicePropertiesForName("TCA_h2NMX_v1_0_ResourceInstanceName1_tca_2")).toBeNull();
98 it('getMicroServiceJsonRepresentationForName', () => {
99 const msJsonRepresentation = {"schema": {}};
100 expect(loopCache.getMicroServiceJsonRepresentationForName("TCA_h2NMX_v1_0_ResourceInstanceName1_tca")).toStrictEqual(msJsonRepresentation);
103 it('getResourceDetailsVfProperty', () => {
105 "vLoadBalancerMS 0": {
106 "resourceVendor": "Test",
107 "resourceVendorModelNumber": "",
108 "name": "vLoadBalancerMS",
109 "description": "vLBMS",
110 "invariantUUID": "1a31b9f2-e50d-43b7-89b3-a040250cf506",
111 "subcategory": "Load Balancer",
112 "category": "Application L4+",
114 "UUID": "b4c4f3d7-929e-4b6d-a1cd-57e952ddc3e6",
116 "resourceVendorRelease": "1.0",
117 "customizationUUID": "465246dc-7748-45f4-a013-308d92922552"
120 expect(loopCache.getResourceDetailsVfProperty()).toStrictEqual(resourceVF);
123 it('getResourceDetailsVfModuleProperty', () => {
125 "Vloadbalancerms..vpkg..module-1": {
126 "vfModuleModelInvariantUUID": "ca052563-eb92-4b5b-ad41-9111768ce043",
127 "vfModuleModelVersion": "1",
128 "vfModuleModelName": "Vloadbalancerms..vpkg..module-1",
129 "vfModuleModelUUID": "1e725ccc-b823-4f67-82b9-4f4367070dbc",
130 "vfModuleModelCustomizationUUID": "1bffdc31-a37d-4dee-b65c-dde623a76e52",
131 "min_vf_module_instances": 0,
132 "vf_module_label": "vpkg",
133 "max_vf_module_instances": 1,
134 "vf_module_type": "Expansion",
137 "volume_group": false
140 expect(loopCache.getResourceDetailsVfModuleProperty()).toStrictEqual(vfModule);
143 it('getLoopLogsArray', () => {
148 "logComponent": "CLAMP",
149 "message": "Operational and Guard policies UPDATED",
150 "logInstant": "2019-07-08T09:44:37Z"
153 expect(loopCache.getLoopLogsArray()).toStrictEqual(logs);
156 it('getComponentStates', () => {
160 "stateName": "NOT_SENT",
161 "description": "The policies defined have NOT yet been created on the policy engine"
166 "stateName": "BLUEPRINT_DEPLOYED",
167 "description": "The DCAE blueprint has been found in the DCAE inventory but not yet instancianted for this loop"
171 expect(loopCache.getComponentStates()).toStrictEqual(component);
174 it('updateGlobalProperties', () => {
175 const newGlobalProps = {
176 "dcaeDeployParameters": {
177 "location_id": "newLocation",
178 "service_id": "newServiceId",
179 "policy_id": "TCA_h2NMX_v1_0_ResourceInstanceName1_tca_2"
182 loopCache.updateGlobalProperties(newGlobalProps);
183 expect(loopCache.getGlobalProperties()).toStrictEqual(newGlobalProps);
186 it('updateOperationalPolicyProperties', () => {
187 const newOpPolicy = [{
188 "name": "OPERATIONAL_h2NMX_v1_0_ResourceInstanceName1_tca_new",
189 "configurationsJson": {
190 "guard_policies": {},
191 "operational_policy": {
197 loopCache.updateOperationalPolicyProperties(newOpPolicy);
198 expect(loopCache.getOperationalPolicies()).toStrictEqual(newOpPolicy);
201 it('updateMicroServiceProperties', () => {
202 const newMsPolicyProperties = {"domain": "measurementsForVfScalingNew"};
203 loopCache.updateMicroServiceProperties("TCA_h2NMX_v1_0_ResourceInstanceName1_tca", newMsPolicyProperties);
204 expect(loopCache.getMicroServicePropertiesForName("TCA_h2NMX_v1_0_ResourceInstanceName1_tca")).toStrictEqual(newMsPolicyProperties);