2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.sdc.be.datamodel.utils;
23 import static org.junit.jupiter.api.Assertions.assertEquals;
24 import static org.junit.jupiter.api.Assertions.assertTrue;
25 import static org.mockito.ArgumentMatchers.any;
26 import static org.mockito.Mockito.mock;
27 import static org.mockito.Mockito.when;
29 import com.google.gson.Gson;
30 import com.google.gson.GsonBuilder;
31 import com.google.gson.reflect.TypeToken;
32 import fj.data.Either;
33 import java.io.IOException;
34 import java.lang.reflect.Type;
35 import java.nio.file.Files;
36 import java.nio.file.Paths;
37 import java.util.Collections;
38 import java.util.List;
40 import org.junit.jupiter.api.BeforeEach;
41 import org.junit.jupiter.api.Test;
42 import org.mockito.InjectMocks;
43 import org.mockito.Mock;
44 import org.mockito.MockitoAnnotations;
45 import org.mockito.Spy;
46 import org.openecomp.sdc.be.components.impl.ResponseFormatManager;
47 import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
48 import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
49 import org.openecomp.sdc.be.datatypes.elements.SchemaDefinition;
50 import org.openecomp.sdc.be.model.ComponentInstanceProperty;
51 import org.openecomp.sdc.be.model.DataTypeDefinition;
52 import org.openecomp.sdc.be.model.InputDefinition;
53 import org.openecomp.sdc.be.model.PropertyConstraint;
54 import org.openecomp.sdc.be.model.PropertyDefinition;
55 import org.openecomp.sdc.be.model.cache.ApplicationDataTypeCache;
56 import org.openecomp.sdc.be.model.operations.impl.PropertyOperation;
57 import org.openecomp.sdc.exception.ResponseFormat;
59 class PropertyValueConstraintValidationUtilTest {
62 ApplicationDataTypeCache applicationDataTypeCache;
66 PropertyValueConstraintValidationUtil propertyValueConstraintValidationUtil;
68 private Map<String, DataTypeDefinition> dataTypeDefinitionMap;
71 void init() throws IOException {
72 MockitoAnnotations.openMocks(this);
73 ResponseFormatManager responseFormatManagerMock = mock(ResponseFormatManager.class);
74 when(responseFormatManagerMock.getResponseFormat(any())).thenReturn(new ResponseFormat());
75 when(responseFormatManagerMock.getResponseFormat(any(), any())).thenReturn(new ResponseFormat());
76 when(responseFormatManagerMock.getResponseFormat(any(), any(), any())).thenReturn(new ResponseFormat());
77 when(propertyValueConstraintValidationUtil.getResponseFormatManager()).thenReturn(responseFormatManagerMock);
83 void primitiveValueSuccessTest() {
84 Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> either = Either.left(dataTypeDefinitionMap);
85 when(applicationDataTypeCache.getAll(null)).thenReturn(either);
87 PropertyDefinition propertyDefinition = new PropertyDefinition();
88 propertyDefinition.setType("integer");
89 propertyDefinition.setValue("10");
91 Either<Boolean, ResponseFormat> responseEither =
92 propertyValueConstraintValidationUtil.validatePropertyConstraints(
93 Collections.singletonList(propertyDefinition), applicationDataTypeCache, null);
95 assertTrue(responseEither.isLeft());
99 void primitiveValueFailTest() {
100 Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> either = Either.left(dataTypeDefinitionMap);
101 when(applicationDataTypeCache.getAll(null)).thenReturn(either);
103 PropertyDefinition propertyDefinition = new PropertyDefinition();
104 propertyDefinition.setType("integer");
105 propertyDefinition.setValue("abcd");
107 Either<Boolean, ResponseFormat> responseEither = propertyValueConstraintValidationUtil.validatePropertyConstraints(
108 Collections.singletonList(propertyDefinition), applicationDataTypeCache, null);
110 assertTrue(responseEither.isRight());
114 void complexWithValidValueSuccessTest() {
115 Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> either = Either.left(dataTypeDefinitionMap);
116 when(applicationDataTypeCache.getAll(null)).thenReturn(either);
118 PropertyDefinition propertyDefinition = new PropertyDefinition();
119 propertyDefinition.setType("org.openecomp.datatypes.heat.network.neutron.Subnet");
120 propertyDefinition.setValue("{\"prefixlen\":\"4\"}");
122 Either<Boolean, ResponseFormat> responseEither =
123 propertyValueConstraintValidationUtil.validatePropertyConstraints(
124 Collections.singletonList(propertyDefinition), applicationDataTypeCache, null);
126 assertTrue(responseEither.isLeft());
130 void complexWithValidValueFailTest() {
131 Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> either = Either.left(dataTypeDefinitionMap);
132 when(applicationDataTypeCache.getAll(null)).thenReturn(either);
134 PropertyDefinition propertyDefinition = new PropertyDefinition();
135 propertyDefinition.setType("org.openecomp.datatypes.heat.network.neutron.Subnet");
136 propertyDefinition.setValue("{\"prefixlen\":\"5\"}");
138 Either<Boolean, ResponseFormat> responseEither = propertyValueConstraintValidationUtil
139 .validatePropertyConstraints(Collections.singletonList(propertyDefinition), applicationDataTypeCache, null);
141 assertTrue(responseEither.isRight());
145 void complexWithListWithPrimitiveValueSuccessTest() {
146 Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> either = Either.left(dataTypeDefinitionMap);
147 when(applicationDataTypeCache.getAll(null)).thenReturn(either);
149 PropertyDefinition propertyDefinition = new PropertyDefinition();
150 propertyDefinition.setType("org.openecomp.datatypes.heat.network.neutron.Subnet");
151 propertyDefinition.setValue("{\"allocation_pools\":[\"slaac\"]}");
153 Either<Boolean, ResponseFormat> responseEither =
154 propertyValueConstraintValidationUtil.validatePropertyConstraints(
155 Collections.singletonList(propertyDefinition), applicationDataTypeCache, null);
157 assertTrue(responseEither.isLeft());
161 void complexWithListWithPrimitiveValueFailTest() {
162 Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> either = Either.left(dataTypeDefinitionMap);
163 when(applicationDataTypeCache.getAll(null)).thenReturn(either);
165 PropertyDefinition propertyDefinition = new PropertyDefinition();
166 propertyDefinition.setType("org.openecomp.datatypes.heat.network.neutron.Subnet");
167 propertyDefinition.setValue("{\"allocation_pools\":[\"value\"]}");
169 Either<Boolean, ResponseFormat> responseEither =
170 propertyValueConstraintValidationUtil.validatePropertyConstraints(
171 Collections.singletonList(propertyDefinition), applicationDataTypeCache, null);
173 assertTrue(responseEither.isRight());
177 void complexWithMapWithPrimitiveValueSuccessTest() {
178 Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> either = Either.left(dataTypeDefinitionMap);
179 when(applicationDataTypeCache.getAll(null)).thenReturn(either);
181 PropertyDefinition propertyDefinition = new PropertyDefinition();
182 propertyDefinition.setType("org.openecomp.datatypes.heat.network.neutron.Subnet");
183 propertyDefinition.setValue("{\"value_specs\":{\"key\":\"slaac\"}}");
185 Either<Boolean, ResponseFormat> responseEither =
186 propertyValueConstraintValidationUtil.validatePropertyConstraints(
187 Collections.singletonList(propertyDefinition), applicationDataTypeCache, null);
189 assertTrue(responseEither.isLeft());
193 void complexWithMapWithPrimitiveValueFailTest() {
194 Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> either = Either.left(dataTypeDefinitionMap);
195 when(applicationDataTypeCache.getAll(null)).thenReturn(either);
197 PropertyDefinition propertyDefinition = new PropertyDefinition();
198 propertyDefinition.setType("org.openecomp.datatypes.heat.network.neutron.Subnet");
199 propertyDefinition.setValue("{\"value_specs\":{\"key\":\"value\"}}");
201 Either<Boolean, ResponseFormat> responseEither =
202 propertyValueConstraintValidationUtil.validatePropertyConstraints(
203 Collections.singletonList(propertyDefinition), applicationDataTypeCache, null);
205 assertTrue(responseEither.isRight());
209 void inputValidValueSuccessTest() {
210 Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> either = Either.left(dataTypeDefinitionMap);
211 when(applicationDataTypeCache.getAll(null)).thenReturn(either);
213 InputDefinition inputDefinition = new InputDefinition();
214 inputDefinition.setInputPath("propetyName#ipv6_ra_mode");
215 inputDefinition.setDefaultValue("slaac");
216 inputDefinition.setType("string");
217 ComponentInstanceProperty propertyDefinition = new ComponentInstanceProperty();
218 propertyDefinition.setType("org.openecomp.datatypes.heat.network.neutron.Subnet");
219 inputDefinition.setProperties(Collections.singletonList(propertyDefinition));
221 Either<Boolean, ResponseFormat> responseEither =
222 propertyValueConstraintValidationUtil.validatePropertyConstraints(
223 Collections.singletonList(inputDefinition), applicationDataTypeCache, null);
225 assertTrue(responseEither.isLeft());
229 void inputValidValueFailTest() {
230 Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> either = Either.left(dataTypeDefinitionMap);
231 when(applicationDataTypeCache.getAll(null)).thenReturn(either);
233 InputDefinition inputDefinition = new InputDefinition();
234 inputDefinition.setInputPath("propetyName#ipv6_ra_mode");
235 inputDefinition.setDefaultValue("incorrectValue");
236 ComponentInstanceProperty propertyDefinition = new ComponentInstanceProperty();
237 propertyDefinition.setType("org.openecomp.datatypes.heat.network.neutron.Subnet");
238 inputDefinition.setProperties(Collections.singletonList(propertyDefinition));
240 Either<Boolean, ResponseFormat> responseEither =
241 propertyValueConstraintValidationUtil.validatePropertyConstraints(
242 Collections.singletonList(inputDefinition), applicationDataTypeCache, null);
244 assertTrue(responseEither.isRight());
248 void serviceConsumptionValidValueSuccessTest() {
249 Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> either = Either.left(dataTypeDefinitionMap);
250 when(applicationDataTypeCache.getAll(null)).thenReturn(either);
252 PropertyDefinition propertyDefinition = new PropertyDefinition();
253 propertyDefinition.setType("org.openecomp.datatypes.heat.network.neutron.Subnet");
254 propertyDefinition.setValue("{\"ipv6_ra_mode\":\"slaac\"}");
255 propertyDefinition.setName("ipv6_ra_mode");
257 Either<Boolean, ResponseFormat> responseEither =
258 propertyValueConstraintValidationUtil.validatePropertyConstraints(
259 Collections.singletonList(propertyDefinition), applicationDataTypeCache, null);
261 assertTrue(responseEither.isLeft());
265 void listOfComplexSuccessTest() {
266 when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(dataTypeDefinitionMap));
268 final var propertyDefinition = new PropertyDefinition();
269 final String type = "list";
270 propertyDefinition.setType(type);
271 final SchemaDefinition schemaDefinition = new SchemaDefinition();
272 final PropertyDataDefinition schemaProperty = new PropertyDataDefinition();
273 final String schemaType = "org.openecomp.datatypes.heat.network.neutron.Subnet";
274 schemaProperty.setType(schemaType);
275 schemaDefinition.setProperty(schemaProperty);
276 propertyDefinition.setSchema(schemaDefinition);
277 final String value = "[{\"ipv6_address_mode\": \"dhcpv6-stateful\"}, {\"ipv6_address_mode\": \"dhcpv6-stateless\"}]";
278 propertyDefinition.setValue(value);
279 final String name = "listOfComplex";
280 propertyDefinition.setName(name);
282 Either<Boolean, ResponseFormat> responseEither =
283 propertyValueConstraintValidationUtil
284 .validatePropertyConstraints(Collections.singletonList(propertyDefinition), applicationDataTypeCache, null);
286 assertTrue(responseEither.isLeft());
287 //original object values should not be changed
288 assertEquals(name, propertyDefinition.getName());
289 assertEquals(type, propertyDefinition.getType());
290 assertEquals(value, propertyDefinition.getValue());
291 assertEquals(schemaType, propertyDefinition.getSchemaType());
295 void listOfComplexSuccessTest1() {
296 when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(dataTypeDefinitionMap));
298 final var propertyDefinition = new PropertyDefinition();
299 final String type = "list";
300 propertyDefinition.setType(type);
301 final String listSchemaType = "org.openecomp.datatypes.heat.network.neutron.Subnet";
302 final PropertyDataDefinition listSchemaProperty = new PropertyDataDefinition();
303 listSchemaProperty.setType(listSchemaType);
304 final SchemaDefinition listSchemaDefinition = new SchemaDefinition();
305 listSchemaDefinition.setProperty(listSchemaProperty);
306 final PropertyDataDefinition schemaProperty = new PropertyDataDefinition();
307 schemaProperty.setSchema(listSchemaDefinition);
308 final String schemaType = "list";
309 schemaProperty.setType(schemaType);
310 final SchemaDefinition schemaDefinition = new SchemaDefinition();
311 schemaDefinition.setProperty(schemaProperty);
312 propertyDefinition.setSchema(schemaDefinition);
313 final String value = "[[{\"ipv6_address_mode\": \"dhcpv6-stateful\"}, {\"ipv6_address_mode\": \"dhcpv6-stateless\"}], [{\"ipv6_address_mode\": \"dhcpv6-stateful\"}]]";
314 propertyDefinition.setValue(value);
315 final String name = "listOfComplex";
316 propertyDefinition.setName(name);
318 Either<Boolean, ResponseFormat> responseEither =
319 propertyValueConstraintValidationUtil
320 .validatePropertyConstraints(Collections.singletonList(propertyDefinition), applicationDataTypeCache, null);
322 assertTrue(responseEither.isLeft());
323 //original object values should not be changed
324 assertEquals(name, propertyDefinition.getName());
325 assertEquals(type, propertyDefinition.getType());
326 assertEquals(value, propertyDefinition.getValue());
327 assertEquals(schemaType, propertyDefinition.getSchemaType());
331 void mapOfComplexSuccessTest() {
332 when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(dataTypeDefinitionMap));
334 final var propertyDefinition = new PropertyDefinition();
335 final String type = "map";
336 propertyDefinition.setType(type);
337 final SchemaDefinition schemaDefinition = new SchemaDefinition();
338 final PropertyDataDefinition schemaProperty = new PropertyDataDefinition();
339 final String schemaType = "org.openecomp.datatypes.heat.network.neutron.Subnet";
340 schemaProperty.setType(schemaType);
341 schemaDefinition.setProperty(schemaProperty);
342 propertyDefinition.setSchema(schemaDefinition);
343 final String value = "{\"key1\": {\"ipv6_address_mode\": \"dhcpv6-stateful\"}, \"key2\": {\"ipv6_address_mode\": \"dhcpv6-stateless\"}}";
344 propertyDefinition.setValue(value);
345 final String name = "mapOfComplex";
346 propertyDefinition.setName(name);
348 Either<Boolean, ResponseFormat> responseEither =
349 propertyValueConstraintValidationUtil.validatePropertyConstraints(
350 Collections.singletonList(propertyDefinition), applicationDataTypeCache, null);
352 assertTrue(responseEither.isLeft());
353 //original object values should not be changed
354 assertEquals(name, propertyDefinition.getName());
355 assertEquals(type, propertyDefinition.getType());
356 assertEquals(value, propertyDefinition.getValue());
357 assertEquals(schemaType, propertyDefinition.getSchemaType());
361 void serviceConsumptionValidValueFailTest() {
362 Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> either = Either.left(dataTypeDefinitionMap);
363 when(applicationDataTypeCache.getAll(null)).thenReturn(either);
365 PropertyDefinition propertyDefinition = new PropertyDefinition();
366 propertyDefinition.setType("org.openecomp.datatypes.heat.network.neutron.Subnet");
367 propertyDefinition.setValue("{\"ipv6_ra_mode\":\"incorrectValue\"}");
368 propertyDefinition.setName("ipv6_ra_mode");
370 Either<Boolean, ResponseFormat> responseEither =
371 propertyValueConstraintValidationUtil.validatePropertyConstraints(
372 Collections.singletonList(propertyDefinition), applicationDataTypeCache, null);
374 assertTrue(responseEither.isRight());
378 void bandwidthTypeValueSuccessTest(){
379 Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> either = Either.left(dataTypeDefinitionMap);
380 when(applicationDataTypeCache.getAll(null)).thenReturn(either);
382 PropertyDefinition propertyDefinition = new PropertyDefinition();
383 propertyDefinition.setType("onap.datatypes.partner.bandwidth");
384 propertyDefinition.setValue("{\"bandwidth_type\":\"guaranteed\"}");
385 propertyDefinition.setName("bandwidth_type");
387 Either<Boolean, ResponseFormat> responseEither = propertyValueConstraintValidationUtil.validatePropertyConstraints(
388 Collections.singletonList(propertyDefinition), applicationDataTypeCache, null);
389 assertTrue(responseEither.isLeft());
393 void bandwidthTypeValueFailTest(){
394 Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> either = Either.left(dataTypeDefinitionMap);
395 when(applicationDataTypeCache.getAll(null)).thenReturn(either);
397 PropertyDefinition propertyDefinition = new PropertyDefinition();
398 propertyDefinition.setType("onap.datatypes.partner.bandwidth");
399 propertyDefinition.setValue("{\"bandwidth_type\":\"incorrectValue\"}");
400 propertyDefinition.setName("bandwidth_type");
402 Either<Boolean, ResponseFormat> responseEither = propertyValueConstraintValidationUtil.validatePropertyConstraints(
403 Collections.singletonList(propertyDefinition), applicationDataTypeCache, null);
405 assertTrue(responseEither.isRight());
409 void bandwidthDownstreamValueSuccessTest(){
410 Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> either = Either.left(dataTypeDefinitionMap);
411 when(applicationDataTypeCache.getAll(null)).thenReturn(either);
413 PropertyDefinition propertyDefinition = new PropertyDefinition();
414 propertyDefinition.setType("onap.datatypes.partner.bandwidth");
415 propertyDefinition.setValue("{\"downstream\":\"128\"}");
416 propertyDefinition.setName("downstream");
418 Either<Boolean, ResponseFormat> responseEither =
419 propertyValueConstraintValidationUtil.validatePropertyConstraints(
420 Collections.singletonList(propertyDefinition), applicationDataTypeCache, null);
422 assertTrue(responseEither.isLeft());
426 void bandwidthDownstreamValueFailTest(){
427 Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> either = Either.left(dataTypeDefinitionMap);
428 when(applicationDataTypeCache.getAll(null)).thenReturn(either);
430 PropertyDefinition propertyDefinition = new PropertyDefinition();
431 propertyDefinition.setType("onap.datatypes.partner.bandwidth");
432 propertyDefinition.setValue("{\"downstream\":\"incorrectValue\"}");
433 propertyDefinition.setName("downstream");
435 Either<Boolean, ResponseFormat> responseEither =
436 propertyValueConstraintValidationUtil.validatePropertyConstraints(
437 Collections.singletonList(propertyDefinition), applicationDataTypeCache, null);
439 assertTrue(responseEither.isRight());
443 void bandwidthUpstreamValueSuccessTest(){
444 Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> either = Either.left(dataTypeDefinitionMap);
445 when(applicationDataTypeCache.getAll(null)).thenReturn(either);
447 PropertyDefinition propertyDefinition = new PropertyDefinition();
448 propertyDefinition.setType("onap.datatypes.partner.bandwidth");
449 propertyDefinition.setValue("{\"upstream\":\"128\"}");
450 propertyDefinition.setName("upstream");
452 Either<Boolean, ResponseFormat> responseEither =
453 propertyValueConstraintValidationUtil.validatePropertyConstraints(
454 Collections.singletonList(propertyDefinition), applicationDataTypeCache, null);
456 assertTrue(responseEither.isLeft());
460 void bandwidthUpstreamValueFailTest(){
461 Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> either = Either.left(dataTypeDefinitionMap);
462 when(applicationDataTypeCache.getAll(null)).thenReturn(either);
464 PropertyDefinition propertyDefinition = new PropertyDefinition();
465 propertyDefinition.setType("onap.datatypes.partner.bandwidth");
466 propertyDefinition.setValue("{\"upstream\":\"incorrectValue\"}");
467 propertyDefinition.setName("upstream");
469 Either<Boolean, ResponseFormat> responseEither =
470 propertyValueConstraintValidationUtil.validatePropertyConstraints(
471 Collections.singletonList(propertyDefinition), applicationDataTypeCache, null);
473 assertTrue(responseEither.isRight());
477 void bandwidthUnitsValueSuccessTest(){
478 Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> either = Either.left(dataTypeDefinitionMap);
479 when(applicationDataTypeCache.getAll(null)).thenReturn(either);
481 PropertyDefinition propertyDefinition = new PropertyDefinition();
482 propertyDefinition.setType("onap.datatypes.partner.bandwidth");
483 propertyDefinition.setValue("{\"units\":\"M\"}");
484 propertyDefinition.setName("units");
486 Either<Boolean, ResponseFormat> responseEither =
487 propertyValueConstraintValidationUtil.validatePropertyConstraints(
488 Collections.singletonList(propertyDefinition), applicationDataTypeCache, null);
490 assertTrue(responseEither.isLeft());
494 void bandwidthUnitsValueFailTest(){
495 Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> either = Either.left(dataTypeDefinitionMap);
496 when(applicationDataTypeCache.getAll(null)).thenReturn(either);
498 PropertyDefinition propertyDefinition = new PropertyDefinition();
499 propertyDefinition.setType("onap.datatypes.partner.bandwidth");
500 propertyDefinition.setValue("{\"units\":\"incorrectValue\"}");
501 propertyDefinition.setName("units");
503 Either<Boolean, ResponseFormat> responseEither =
504 propertyValueConstraintValidationUtil.validatePropertyConstraints(
505 Collections.singletonList(propertyDefinition), applicationDataTypeCache, null);
507 assertTrue(responseEither.isRight());
510 private void createDataTypeMap() throws IOException {
511 Type constraintType = new TypeToken<PropertyConstraint>() {}.getType();
512 Type typeOfHashMap = new TypeToken<Map<String, DataTypeDefinition>>() { }.getType();
513 Gson gson = new GsonBuilder().registerTypeAdapter(constraintType,
514 new PropertyOperation.PropertyConstraintDeserialiser()).create();
516 dataTypeDefinitionMap = gson.fromJson(readDataTypeDefinitionFile(), typeOfHashMap);
518 DataTypeDefinition dataTypeDefinition = dataTypeDefinitionMap.get("org.openecomp.datatypes.heat.network"
519 + ".neutron.Subnet");
521 PropertyDefinition mapProperty = null;
522 PropertyDefinition listProperty = null;
523 List<PropertyConstraint> constraints = null;
524 for (PropertyDefinition propertyDefinition : dataTypeDefinition.getProperties()) {
525 if ("value_specs".equals(propertyDefinition.getName())) {
526 mapProperty = propertyDefinition;
527 } else if ("allocation_pools".equals(propertyDefinition.getName())) {
528 listProperty = propertyDefinition;
529 } else if ("ipv6_ra_mode".equals(propertyDefinition.getName())) {
530 constraints = propertyDefinition.getConstraints();
534 PropertyDefinition definition = new PropertyDefinition(mapProperty.getSchema().getProperty());
535 definition.setConstraints(constraints);
536 mapProperty.getSchema().setProperty(definition);
538 definition = new PropertyDefinition(listProperty.getSchema().getProperty());
539 definition.setConstraints(constraints);
540 listProperty.getSchema().setProperty(definition);
543 private static String readDataTypeDefinitionFile() throws IOException {
544 return Files.readString(Paths.get("src/test/resources/types/datatypes/constraintTest.json"));