2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2019-2020 Nordix Foundation.
4 * Copyright (C) 2019-2020 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;
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.JpaToscaPolicyType;
44 import org.onap.policy.models.tosca.simple.concepts.JpaToscaProperty;
45 import org.onap.policy.models.tosca.simple.concepts.JpaToscaServiceTemplate;
46 import org.slf4j.Logger;
47 import org.slf4j.LoggerFactory;
48 import org.yaml.snakeyaml.Yaml;
51 * Test serialization of monitoring policy types.
53 * @author Chenfei Gao (cgao@research.att.com)
55 public class MonitoringPolicyTypeSerializationTest {
57 private static final String DATATYPE_ROOT = "tosca.datatypes.Root";
59 private static final String STRING_TEXT = "string";
61 private static final String DCAE = "onap.policies.monitoring.dcaegen2.collectors.datafile.datafile-app-server";
63 private static final String MONITORING = "onap.policies.Monitoring";
65 private static final String THRESHOLDS = "onap.datatypes.monitoring.thresholds";
67 private static final String TCA = "onap.datatypes.monitoring.tca_policy";
69 private static final String METRICS = "onap.datatypes.monitoring.metricsPerEventName";
71 private static final String VERSION_100 = "1.0.0";
73 private static final String VERSION_000 = "0.0.0";
75 private static final Logger LOGGER = LoggerFactory.getLogger(MonitoringPolicyTypeSerializationTest.class);
77 private static final String MONITORING_TCA_YAML = "policytypes/onap.policies.monitoring.cdap.tca.hi.lo.app.yaml";
78 private static final String MONITORING_COLLECTORS_YAML =
79 "policytypes/onap.policies.monitoring.dcaegen2.collectors.datafile.datafile-app-server.yaml";
81 private StandardCoder coder;
85 coder = new StandardCoder();
89 public void testDeserialization() throws Exception {
91 JpaToscaServiceTemplate serviceTemplateFromYaml = deserializeMonitoringInputYaml(MONITORING_TCA_YAML);
92 verifyTcaInputDeserialization(serviceTemplateFromYaml);
95 serviceTemplateFromYaml = deserializeMonitoringInputYaml(MONITORING_COLLECTORS_YAML);
96 verifyCollectorInputDeserialization(serviceTemplateFromYaml);
100 public void testSerialization() throws Exception {
102 JpaToscaServiceTemplate tcaServiceTemplateFromYaml = deserializeMonitoringInputYaml(MONITORING_TCA_YAML);
103 String serializedServiceTemplateTca = serializeMonitoringServiceTemplate(tcaServiceTemplateFromYaml);
105 ToscaServiceTemplate toscaServiceTemplateFromJsonTca =
106 coder.decode(serializedServiceTemplateTca, ToscaServiceTemplate.class);
108 JpaToscaServiceTemplate serviceTemplateFromJsonTca = new JpaToscaServiceTemplate();
109 serviceTemplateFromJsonTca.fromAuthorative(toscaServiceTemplateFromJsonTca);
110 String serializedServiceTemplateTcaOut = serializeMonitoringServiceTemplate(serviceTemplateFromJsonTca);
111 assertEquals(serializedServiceTemplateTca, serializedServiceTemplateTcaOut);
114 JpaToscaServiceTemplate collectorServiceTemplateFromYaml =
115 deserializeMonitoringInputYaml(MONITORING_COLLECTORS_YAML);
116 String serializedServiceTemplateCollector =
117 serializeMonitoringServiceTemplate(collectorServiceTemplateFromYaml);
118 ToscaServiceTemplate toscaServiceTemplateFromJsonCollector =
119 coder.decode(serializedServiceTemplateCollector, ToscaServiceTemplate.class);
120 JpaToscaServiceTemplate serviceTemplateFromJsonCollector = new JpaToscaServiceTemplate();
121 serviceTemplateFromJsonCollector.fromAuthorative(toscaServiceTemplateFromJsonCollector);
122 String serializedServiceTemplateCollectorsOut =
123 serializeMonitoringServiceTemplate(serviceTemplateFromJsonCollector);
124 assertEquals(serializedServiceTemplateCollector, serializedServiceTemplateCollectorsOut);
127 private JpaToscaServiceTemplate deserializeMonitoringInputYaml(String resourcePath) throws Exception {
129 Yaml yaml = new Yaml();
130 String policyTypeYaml = ResourceUtils.getResourceAsString(resourcePath);
131 Object yamlObject = yaml.load(policyTypeYaml);
132 String yamlAsJsonString = coder.encode(yamlObject);
133 ToscaServiceTemplate serviceTemplate = coder.decode(yamlAsJsonString, ToscaServiceTemplate.class);
135 JpaToscaServiceTemplate jpaToscaServiceTemplate = new JpaToscaServiceTemplate();
136 jpaToscaServiceTemplate.fromAuthorative(serviceTemplate);
137 return jpaToscaServiceTemplate;
140 private void verifyTcaInputDeserialization(JpaToscaServiceTemplate serviceTemplate) {
142 // Sanity check the entire structure
143 assertNotNull(serviceTemplate);
144 LOGGER.info(serviceTemplate.validate(new PfValidationResult()).toString());
145 assertTrue(serviceTemplate.validate(new PfValidationResult()).isValid());
147 // Check tosca_definitions_version
148 assertEquals("tosca_simple_yaml_1_1_0", serviceTemplate.getToscaDefinitionsVersion());
150 // Check policy_types
151 Map<PfConceptKey, JpaToscaPolicyType> policyTypesConceptMap = serviceTemplate.getPolicyTypes().getConceptMap();
152 assertTrue(policyTypesConceptMap.size() == 2);
153 Iterator<Entry<PfConceptKey, JpaToscaPolicyType>> policyTypesIter = policyTypesConceptMap.entrySet().iterator();
155 Entry<PfConceptKey, JpaToscaPolicyType> firstPolicyType = policyTypesIter.next();
156 assertEquals(MONITORING, firstPolicyType.getKey().getName());
157 assertEquals(VERSION_100, firstPolicyType.getKey().getVersion());
158 assertEquals("tosca.policies.Root", firstPolicyType.getValue().getDerivedFrom().getName());
159 assertEquals("a base policy type for all policies that govern monitoring provisioning",
160 firstPolicyType.getValue().getDescription());
162 Entry<PfConceptKey, JpaToscaPolicyType> secondPolicyType = policyTypesIter.next();
163 assertEquals("onap.policies.monitoring.cdap.tca.hi.lo.app", secondPolicyType.getKey().getName());
164 assertEquals(VERSION_100, secondPolicyType.getKey().getVersion());
165 assertEquals(MONITORING, secondPolicyType.getValue().getDerivedFrom().getName());
166 assertTrue(secondPolicyType.getValue().getProperties().size() == 1);
168 JpaToscaProperty property = secondPolicyType.getValue().getProperties().values().iterator().next();
169 assertEquals("onap.policies.monitoring.cdap.tca.hi.lo.app", property.getKey().getParentKeyName());
170 assertEquals(VERSION_100, property.getKey().getParentKeyVersion());
171 assertEquals("tca_policy", property.getKey().getLocalName());
172 assertEquals(TCA, property.getType().getName());
173 assertEquals("TCA Policy JSON", property.getDescription());
176 Map<PfConceptKey, JpaToscaDataType> dataTypesConceptMap = serviceTemplate.getDataTypes().getConceptMap();
177 assertTrue(dataTypesConceptMap.size() == 3);
178 Iterator<Entry<PfConceptKey, JpaToscaDataType>> dataTypesIter = dataTypesConceptMap.entrySet().iterator();
180 Entry<PfConceptKey, JpaToscaDataType> firstDataType = dataTypesIter.next();
181 assertEquals(METRICS, firstDataType.getKey().getName());
182 JpaToscaDataType firstDataTypeVal = firstDataType.getValue();
183 assertEquals(DATATYPE_ROOT, firstDataTypeVal.getDerivedFrom().getName());
184 assertEquals(VERSION_000, firstDataTypeVal.getDerivedFrom().getVersion());
185 assertTrue(firstDataTypeVal.getProperties().size() == 6);
186 Iterator<JpaToscaProperty> firstDataTypePropertiesIter = firstDataTypeVal.getProperties().values().iterator();
188 JpaToscaProperty firstDataTypeFirstProperty = firstDataTypePropertiesIter.next();
189 assertEquals(METRICS, firstDataTypeFirstProperty.getKey().getParentKeyName());
190 assertEquals("controlLoopSchemaType", firstDataTypeFirstProperty.getKey().getLocalName());
191 assertEquals(STRING_TEXT, firstDataTypeFirstProperty.getType().getName());
192 assertTrue(firstDataTypeFirstProperty.isRequired());
193 assertEquals("Specifies Control Loop Schema Type for the event Name e.g. VNF, VM",
194 firstDataTypeFirstProperty.getDescription());
195 assertTrue(firstDataTypeFirstProperty.getConstraints().size() == 1);
196 assertEquals("org.onap.policy.models.tosca.simple.concepts.JpaToscaConstraintValidValues",
197 firstDataTypeFirstProperty.getConstraints().iterator().next().getClass().getName());
199 ((JpaToscaConstraintValidValues) (firstDataTypeFirstProperty.getConstraints().iterator().next()))
200 .getValidValues().size());
202 JpaToscaProperty firstDataTypeSecondProperty = firstDataTypePropertiesIter.next();
203 assertEquals(METRICS, firstDataTypeSecondProperty.getKey().getParentKeyName());
204 assertEquals("eventName", firstDataTypeSecondProperty.getKey().getLocalName());
205 assertEquals(STRING_TEXT, firstDataTypeSecondProperty.getType().getName());
206 assertTrue(firstDataTypeSecondProperty.isRequired());
207 assertEquals("Event name to which thresholds need to be applied", firstDataTypeSecondProperty.getDescription());
209 JpaToscaProperty firstDataTypeThirdProperty = firstDataTypePropertiesIter.next();
210 assertEquals(METRICS, firstDataTypeThirdProperty.getKey().getParentKeyName());
211 assertEquals("policyName", firstDataTypeThirdProperty.getKey().getLocalName());
212 assertEquals(STRING_TEXT, firstDataTypeThirdProperty.getType().getName());
213 assertTrue(firstDataTypeThirdProperty.isRequired());
214 assertEquals("TCA Policy Scope Name", firstDataTypeThirdProperty.getDescription());
216 JpaToscaProperty firstDataTypeFourthProperty = firstDataTypePropertiesIter.next();
217 assertEquals(METRICS, firstDataTypeFourthProperty.getKey().getParentKeyName());
218 assertEquals("policyScope", firstDataTypeFourthProperty.getKey().getLocalName());
219 assertEquals(STRING_TEXT, firstDataTypeFourthProperty.getType().getName());
220 assertTrue(firstDataTypeFourthProperty.isRequired());
221 assertEquals("TCA Policy Scope", firstDataTypeFourthProperty.getDescription());
223 JpaToscaProperty firstDataTypeFifthProperty = firstDataTypePropertiesIter.next();
224 assertEquals(METRICS, firstDataTypeFifthProperty.getKey().getParentKeyName());
225 assertEquals("policyVersion", firstDataTypeFifthProperty.getKey().getLocalName());
226 assertEquals(STRING_TEXT, firstDataTypeFifthProperty.getType().getName());
227 assertTrue(firstDataTypeFifthProperty.isRequired());
228 assertEquals("TCA Policy Scope Version", firstDataTypeFifthProperty.getDescription());
230 JpaToscaProperty firstDataTypeSixthProperty = firstDataTypePropertiesIter.next();
231 assertEquals(METRICS, firstDataTypeSixthProperty.getKey().getParentKeyName());
232 assertEquals("thresholds", firstDataTypeSixthProperty.getKey().getLocalName());
233 assertEquals("list", firstDataTypeSixthProperty.getType().getName());
234 assertTrue(firstDataTypeSixthProperty.isRequired());
235 assertEquals("Thresholds associated with eventName", firstDataTypeSixthProperty.getDescription());
236 assertNotNull(firstDataTypeSixthProperty.getEntrySchema());
237 assertEquals(THRESHOLDS, firstDataTypeSixthProperty.getEntrySchema().getType().getName());
239 Entry<PfConceptKey, JpaToscaDataType> secondDataType = dataTypesIter.next();
240 assertEquals(TCA, secondDataType.getKey().getName());
241 JpaToscaDataType secondDataTypeVal = secondDataType.getValue();
242 assertEquals(DATATYPE_ROOT, secondDataTypeVal.getDerivedFrom().getName());
243 assertEquals(VERSION_000, secondDataTypeVal.getDerivedFrom().getVersion());
244 assertTrue(secondDataTypeVal.getProperties().size() == 2);
245 Iterator<JpaToscaProperty> secondDataTypePropertiesIter = secondDataTypeVal.getProperties().values().iterator();
247 JpaToscaProperty secondDataTypeFirstProperty = secondDataTypePropertiesIter.next();
248 assertEquals(TCA, secondDataTypeFirstProperty.getKey().getParentKeyName());
249 assertEquals("domain", secondDataTypeFirstProperty.getKey().getLocalName());
250 assertEquals(STRING_TEXT, secondDataTypeFirstProperty.getType().getName());
251 assertTrue(secondDataTypeFirstProperty.isRequired());
252 assertEquals("Domain name to which TCA needs to be applied", secondDataTypeFirstProperty.getDescription());
253 assertEquals("measurementsForVfScaling", secondDataTypeFirstProperty.getDefaultValue());
254 assertTrue(secondDataTypeFirstProperty.getConstraints().size() == 1);
255 assertTrue(secondDataTypeFirstProperty.getConstraints().iterator().next() instanceof JpaToscaConstraintLogical);
256 assertEquals("measurementsForVfScaling",
257 ((JpaToscaConstraintLogical) (secondDataTypeFirstProperty.getConstraints().iterator().next()))
260 JpaToscaProperty secondDataTypeSecondProperty = secondDataTypePropertiesIter.next();
261 assertEquals(TCA, secondDataTypeSecondProperty.getKey().getParentKeyName());
262 assertEquals("metricsPerEventName", secondDataTypeSecondProperty.getKey().getLocalName());
263 assertEquals("list", secondDataTypeSecondProperty.getType().getName());
264 assertTrue(secondDataTypeSecondProperty.isRequired());
265 assertEquals("Contains eventName and threshold details that need to be applied to given eventName",
266 secondDataTypeSecondProperty.getDescription());
267 assertNotNull(secondDataTypeSecondProperty.getEntrySchema());
268 assertEquals(METRICS, secondDataTypeSecondProperty.getEntrySchema().getType().getName());
270 Entry<PfConceptKey, JpaToscaDataType> thirdDataType = dataTypesIter.next();
271 assertEquals(THRESHOLDS, thirdDataType.getKey().getName());
272 JpaToscaDataType thirdDataTypeVal = thirdDataType.getValue();
273 assertEquals(DATATYPE_ROOT, thirdDataTypeVal.getDerivedFrom().getName());
274 assertEquals(VERSION_000, thirdDataTypeVal.getDerivedFrom().getVersion());
275 assertTrue(thirdDataTypeVal.getProperties().size() == 7);
276 Iterator<JpaToscaProperty> thirdDataTypePropertiesIter = thirdDataTypeVal.getProperties().values().iterator();
278 JpaToscaProperty thirdDataTypeFirstProperty = thirdDataTypePropertiesIter.next();
279 assertEquals(THRESHOLDS, thirdDataTypeFirstProperty.getKey().getParentKeyName());
280 assertEquals("closedLoopControlName", thirdDataTypeFirstProperty.getKey().getLocalName());
281 assertEquals(STRING_TEXT, thirdDataTypeFirstProperty.getType().getName());
282 assertTrue(thirdDataTypeFirstProperty.isRequired());
283 assertEquals("Closed Loop Control Name associated with the threshold",
284 thirdDataTypeFirstProperty.getDescription());
286 JpaToscaProperty thirdDataTypeSecondProperty = thirdDataTypePropertiesIter.next();
287 assertEquals(THRESHOLDS, thirdDataTypeSecondProperty.getKey().getParentKeyName());
288 assertEquals("closedLoopEventStatus", thirdDataTypeSecondProperty.getKey().getLocalName());
289 assertEquals(STRING_TEXT, thirdDataTypeSecondProperty.getType().getName());
290 assertTrue(thirdDataTypeSecondProperty.isRequired());
291 assertEquals("Closed Loop Event Status of the threshold", thirdDataTypeSecondProperty.getDescription());
292 assertNotNull(thirdDataTypeSecondProperty.getConstraints());
293 assertTrue(thirdDataTypeSecondProperty.getConstraints().size() == 1);
294 assertEquals("JpaToscaConstraintValidValues(validValues=[ONSET, ABATED])",
295 thirdDataTypeSecondProperty.getConstraints().iterator().next().toString());
296 assertTrue(thirdDataTypeSecondProperty.getConstraints().iterator()
297 .next() instanceof JpaToscaConstraintValidValues);
298 assertTrue(((JpaToscaConstraintValidValues) (thirdDataTypeSecondProperty.getConstraints().iterator().next()))
299 .getValidValues().size() == 2);
301 JpaToscaProperty thirdDataTypeThirdProperty = thirdDataTypePropertiesIter.next();
302 assertEquals(THRESHOLDS, thirdDataTypeThirdProperty.getKey().getParentKeyName());
303 assertEquals("direction", thirdDataTypeThirdProperty.getKey().getLocalName());
304 assertEquals(STRING_TEXT, thirdDataTypeThirdProperty.getType().getName());
305 assertTrue(thirdDataTypeThirdProperty.isRequired());
306 assertEquals("Direction of the threshold", thirdDataTypeThirdProperty.getDescription());
307 assertNotNull(thirdDataTypeThirdProperty.getConstraints());
308 assertTrue(thirdDataTypeThirdProperty.getConstraints().size() == 1);
310 "JpaToscaConstraintValidValues(validValues=[LESS, LESS_OR_EQUAL, GREATER, GREATER_OR_EQUAL, EQUAL])",
311 thirdDataTypeThirdProperty.getConstraints().iterator().next().toString());
312 assertTrue(((JpaToscaConstraintValidValues) (thirdDataTypeThirdProperty.getConstraints().iterator().next()))
313 .getValidValues().size() == 5);
315 JpaToscaProperty thirdDataTypeFourthProperty = thirdDataTypePropertiesIter.next();
316 assertEquals(THRESHOLDS, thirdDataTypeFourthProperty.getKey().getParentKeyName());
317 assertEquals("fieldPath", thirdDataTypeFourthProperty.getKey().getLocalName());
318 assertEquals(STRING_TEXT, thirdDataTypeFourthProperty.getType().getName());
319 assertTrue(thirdDataTypeFourthProperty.isRequired());
320 assertEquals("Json field Path as per CEF message which needs to be analyzed for TCA",
321 thirdDataTypeFourthProperty.getDescription());
322 assertNotNull(thirdDataTypeFourthProperty.getConstraints());
323 assertTrue(thirdDataTypeFourthProperty.getConstraints().size() == 1);
324 assertTrue(((JpaToscaConstraintValidValues) (thirdDataTypeFourthProperty.getConstraints().iterator().next()))
325 .getValidValues().size() == 43);
327 JpaToscaProperty thirdDataTypeFifthProperty = thirdDataTypePropertiesIter.next();
328 assertEquals(THRESHOLDS, thirdDataTypeFifthProperty.getKey().getParentKeyName());
329 assertEquals("severity", thirdDataTypeFifthProperty.getKey().getLocalName());
330 assertEquals(STRING_TEXT, thirdDataTypeFifthProperty.getType().getName());
331 assertTrue(thirdDataTypeFifthProperty.isRequired());
332 assertEquals("Threshold Event Severity", thirdDataTypeFifthProperty.getDescription());
333 assertNotNull(thirdDataTypeFifthProperty.getConstraints());
334 assertTrue(thirdDataTypeFifthProperty.getConstraints().size() == 1);
335 assertEquals("JpaToscaConstraintValidValues(validValues=[CRITICAL, MAJOR, MINOR, WARNING, NORMAL])",
336 thirdDataTypeFifthProperty.getConstraints().iterator().next().toString());
337 assertTrue(((JpaToscaConstraintValidValues) (thirdDataTypeFifthProperty.getConstraints().iterator().next()))
338 .getValidValues().size() == 5);
341 JpaToscaProperty thirdDataTypeSixthProperty = thirdDataTypePropertiesIter.next();
342 assertEquals(THRESHOLDS, thirdDataTypeSixthProperty.getKey().getParentKeyName());
343 assertEquals("thresholdValue", thirdDataTypeSixthProperty.getKey().getLocalName());
344 assertEquals("integer", thirdDataTypeSixthProperty.getType().getName());
345 assertTrue(thirdDataTypeSixthProperty.isRequired());
346 assertEquals("Threshold value for the field Path inside CEF message",
347 thirdDataTypeSixthProperty.getDescription());
349 JpaToscaProperty thirdDataTypeSeventhProperty = thirdDataTypePropertiesIter.next();
350 assertEquals(THRESHOLDS, thirdDataTypeSeventhProperty.getKey().getParentKeyName());
351 assertEquals("version", thirdDataTypeSeventhProperty.getKey().getLocalName());
352 assertEquals(STRING_TEXT, thirdDataTypeSeventhProperty.getType().getName());
353 assertTrue(thirdDataTypeSeventhProperty.isRequired());
354 assertEquals("Version number associated with the threshold", thirdDataTypeSeventhProperty.getDescription());
357 private void verifyCollectorInputDeserialization(JpaToscaServiceTemplate serviceTemplate) {
359 // Sanity check the entire structure
360 assertNotNull(serviceTemplate);
361 LOGGER.info(serviceTemplate.validate(new PfValidationResult()).toString());
362 assertTrue(serviceTemplate.validate(new PfValidationResult()).isValid());
364 // Check tosca_definitions_version
365 assertEquals("tosca_simple_yaml_1_1_0", serviceTemplate.getToscaDefinitionsVersion());
367 // Check policy_types
368 Map<PfConceptKey, JpaToscaPolicyType> policyTypesConceptMap = serviceTemplate.getPolicyTypes().getConceptMap();
369 assertTrue(policyTypesConceptMap.size() == 2);
370 Iterator<Entry<PfConceptKey, JpaToscaPolicyType>> policyTypesIter = policyTypesConceptMap.entrySet().iterator();
372 Entry<PfConceptKey, JpaToscaPolicyType> firstPolicyType = policyTypesIter.next();
373 assertEquals(MONITORING, firstPolicyType.getKey().getName());
374 assertEquals(VERSION_100, firstPolicyType.getKey().getVersion());
375 assertEquals("tosca.policies.Root", firstPolicyType.getValue().getDerivedFrom().getName());
376 assertEquals("a base policy type for all policies that govern monitoring provisioning",
377 firstPolicyType.getValue().getDescription());
379 Entry<PfConceptKey, JpaToscaPolicyType> secondPolicyType = policyTypesIter.next();
380 assertEquals(DCAE, secondPolicyType.getKey().getName());
381 assertEquals(VERSION_100, secondPolicyType.getKey().getVersion());
382 assertEquals("onap.policies.Monitoring", secondPolicyType.getValue().getDerivedFrom().getName());
383 assertTrue(secondPolicyType.getValue().getProperties().size() == 2);
385 Iterator<JpaToscaProperty> propertiesIter = secondPolicyType.getValue().getProperties().values().iterator();
387 JpaToscaProperty firstProperty = propertiesIter.next();
388 assertEquals(DCAE, firstProperty.getKey().getParentKeyName());
389 assertEquals(VERSION_100, firstProperty.getKey().getParentKeyVersion());
390 assertEquals("buscontroller_feed_publishing_endpoint", firstProperty.getKey().getLocalName());
391 assertEquals(STRING_TEXT, firstProperty.getType().getName());
392 assertEquals("DMAAP Bus Controller feed endpoint", firstProperty.getDescription());
394 JpaToscaProperty secondProperty = propertiesIter.next();
395 assertEquals(DCAE, secondProperty.getKey().getParentKeyName());
396 assertEquals(VERSION_100, secondProperty.getKey().getParentKeyVersion());
397 assertEquals("datafile.policy", secondProperty.getKey().getLocalName());
398 assertEquals(STRING_TEXT, secondProperty.getType().getName());
399 assertEquals("datafile Policy JSON as string", secondProperty.getDescription());
402 private String serializeMonitoringServiceTemplate(JpaToscaServiceTemplate serviceTemplate) throws CoderException {
403 ToscaServiceTemplate toscaServiceTemplate = serviceTemplate.toAuthorative();
404 return coder.encode(toscaServiceTemplate);