package org.openecomp.sdc.be.datatypes.elements;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
-
-import java.util.List;
-
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;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.util.List;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
+import org.openecomp.sdc.be.datatypes.tosca.ToscaGetFunctionType;
-public class PropertyDataDefinitionTest {
+class PropertyDataDefinitionTest {
private PropertyDataDefinition propDef;
- @Before
+ @BeforeEach
public void setUp() {
propDef = new PropertyDataDefinition();
}
@Test
- public void setStringField() {
+ void setStringField() {
final String name = "name";
assertNull(propDef.getName());
assertNull(propDef.getToscaPresentationValue(JsonPresentationFields.NAME));
}
@Test
- public void setDefaultValue() {
+ void setDefaultValue() {
final String defaultValue = "text";
assertNull(propDef.getDefaultValue());
assertNull(propDef.getToscaPresentationValue(JsonPresentationFields.DEFAULT_VALUE));
}
@Test
- public void setValueNotDefinedInPropDataDefinition() {
+ void setValueNotDefinedInPropDataDefinition() {
final String defaultValue = "VF";
assertNull(propDef.getToscaPresentationValue(JsonPresentationFields.COMPONENT_TYPE));
propDef.setToscaPresentationValue(JsonPresentationFields.COMPONENT_TYPE, defaultValue);
}
@Test
- public void setBooleanField() {
+ void setBooleanField() {
assertFalse((Boolean) propDef.getToscaPresentationValue(JsonPresentationFields.PASSWORD));
assertFalse(propDef.isPassword());
propDef.setToscaPresentationValue(JsonPresentationFields.PASSWORD, Boolean.TRUE);
}
@Test
- public void mergeDefaultValueWhenItWasNullBeforeMerge() {
+ void mergeDefaultValueWhenItWasNullBeforeMerge() {
final String defaultValue = "12345";
final String type = "1";
PropertyDataDefinition propForMerge = new PropertyDataDefinition();
}
@Test
- public void mergeDefaultValueAndOverrideIt() {
+ void mergeDefaultValueAndOverrideIt() {
final String defaultValue = "12345";
final String defaultValueForOther = "7890";
final String type = "1";
}
@Test
- public void mergeDefaultValueWhenOverridingIsNotAllowed() {
+ void mergeDefaultValueWhenOverridingIsNotAllowed() {
final String defaultValue = "12345";
final String defaultValueForOther = "7890";
final String type = "1";
}
@Test
- public void testConstructor() throws Exception {
+ void testConstructor() {
PropertyDataDefinition testSubject;
String result;
}
@Test
- public void testGetInputPath() throws Exception {
+ void testGetInputPath() {
PropertyDataDefinition testSubject;
String result;
@Test
- public void testSetInputPath() throws Exception {
+ void testSetInputPath() {
PropertyDataDefinition testSubject;
String inputPath = "";
@Test
- public void testGetName() throws Exception {
+ void testGetName() {
PropertyDataDefinition testSubject;
String result;
@Test
- public void testSetName() throws Exception {
+ void testSetName() {
PropertyDataDefinition testSubject;
String name = "";
@Test
- public void testGetValue() throws Exception {
+ void testGetValue() {
PropertyDataDefinition testSubject;
String result;
@Test
- public void testSetValue() throws Exception {
+ void testSetValue() {
PropertyDataDefinition testSubject;
String value = "";
@Test
- public void testIsDefinition() throws Exception {
+ void testIsDefinition() {
PropertyDataDefinition testSubject;
boolean result;
@Test
- public void testSetDefinition() throws Exception {
+ void testSetDefinition() {
PropertyDataDefinition testSubject;
boolean definition = false;
@Test
- public void testGetType() throws Exception {
+ void testGetType() {
PropertyDataDefinition testSubject;
String result;
@Test
- public void testGetDefaultValue() throws Exception {
+ void testGetDefaultValue() {
PropertyDataDefinition testSubject;
String result;
@Test
- public void testSetDefaultValue() throws Exception {
+ void testSetDefaultValue() {
PropertyDataDefinition testSubject;
String defaultValue = "";
@Test
- public void testSetType() throws Exception {
+ void testSetType() {
PropertyDataDefinition testSubject;
String type = "";
@Test
- public void testIsRequired() throws Exception {
+ void testIsRequired() {
PropertyDataDefinition testSubject;
Boolean result;
@Test
- public void testSetRequired() throws Exception {
+ void testSetRequired() {
PropertyDataDefinition testSubject;
Boolean required = null;
@Test
- public void testGetDescription() throws Exception {
+ void testGetDescription() {
PropertyDataDefinition testSubject;
String result;
@Test
- public void testSetDescription() throws Exception {
+ void testSetDescription() {
PropertyDataDefinition testSubject;
String description = "";
@Test
- public void testIsPassword() throws Exception {
+ void testIsPassword() {
PropertyDataDefinition testSubject;
boolean result;
@Test
- public void testSetPassword() throws Exception {
+ void testSetPassword() {
PropertyDataDefinition testSubject;
boolean password = false;
@Test
- public void testGetUniqueId() throws Exception {
+ void testGetUniqueId() {
PropertyDataDefinition testSubject;
String result;
@Test
- public void testSetUniqueId() throws Exception {
+ void testSetUniqueId() {
PropertyDataDefinition testSubject;
String uniqueId = "";
@Test
- public void testGetSchema() throws Exception {
+ void testGetSchema() {
PropertyDataDefinition testSubject;
SchemaDefinition result;
@Test
- public void testSetSchema() throws Exception {
+ void testSetSchema() {
PropertyDataDefinition testSubject;
SchemaDefinition entrySchema = null;
@Test
- public void testGetLabel() throws Exception {
+ void testGetLabel() {
PropertyDataDefinition testSubject;
String result;
@Test
- public void testSetLabel() throws Exception {
+ void testSetLabel() {
PropertyDataDefinition testSubject;
String label = "";
@Test
- public void testIsHidden() throws Exception {
+ void testIsHidden() {
PropertyDataDefinition testSubject;
Boolean result;
@Test
- public void testSetHidden() throws Exception {
+ void testSetHidden() {
PropertyDataDefinition testSubject;
Boolean hidden = null;
@Test
- public void testIsImmutable() throws Exception {
+ void testIsImmutable() {
PropertyDataDefinition testSubject;
Boolean result;
@Test
- public void testSetImmutable() throws Exception {
+ void testSetImmutable() {
PropertyDataDefinition testSubject;
Boolean immutable = null;
@Test
- public void testGetParentUniqueId() throws Exception {
+ void testGetParentUniqueId() {
PropertyDataDefinition testSubject;
String result;
@Test
- public void testSetParentUniqueId() throws Exception {
+ void testSetParentUniqueId() {
PropertyDataDefinition testSubject;
String parentUniqueId = "";
@Test
- public void testGetGetInputValues() throws Exception {
+ void testGetGetInputValues() {
PropertyDataDefinition testSubject;
List<GetInputValueDataDefinition> result;
@Test
- public void testSetGetInputValues() throws Exception {
+ void testSetGetInputValues() {
PropertyDataDefinition testSubject;
List<GetInputValueDataDefinition> getInputValues = null;
@Test
- public void testGetStatus() throws Exception {
+ void testGetStatus() {
PropertyDataDefinition testSubject;
String result;
@Test
- public void testSetStatus() throws Exception {
+ void testSetStatus() {
PropertyDataDefinition testSubject;
String status = "";
@Test
- public void testGetInputId() throws Exception {
+ void testGetInputId() {
PropertyDataDefinition testSubject;
String result;
@Test
- public void testSetInputId() throws Exception {
+ void testSetInputId() {
PropertyDataDefinition testSubject;
String inputId = "";
@Test
- public void testGetInstanceUniqueId() throws Exception {
+ void testGetInstanceUniqueId() {
PropertyDataDefinition testSubject;
String result;
@Test
- public void testSetInstanceUniqueId() throws Exception {
+ void testSetInstanceUniqueId() {
PropertyDataDefinition testSubject;
String instanceUniqueId = "";
@Test
- public void testGetPropertyId() throws Exception {
+ void testGetPropertyId() {
PropertyDataDefinition testSubject;
String result;
@Test
- public void testSetPropertyId() throws Exception {
+ void testSetPropertyId() {
PropertyDataDefinition testSubject;
String propertyId = "";
@Test
- public void testToString() throws Exception {
+ void testToString() {
PropertyDataDefinition testSubject;
String result;
@Test
- public void testHashCode() throws Exception {
+ void testHashCode() {
PropertyDataDefinition testSubject;
int result;
@Test
- public void testEquals() throws Exception {
+ void testEquals() {
PropertyDataDefinition testSubject;
Object obj = null;
boolean result;
testSubject = createTestSubject();
obj = null;
result = testSubject.equals(obj);
- Assert.assertEquals(false, result);
+ assertEquals(false, result);
result = testSubject.equals(testSubject);
- Assert.assertEquals(true, result);
+ assertEquals(true, result);
PropertyDataDefinition other = createTestSubject();
result = testSubject.equals(other);
- Assert.assertEquals(true, result);
+ assertEquals(true, result);
}
@Test
- public void testConvertPropertyDataToInstancePropertyData() throws Exception {
+ void testConvertPropertyDataToInstancePropertyData() {
PropertyDataDefinition testSubject;
// default test
}
@Test
- public void testTypeEquals() throws Exception {
+ void testTypeEquals() {
PropertyDataDefinition testSubject;
// default test
}
@Test
- public void testMergeFunction() throws Exception {
+ void testMergeFunction() {
PropertyDataDefinition testSubject;
// default test
}
@Test
- public void schemaTypeNullWhenSchemaIsNull() {
+ void schemaTypeNullWhenSchemaIsNull() {
String sampleSchemaType = "sampleSchemaType";
PropertyDataDefinition testSubject = createTestSubject();
testSubject.setSchemaType(sampleSchemaType);
}
@Test
- public void schemaTypeIsReturnedWhenSchemaisPresent() {
+ void schemaTypeIsReturnedWhenSchemaIsPresent() {
String sampleSchemaType = "sampleSchemaType";
SchemaDefinition schemaDefinition = new SchemaDefinition();
schemaDefinition.setProperty(new PropertyDataDefinition());
assertThat(testSubject.getSchemaType(), is(equalTo(sampleSchemaType)));
}
+
+ @Test
+ void getToscaGetFunctionTypeTest() {
+ var propertyDataDefinition = new PropertyDataDefinition();
+ assertNull(propertyDataDefinition.getToscaGetFunctionType());
+
+ final var toscaGetFunction = new ToscaGetFunctionDataDefinition();
+ propertyDataDefinition.setToscaFunction(toscaGetFunction);
+
+ toscaGetFunction.setFunctionType(ToscaGetFunctionType.GET_INPUT);
+ assertEquals(ToscaGetFunctionType.GET_INPUT, propertyDataDefinition.getToscaGetFunctionType());
+
+ toscaGetFunction.setFunctionType(ToscaGetFunctionType.GET_PROPERTY);
+ assertEquals(ToscaGetFunctionType.GET_PROPERTY, propertyDataDefinition.getToscaGetFunctionType());
+
+ toscaGetFunction.setFunctionType(ToscaGetFunctionType.GET_ATTRIBUTE);
+ assertEquals(ToscaGetFunctionType.GET_ATTRIBUTE, propertyDataDefinition.getToscaGetFunctionType());
+
+ propertyDataDefinition = new PropertyDataDefinition();
+ propertyDataDefinition.setToscaGetFunctionType(ToscaGetFunctionType.GET_INPUT);
+ assertEquals(ToscaGetFunctionType.GET_INPUT, propertyDataDefinition.getToscaGetFunctionType());
+
+ propertyDataDefinition.setToscaGetFunctionType(ToscaGetFunctionType.GET_PROPERTY);
+ assertEquals(ToscaGetFunctionType.GET_PROPERTY, propertyDataDefinition.getToscaGetFunctionType());
+
+ propertyDataDefinition.setToscaGetFunctionType(ToscaGetFunctionType.GET_ATTRIBUTE);
+ assertEquals(ToscaGetFunctionType.GET_ATTRIBUTE, propertyDataDefinition.getToscaGetFunctionType());
+ }
+
+ @Test
+ void isToscaFunctionTest() {
+ var propertyDataDefinition = new PropertyDataDefinition();
+ assertFalse(propertyDataDefinition.isToscaFunction());
+
+ propertyDataDefinition.setToscaGetFunctionType(ToscaGetFunctionType.GET_PROPERTY);
+ assertTrue(propertyDataDefinition.isToscaFunction());
+
+ propertyDataDefinition = new PropertyDataDefinition();
+ propertyDataDefinition.setToscaFunction(new ToscaConcatFunction());
+ assertTrue(propertyDataDefinition.isToscaFunction());
+ }
+
+ @Test
+ void isToscaGetFunctionTest() {
+ var propertyDataDefinition = new PropertyDataDefinition();
+ propertyDataDefinition.setToscaGetFunctionType(ToscaGetFunctionType.GET_PROPERTY);
+ assertTrue(propertyDataDefinition.isToscaGetFunction());
+
+ propertyDataDefinition = new PropertyDataDefinition();
+ final ToscaGetFunctionDataDefinition toscaGetFunction = new ToscaGetFunctionDataDefinition();
+ toscaGetFunction.setFunctionType(ToscaGetFunctionType.GET_INPUT);
+ propertyDataDefinition.setToscaFunction(toscaGetFunction);
+ assertTrue(propertyDataDefinition.isToscaGetFunction());
+
+ propertyDataDefinition.setToscaFunction(new ToscaConcatFunction());
+ assertFalse(propertyDataDefinition.isToscaGetFunction());
+ }
+
}