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 java.util.Iterator;
31 import java.util.Map.Entry;
32 import org.junit.Before;
33 import org.junit.Test;
34 import org.onap.policy.common.utils.coder.CoderException;
35 import org.onap.policy.common.utils.coder.StandardCoder;
36 import org.onap.policy.common.utils.resources.ResourceUtils;
37 import org.onap.policy.models.base.PfConceptKey;
38 import org.onap.policy.models.base.PfValidationResult;
39 import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
40 import org.onap.policy.models.tosca.simple.concepts.JpaToscaConstraintLogical;
41 import org.onap.policy.models.tosca.simple.concepts.JpaToscaConstraintValidValues;
42 import org.onap.policy.models.tosca.simple.concepts.JpaToscaDataType;
43 import org.onap.policy.models.tosca.simple.concepts.JpaToscaEntrySchema;
44 import org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicyType;
45 import org.onap.policy.models.tosca.simple.concepts.JpaToscaProperty;
46 import org.onap.policy.models.tosca.simple.concepts.JpaToscaServiceTemplate;
47 import org.slf4j.Logger;
48 import org.slf4j.LoggerFactory;
49 import org.yaml.snakeyaml.Yaml;
52 * Test serialization of monitoring policy types.
54 * @author Chenfei Gao (cgao@research.att.com)
56 public class MonitoringPolicyTypeSerializationTest {
58 private static final Logger LOGGER = LoggerFactory.getLogger(MonitoringPolicyTypeSerializationTest.class);
60 private static final String MONITORING_TCA_YAML = "policytypes/onap.policy.monitoring.cdap.tca.hi.lo.app.yaml";
61 private static final String MONITORING_COLLECTORS_YAML =
62 "policytypes/onap.policies.monitoring.dcaegen2.collectors.datafile.datafile-app-server.yaml";
64 private StandardCoder coder;
68 coder = new StandardCoder();
72 public void testDeserialization() {
75 JpaToscaServiceTemplate serviceTemplateFromYaml = deserializeMonitoringInputYaml(MONITORING_TCA_YAML);
76 verifyTcaInputDeserialization(serviceTemplateFromYaml);
79 serviceTemplateFromYaml = deserializeMonitoringInputYaml(MONITORING_COLLECTORS_YAML);
80 verifyCollectorInputDeserialization(serviceTemplateFromYaml);
82 } catch (Exception e) {
83 LOGGER.warn("No exception should be thrown", e);
84 fail("No exception should be thrown");
89 public void testSerialization() {
92 JpaToscaServiceTemplate tcaServiceTemplateFromYaml = deserializeMonitoringInputYaml(MONITORING_TCA_YAML);
93 String serializedServiceTemplateTca = serializeMonitoringServiceTemplate(tcaServiceTemplateFromYaml);
95 ToscaServiceTemplate toscaServiceTemplateFromJsonTca =
96 coder.decode(serializedServiceTemplateTca, ToscaServiceTemplate.class);
98 JpaToscaServiceTemplate serviceTemplateFromJsonTca = new JpaToscaServiceTemplate();
99 serviceTemplateFromJsonTca.fromAuthorative(toscaServiceTemplateFromJsonTca);
100 String serializedServiceTemplateTcaOut = serializeMonitoringServiceTemplate(serviceTemplateFromJsonTca);
101 assertEquals(serializedServiceTemplateTca, serializedServiceTemplateTcaOut);
104 JpaToscaServiceTemplate collectorServiceTemplateFromYaml =
105 deserializeMonitoringInputYaml(MONITORING_COLLECTORS_YAML);
106 String serializedServiceTemplateCollector =
107 serializeMonitoringServiceTemplate(collectorServiceTemplateFromYaml);
108 ToscaServiceTemplate toscaServiceTemplateFromJsonCollector =
109 coder.decode(serializedServiceTemplateCollector, ToscaServiceTemplate.class);
110 JpaToscaServiceTemplate serviceTemplateFromJsonCollector = new JpaToscaServiceTemplate();
111 serviceTemplateFromJsonCollector.fromAuthorative(toscaServiceTemplateFromJsonCollector);
112 String serializedServiceTemplateCollectorsOut =
113 serializeMonitoringServiceTemplate(serviceTemplateFromJsonCollector);
114 assertEquals(serializedServiceTemplateCollector, serializedServiceTemplateCollectorsOut);
116 } catch (Exception e) {
117 LOGGER.warn("No exception should be thrown", e);
118 fail("No exception should be thrown");
122 private JpaToscaServiceTemplate deserializeMonitoringInputYaml(String resourcePath) throws Exception {
124 Yaml yaml = new Yaml();
125 String policyTypeYaml = ResourceUtils.getResourceAsString(resourcePath);
126 Object yamlObject = yaml.load(policyTypeYaml);
127 String yamlAsJsonString = coder.encode(yamlObject);
128 ToscaServiceTemplate serviceTemplate = coder.decode(yamlAsJsonString, ToscaServiceTemplate.class);
130 JpaToscaServiceTemplate jpaToscaServiceTemplate = new JpaToscaServiceTemplate();
131 jpaToscaServiceTemplate.fromAuthorative(serviceTemplate);
132 return jpaToscaServiceTemplate;
135 private void verifyTcaInputDeserialization(JpaToscaServiceTemplate serviceTemplate) {
137 // Sanity check the entire structure
138 assertNotNull(serviceTemplate);
139 LOGGER.info(serviceTemplate.validate(new PfValidationResult()).toString());
140 assertTrue(serviceTemplate.validate(new PfValidationResult()).isValid());
142 // Check tosca_definitions_version
143 assertEquals("tosca_simple_yaml_1_0_0", serviceTemplate.getToscaDefinitionsVersion());
145 // Check policy_types
146 Map<PfConceptKey, JpaToscaPolicyType> policyTypesConceptMap = serviceTemplate.getPolicyTypes().getConceptMap();
147 assertTrue(policyTypesConceptMap.size() == 2);
148 Iterator<Entry<PfConceptKey, JpaToscaPolicyType>> policyTypesIter = policyTypesConceptMap.entrySet().iterator();
150 Entry<PfConceptKey, JpaToscaPolicyType> firstPolicyType = policyTypesIter.next();
151 assertEquals("onap.policies.Monitoring", firstPolicyType.getKey().getName());
152 assertEquals("0.0.0", firstPolicyType.getKey().getVersion());
153 assertEquals("tosca.policies.Root", firstPolicyType.getValue().getDerivedFrom().getName());
154 assertEquals("a base policy type for all policies that governs monitoring provisioning",
155 firstPolicyType.getValue().getDescription());
157 Entry<PfConceptKey, JpaToscaPolicyType> secondPolicyType = policyTypesIter.next();
158 assertEquals("onap.policy.monitoring.cdap.tca.hi.lo.app", secondPolicyType.getKey().getName());
159 assertEquals("1.0.0", secondPolicyType.getKey().getVersion());
160 assertEquals("onap.policies.Monitoring", secondPolicyType.getValue().getDerivedFrom().getName());
161 assertTrue(secondPolicyType.getValue().getProperties().size() == 1);
163 JpaToscaProperty property = secondPolicyType.getValue().getProperties().values().iterator().next();
164 assertEquals("onap.policy.monitoring.cdap.tca.hi.lo.app", property.getKey().getParentKeyName());
165 assertEquals("1.0.0", property.getKey().getParentKeyVersion());
166 assertEquals("tca_policy", property.getKey().getLocalName());
167 assertEquals("map", property.getType().getName());
168 assertEquals("TCA Policy JSON", property.getDescription());
170 JpaToscaEntrySchema entrySchema = property.getEntrySchema();
171 assertEquals("onap.datatypes.monitoring.tca_policy", entrySchema.getType().getName());
174 Map<PfConceptKey, JpaToscaDataType> dataTypesConceptMap = serviceTemplate.getDataTypes().getConceptMap();
175 assertTrue(dataTypesConceptMap.size() == 3);
176 Iterator<Entry<PfConceptKey, JpaToscaDataType>> dataTypesIter = dataTypesConceptMap.entrySet().iterator();
178 Entry<PfConceptKey, JpaToscaDataType> firstDataType = dataTypesIter.next();
179 assertEquals("onap.datatypes.monitoring.metricsPerEventName", firstDataType.getKey().getName());
180 JpaToscaDataType firstDataTypeVal = firstDataType.getValue();
181 assertEquals("tosca.datatypes.Root", firstDataTypeVal.getDerivedFrom().getName());
182 assertEquals("0.0.0", firstDataTypeVal.getDerivedFrom().getVersion());
183 assertTrue(firstDataTypeVal.getProperties().size() == 6);
184 Iterator<JpaToscaProperty> firstDataTypePropertiesIter = firstDataTypeVal.getProperties().values().iterator();
186 JpaToscaProperty firstDataTypeFirstProperty = firstDataTypePropertiesIter.next();
187 assertEquals("onap.datatypes.monitoring.metricsPerEventName",
188 firstDataTypeFirstProperty.getKey().getParentKeyName());
189 assertEquals("controlLoopSchemaType", firstDataTypeFirstProperty.getKey().getLocalName());
190 assertEquals("string", firstDataTypeFirstProperty.getType().getName());
191 assertTrue(firstDataTypeFirstProperty.isRequired());
192 assertEquals("Specifies Control Loop Schema Type for the event Name e.g. VNF, VM",
193 firstDataTypeFirstProperty.getDescription());
194 assertTrue(firstDataTypeFirstProperty.getConstraints().size() == 1);
195 assertEquals("org.onap.policy.models.tosca.simple.concepts.JpaToscaConstraintValidValues",
196 firstDataTypeFirstProperty.getConstraints().iterator().next().getClass().getCanonicalName());
197 assertTrue(((JpaToscaConstraintValidValues) (firstDataTypeFirstProperty.getConstraints().iterator().next()))
198 .getValidValues().size() == 2);
200 JpaToscaProperty firstDataTypeSecondProperty = firstDataTypePropertiesIter.next();
201 assertEquals("onap.datatypes.monitoring.metricsPerEventName",
202 firstDataTypeSecondProperty.getKey().getParentKeyName());
203 assertEquals("eventName", firstDataTypeSecondProperty.getKey().getLocalName());
204 assertEquals("string", firstDataTypeSecondProperty.getType().getName());
205 assertTrue(firstDataTypeSecondProperty.isRequired());
206 assertEquals("Event name to which thresholds need to be applied", firstDataTypeSecondProperty.getDescription());
208 JpaToscaProperty firstDataTypeThirdProperty = firstDataTypePropertiesIter.next();
209 assertEquals("onap.datatypes.monitoring.metricsPerEventName",
210 firstDataTypeThirdProperty.getKey().getParentKeyName());
211 assertEquals("policyName", firstDataTypeThirdProperty.getKey().getLocalName());
212 assertEquals("string", firstDataTypeThirdProperty.getType().getName());
213 assertTrue(firstDataTypeThirdProperty.isRequired());
214 assertEquals("TCA Policy Scope Name", firstDataTypeThirdProperty.getDescription());
216 JpaToscaProperty firstDataTypeFourthProperty = firstDataTypePropertiesIter.next();
217 assertEquals("onap.datatypes.monitoring.metricsPerEventName",
218 firstDataTypeFourthProperty.getKey().getParentKeyName());
219 assertEquals("policyScope", firstDataTypeFourthProperty.getKey().getLocalName());
220 assertEquals("string", firstDataTypeFourthProperty.getType().getName());
221 assertTrue(firstDataTypeFourthProperty.isRequired());
222 assertEquals("TCA Policy Scope", firstDataTypeFourthProperty.getDescription());
224 JpaToscaProperty firstDataTypeFifthProperty = firstDataTypePropertiesIter.next();
225 assertEquals("onap.datatypes.monitoring.metricsPerEventName",
226 firstDataTypeFifthProperty.getKey().getParentKeyName());
227 assertEquals("policyVersion", firstDataTypeFifthProperty.getKey().getLocalName());
228 assertEquals("string", firstDataTypeFifthProperty.getType().getName());
229 assertTrue(firstDataTypeFifthProperty.isRequired());
230 assertEquals("TCA Policy Scope Version", firstDataTypeFifthProperty.getDescription());
232 JpaToscaProperty firstDataTypeSixthProperty = firstDataTypePropertiesIter.next();
233 assertEquals("onap.datatypes.monitoring.metricsPerEventName",
234 firstDataTypeSixthProperty.getKey().getParentKeyName());
235 assertEquals("thresholds", firstDataTypeSixthProperty.getKey().getLocalName());
236 assertEquals("list", firstDataTypeSixthProperty.getType().getName());
237 assertTrue(firstDataTypeSixthProperty.isRequired());
238 assertEquals("Thresholds associated with eventName", firstDataTypeSixthProperty.getDescription());
239 assertNotNull(firstDataTypeSixthProperty.getEntrySchema());
240 assertEquals("onap.datatypes.monitoring.thresholds",
241 firstDataTypeSixthProperty.getEntrySchema().getType().getName());
243 Entry<PfConceptKey, JpaToscaDataType> secondDataType = dataTypesIter.next();
244 assertEquals("onap.datatypes.monitoring.tca_policy", secondDataType.getKey().getName());
245 JpaToscaDataType secondDataTypeVal = secondDataType.getValue();
246 assertEquals("tosca.datatypes.Root", secondDataTypeVal.getDerivedFrom().getName());
247 assertEquals("0.0.0", secondDataTypeVal.getDerivedFrom().getVersion());
248 assertTrue(secondDataTypeVal.getProperties().size() == 2);
249 Iterator<JpaToscaProperty> secondDataTypePropertiesIter = secondDataTypeVal.getProperties().values().iterator();
251 JpaToscaProperty secondDataTypeFirstProperty = secondDataTypePropertiesIter.next();
252 assertEquals("onap.datatypes.monitoring.tca_policy", secondDataTypeFirstProperty.getKey().getParentKeyName());
253 assertEquals("domain", secondDataTypeFirstProperty.getKey().getLocalName());
254 assertEquals("string", secondDataTypeFirstProperty.getType().getName());
255 assertTrue(secondDataTypeFirstProperty.isRequired());
256 assertEquals("Domain name to which TCA needs to be applied", secondDataTypeFirstProperty.getDescription());
257 assertEquals("measurementsForVfScaling", secondDataTypeFirstProperty.getDefaultValue());
258 assertTrue(secondDataTypeFirstProperty.getConstraints().size() == 1);
259 assertTrue(secondDataTypeFirstProperty.getConstraints().iterator().next() instanceof JpaToscaConstraintLogical);
260 assertEquals("measurementsForVfScaling",
261 ((JpaToscaConstraintLogical) (secondDataTypeFirstProperty.getConstraints().iterator().next()))
264 JpaToscaProperty secondDataTypeSecondProperty = secondDataTypePropertiesIter.next();
265 assertEquals("onap.datatypes.monitoring.tca_policy", secondDataTypeSecondProperty.getKey().getParentKeyName());
266 assertEquals("metricsPerEventName", secondDataTypeSecondProperty.getKey().getLocalName());
267 assertEquals("list", secondDataTypeSecondProperty.getType().getName());
268 assertTrue(secondDataTypeSecondProperty.isRequired());
269 assertEquals("Contains eventName and threshold details that need to be applied to given eventName",
270 secondDataTypeSecondProperty.getDescription());
271 assertNotNull(secondDataTypeSecondProperty.getEntrySchema());
272 assertEquals("onap.datatypes.monitoring.metricsPerEventName",
273 secondDataTypeSecondProperty.getEntrySchema().getType().getName());
275 Entry<PfConceptKey, JpaToscaDataType> thirdDataType = dataTypesIter.next();
276 assertEquals("onap.datatypes.monitoring.thresholds", thirdDataType.getKey().getName());
277 JpaToscaDataType thirdDataTypeVal = thirdDataType.getValue();
278 assertEquals("tosca.datatypes.Root", thirdDataTypeVal.getDerivedFrom().getName());
279 assertEquals("0.0.0", thirdDataTypeVal.getDerivedFrom().getVersion());
280 assertTrue(thirdDataTypeVal.getProperties().size() == 7);
281 Iterator<JpaToscaProperty> thirdDataTypePropertiesIter = thirdDataTypeVal.getProperties().values().iterator();
283 JpaToscaProperty thirdDataTypeFirstProperty = thirdDataTypePropertiesIter.next();
284 assertEquals("onap.datatypes.monitoring.thresholds", thirdDataTypeFirstProperty.getKey().getParentKeyName());
285 assertEquals("closedLoopControlName", thirdDataTypeFirstProperty.getKey().getLocalName());
286 assertEquals("string", thirdDataTypeFirstProperty.getType().getName());
287 assertTrue(thirdDataTypeFirstProperty.isRequired());
288 assertEquals("Closed Loop Control Name associated with the threshold",
289 thirdDataTypeFirstProperty.getDescription());
291 JpaToscaProperty thirdDataTypeSecondProperty = thirdDataTypePropertiesIter.next();
292 assertEquals("onap.datatypes.monitoring.thresholds", thirdDataTypeSecondProperty.getKey().getParentKeyName());
293 assertEquals("closedLoopEventStatus", thirdDataTypeSecondProperty.getKey().getLocalName());
294 assertEquals("string", thirdDataTypeSecondProperty.getType().getName());
295 assertTrue(thirdDataTypeSecondProperty.isRequired());
296 assertEquals("Closed Loop Event Status of the threshold", thirdDataTypeSecondProperty.getDescription());
297 assertNotNull(thirdDataTypeSecondProperty.getConstraints());
298 assertTrue(thirdDataTypeSecondProperty.getConstraints().size() == 1);
299 assertEquals("JpaToscaConstraintValidValues(validValues=[ONSET, ABATED])",
300 thirdDataTypeSecondProperty.getConstraints().iterator().next().toString());
301 assertTrue(thirdDataTypeSecondProperty.getConstraints().iterator()
302 .next() instanceof JpaToscaConstraintValidValues);
303 assertTrue(((JpaToscaConstraintValidValues) (thirdDataTypeSecondProperty.getConstraints().iterator().next()))
304 .getValidValues().size() == 2);
306 JpaToscaProperty thirdDataTypeThirdProperty = thirdDataTypePropertiesIter.next();
307 assertEquals("onap.datatypes.monitoring.thresholds", thirdDataTypeThirdProperty.getKey().getParentKeyName());
308 assertEquals("direction", thirdDataTypeThirdProperty.getKey().getLocalName());
309 assertEquals("string", thirdDataTypeThirdProperty.getType().getName());
310 assertTrue(thirdDataTypeThirdProperty.isRequired());
311 assertEquals("Direction of the threshold", thirdDataTypeThirdProperty.getDescription());
312 assertNotNull(thirdDataTypeThirdProperty.getConstraints());
313 assertTrue(thirdDataTypeThirdProperty.getConstraints().size() == 1);
315 "JpaToscaConstraintValidValues(validValues=[LESS, LESS_OR_EQUAL, GREATER, GREATER_OR_EQUAL, EQUAL])",
316 thirdDataTypeThirdProperty.getConstraints().iterator().next().toString());
317 assertTrue(((JpaToscaConstraintValidValues) (thirdDataTypeThirdProperty.getConstraints().iterator().next()))
318 .getValidValues().size() == 5);
320 JpaToscaProperty thirdDataTypeFourthProperty = thirdDataTypePropertiesIter.next();
321 assertEquals("onap.datatypes.monitoring.thresholds", thirdDataTypeFourthProperty.getKey().getParentKeyName());
322 assertEquals("fieldPath", thirdDataTypeFourthProperty.getKey().getLocalName());
323 assertEquals("string", thirdDataTypeFourthProperty.getType().getName());
324 assertTrue(thirdDataTypeFourthProperty.isRequired());
325 assertEquals("Json field Path as per CEF message which needs to be analyzed for TCA",
326 thirdDataTypeFourthProperty.getDescription());
327 assertNotNull(thirdDataTypeFourthProperty.getConstraints());
328 assertTrue(thirdDataTypeFourthProperty.getConstraints().size() == 1);
329 assertTrue(((JpaToscaConstraintValidValues) (thirdDataTypeFourthProperty.getConstraints().iterator().next()))
330 .getValidValues().size() == 43);
332 JpaToscaProperty thirdDataTypeFifthProperty = thirdDataTypePropertiesIter.next();
333 assertEquals("onap.datatypes.monitoring.thresholds", thirdDataTypeFifthProperty.getKey().getParentKeyName());
334 assertEquals("severity", thirdDataTypeFifthProperty.getKey().getLocalName());
335 assertEquals("string", thirdDataTypeFifthProperty.getType().getName());
336 assertTrue(thirdDataTypeFifthProperty.isRequired());
337 assertEquals("Threshold Event Severity", thirdDataTypeFifthProperty.getDescription());
338 assertNotNull(thirdDataTypeFifthProperty.getConstraints());
339 assertTrue(thirdDataTypeFifthProperty.getConstraints().size() == 1);
340 assertEquals("JpaToscaConstraintValidValues(validValues=[CRITICAL, MAJOR, MINOR, WARNING, NORMAL])",
341 thirdDataTypeFifthProperty.getConstraints().iterator().next().toString());
342 assertTrue(((JpaToscaConstraintValidValues) (thirdDataTypeFifthProperty.getConstraints().iterator().next()))
343 .getValidValues().size() == 5);;
345 JpaToscaProperty thirdDataTypeSixthProperty = thirdDataTypePropertiesIter.next();
346 assertEquals("onap.datatypes.monitoring.thresholds", thirdDataTypeSixthProperty.getKey().getParentKeyName());
347 assertEquals("thresholdValue", thirdDataTypeSixthProperty.getKey().getLocalName());
348 assertEquals("integer", thirdDataTypeSixthProperty.getType().getName());
349 assertTrue(thirdDataTypeSixthProperty.isRequired());
350 assertEquals("Threshold value for the field Path inside CEF message",
351 thirdDataTypeSixthProperty.getDescription());
353 JpaToscaProperty thirdDataTypeSeventhProperty = thirdDataTypePropertiesIter.next();
354 assertEquals("onap.datatypes.monitoring.thresholds", thirdDataTypeSeventhProperty.getKey().getParentKeyName());
355 assertEquals("version", thirdDataTypeSeventhProperty.getKey().getLocalName());
356 assertEquals("string", thirdDataTypeSeventhProperty.getType().getName());
357 assertTrue(thirdDataTypeSeventhProperty.isRequired());
358 assertEquals("Version number associated with the threshold", thirdDataTypeSeventhProperty.getDescription());
361 private void verifyCollectorInputDeserialization(JpaToscaServiceTemplate serviceTemplate) {
363 // Sanity check the entire structure
364 assertNotNull(serviceTemplate);
365 LOGGER.info(serviceTemplate.validate(new PfValidationResult()).toString());
366 assertTrue(serviceTemplate.validate(new PfValidationResult()).isValid());
368 // Check tosca_definitions_version
369 assertEquals("tosca_simple_yaml_1_0_0", serviceTemplate.getToscaDefinitionsVersion());
371 // Check policy_types
372 Map<PfConceptKey, JpaToscaPolicyType> policyTypesConceptMap = serviceTemplate.getPolicyTypes().getConceptMap();
373 assertTrue(policyTypesConceptMap.size() == 2);
374 Iterator<Entry<PfConceptKey, JpaToscaPolicyType>> policyTypesIter = policyTypesConceptMap.entrySet().iterator();
376 Entry<PfConceptKey, JpaToscaPolicyType> firstPolicyType = policyTypesIter.next();
377 assertEquals("onap.policies.Monitoring", firstPolicyType.getKey().getName());
378 assertEquals("1.0.0", firstPolicyType.getKey().getVersion());
379 assertEquals("tosca.policies.Root", firstPolicyType.getValue().getDerivedFrom().getName());
380 assertEquals("a base policy type for all policies that govern monitoring provision",
381 firstPolicyType.getValue().getDescription());
383 Entry<PfConceptKey, JpaToscaPolicyType> secondPolicyType = policyTypesIter.next();
384 assertEquals("onap.policies.monitoring.dcaegen2.collectors.datafile.datafile-app-server",
385 secondPolicyType.getKey().getName());
386 assertEquals("1.0.0", secondPolicyType.getKey().getVersion());
387 assertEquals("policy.nodes.Root", secondPolicyType.getValue().getDerivedFrom().getName());
388 assertTrue(secondPolicyType.getValue().getProperties().size() == 2);
390 Iterator<JpaToscaProperty> propertiesIter = secondPolicyType.getValue().getProperties().values().iterator();
392 JpaToscaProperty firstProperty = propertiesIter.next();
393 assertEquals("onap.policies.monitoring.dcaegen2.collectors.datafile.datafile-app-server",
394 firstProperty.getKey().getParentKeyName());
395 assertEquals("1.0.0", firstProperty.getKey().getParentKeyVersion());
396 assertEquals("buscontroller_feed_publishing_endpoint", firstProperty.getKey().getLocalName());
397 assertEquals("string", firstProperty.getType().getName());
398 assertEquals("DMAAP Bus Controller feed endpoint", firstProperty.getDescription());
400 JpaToscaProperty secondProperty = propertiesIter.next();
401 assertEquals("onap.policies.monitoring.dcaegen2.collectors.datafile.datafile-app-server",
402 secondProperty.getKey().getParentKeyName());
403 assertEquals("1.0.0", secondProperty.getKey().getParentKeyVersion());
404 assertEquals("datafile.policy", secondProperty.getKey().getLocalName());
405 assertEquals("string", secondProperty.getType().getName());
406 assertEquals("datafile Policy JSON as string", secondProperty.getDescription());
409 private String serializeMonitoringServiceTemplate(JpaToscaServiceTemplate serviceTemplate) throws CoderException {
410 ToscaServiceTemplate toscaServiceTemplate = serviceTemplate.toAuthorative();
411 return coder.encode(toscaServiceTemplate);