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 String DATATYPE_ROOT = "tosca.datatypes.Root";
60 private static final String STRING_TEXT = "string";
62 private static final String DCAE = "onap.policies.monitoring.dcaegen2.collectors.datafile.datafile-app-server";
64 private static final String MONITORING = "onap.policies.Monitoring";
66 private static final String THRESHOLDS = "onap.datatypes.monitoring.thresholds";
68 private static final String TCA = "onap.datatypes.monitoring.tca_policy";
70 private static final String METRICS = "onap.datatypes.monitoring.metricsPerEventName";
72 private static final String VERSION_100 = "1.0.0";
74 private static final String VERSION_000 = "0.0.0";
76 private static final Logger LOGGER = LoggerFactory.getLogger(MonitoringPolicyTypeSerializationTest.class);
78 private static final String MONITORING_TCA_YAML = "policytypes/onap.policies.monitoring.cdap.tca.hi.lo.app.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);
96 serviceTemplateFromYaml = deserializeMonitoringInputYaml(MONITORING_COLLECTORS_YAML);
97 verifyCollectorInputDeserialization(serviceTemplateFromYaml);
101 public void testSerialization() {
104 JpaToscaServiceTemplate tcaServiceTemplateFromYaml = deserializeMonitoringInputYaml(MONITORING_TCA_YAML);
105 String serializedServiceTemplateTca = serializeMonitoringServiceTemplate(tcaServiceTemplateFromYaml);
107 ToscaServiceTemplate toscaServiceTemplateFromJsonTca =
108 coder.decode(serializedServiceTemplateTca, ToscaServiceTemplate.class);
110 JpaToscaServiceTemplate serviceTemplateFromJsonTca = new JpaToscaServiceTemplate();
111 serviceTemplateFromJsonTca.fromAuthorative(toscaServiceTemplateFromJsonTca);
112 String serializedServiceTemplateTcaOut = serializeMonitoringServiceTemplate(serviceTemplateFromJsonTca);
113 assertEquals(serializedServiceTemplateTca, serializedServiceTemplateTcaOut);
116 JpaToscaServiceTemplate collectorServiceTemplateFromYaml =
117 deserializeMonitoringInputYaml(MONITORING_COLLECTORS_YAML);
118 String serializedServiceTemplateCollector =
119 serializeMonitoringServiceTemplate(collectorServiceTemplateFromYaml);
120 ToscaServiceTemplate toscaServiceTemplateFromJsonCollector =
121 coder.decode(serializedServiceTemplateCollector, ToscaServiceTemplate.class);
122 JpaToscaServiceTemplate serviceTemplateFromJsonCollector = new JpaToscaServiceTemplate();
123 serviceTemplateFromJsonCollector.fromAuthorative(toscaServiceTemplateFromJsonCollector);
124 String serializedServiceTemplateCollectorsOut =
125 serializeMonitoringServiceTemplate(serviceTemplateFromJsonCollector);
126 assertEquals(serializedServiceTemplateCollector, serializedServiceTemplateCollectorsOut);
128 } catch (Exception e) {
129 LOGGER.warn("No exception should be thrown", e);
130 fail("No exception should be thrown");
134 private JpaToscaServiceTemplate deserializeMonitoringInputYaml(String resourcePath) throws Exception {
136 Yaml yaml = new Yaml();
137 String policyTypeYaml = ResourceUtils.getResourceAsString(resourcePath);
138 Object yamlObject = yaml.load(policyTypeYaml);
139 String yamlAsJsonString = coder.encode(yamlObject);
140 ToscaServiceTemplate serviceTemplate = coder.decode(yamlAsJsonString, ToscaServiceTemplate.class);
142 JpaToscaServiceTemplate jpaToscaServiceTemplate = new JpaToscaServiceTemplate();
143 jpaToscaServiceTemplate.fromAuthorative(serviceTemplate);
144 return jpaToscaServiceTemplate;
147 private void verifyTcaInputDeserialization(JpaToscaServiceTemplate serviceTemplate) {
149 // Sanity check the entire structure
150 assertNotNull(serviceTemplate);
151 LOGGER.info(serviceTemplate.validate(new PfValidationResult()).toString());
152 assertTrue(serviceTemplate.validate(new PfValidationResult()).isValid());
154 // Check tosca_definitions_version
155 assertEquals("tosca_simple_yaml_1_0_0", serviceTemplate.getToscaDefinitionsVersion());
157 // Check policy_types
158 Map<PfConceptKey, JpaToscaPolicyType> policyTypesConceptMap = serviceTemplate.getPolicyTypes().getConceptMap();
159 assertTrue(policyTypesConceptMap.size() == 2);
160 Iterator<Entry<PfConceptKey, JpaToscaPolicyType>> policyTypesIter = policyTypesConceptMap.entrySet().iterator();
162 Entry<PfConceptKey, JpaToscaPolicyType> firstPolicyType = policyTypesIter.next();
163 assertEquals(MONITORING, firstPolicyType.getKey().getName());
164 assertEquals(VERSION_000, firstPolicyType.getKey().getVersion());
165 assertEquals("tosca.policies.Root", firstPolicyType.getValue().getDerivedFrom().getName());
166 assertEquals("a base policy type for all policies that governs monitoring provisioning",
167 firstPolicyType.getValue().getDescription());
169 Entry<PfConceptKey, JpaToscaPolicyType> secondPolicyType = policyTypesIter.next();
170 assertEquals("onap.policies.monitoring.cdap.tca.hi.lo.app", secondPolicyType.getKey().getName());
171 assertEquals(VERSION_100, secondPolicyType.getKey().getVersion());
172 assertEquals(MONITORING, secondPolicyType.getValue().getDerivedFrom().getName());
173 assertTrue(secondPolicyType.getValue().getProperties().size() == 1);
175 JpaToscaProperty property = secondPolicyType.getValue().getProperties().values().iterator().next();
176 assertEquals("onap.policies.monitoring.cdap.tca.hi.lo.app", property.getKey().getParentKeyName());
177 assertEquals(VERSION_100, property.getKey().getParentKeyVersion());
178 assertEquals("tca_policy", property.getKey().getLocalName());
179 assertEquals("map", property.getType().getName());
180 assertEquals("TCA Policy JSON", property.getDescription());
182 JpaToscaEntrySchema entrySchema = property.getEntrySchema();
183 assertEquals(TCA, entrySchema.getType().getName());
186 Map<PfConceptKey, JpaToscaDataType> dataTypesConceptMap = serviceTemplate.getDataTypes().getConceptMap();
187 assertTrue(dataTypesConceptMap.size() == 3);
188 Iterator<Entry<PfConceptKey, JpaToscaDataType>> dataTypesIter = dataTypesConceptMap.entrySet().iterator();
190 Entry<PfConceptKey, JpaToscaDataType> firstDataType = dataTypesIter.next();
191 assertEquals(METRICS, firstDataType.getKey().getName());
192 JpaToscaDataType firstDataTypeVal = firstDataType.getValue();
193 assertEquals(DATATYPE_ROOT, firstDataTypeVal.getDerivedFrom().getName());
194 assertEquals(VERSION_000, firstDataTypeVal.getDerivedFrom().getVersion());
195 assertTrue(firstDataTypeVal.getProperties().size() == 6);
196 Iterator<JpaToscaProperty> firstDataTypePropertiesIter = firstDataTypeVal.getProperties().values().iterator();
198 JpaToscaProperty firstDataTypeFirstProperty = firstDataTypePropertiesIter.next();
199 assertEquals(METRICS,
200 firstDataTypeFirstProperty.getKey().getParentKeyName());
201 assertEquals("controlLoopSchemaType", firstDataTypeFirstProperty.getKey().getLocalName());
202 assertEquals(STRING_TEXT, firstDataTypeFirstProperty.getType().getName());
203 assertTrue(firstDataTypeFirstProperty.isRequired());
204 assertEquals("Specifies Control Loop Schema Type for the event Name e.g. VNF, VM",
205 firstDataTypeFirstProperty.getDescription());
206 assertTrue(firstDataTypeFirstProperty.getConstraints().size() == 1);
207 assertEquals("org.onap.policy.models.tosca.simple.concepts.JpaToscaConstraintValidValues",
208 firstDataTypeFirstProperty.getConstraints().iterator().next().getClass().getName());
209 assertTrue(((JpaToscaConstraintValidValues) (firstDataTypeFirstProperty.getConstraints().iterator().next()))
210 .getValidValues().size() == 2);
212 JpaToscaProperty firstDataTypeSecondProperty = firstDataTypePropertiesIter.next();
213 assertEquals(METRICS,
214 firstDataTypeSecondProperty.getKey().getParentKeyName());
215 assertEquals("eventName", firstDataTypeSecondProperty.getKey().getLocalName());
216 assertEquals(STRING_TEXT, firstDataTypeSecondProperty.getType().getName());
217 assertTrue(firstDataTypeSecondProperty.isRequired());
218 assertEquals("Event name to which thresholds need to be applied", firstDataTypeSecondProperty.getDescription());
220 JpaToscaProperty firstDataTypeThirdProperty = firstDataTypePropertiesIter.next();
221 assertEquals(METRICS,
222 firstDataTypeThirdProperty.getKey().getParentKeyName());
223 assertEquals("policyName", firstDataTypeThirdProperty.getKey().getLocalName());
224 assertEquals(STRING_TEXT, firstDataTypeThirdProperty.getType().getName());
225 assertTrue(firstDataTypeThirdProperty.isRequired());
226 assertEquals("TCA Policy Scope Name", firstDataTypeThirdProperty.getDescription());
228 JpaToscaProperty firstDataTypeFourthProperty = firstDataTypePropertiesIter.next();
229 assertEquals(METRICS,
230 firstDataTypeFourthProperty.getKey().getParentKeyName());
231 assertEquals("policyScope", firstDataTypeFourthProperty.getKey().getLocalName());
232 assertEquals(STRING_TEXT, firstDataTypeFourthProperty.getType().getName());
233 assertTrue(firstDataTypeFourthProperty.isRequired());
234 assertEquals("TCA Policy Scope", firstDataTypeFourthProperty.getDescription());
236 JpaToscaProperty firstDataTypeFifthProperty = firstDataTypePropertiesIter.next();
237 assertEquals(METRICS,
238 firstDataTypeFifthProperty.getKey().getParentKeyName());
239 assertEquals("policyVersion", firstDataTypeFifthProperty.getKey().getLocalName());
240 assertEquals(STRING_TEXT, firstDataTypeFifthProperty.getType().getName());
241 assertTrue(firstDataTypeFifthProperty.isRequired());
242 assertEquals("TCA Policy Scope Version", firstDataTypeFifthProperty.getDescription());
244 JpaToscaProperty firstDataTypeSixthProperty = firstDataTypePropertiesIter.next();
245 assertEquals(METRICS,
246 firstDataTypeSixthProperty.getKey().getParentKeyName());
247 assertEquals("thresholds", firstDataTypeSixthProperty.getKey().getLocalName());
248 assertEquals("list", firstDataTypeSixthProperty.getType().getName());
249 assertTrue(firstDataTypeSixthProperty.isRequired());
250 assertEquals("Thresholds associated with eventName", firstDataTypeSixthProperty.getDescription());
251 assertNotNull(firstDataTypeSixthProperty.getEntrySchema());
252 assertEquals(THRESHOLDS,
253 firstDataTypeSixthProperty.getEntrySchema().getType().getName());
255 Entry<PfConceptKey, JpaToscaDataType> secondDataType = dataTypesIter.next();
256 assertEquals(TCA, secondDataType.getKey().getName());
257 JpaToscaDataType secondDataTypeVal = secondDataType.getValue();
258 assertEquals(DATATYPE_ROOT, secondDataTypeVal.getDerivedFrom().getName());
259 assertEquals(VERSION_000, secondDataTypeVal.getDerivedFrom().getVersion());
260 assertTrue(secondDataTypeVal.getProperties().size() == 2);
261 Iterator<JpaToscaProperty> secondDataTypePropertiesIter = secondDataTypeVal.getProperties().values().iterator();
263 JpaToscaProperty secondDataTypeFirstProperty = secondDataTypePropertiesIter.next();
264 assertEquals(TCA, 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 assertTrue(secondDataTypeFirstProperty.getConstraints().size() == 1);
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, 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,
285 secondDataTypeSecondProperty.getEntrySchema().getType().getName());
287 Entry<PfConceptKey, JpaToscaDataType> thirdDataType = dataTypesIter.next();
288 assertEquals(THRESHOLDS, thirdDataType.getKey().getName());
289 JpaToscaDataType thirdDataTypeVal = thirdDataType.getValue();
290 assertEquals(DATATYPE_ROOT, thirdDataTypeVal.getDerivedFrom().getName());
291 assertEquals(VERSION_000, thirdDataTypeVal.getDerivedFrom().getVersion());
292 assertTrue(thirdDataTypeVal.getProperties().size() == 7);
293 Iterator<JpaToscaProperty> thirdDataTypePropertiesIter = thirdDataTypeVal.getProperties().values().iterator();
295 JpaToscaProperty thirdDataTypeFirstProperty = thirdDataTypePropertiesIter.next();
296 assertEquals(THRESHOLDS, thirdDataTypeFirstProperty.getKey().getParentKeyName());
297 assertEquals("closedLoopControlName", thirdDataTypeFirstProperty.getKey().getLocalName());
298 assertEquals(STRING_TEXT, thirdDataTypeFirstProperty.getType().getName());
299 assertTrue(thirdDataTypeFirstProperty.isRequired());
300 assertEquals("Closed Loop Control Name associated with the threshold",
301 thirdDataTypeFirstProperty.getDescription());
303 JpaToscaProperty thirdDataTypeSecondProperty = thirdDataTypePropertiesIter.next();
304 assertEquals(THRESHOLDS, thirdDataTypeSecondProperty.getKey().getParentKeyName());
305 assertEquals("closedLoopEventStatus", thirdDataTypeSecondProperty.getKey().getLocalName());
306 assertEquals(STRING_TEXT, thirdDataTypeSecondProperty.getType().getName());
307 assertTrue(thirdDataTypeSecondProperty.isRequired());
308 assertEquals("Closed Loop Event Status of the threshold", thirdDataTypeSecondProperty.getDescription());
309 assertNotNull(thirdDataTypeSecondProperty.getConstraints());
310 assertTrue(thirdDataTypeSecondProperty.getConstraints().size() == 1);
311 assertEquals("JpaToscaConstraintValidValues(validValues=[ONSET, ABATED])",
312 thirdDataTypeSecondProperty.getConstraints().iterator().next().toString());
313 assertTrue(thirdDataTypeSecondProperty.getConstraints().iterator()
314 .next() instanceof JpaToscaConstraintValidValues);
315 assertTrue(((JpaToscaConstraintValidValues) (thirdDataTypeSecondProperty.getConstraints().iterator().next()))
316 .getValidValues().size() == 2);
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 assertTrue(thirdDataTypeThirdProperty.getConstraints().size() == 1);
327 "JpaToscaConstraintValidValues(validValues=[LESS, LESS_OR_EQUAL, GREATER, GREATER_OR_EQUAL, EQUAL])",
328 thirdDataTypeThirdProperty.getConstraints().iterator().next().toString());
329 assertTrue(((JpaToscaConstraintValidValues) (thirdDataTypeThirdProperty.getConstraints().iterator().next()))
330 .getValidValues().size() == 5);
332 JpaToscaProperty thirdDataTypeFourthProperty = thirdDataTypePropertiesIter.next();
333 assertEquals(THRESHOLDS, thirdDataTypeFourthProperty.getKey().getParentKeyName());
334 assertEquals("fieldPath", thirdDataTypeFourthProperty.getKey().getLocalName());
335 assertEquals(STRING_TEXT, thirdDataTypeFourthProperty.getType().getName());
336 assertTrue(thirdDataTypeFourthProperty.isRequired());
337 assertEquals("Json field Path as per CEF message which needs to be analyzed for TCA",
338 thirdDataTypeFourthProperty.getDescription());
339 assertNotNull(thirdDataTypeFourthProperty.getConstraints());
340 assertTrue(thirdDataTypeFourthProperty.getConstraints().size() == 1);
341 assertTrue(((JpaToscaConstraintValidValues) (thirdDataTypeFourthProperty.getConstraints().iterator().next()))
342 .getValidValues().size() == 43);
344 JpaToscaProperty thirdDataTypeFifthProperty = thirdDataTypePropertiesIter.next();
345 assertEquals(THRESHOLDS, thirdDataTypeFifthProperty.getKey().getParentKeyName());
346 assertEquals("severity", thirdDataTypeFifthProperty.getKey().getLocalName());
347 assertEquals(STRING_TEXT, thirdDataTypeFifthProperty.getType().getName());
348 assertTrue(thirdDataTypeFifthProperty.isRequired());
349 assertEquals("Threshold Event Severity", thirdDataTypeFifthProperty.getDescription());
350 assertNotNull(thirdDataTypeFifthProperty.getConstraints());
351 assertTrue(thirdDataTypeFifthProperty.getConstraints().size() == 1);
352 assertEquals("JpaToscaConstraintValidValues(validValues=[CRITICAL, MAJOR, MINOR, WARNING, NORMAL])",
353 thirdDataTypeFifthProperty.getConstraints().iterator().next().toString());
354 assertTrue(((JpaToscaConstraintValidValues) (thirdDataTypeFifthProperty.getConstraints().iterator().next()))
355 .getValidValues().size() == 5);;
357 JpaToscaProperty thirdDataTypeSixthProperty = thirdDataTypePropertiesIter.next();
358 assertEquals(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",
363 thirdDataTypeSixthProperty.getDescription());
365 JpaToscaProperty thirdDataTypeSeventhProperty = thirdDataTypePropertiesIter.next();
366 assertEquals(THRESHOLDS, thirdDataTypeSeventhProperty.getKey().getParentKeyName());
367 assertEquals("version", thirdDataTypeSeventhProperty.getKey().getLocalName());
368 assertEquals(STRING_TEXT, thirdDataTypeSeventhProperty.getType().getName());
369 assertTrue(thirdDataTypeSeventhProperty.isRequired());
370 assertEquals("Version number associated with the threshold", thirdDataTypeSeventhProperty.getDescription());
373 private void verifyCollectorInputDeserialization(JpaToscaServiceTemplate 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, JpaToscaPolicyType> policyTypesConceptMap = serviceTemplate.getPolicyTypes().getConceptMap();
385 assertTrue(policyTypesConceptMap.size() == 2);
386 Iterator<Entry<PfConceptKey, JpaToscaPolicyType>> policyTypesIter = policyTypesConceptMap.entrySet().iterator();
388 Entry<PfConceptKey, JpaToscaPolicyType> firstPolicyType = policyTypesIter.next();
389 assertEquals(MONITORING, firstPolicyType.getKey().getName());
390 assertEquals(VERSION_100, 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, JpaToscaPolicyType> secondPolicyType = policyTypesIter.next();
397 secondPolicyType.getKey().getName());
398 assertEquals(VERSION_100, secondPolicyType.getKey().getVersion());
399 assertEquals("policy.nodes.Root", secondPolicyType.getValue().getDerivedFrom().getName());
400 assertTrue(secondPolicyType.getValue().getProperties().size() == 2);
402 Iterator<JpaToscaProperty> propertiesIter = secondPolicyType.getValue().getProperties().values().iterator();
404 JpaToscaProperty firstProperty = propertiesIter.next();
406 firstProperty.getKey().getParentKeyName());
407 assertEquals(VERSION_100, firstProperty.getKey().getParentKeyVersion());
408 assertEquals("buscontroller_feed_publishing_endpoint", firstProperty.getKey().getLocalName());
409 assertEquals(STRING_TEXT, firstProperty.getType().getName());
410 assertEquals("DMAAP Bus Controller feed endpoint", firstProperty.getDescription());
412 JpaToscaProperty secondProperty = propertiesIter.next();
414 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);