2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2019-2020 Nordix Foundation.
4 * Copyright (C) 2019-2020,2022 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;
28 import java.util.Iterator;
30 import java.util.Map.Entry;
31 import org.junit.Before;
32 import org.junit.Test;
33 import org.onap.policy.common.utils.coder.CoderException;
34 import org.onap.policy.common.utils.coder.StandardCoder;
35 import org.onap.policy.common.utils.resources.ResourceUtils;
36 import org.onap.policy.models.base.PfConceptKey;
37 import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
38 import org.onap.policy.models.tosca.simple.concepts.JpaToscaConstraintLogical;
39 import org.onap.policy.models.tosca.simple.concepts.JpaToscaConstraintValidValues;
40 import org.onap.policy.models.tosca.simple.concepts.JpaToscaDataType;
41 import org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicyType;
42 import org.onap.policy.models.tosca.simple.concepts.JpaToscaProperty;
43 import org.onap.policy.models.tosca.simple.concepts.JpaToscaServiceTemplate;
44 import org.slf4j.Logger;
45 import org.slf4j.LoggerFactory;
46 import org.yaml.snakeyaml.Yaml;
49 * Test serialization of monitoring policy types.
51 * @author Chenfei Gao (cgao@research.att.com)
53 public class MonitoringPolicyTypeSerializationTest {
55 private static final String DATATYPE_ROOT = "tosca.datatypes.Root";
57 private static final String STRING_TEXT = "string";
59 private static final String DCAE = "onap.policies.monitoring.dcaegen2.collectors.datafile.datafile-app-server";
61 private static final String MONITORING = "onap.policies.Monitoring";
63 private static final String THRESHOLDS = "onap.datatypes.monitoring.thresholds";
65 private static final String TCA_V1 = "onap.datatypes.monitoring.tca_policy";
66 private static final String TCA_V2 = "list";
68 private static final String METRICS = "onap.datatypes.monitoring.metricsPerEventName";
70 private static final String VERSION_000 = "0.0.0";
71 private static final String VERSION_100 = "1.0.0";
72 private static final String VERSION_200 = "2.0.0";
74 private static final Logger LOGGER = LoggerFactory.getLogger(MonitoringPolicyTypeSerializationTest.class);
76 private static final String MONITORING_TCA_YAML = "policytypes/onap.policies.monitoring.tcagen2.yaml";
77 private static final String MONITORING_TCA_V2_YAML = "policytypes/onap.policies.monitoring.tcagen2.v2.yaml";
79 private static final String MONITORING_COLLECTORS_YAML =
80 "policytypes/onap.policies.monitoring.dcaegen2.collectors.datafile.datafile-app-server.yaml";
82 private StandardCoder coder;
86 coder = new StandardCoder();
90 public void testDeserialization() throws Exception {
92 JpaToscaServiceTemplate serviceTemplateFromYaml = deserializeMonitoringInputYaml(MONITORING_TCA_YAML);
93 verifyTcaInputDeserialization(serviceTemplateFromYaml, VERSION_100, TCA_V1);
96 serviceTemplateFromYaml = deserializeMonitoringInputYaml(MONITORING_TCA_V2_YAML);
97 verifyTcaInputDeserialization(serviceTemplateFromYaml, VERSION_200, TCA_V2);
100 serviceTemplateFromYaml = deserializeMonitoringInputYaml(MONITORING_COLLECTORS_YAML);
101 verifyCollectorInputDeserialization(serviceTemplateFromYaml);
105 public void testSerialization() throws Exception {
107 JpaToscaServiceTemplate tcaServiceTemplateFromYaml = deserializeMonitoringInputYaml(MONITORING_TCA_YAML);
108 String serializedServiceTemplateTca = serializeMonitoringServiceTemplate(tcaServiceTemplateFromYaml);
110 ToscaServiceTemplate toscaServiceTemplateFromJsonTca =
111 coder.decode(serializedServiceTemplateTca, ToscaServiceTemplate.class);
113 JpaToscaServiceTemplate serviceTemplateFromJsonTca = new JpaToscaServiceTemplate();
114 serviceTemplateFromJsonTca.fromAuthorative(toscaServiceTemplateFromJsonTca);
115 String serializedServiceTemplateTcaOut = serializeMonitoringServiceTemplate(serviceTemplateFromJsonTca);
116 assertEquals(serializedServiceTemplateTca, serializedServiceTemplateTcaOut);
119 tcaServiceTemplateFromYaml = deserializeMonitoringInputYaml(MONITORING_TCA_V2_YAML);
120 serializedServiceTemplateTca = serializeMonitoringServiceTemplate(tcaServiceTemplateFromYaml);
122 toscaServiceTemplateFromJsonTca =
123 coder.decode(serializedServiceTemplateTca, ToscaServiceTemplate.class);
125 serviceTemplateFromJsonTca = new JpaToscaServiceTemplate();
126 serviceTemplateFromJsonTca.fromAuthorative(toscaServiceTemplateFromJsonTca);
127 serializedServiceTemplateTcaOut = serializeMonitoringServiceTemplate(serviceTemplateFromJsonTca);
128 assertEquals(serializedServiceTemplateTca, serializedServiceTemplateTcaOut);
131 JpaToscaServiceTemplate collectorServiceTemplateFromYaml =
132 deserializeMonitoringInputYaml(MONITORING_COLLECTORS_YAML);
133 String serializedServiceTemplateCollector =
134 serializeMonitoringServiceTemplate(collectorServiceTemplateFromYaml);
135 ToscaServiceTemplate toscaServiceTemplateFromJsonCollector =
136 coder.decode(serializedServiceTemplateCollector, ToscaServiceTemplate.class);
137 JpaToscaServiceTemplate serviceTemplateFromJsonCollector = new JpaToscaServiceTemplate();
138 serviceTemplateFromJsonCollector.fromAuthorative(toscaServiceTemplateFromJsonCollector);
139 String serializedServiceTemplateCollectorsOut =
140 serializeMonitoringServiceTemplate(serviceTemplateFromJsonCollector);
141 assertEquals(serializedServiceTemplateCollector, serializedServiceTemplateCollectorsOut);
144 private JpaToscaServiceTemplate deserializeMonitoringInputYaml(String resourcePath) throws Exception {
145 Yaml yaml = new Yaml();
146 String policyTypeYaml = ResourceUtils.getResourceAsString(resourcePath);
147 Object yamlObject = yaml.load(policyTypeYaml);
148 String yamlAsJsonString = coder.encode(yamlObject);
149 ToscaServiceTemplate serviceTemplate = coder.decode(yamlAsJsonString, ToscaServiceTemplate.class);
151 JpaToscaServiceTemplate jpaToscaServiceTemplate = new JpaToscaServiceTemplate();
152 jpaToscaServiceTemplate.fromAuthorative(serviceTemplate);
153 return jpaToscaServiceTemplate;
156 private void verifyTcaInputDeserialization(JpaToscaServiceTemplate serviceTemplate, String version, String tca) {
158 // Sanity check the entire structure
159 assertNotNull(serviceTemplate);
160 LOGGER.info(serviceTemplate.validate("").toString());
161 assertTrue(serviceTemplate.validate("").isValid());
163 // Check tosca_definitions_version
164 assertEquals("tosca_simple_yaml_1_1_0", serviceTemplate.getToscaDefinitionsVersion());
166 // Check policy_types
167 Map<PfConceptKey, JpaToscaPolicyType> policyTypesConceptMap = serviceTemplate.getPolicyTypes().getConceptMap();
168 assertEquals(2, policyTypesConceptMap.size());
169 Iterator<Entry<PfConceptKey, JpaToscaPolicyType>> policyTypesIter = policyTypesConceptMap.entrySet().iterator();
171 Entry<PfConceptKey, JpaToscaPolicyType> firstPolicyType = policyTypesIter.next();
172 assertEquals(MONITORING, firstPolicyType.getKey().getName());
173 assertEquals(VERSION_100, firstPolicyType.getKey().getVersion());
174 assertEquals("tosca.policies.Root", firstPolicyType.getValue().getDerivedFrom().getName());
175 assertEquals("a base policy type for all policies that govern monitoring provisioning",
176 firstPolicyType.getValue().getDescription());
178 Entry<PfConceptKey, JpaToscaPolicyType> secondPolicyType = policyTypesIter.next();
179 assertEquals("onap.policies.monitoring.tcagen2", secondPolicyType.getKey().getName());
180 assertEquals(version, secondPolicyType.getKey().getVersion());
181 assertEquals(MONITORING, secondPolicyType.getValue().getDerivedFrom().getName());
182 assertEquals(1, secondPolicyType.getValue().getProperties().size());
184 JpaToscaProperty property = secondPolicyType.getValue().getProperties().values().iterator().next();
185 assertEquals("onap.policies.monitoring.tcagen2", property.getKey().getParentKeyName());
186 assertEquals(version, property.getKey().getParentKeyVersion());
187 assertEquals("tca.policy", property.getKey().getLocalName());
188 assertEquals(tca, property.getType().getName());
189 assertEquals("TCA Policy JSON", property.getDescription());
192 Map<PfConceptKey, JpaToscaDataType> dataTypesConceptMap = serviceTemplate.getDataTypes().getConceptMap();
193 assertEquals(3, dataTypesConceptMap.size());
194 Iterator<Entry<PfConceptKey, JpaToscaDataType>> dataTypesIter = dataTypesConceptMap.entrySet().iterator();
196 Entry<PfConceptKey, JpaToscaDataType> firstDataType = dataTypesIter.next();
197 assertEquals(METRICS, firstDataType.getKey().getName());
198 JpaToscaDataType firstDataTypeVal = firstDataType.getValue();
199 assertEquals(DATATYPE_ROOT, firstDataTypeVal.getDerivedFrom().getName());
200 assertEquals(VERSION_000, firstDataTypeVal.getDerivedFrom().getVersion());
201 assertEquals(6, firstDataTypeVal.getProperties().size());
202 Iterator<JpaToscaProperty> firstDataTypePropertiesIter = firstDataTypeVal.getProperties().values().iterator();
204 JpaToscaProperty firstDataTypeFirstProperty = firstDataTypePropertiesIter.next();
205 assertEquals(METRICS, firstDataTypeFirstProperty.getKey().getParentKeyName());
206 assertEquals("controlLoopSchemaType", firstDataTypeFirstProperty.getKey().getLocalName());
207 assertEquals(STRING_TEXT, firstDataTypeFirstProperty.getType().getName());
208 assertTrue(firstDataTypeFirstProperty.isRequired());
209 assertEquals("Specifies Control Loop Schema Type for the event Name e.g. VNF, VM",
210 firstDataTypeFirstProperty.getDescription());
211 assertEquals(1, firstDataTypeFirstProperty.getConstraints().size());
212 assertEquals("org.onap.policy.models.tosca.simple.concepts.JpaToscaConstraintValidValues",
213 firstDataTypeFirstProperty.getConstraints().iterator().next().getClass().getName());
215 ((JpaToscaConstraintValidValues) (firstDataTypeFirstProperty.getConstraints().iterator().next()))
216 .getValidValues().size());
218 JpaToscaProperty firstDataTypeSecondProperty = firstDataTypePropertiesIter.next();
219 assertEquals(METRICS, firstDataTypeSecondProperty.getKey().getParentKeyName());
220 assertEquals("eventName", firstDataTypeSecondProperty.getKey().getLocalName());
221 assertEquals(STRING_TEXT, firstDataTypeSecondProperty.getType().getName());
222 assertTrue(firstDataTypeSecondProperty.isRequired());
223 assertEquals("Event name to which thresholds need to be applied", firstDataTypeSecondProperty.getDescription());
225 JpaToscaProperty firstDataTypeThirdProperty = firstDataTypePropertiesIter.next();
226 assertEquals(METRICS, firstDataTypeThirdProperty.getKey().getParentKeyName());
227 assertEquals("policyName", firstDataTypeThirdProperty.getKey().getLocalName());
228 assertEquals(STRING_TEXT, firstDataTypeThirdProperty.getType().getName());
229 assertTrue(firstDataTypeThirdProperty.isRequired());
230 assertEquals("TCA Policy Scope Name", firstDataTypeThirdProperty.getDescription());
232 JpaToscaProperty firstDataTypeFourthProperty = firstDataTypePropertiesIter.next();
233 assertEquals(METRICS, firstDataTypeFourthProperty.getKey().getParentKeyName());
234 assertEquals("policyScope", firstDataTypeFourthProperty.getKey().getLocalName());
235 assertEquals(STRING_TEXT, firstDataTypeFourthProperty.getType().getName());
236 assertTrue(firstDataTypeFourthProperty.isRequired());
237 assertEquals("TCA Policy Scope", firstDataTypeFourthProperty.getDescription());
239 JpaToscaProperty firstDataTypeFifthProperty = firstDataTypePropertiesIter.next();
240 assertEquals(METRICS, firstDataTypeFifthProperty.getKey().getParentKeyName());
241 assertEquals("policyVersion", firstDataTypeFifthProperty.getKey().getLocalName());
242 assertEquals(STRING_TEXT, firstDataTypeFifthProperty.getType().getName());
243 assertTrue(firstDataTypeFifthProperty.isRequired());
244 assertEquals("TCA Policy Scope Version", firstDataTypeFifthProperty.getDescription());
246 JpaToscaProperty firstDataTypeSixthProperty = firstDataTypePropertiesIter.next();
247 assertEquals(METRICS, firstDataTypeSixthProperty.getKey().getParentKeyName());
248 assertEquals("thresholds", firstDataTypeSixthProperty.getKey().getLocalName());
249 assertEquals("list", firstDataTypeSixthProperty.getType().getName());
250 assertTrue(firstDataTypeSixthProperty.isRequired());
251 assertEquals("Thresholds associated with eventName", firstDataTypeSixthProperty.getDescription());
252 assertNotNull(firstDataTypeSixthProperty.getEntrySchema());
253 assertEquals(THRESHOLDS, firstDataTypeSixthProperty.getEntrySchema().getType().getName());
255 Entry<PfConceptKey, JpaToscaDataType> secondDataType = dataTypesIter.next();
256 assertEquals(TCA_V1, secondDataType.getKey().getName());
257 JpaToscaDataType secondDataTypeVal = secondDataType.getValue();
258 assertEquals(DATATYPE_ROOT, secondDataTypeVal.getDerivedFrom().getName());
259 assertEquals(VERSION_000, secondDataTypeVal.getDerivedFrom().getVersion());
260 assertEquals(2, secondDataTypeVal.getProperties().size());
261 Iterator<JpaToscaProperty> secondDataTypePropertiesIter = secondDataTypeVal.getProperties().values().iterator();
263 JpaToscaProperty secondDataTypeFirstProperty = secondDataTypePropertiesIter.next();
264 assertEquals(TCA_V1, secondDataTypeFirstProperty.getKey().getParentKeyName());
265 assertEquals("domain", secondDataTypeFirstProperty.getKey().getLocalName());
266 assertEquals(STRING_TEXT, secondDataTypeFirstProperty.getType().getName());
267 assertTrue(secondDataTypeFirstProperty.isRequired());
268 assertEquals("Domain name to which TCA needs to be applied", secondDataTypeFirstProperty.getDescription());
269 assertEquals("measurementsForVfScaling", secondDataTypeFirstProperty.getDefaultValue());
270 assertEquals(1, secondDataTypeFirstProperty.getConstraints().size());
271 assertTrue(secondDataTypeFirstProperty.getConstraints().iterator().next() instanceof JpaToscaConstraintLogical);
272 assertEquals("measurementsForVfScaling",
273 ((JpaToscaConstraintLogical) (secondDataTypeFirstProperty.getConstraints().iterator().next()))
276 JpaToscaProperty secondDataTypeSecondProperty = secondDataTypePropertiesIter.next();
277 assertEquals(TCA_V1, secondDataTypeSecondProperty.getKey().getParentKeyName());
278 assertEquals("metricsPerEventName", secondDataTypeSecondProperty.getKey().getLocalName());
279 assertEquals("list", secondDataTypeSecondProperty.getType().getName());
280 assertTrue(secondDataTypeSecondProperty.isRequired());
281 assertEquals("Contains eventName and threshold details that need to be applied to given eventName",
282 secondDataTypeSecondProperty.getDescription());
283 assertNotNull(secondDataTypeSecondProperty.getEntrySchema());
284 assertEquals(METRICS, secondDataTypeSecondProperty.getEntrySchema().getType().getName());
286 Entry<PfConceptKey, JpaToscaDataType> thirdDataType = dataTypesIter.next();
287 assertEquals(THRESHOLDS, thirdDataType.getKey().getName());
288 JpaToscaDataType thirdDataTypeVal = thirdDataType.getValue();
289 assertEquals(DATATYPE_ROOT, thirdDataTypeVal.getDerivedFrom().getName());
290 assertEquals(VERSION_000, thirdDataTypeVal.getDerivedFrom().getVersion());
291 assertEquals(7, thirdDataTypeVal.getProperties().size());
292 Iterator<JpaToscaProperty> thirdDataTypePropertiesIter = thirdDataTypeVal.getProperties().values().iterator();
294 JpaToscaProperty thirdDataTypeFirstProperty = thirdDataTypePropertiesIter.next();
295 assertEquals(THRESHOLDS, thirdDataTypeFirstProperty.getKey().getParentKeyName());
296 assertEquals("closedLoopControlName", thirdDataTypeFirstProperty.getKey().getLocalName());
297 assertEquals(STRING_TEXT, thirdDataTypeFirstProperty.getType().getName());
298 assertTrue(thirdDataTypeFirstProperty.isRequired());
299 assertEquals("Closed Loop Control Name associated with the threshold",
300 thirdDataTypeFirstProperty.getDescription());
302 JpaToscaProperty thirdDataTypeSecondProperty = thirdDataTypePropertiesIter.next();
303 assertEquals(THRESHOLDS, thirdDataTypeSecondProperty.getKey().getParentKeyName());
304 assertEquals("closedLoopEventStatus", thirdDataTypeSecondProperty.getKey().getLocalName());
305 assertEquals(STRING_TEXT, thirdDataTypeSecondProperty.getType().getName());
306 assertTrue(thirdDataTypeSecondProperty.isRequired());
307 assertEquals("Closed Loop Event Status of the threshold", thirdDataTypeSecondProperty.getDescription());
308 assertNotNull(thirdDataTypeSecondProperty.getConstraints());
309 assertEquals(1, thirdDataTypeSecondProperty.getConstraints().size());
310 assertEquals("JpaToscaConstraintValidValues(validValues=[ONSET, ABATED])",
311 thirdDataTypeSecondProperty.getConstraints().iterator().next().toString());
312 assertTrue(thirdDataTypeSecondProperty.getConstraints().iterator()
313 .next() instanceof JpaToscaConstraintValidValues);
315 ((JpaToscaConstraintValidValues) (thirdDataTypeSecondProperty.getConstraints().iterator().next()))
316 .getValidValues().size());
318 JpaToscaProperty thirdDataTypeThirdProperty = thirdDataTypePropertiesIter.next();
319 assertEquals(THRESHOLDS, thirdDataTypeThirdProperty.getKey().getParentKeyName());
320 assertEquals("direction", thirdDataTypeThirdProperty.getKey().getLocalName());
321 assertEquals(STRING_TEXT, thirdDataTypeThirdProperty.getType().getName());
322 assertTrue(thirdDataTypeThirdProperty.isRequired());
323 assertEquals("Direction of the threshold", thirdDataTypeThirdProperty.getDescription());
324 assertNotNull(thirdDataTypeThirdProperty.getConstraints());
325 assertEquals(1, thirdDataTypeThirdProperty.getConstraints().size());
327 "JpaToscaConstraintValidValues(validValues=[LESS, LESS_OR_EQUAL, GREATER, GREATER_OR_EQUAL, EQUAL])",
328 thirdDataTypeThirdProperty.getConstraints().iterator().next().toString());
330 ((JpaToscaConstraintValidValues) (thirdDataTypeThirdProperty.getConstraints().iterator().next()))
331 .getValidValues().size());
333 JpaToscaProperty thirdDataTypeFourthProperty = thirdDataTypePropertiesIter.next();
334 assertEquals(THRESHOLDS, thirdDataTypeFourthProperty.getKey().getParentKeyName());
335 assertEquals("fieldPath", thirdDataTypeFourthProperty.getKey().getLocalName());
336 assertEquals(STRING_TEXT, thirdDataTypeFourthProperty.getType().getName());
337 assertTrue(thirdDataTypeFourthProperty.isRequired());
338 assertEquals("Json field Path as per CEF message which needs to be analyzed for TCA",
339 thirdDataTypeFourthProperty.getDescription());
340 assertNotNull(thirdDataTypeFourthProperty.getConstraints());
341 assertEquals(1, thirdDataTypeFourthProperty.getConstraints().size());
343 ((JpaToscaConstraintValidValues) (thirdDataTypeFourthProperty.getConstraints().iterator().next()))
344 .getValidValues().size());
346 JpaToscaProperty thirdDataTypeFifthProperty = thirdDataTypePropertiesIter.next();
347 assertEquals(THRESHOLDS, thirdDataTypeFifthProperty.getKey().getParentKeyName());
348 assertEquals("severity", thirdDataTypeFifthProperty.getKey().getLocalName());
349 assertEquals(STRING_TEXT, thirdDataTypeFifthProperty.getType().getName());
350 assertTrue(thirdDataTypeFifthProperty.isRequired());
351 assertEquals("Threshold Event Severity", thirdDataTypeFifthProperty.getDescription());
352 assertNotNull(thirdDataTypeFifthProperty.getConstraints());
353 assertEquals(1, thirdDataTypeFifthProperty.getConstraints().size());
354 assertEquals("JpaToscaConstraintValidValues(validValues=[CRITICAL, MAJOR, MINOR, WARNING, NORMAL])",
355 thirdDataTypeFifthProperty.getConstraints().iterator().next().toString());
357 ((JpaToscaConstraintValidValues) (thirdDataTypeFifthProperty.getConstraints().iterator().next()))
358 .getValidValues().size());
360 JpaToscaProperty thirdDataTypeSixthProperty = thirdDataTypePropertiesIter.next();
361 assertEquals(THRESHOLDS, thirdDataTypeSixthProperty.getKey().getParentKeyName());
362 assertEquals("thresholdValue", thirdDataTypeSixthProperty.getKey().getLocalName());
363 assertEquals("integer", thirdDataTypeSixthProperty.getType().getName());
364 assertTrue(thirdDataTypeSixthProperty.isRequired());
365 assertEquals("Threshold value for the field Path inside CEF message",
366 thirdDataTypeSixthProperty.getDescription());
368 JpaToscaProperty thirdDataTypeSeventhProperty = thirdDataTypePropertiesIter.next();
369 assertEquals(THRESHOLDS, thirdDataTypeSeventhProperty.getKey().getParentKeyName());
370 assertEquals("version", thirdDataTypeSeventhProperty.getKey().getLocalName());
371 assertEquals(STRING_TEXT, thirdDataTypeSeventhProperty.getType().getName());
372 assertTrue(thirdDataTypeSeventhProperty.isRequired());
373 assertEquals("Version number associated with the threshold", thirdDataTypeSeventhProperty.getDescription());
376 private void verifyCollectorInputDeserialization(JpaToscaServiceTemplate serviceTemplate) {
378 // Sanity check the entire structure
379 assertNotNull(serviceTemplate);
380 LOGGER.info(serviceTemplate.validate("").toString());
381 assertTrue(serviceTemplate.validate("").isValid());
383 // Check tosca_definitions_version
384 assertEquals("tosca_simple_yaml_1_1_0", serviceTemplate.getToscaDefinitionsVersion());
386 // Check policy_types
387 Map<PfConceptKey, JpaToscaPolicyType> policyTypesConceptMap = serviceTemplate.getPolicyTypes().getConceptMap();
388 assertEquals(2, policyTypesConceptMap.size());
389 Iterator<Entry<PfConceptKey, JpaToscaPolicyType>> policyTypesIter = policyTypesConceptMap.entrySet().iterator();
391 Entry<PfConceptKey, JpaToscaPolicyType> firstPolicyType = policyTypesIter.next();
392 assertEquals(MONITORING, firstPolicyType.getKey().getName());
393 assertEquals(VERSION_100, firstPolicyType.getKey().getVersion());
394 assertEquals("tosca.policies.Root", firstPolicyType.getValue().getDerivedFrom().getName());
395 assertEquals("a base policy type for all policies that govern monitoring provisioning",
396 firstPolicyType.getValue().getDescription());
398 Entry<PfConceptKey, JpaToscaPolicyType> secondPolicyType = policyTypesIter.next();
399 assertEquals(DCAE, secondPolicyType.getKey().getName());
400 assertEquals(VERSION_100, secondPolicyType.getKey().getVersion());
401 assertEquals("onap.policies.Monitoring", secondPolicyType.getValue().getDerivedFrom().getName());
402 assertEquals(2, secondPolicyType.getValue().getProperties().size());
404 Iterator<JpaToscaProperty> propertiesIter = secondPolicyType.getValue().getProperties().values().iterator();
406 JpaToscaProperty firstProperty = propertiesIter.next();
407 assertEquals(DCAE, firstProperty.getKey().getParentKeyName());
408 assertEquals(VERSION_100, firstProperty.getKey().getParentKeyVersion());
409 assertEquals("buscontroller_feed_publishing_endpoint", firstProperty.getKey().getLocalName());
410 assertEquals(STRING_TEXT, firstProperty.getType().getName());
411 assertEquals("DMAAP Bus Controller feed endpoint", firstProperty.getDescription());
413 JpaToscaProperty secondProperty = propertiesIter.next();
414 assertEquals(DCAE, secondProperty.getKey().getParentKeyName());
415 assertEquals(VERSION_100, secondProperty.getKey().getParentKeyVersion());
416 assertEquals("datafile.policy", secondProperty.getKey().getLocalName());
417 assertEquals(STRING_TEXT, secondProperty.getType().getName());
418 assertEquals("datafile Policy JSON as string", secondProperty.getDescription());
421 private String serializeMonitoringServiceTemplate(JpaToscaServiceTemplate serviceTemplate) throws CoderException {
422 ToscaServiceTemplate toscaServiceTemplate = serviceTemplate.toAuthorative();
423 return coder.encode(toscaServiceTemplate);