2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2019 Nordix Foundation.
4 * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
5 * ================================================================================
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 * SPDX-License-Identifier: Apache-2.0
19 * ============LICENSE_END=========================================================
22 package org.onap.policy.models.tosca.simple.serialization;
24 import static org.junit.Assert.assertEquals;
25 import static org.junit.Assert.assertNotNull;
26 import static org.junit.Assert.assertTrue;
27 import static org.junit.Assert.fail;
29 import com.google.gson.Gson;
30 import com.google.gson.JsonSyntaxException;
32 import java.io.IOException;
33 import java.util.Iterator;
35 import java.util.Map.Entry;
36 import org.junit.Before;
37 import org.junit.Test;
38 import org.onap.policy.common.utils.resources.ResourceUtils;
39 import org.onap.policy.models.base.PfConceptKey;
40 import org.onap.policy.models.base.PfValidationResult;
41 import org.onap.policy.models.tosca.simple.concepts.ToscaConstraintLogicalString;
42 import org.onap.policy.models.tosca.simple.concepts.ToscaConstraintValidValues;
43 import org.onap.policy.models.tosca.simple.concepts.ToscaDataType;
44 import org.onap.policy.models.tosca.simple.concepts.ToscaEntrySchema;
45 import org.onap.policy.models.tosca.simple.concepts.ToscaPolicyType;
46 import org.onap.policy.models.tosca.simple.concepts.ToscaProperty;
47 import org.onap.policy.models.tosca.simple.concepts.ToscaServiceTemplate;
48 import org.onap.policy.models.tosca.simple.serialization.ToscaServiceTemplateMessageBodyHandler;
49 import org.slf4j.Logger;
50 import org.slf4j.LoggerFactory;
51 import org.yaml.snakeyaml.Yaml;
54 * Test serialization of monitoring policy types.
56 * @author Chenfei Gao (cgao@research.att.com)
58 public class MonitoringPolicyTypeSerializationTest {
60 private static final Logger LOGGER = LoggerFactory.getLogger(MonitoringPolicyTypeSerializationTest.class);
62 private static final String MONITORING_TCA_YAML = "policytypes/onap.policy.monitoring.cdap.tca.hi.lo.app.yaml";
63 private static final String MONITORING_COLLECTORS_YAML =
64 "policytypes/onap.policies.monitoring.dcaegen2.collectors.datafile.datafile-app-server.yaml";
70 gson = new ToscaServiceTemplateMessageBodyHandler().getGson();
74 public void testDeserialization() {
77 ToscaServiceTemplate serviceTemplateFromYaml = deserializeMonitoringInputYaml(MONITORING_TCA_YAML);
78 verifyTcaInputDeserialization(serviceTemplateFromYaml);
81 serviceTemplateFromYaml = deserializeMonitoringInputYaml(MONITORING_COLLECTORS_YAML);
82 verifyCollectorInputDeserialization(serviceTemplateFromYaml);
84 } catch (Exception e) {
85 fail("No exception should be thrown");
90 public void testSerialization() {
93 ToscaServiceTemplate serviceTemplateFromYaml = deserializeMonitoringInputYaml(MONITORING_TCA_YAML);
94 String serializedServiceTemplate1 = serializeMonitoringServiceTemplate(serviceTemplateFromYaml);
95 ToscaServiceTemplate serviceTemplateFromJson = gson.fromJson(serializedServiceTemplate1,
96 ToscaServiceTemplate.class);
97 String serializedServiceTemplate2 = serializeMonitoringServiceTemplate(serviceTemplateFromJson);
98 assertEquals(serializedServiceTemplate1, serializedServiceTemplate2);
101 serviceTemplateFromYaml = deserializeMonitoringInputYaml(MONITORING_COLLECTORS_YAML);
102 serializedServiceTemplate1 = serializeMonitoringServiceTemplate(serviceTemplateFromYaml);
103 serviceTemplateFromJson = gson.fromJson(serializedServiceTemplate1, ToscaServiceTemplate.class);
104 serializedServiceTemplate2 = serializeMonitoringServiceTemplate(serviceTemplateFromJson);
105 assertEquals(serializedServiceTemplate1, serializedServiceTemplate2);
107 } catch (Exception e) {
108 fail("No exception should be thrown");
112 private ToscaServiceTemplate deserializeMonitoringInputYaml(String resourcePath)
113 throws JsonSyntaxException, IOException {
115 Yaml yaml = new Yaml();
116 String policyTypeYaml = ResourceUtils.getResourceAsString(resourcePath);
117 Object yamlObject = yaml.load(policyTypeYaml);
118 String yamlAsJsonString = new Gson().toJson(yamlObject);
119 ToscaServiceTemplate serviceTemplate = gson.fromJson(yamlAsJsonString, ToscaServiceTemplate.class);
120 return serviceTemplate;
123 private void verifyTcaInputDeserialization(ToscaServiceTemplate serviceTemplate) {
125 // Sanity check the entire structure
126 assertNotNull(serviceTemplate);
127 LOGGER.info(serviceTemplate.validate(new PfValidationResult()).toString());
128 assertTrue(serviceTemplate.validate(new PfValidationResult()).isValid());
130 // Check tosca_definitions_version
131 assertEquals("tosca_simple_yaml_1_0_0", serviceTemplate.getToscaDefinitionsVersion());
133 // Check policy_types
134 Map<PfConceptKey, ToscaPolicyType> policyTypesConceptMap = serviceTemplate.getPolicyTypes().getConceptMap();
135 assertTrue(policyTypesConceptMap.size() == 2);
136 Iterator<Entry<PfConceptKey, ToscaPolicyType>> policyTypesIter = policyTypesConceptMap.entrySet().iterator();
138 Entry<PfConceptKey, ToscaPolicyType> firstPolicyType = policyTypesIter.next();
139 assertEquals("onap.policies.Monitoring", firstPolicyType.getKey().getName());
140 assertEquals("1.0.0", firstPolicyType.getKey().getVersion());
141 assertEquals("tosca.policies.Root", firstPolicyType.getValue().getDerivedFrom().getName());
142 assertEquals("a base policy type for all policies that governs monitoring provisioning",
143 firstPolicyType.getValue().getDescription());
145 Entry<PfConceptKey, ToscaPolicyType> secondPolicyType = policyTypesIter.next();
146 assertEquals("onap.policy.monitoring.cdap.tca.hi.lo.app", secondPolicyType.getKey().getName());
147 assertEquals("1.0.0", secondPolicyType.getKey().getVersion());
148 assertEquals("onap.policies.Monitoring", secondPolicyType.getValue().getDerivedFrom().getName());
149 assertTrue(secondPolicyType.getValue().getProperties().size() == 1);
151 ToscaProperty property = secondPolicyType.getValue().getProperties().iterator().next();
152 assertEquals("onap.policy.monitoring.cdap.tca.hi.lo.app", property.getKey().getParentKeyName());
153 assertEquals("1.0.0", property.getKey().getParentKeyVersion());
154 assertEquals("tca_policy", property.getKey().getLocalName());
155 assertEquals("map", property.getType().getName());
156 assertEquals("TCA Policy JSON", property.getDescription());
158 ToscaEntrySchema entrySchema = property.getEntrySchema();
159 assertEquals("map", entrySchema.getKey().getParentKeyName());
160 assertEquals("1.0.0", entrySchema.getKey().getParentKeyVersion());
161 assertEquals("entry_schema", entrySchema.getKey().getLocalName());
162 assertEquals("onap.datatypes.monitoring.tca_policy", entrySchema.getType().getName());
165 Map<PfConceptKey, ToscaDataType> dataTypesConceptMap = serviceTemplate.getDataTypes().getConceptMap();
166 assertTrue(dataTypesConceptMap.size() == 3);
167 Iterator<Entry<PfConceptKey, ToscaDataType>> dataTypesIter = dataTypesConceptMap.entrySet().iterator();
169 Entry<PfConceptKey, ToscaDataType> firstDataType = dataTypesIter.next();
170 assertEquals("onap.datatypes.monitoring.metricsPerEventName", firstDataType.getKey().getName());
171 ToscaDataType firstDataTypeVal = firstDataType.getValue();
172 assertEquals("tosca.datatypes.Root", firstDataTypeVal.getDerivedFrom().getName());
173 assertEquals("1.0.0", firstDataTypeVal.getDerivedFrom().getVersion());
174 assertTrue(firstDataTypeVal.getProperties().size() == 6);
175 Iterator<ToscaProperty> firstDataTypePropertiesIter = firstDataTypeVal.getProperties().iterator();
177 ToscaProperty firstDataTypeFirstProperty = firstDataTypePropertiesIter.next();
178 assertEquals("onap.datatypes.monitoring.metricsPerEventName", firstDataTypeFirstProperty.getKey()
179 .getParentKeyName());
180 assertEquals("controlLoopSchemaType", firstDataTypeFirstProperty.getKey().getLocalName());
181 assertEquals("string", firstDataTypeFirstProperty.getType().getName());
182 assertTrue(firstDataTypeFirstProperty.isRequired());
183 assertEquals("Specifies Control Loop Schema Type for the event Name e.g. VNF, VM",
184 firstDataTypeFirstProperty.getDescription());
185 assertTrue(firstDataTypeFirstProperty.getConstraints().size() == 1);
186 assertEquals("valid_values", firstDataTypeFirstProperty.getConstraints().iterator().next().getKey()
188 assertEquals("string", firstDataTypeFirstProperty.getConstraints().iterator().next().getKey()
189 .getParentKeyName());
190 assertTrue(firstDataTypeFirstProperty.getConstraints().iterator().next()
191 instanceof ToscaConstraintValidValues);
192 assertTrue(((ToscaConstraintValidValues)(firstDataTypeFirstProperty.getConstraints().iterator().next()))
193 .getValidValues().size() == 2);
195 ToscaProperty firstDataTypeSecondProperty = firstDataTypePropertiesIter.next();
196 assertEquals("onap.datatypes.monitoring.metricsPerEventName", firstDataTypeSecondProperty.getKey()
197 .getParentKeyName());
198 assertEquals("eventName", firstDataTypeSecondProperty.getKey().getLocalName());
199 assertEquals("string", firstDataTypeSecondProperty.getType().getName());
200 assertTrue(firstDataTypeSecondProperty.isRequired());
201 assertEquals("Event name to which thresholds need to be applied", firstDataTypeSecondProperty
204 ToscaProperty firstDataTypeThirdProperty = firstDataTypePropertiesIter.next();
205 assertEquals("onap.datatypes.monitoring.metricsPerEventName", firstDataTypeThirdProperty.getKey()
206 .getParentKeyName());
207 assertEquals("policyName", firstDataTypeThirdProperty.getKey().getLocalName());
208 assertEquals("string", firstDataTypeThirdProperty.getType().getName());
209 assertTrue(firstDataTypeThirdProperty.isRequired());
210 assertEquals("TCA Policy Scope Name", firstDataTypeThirdProperty.getDescription());
212 ToscaProperty firstDataTypeFourthProperty = firstDataTypePropertiesIter.next();
213 assertEquals("onap.datatypes.monitoring.metricsPerEventName", firstDataTypeFourthProperty.getKey()
214 .getParentKeyName());
215 assertEquals("policyScope", firstDataTypeFourthProperty.getKey().getLocalName());
216 assertEquals("string", firstDataTypeFourthProperty.getType().getName());
217 assertTrue(firstDataTypeFourthProperty.isRequired());
218 assertEquals("TCA Policy Scope", firstDataTypeFourthProperty.getDescription());
220 ToscaProperty firstDataTypeFifthProperty = firstDataTypePropertiesIter.next();
221 assertEquals("onap.datatypes.monitoring.metricsPerEventName", firstDataTypeFifthProperty.getKey()
222 .getParentKeyName());
223 assertEquals("policyVersion", firstDataTypeFifthProperty.getKey().getLocalName());
224 assertEquals("string", firstDataTypeFifthProperty.getType().getName());
225 assertTrue(firstDataTypeFifthProperty.isRequired());
226 assertEquals("TCA Policy Scope Version", firstDataTypeFifthProperty.getDescription());
228 ToscaProperty firstDataTypeSixthProperty = firstDataTypePropertiesIter.next();
229 assertEquals("onap.datatypes.monitoring.metricsPerEventName", firstDataTypeSixthProperty.getKey()
230 .getParentKeyName());
231 assertEquals("thresholds", firstDataTypeSixthProperty.getKey().getLocalName());
232 assertEquals("list", firstDataTypeSixthProperty.getType().getName());
233 assertTrue(firstDataTypeSixthProperty.isRequired());
234 assertEquals("Thresholds associated with eventName", firstDataTypeSixthProperty.getDescription());
235 assertNotNull(firstDataTypeSixthProperty.getEntrySchema());
236 assertEquals("entry_schema", firstDataTypeSixthProperty.getEntrySchema().getKey().getLocalName());
237 assertEquals("list", firstDataTypeSixthProperty.getEntrySchema().getKey().getParentKeyName());
238 assertEquals("onap.datatypes.monitoring.thresholds", firstDataTypeSixthProperty.getEntrySchema().getType()
241 Entry<PfConceptKey, ToscaDataType> secondDataType = dataTypesIter.next();
242 assertEquals("onap.datatypes.monitoring.tca_policy", secondDataType.getKey().getName());
243 ToscaDataType secondDataTypeVal = secondDataType.getValue();
244 assertEquals("tosca.datatypes.Root", secondDataTypeVal.getDerivedFrom().getName());
245 assertEquals("1.0.0", secondDataTypeVal.getDerivedFrom().getVersion());
246 assertTrue(secondDataTypeVal.getProperties().size() == 2);
247 Iterator<ToscaProperty> secondDataTypePropertiesIter = secondDataTypeVal.getProperties().iterator();
249 ToscaProperty secondDataTypeFirstProperty = secondDataTypePropertiesIter.next();
250 assertEquals("onap.datatypes.monitoring.tca_policy", secondDataTypeFirstProperty.getKey().getParentKeyName());
251 assertEquals("domain", secondDataTypeFirstProperty.getKey().getLocalName());
252 assertEquals("string", secondDataTypeFirstProperty.getType().getName());
253 assertTrue(secondDataTypeFirstProperty.isRequired());
254 assertEquals("Domain name to which TCA needs to be applied", secondDataTypeFirstProperty.getDescription());
255 assertEquals("measurementsForVfScaling", secondDataTypeFirstProperty.getDefaultValue());
256 assertTrue(secondDataTypeFirstProperty.getConstraints().size() == 1);
257 assertEquals("string", secondDataTypeFirstProperty.getConstraints().iterator().next().getKey()
258 .getParentKeyName());
259 assertEquals("equal", secondDataTypeFirstProperty.getConstraints().iterator().next().getKey().getLocalName());
260 assertTrue(secondDataTypeFirstProperty.getConstraints().iterator().next()
261 instanceof ToscaConstraintLogicalString);
262 assertEquals("measurementsForVfScaling", ((ToscaConstraintLogicalString)(secondDataTypeFirstProperty
263 .getConstraints().iterator().next())).getCompareToString());
265 ToscaProperty secondDataTypeSecondProperty = secondDataTypePropertiesIter.next();
266 assertEquals("onap.datatypes.monitoring.tca_policy", secondDataTypeSecondProperty.getKey().getParentKeyName());
267 assertEquals("metricsPerEventName", secondDataTypeSecondProperty.getKey().getLocalName());
268 assertEquals("list", secondDataTypeSecondProperty.getType().getName());
269 assertTrue(secondDataTypeSecondProperty.isRequired());
270 assertEquals("Contains eventName and threshold details that need to be applied to given eventName",
271 secondDataTypeSecondProperty.getDescription());
272 assertNotNull(secondDataTypeSecondProperty.getEntrySchema());
273 assertEquals("list", secondDataTypeSecondProperty.getEntrySchema().getKey().getParentKeyName());
274 assertEquals("onap.datatypes.monitoring.metricsPerEventName",
275 secondDataTypeSecondProperty.getEntrySchema().getType().getName());
276 assertEquals("entry_schema", secondDataTypeSecondProperty.getEntrySchema().getKey().getLocalName());
278 Entry<PfConceptKey, ToscaDataType> thirdDataType = dataTypesIter.next();
279 assertEquals("onap.datatypes.monitoring.thresholds", thirdDataType.getKey().getName());
280 ToscaDataType thirdDataTypeVal = thirdDataType.getValue();
281 assertEquals("tosca.datatypes.Root", thirdDataTypeVal.getDerivedFrom().getName());
282 assertEquals("1.0.0", thirdDataTypeVal.getDerivedFrom().getVersion());
283 assertTrue(thirdDataTypeVal.getProperties().size() == 7);
284 Iterator<ToscaProperty> thirdDataTypePropertiesIter = thirdDataTypeVal.getProperties().iterator();
286 ToscaProperty thirdDataTypeFirstProperty = thirdDataTypePropertiesIter.next();
287 assertEquals("onap.datatypes.monitoring.thresholds", thirdDataTypeFirstProperty.getKey().getParentKeyName());
288 assertEquals("closedLoopControlName", thirdDataTypeFirstProperty.getKey().getLocalName());
289 assertEquals("string", thirdDataTypeFirstProperty.getType().getName());
290 assertTrue(thirdDataTypeFirstProperty.isRequired());
291 assertEquals("Closed Loop Control Name associated with the threshold", thirdDataTypeFirstProperty
294 ToscaProperty thirdDataTypeSecondProperty = thirdDataTypePropertiesIter.next();
295 assertEquals("onap.datatypes.monitoring.thresholds", thirdDataTypeSecondProperty.getKey().getParentKeyName());
296 assertEquals("closedLoopEventStatus", thirdDataTypeSecondProperty.getKey().getLocalName());
297 assertEquals("string", thirdDataTypeSecondProperty.getType().getName());
298 assertTrue(thirdDataTypeSecondProperty.isRequired());
299 assertEquals("Closed Loop Event Status of the threshold", thirdDataTypeSecondProperty.getDescription());
300 assertNotNull(thirdDataTypeSecondProperty.getConstraints());
301 assertTrue(thirdDataTypeSecondProperty.getConstraints().size() == 1);
302 assertEquals("string", thirdDataTypeSecondProperty.getConstraints().iterator().next().getKey()
303 .getParentKeyName());
304 assertEquals("valid_values", thirdDataTypeSecondProperty.getConstraints().iterator().next().getKey()
306 assertTrue(thirdDataTypeSecondProperty.getConstraints().iterator().next()
307 instanceof ToscaConstraintValidValues);
308 assertTrue(((ToscaConstraintValidValues)(thirdDataTypeSecondProperty.getConstraints().iterator().next()))
309 .getValidValues().size() == 2);
311 ToscaProperty thirdDataTypeThirdProperty = thirdDataTypePropertiesIter.next();
312 assertEquals("onap.datatypes.monitoring.thresholds", thirdDataTypeThirdProperty.getKey().getParentKeyName());
313 assertEquals("direction", thirdDataTypeThirdProperty.getKey().getLocalName());
314 assertEquals("string", thirdDataTypeThirdProperty.getType().getName());
315 assertTrue(thirdDataTypeThirdProperty.isRequired());
316 assertEquals("Direction of the threshold", thirdDataTypeThirdProperty.getDescription());
317 assertNotNull(thirdDataTypeThirdProperty.getConstraints());
318 assertTrue(thirdDataTypeThirdProperty.getConstraints().size() == 1);
319 assertEquals("string", thirdDataTypeThirdProperty.getConstraints().iterator().next().getKey()
320 .getParentKeyName());
321 assertEquals("valid_values", thirdDataTypeThirdProperty.getConstraints().iterator().next().getKey()
323 assertTrue(((ToscaConstraintValidValues)(thirdDataTypeThirdProperty.getConstraints().iterator().next()))
324 .getValidValues().size() == 5);
326 ToscaProperty thirdDataTypeFourthProperty = thirdDataTypePropertiesIter.next();
327 assertEquals("onap.datatypes.monitoring.thresholds", thirdDataTypeFourthProperty.getKey().getParentKeyName());
328 assertEquals("fieldPath", thirdDataTypeFourthProperty.getKey().getLocalName());
329 assertEquals("string", thirdDataTypeFourthProperty.getType().getName());
330 assertTrue(thirdDataTypeFourthProperty.isRequired());
331 assertEquals("Json field Path as per CEF message which needs to be analyzed for TCA",
332 thirdDataTypeFourthProperty.getDescription());
333 assertNotNull(thirdDataTypeFourthProperty.getConstraints());
334 assertTrue(thirdDataTypeFourthProperty.getConstraints().size() == 1);
335 assertEquals("string", thirdDataTypeFourthProperty.getConstraints().iterator().next().getKey()
336 .getParentKeyName());
337 assertEquals("valid_values", thirdDataTypeFourthProperty.getConstraints().iterator().next().getKey()
339 assertTrue(((ToscaConstraintValidValues)(thirdDataTypeFourthProperty.getConstraints().iterator().next()))
340 .getValidValues().size() == 43);
342 ToscaProperty thirdDataTypeFifthProperty = thirdDataTypePropertiesIter.next();
343 assertEquals("onap.datatypes.monitoring.thresholds", thirdDataTypeFifthProperty.getKey().getParentKeyName());
344 assertEquals("severity", thirdDataTypeFifthProperty.getKey().getLocalName());
345 assertEquals("string", thirdDataTypeFifthProperty.getType().getName());
346 assertTrue(thirdDataTypeFifthProperty.isRequired());
347 assertEquals("Threshold Event Severity", thirdDataTypeFifthProperty.getDescription());
348 assertNotNull(thirdDataTypeFifthProperty.getConstraints());
349 assertTrue(thirdDataTypeFifthProperty.getConstraints().size() == 1);
350 assertEquals("string", thirdDataTypeFifthProperty.getConstraints().iterator().next().getKey()
351 .getParentKeyName());
352 assertEquals("valid_values", thirdDataTypeFifthProperty.getConstraints().iterator().next().getKey()
354 assertTrue(((ToscaConstraintValidValues)(thirdDataTypeFifthProperty.getConstraints().iterator().next()))
355 .getValidValues().size() == 5);;
357 ToscaProperty thirdDataTypeSixthProperty = thirdDataTypePropertiesIter.next();
358 assertEquals("onap.datatypes.monitoring.thresholds", thirdDataTypeSixthProperty.getKey().getParentKeyName());
359 assertEquals("thresholdValue", thirdDataTypeSixthProperty.getKey().getLocalName());
360 assertEquals("integer", thirdDataTypeSixthProperty.getType().getName());
361 assertTrue(thirdDataTypeSixthProperty.isRequired());
362 assertEquals("Threshold value for the field Path inside CEF message", thirdDataTypeSixthProperty
365 ToscaProperty thirdDataTypeSeventhProperty = thirdDataTypePropertiesIter.next();
366 assertEquals("onap.datatypes.monitoring.thresholds", thirdDataTypeSeventhProperty.getKey().getParentKeyName());
367 assertEquals("version", thirdDataTypeSeventhProperty.getKey().getLocalName());
368 assertEquals("string", thirdDataTypeSeventhProperty.getType().getName());
369 assertTrue(thirdDataTypeSeventhProperty.isRequired());
370 assertEquals("Version number associated with the threshold", thirdDataTypeSeventhProperty.getDescription());
373 private void verifyCollectorInputDeserialization(ToscaServiceTemplate serviceTemplate) {
375 // Sanity check the entire structure
376 assertNotNull(serviceTemplate);
377 LOGGER.info(serviceTemplate.validate(new PfValidationResult()).toString());
378 assertTrue(serviceTemplate.validate(new PfValidationResult()).isValid());
380 // Check tosca_definitions_version
381 assertEquals("tosca_simple_yaml_1_0_0", serviceTemplate.getToscaDefinitionsVersion());
383 // Check policy_types
384 Map<PfConceptKey, ToscaPolicyType> policyTypesConceptMap = serviceTemplate.getPolicyTypes().getConceptMap();
385 assertTrue(policyTypesConceptMap.size() == 2);
386 Iterator<Entry<PfConceptKey, ToscaPolicyType>> policyTypesIter = policyTypesConceptMap.entrySet().iterator();
388 Entry<PfConceptKey, ToscaPolicyType> firstPolicyType = policyTypesIter.next();
389 assertEquals("onap.policies.Monitoring", firstPolicyType.getKey().getName());
390 assertEquals("1.0.0", firstPolicyType.getKey().getVersion());
391 assertEquals("tosca.policies.Root", firstPolicyType.getValue().getDerivedFrom().getName());
392 assertEquals("a base policy type for all policies that govern monitoring provision",
393 firstPolicyType.getValue().getDescription());
395 Entry<PfConceptKey, ToscaPolicyType> secondPolicyType = policyTypesIter.next();
396 assertEquals("onap.policies.monitoring.dcaegen2.collectors.datafile.datafile-app-server",
397 secondPolicyType.getKey().getName());
398 assertEquals("1.0.0", secondPolicyType.getKey().getVersion());
399 assertEquals("policy.nodes.Root", secondPolicyType.getValue().getDerivedFrom().getName());
400 assertTrue(secondPolicyType.getValue().getProperties().size() == 2);
402 Iterator<ToscaProperty> propertiesIter = secondPolicyType.getValue().getProperties().iterator();
404 ToscaProperty firstProperty = propertiesIter.next();
405 assertEquals("onap.policies.monitoring.dcaegen2.collectors.datafile.datafile-app-server",
406 firstProperty.getKey().getParentKeyName());
407 assertEquals("1.0.0", firstProperty.getKey().getParentKeyVersion());
408 assertEquals("buscontroller_feed_publishing_endpoint", firstProperty.getKey().getLocalName());
409 assertEquals("string", firstProperty.getType().getName());
410 assertEquals("DMAAP Bus Controller feed endpoint", firstProperty.getDescription());
412 ToscaProperty secondProperty = propertiesIter.next();
413 assertEquals("onap.policies.monitoring.dcaegen2.collectors.datafile.datafile-app-server",
414 secondProperty.getKey().getParentKeyName());
415 assertEquals("1.0.0", secondProperty.getKey().getParentKeyVersion());
416 assertEquals("datafile.policy", secondProperty.getKey().getLocalName());
417 assertEquals("string", secondProperty.getType().getName());
418 assertEquals("datafile Policy JSON as string", secondProperty.getDescription());
421 private String serializeMonitoringServiceTemplate(ToscaServiceTemplate serviceTemplate) {
422 return gson.toJson(serviceTemplate);