Fixed bug on property type name representation

This commit is contained in:
Luca Frosini 2021-01-20 15:53:00 +01:00
parent 72ddb4718a
commit 502ba899f7
2 changed files with 18 additions and 2 deletions

View File

@ -310,9 +310,9 @@ public class PropertyTypeName {
stringBuffer.append(",");
}
if(genericBaseType!=null) {
stringBuffer.append(genericBaseType.toString());
}else {
stringBuffer.append(genericClassName);
}else {
stringBuffer.append(genericBaseType.toString());
}
stringBuffer.append(">");
break;

View File

@ -12,6 +12,7 @@ import org.gcube.informationsystem.base.reference.properties.PropertyElement;
import org.gcube.informationsystem.base.reference.relations.RelationElement;
import org.gcube.informationsystem.types.TypeMapper;
import org.gcube.informationsystem.types.reference.Type;
import org.gcube.informationsystem.types.reference.properties.PropertyDefinition;
import org.gcube.informationsystem.types.reference.properties.PropertyType;
import org.gcube.informationsystem.utils.TypeVersion;
import org.junit.Assert;
@ -131,4 +132,19 @@ public class ISMDiscoveryTest {
ElementSpecilizationDiscovery.manageISM(schemaAction , packages);
}
@Test
public void testTypeDefinition() throws Exception {
Class<? extends Element> clz = PropertyType.class;
Type type = TypeMapper.createTypeDefinition(clz);
Assert.assertTrue(type.getName().compareTo(PropertyType.NAME)==0);
for(PropertyDefinition propertyDefinition : type.getProperties()) {
if(propertyDefinition.getName().compareTo(PropertyType.PROPERTIES_PROPERTY)==0) {
logger.debug("{}", propertyDefinition);
Assert.assertTrue(propertyDefinition.getType().compareTo("Set<PropertyDefinition>")==0);
}
}
String typeDefinitionJsonString = TypeMapper.serializeTypeDefinition(type);
logger.debug(typeDefinitionJsonString);
}
}