+ void listOfComplexSuccessTest() {
+ when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(dataTypeDefinitionMap));
+
+ final var propertyDefinition = new PropertyDefinition();
+ final String type = "list";
+ propertyDefinition.setType(type);
+ final SchemaDefinition schemaDefinition = new SchemaDefinition();
+ final PropertyDataDefinition schemaProperty = new PropertyDataDefinition();
+ final String schemaType = "org.openecomp.datatypes.heat.network.neutron.Subnet";
+ schemaProperty.setType(schemaType);
+ schemaDefinition.setProperty(schemaProperty);
+ propertyDefinition.setSchema(schemaDefinition);
+ final String value = "[{\"ipv6_address_mode\": \"dhcpv6-stateful\"}, {\"ipv6_address_mode\": \"dhcpv6-stateless\"}]";
+ propertyDefinition.setValue(value);
+ final String name = "listOfComplex";
+ propertyDefinition.setName(name);
+
+ Either<Boolean, ResponseFormat> responseEither =
+ propertyValueConstraintValidationUtil
+ .validatePropertyConstraints(Collections.singletonList(propertyDefinition), applicationDataTypeCache, null);
+
+ assertTrue(responseEither.isLeft());
+ //original object values should not be changed
+ assertEquals(name, propertyDefinition.getName());
+ assertEquals(type, propertyDefinition.getType());
+ assertEquals(value, propertyDefinition.getValue());
+ assertEquals(schemaType, propertyDefinition.getSchemaType());
+ }
+
+ @Test
+ void listOfComplexSuccessTest1() {
+ when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(dataTypeDefinitionMap));
+
+ final var propertyDefinition = new PropertyDefinition();
+ final String type = "list";
+ propertyDefinition.setType(type);
+ final String listSchemaType = "org.openecomp.datatypes.heat.network.neutron.Subnet";
+ final PropertyDataDefinition listSchemaProperty = new PropertyDataDefinition();
+ listSchemaProperty.setType(listSchemaType);
+ final SchemaDefinition listSchemaDefinition = new SchemaDefinition();
+ listSchemaDefinition.setProperty(listSchemaProperty);
+ final PropertyDataDefinition schemaProperty = new PropertyDataDefinition();
+ schemaProperty.setSchema(listSchemaDefinition);
+ final String schemaType = "list";
+ schemaProperty.setType(schemaType);
+ final SchemaDefinition schemaDefinition = new SchemaDefinition();
+ schemaDefinition.setProperty(schemaProperty);
+ propertyDefinition.setSchema(schemaDefinition);
+ final String value = "[[{\"ipv6_address_mode\": \"dhcpv6-stateful\"}, {\"ipv6_address_mode\": \"dhcpv6-stateless\"}], [{\"ipv6_address_mode\": \"dhcpv6-stateful\"}]]";
+ propertyDefinition.setValue(value);
+ final String name = "listOfComplex";
+ propertyDefinition.setName(name);
+
+ Either<Boolean, ResponseFormat> responseEither =
+ propertyValueConstraintValidationUtil
+ .validatePropertyConstraints(Collections.singletonList(propertyDefinition), applicationDataTypeCache, null);
+
+ assertTrue(responseEither.isLeft());
+ //original object values should not be changed
+ assertEquals(name, propertyDefinition.getName());
+ assertEquals(type, propertyDefinition.getType());
+ assertEquals(value, propertyDefinition.getValue());
+ assertEquals(schemaType, propertyDefinition.getSchemaType());
+ }
+
+ @Test
+ void mapOfComplexSuccessTest() {
+ when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(dataTypeDefinitionMap));
+
+ final var propertyDefinition = new PropertyDefinition();
+ final String type = "map";
+ propertyDefinition.setType(type);
+ final SchemaDefinition schemaDefinition = new SchemaDefinition();
+ final PropertyDataDefinition schemaProperty = new PropertyDataDefinition();
+ final String schemaType = "org.openecomp.datatypes.heat.network.neutron.Subnet";
+ schemaProperty.setType(schemaType);
+ schemaDefinition.setProperty(schemaProperty);
+ propertyDefinition.setSchema(schemaDefinition);
+ final String value = "{\"key1\": {\"ipv6_address_mode\": \"dhcpv6-stateful\"}, \"key2\": {\"ipv6_address_mode\": \"dhcpv6-stateless\"}}";
+ propertyDefinition.setValue(value);
+ final String name = "mapOfComplex";
+ propertyDefinition.setName(name);
+
+ Either<Boolean, ResponseFormat> responseEither =
+ propertyValueConstraintValidationUtil.validatePropertyConstraints(
+ Collections.singletonList(propertyDefinition), applicationDataTypeCache, null);
+
+ assertTrue(responseEither.isLeft());
+ //original object values should not be changed
+ assertEquals(name, propertyDefinition.getName());
+ assertEquals(type, propertyDefinition.getType());
+ assertEquals(value, propertyDefinition.getValue());
+ assertEquals(schemaType, propertyDefinition.getSchemaType());
+ }
+
+ @Test
+ void serviceConsumptionValidValueFailTest() {