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('getMicroServicesJsonForType', () => {
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.getMicroServicesJsonForType("TCA_h2NMX_v1_0_ResourceInstanceName1_tca")).toStrictEqual(msJson);
89 expect(loopCache.getMicroServicesJsonForType("TCA_h2NMX_v1_0_ResourceInstanceName1_tca_2")).toBeNull();
92 it('getMicroServiceProperties', () => {
93 const msProp = {"domain": "measurementsForVfScaling"};
94 expect(loopCache.getMicroServiceProperties("TCA_h2NMX_v1_0_ResourceInstanceName1_tca")).toStrictEqual(msProp);
95 expect(loopCache.getMicroServiceProperties("TCA_h2NMX_v1_0_ResourceInstanceName1_tca_2")).toBeNull();
98 it('getMicroServiceJsonRepresentationForType', () => {
99 const msJsonRepresentation = {"schema": {}};
100 expect(loopCache.getMicroServiceJsonRepresentationForType("TCA_h2NMX_v1_0_ResourceInstanceName1_tca")).toStrictEqual(msJsonRepresentation);
103 it('getMicroServiceJsonRepresentationForType', () => {
104 const msJsonRepresentation = {"schema": {}};
105 expect(loopCache.getMicroServiceJsonRepresentationForType("TCA_h2NMX_v1_0_ResourceInstanceName1_tca")).toStrictEqual(msJsonRepresentation);
108 it('getResourceDetailsVfProperty', () => {
110 "vLoadBalancerMS 0": {
111 "resourceVendor": "Test",
112 "resourceVendorModelNumber": "",
113 "name": "vLoadBalancerMS",
114 "description": "vLBMS",
115 "invariantUUID": "1a31b9f2-e50d-43b7-89b3-a040250cf506",
116 "subcategory": "Load Balancer",
117 "category": "Application L4+",
119 "UUID": "b4c4f3d7-929e-4b6d-a1cd-57e952ddc3e6",
121 "resourceVendorRelease": "1.0",
122 "customizationUUID": "465246dc-7748-45f4-a013-308d92922552"
125 expect(loopCache.getResourceDetailsVfProperty()).toStrictEqual(resourceVF);
128 it('getResourceDetailsVfModuleProperty', () => {
130 "Vloadbalancerms..vpkg..module-1": {
131 "vfModuleModelInvariantUUID": "ca052563-eb92-4b5b-ad41-9111768ce043",
132 "vfModuleModelVersion": "1",
133 "vfModuleModelName": "Vloadbalancerms..vpkg..module-1",
134 "vfModuleModelUUID": "1e725ccc-b823-4f67-82b9-4f4367070dbc",
135 "vfModuleModelCustomizationUUID": "1bffdc31-a37d-4dee-b65c-dde623a76e52",
136 "min_vf_module_instances": 0,
137 "vf_module_label": "vpkg",
138 "max_vf_module_instances": 1,
139 "vf_module_type": "Expansion",
142 "volume_group": false
145 expect(loopCache.getResourceDetailsVfModuleProperty()).toStrictEqual(vfModule);
148 it('getLoopLogsArray', () => {
153 "logComponent": "CLAMP",
154 "message": "Operational and Guard policies UPDATED",
155 "logInstant": "2019-07-08T09:44:37Z"
158 expect(loopCache.getLoopLogsArray()).toStrictEqual(logs);
161 it('getComponentStates', () => {
165 "stateName": "NOT_SENT",
166 "description": "The policies defined have NOT yet been created on the policy engine"
171 "stateName": "BLUEPRINT_DEPLOYED",
172 "description": "The DCAE blueprint has been found in the DCAE inventory but not yet instancianted for this loop"
176 expect(loopCache.getComponentStates()).toStrictEqual(component);
179 it('updateGlobalProperties', () => {
180 const newGlobalProps = {
181 "dcaeDeployParameters": {
182 "location_id": "newLocation",
183 "service_id": "newServiceId",
184 "policy_id": "TCA_h2NMX_v1_0_ResourceInstanceName1_tca_2"
187 loopCache.updateGlobalProperties(newGlobalProps);
188 expect(loopCache.getGlobalProperties()).toStrictEqual(newGlobalProps);
191 it('updateOperationalPolicyProperties', () => {
192 const newOpPolicy = [{
193 "name": "OPERATIONAL_h2NMX_v1_0_ResourceInstanceName1_tca_new",
194 "configurationsJson": {
195 "guard_policies": {},
196 "operational_policy": {
202 loopCache.updateOperationalPolicyProperties(newOpPolicy);
203 expect(loopCache.getOperationalPolicies()).toStrictEqual(newOpPolicy);
206 it('updateMicroServiceProperties', () => {
207 const newMsPolicy = {
208 "name": "TCA_h2NMX_v1_0_ResourceInstanceName1_tca",
209 "modelType": "onap.policies.monitoring.cdap.tca.hi.lo.app",
210 "properties": {"domain": "measurementsForVfScalingNew"},
212 "jsonRepresentation": {"schema": {}}
214 loopCache.updateMicroServiceProperties("TCA_h2NMX_v1_0_ResourceInstanceName1_tca", newMsPolicy);
215 expect(loopCache.getMicroServicesJsonForType("TCA_h2NMX_v1_0_ResourceInstanceName1_tca")).toStrictEqual(newMsPolicy);