Can't set property for VF 73/91673/2
authorPiotr Darosz <piotr.darosz@nokia.com>
Thu, 18 Jul 2019 12:28:46 +0000 (14:28 +0200)
committerOfir Sonsino <ofir.sonsino@intl.att.com>
Sun, 21 Jul 2019 11:50:47 +0000 (11:50 +0000)
Can't set property for VF due to missing setter for schemaType property

Change-Id: I829a3c81586280b91634fa03f3a023b1452bcdda
Issue-ID: SDC-2420
Signed-off-by: Piotr Darosz <piotr.darosz@nokia.com>
common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/PropertyDataDefinition.java
common-be/src/test/java/org/openecomp/sdc/be/datatypes/elements/PropertyDataDefinitionTest.java

index 218b648..e59d9a6 100644 (file)
@@ -221,6 +221,12 @@ public class PropertyDataDefinition extends ToscaDataDefinition {
                return schema;
        }
 
+       public void setSchemaType(String schemaType) {
+               if (schema != null && schema.getProperty() != null) {
+                       schema.getProperty().setType(schemaType);
+               }
+       }
+
        public void setSchema(SchemaDefinition entrySchema) {
                this.schema = entrySchema;
        }
index 95fe656..899022e 100644 (file)
@@ -27,7 +27,13 @@ import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
 
 import java.util.List;
 
-import static org.junit.Assert.*;
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
 
 
 public class PropertyDataDefinitionTest {
@@ -650,4 +656,25 @@ public class PropertyDataDefinitionTest {
                testSubject.mergeFunction(createTestSubject(), false);
 
        }
+
+       @Test
+       public void schemaTypeNullWhenSchemaIsNull() {
+               String sampleSchemaType = "sampleSchemaType";
+               PropertyDataDefinition testSubject = createTestSubject();
+               testSubject.setSchemaType(sampleSchemaType);
+               assertNull(testSubject.getSchemaType());
+       }
+
+       @Test
+       public void schemaTypeIsReturnedWhenSchemaisPresent() {
+               String sampleSchemaType = "sampleSchemaType";
+               SchemaDefinition schemaDefinition = new SchemaDefinition();
+               schemaDefinition.setProperty(new PropertyDataDefinition());
+
+               PropertyDataDefinition testSubject = createTestSubject();
+               testSubject.setSchema(schemaDefinition);
+               testSubject.setSchemaType(sampleSchemaType);
+
+               assertThat(testSubject.getSchemaType(), is(equalTo(sampleSchemaType)));
+       }
 }