@Test public void mapRelationshipDefinition() { String typeName = "org.example.model.TargetEntity"; importUtils.addType(MapProperty.class.getName()); importUtils.addType(typeName); ObjAttribute attribute = mock(ObjAttribute.class); when(attribute.getType()).thenReturn(String.class.getName()); ObjEntity entity = mock(ObjEntity.class); when(entity.getClassName()).thenReturn(typeName); when(entity.getName()).thenReturn("target"); when(entity.getAttribute(anyString())).thenReturn(attribute); ObjRelationship relationship = mock(ObjRelationship.class); when(relationship.isToMany()).thenReturn(true); when(relationship.getCollectionType()).thenReturn("java.util.Map"); when(relationship.getMapKey()).thenReturn("key"); when(relationship.getTargetEntityName()).thenReturn("target"); when(relationship.getName()).thenReturn("map_rel"); when(relationship.getTargetEntity()).thenReturn(entity); String definition = propertyUtils.propertyDefinition(relationship); assertEquals("public static final MapProperty<String, TargetEntity> MAP_REL = PropertyFactory.createMap(\"map_rel\", String.class, TargetEntity.class);", definition); }
private String mapRelationshipDefinition(ObjRelationship relationship, boolean client) { StringUtils utils = StringUtils.getInstance(); String propertyType = getPropertyTypeForJavaClass(relationship); String propertyFactoryMethod = factoryMethodForPropertyType(propertyType); String mapKeyType = importUtils.formatJavaType(EntityUtils.getMapKeyTypeInternal(relationship)); String attributeType = getRelatedTypeName(relationship, client); return String.format("public static final %s<%s, %s> %s = PropertyFactory.%s(\"%s\", %s.class, %s.class);", importUtils.formatJavaType(propertyType), mapKeyType, attributeType, utils.capitalizedAsConstant(relationship.getName()), propertyFactoryMethod, relationship.getName(), mapKeyType, attributeType ); }
PropertyUtils { private String mapRelationshipDefinition(ObjRelationship relationship, boolean client) { StringUtils utils = StringUtils.getInstance(); String propertyType = getPropertyTypeForJavaClass(relationship); String propertyFactoryMethod = factoryMethodForPropertyType(propertyType); String mapKeyType = importUtils.formatJavaType(EntityUtils.getMapKeyTypeInternal(relationship)); String attributeType = getRelatedTypeName(relationship, client); return String.format("public static final %s<%s, %s> %s = PropertyFactory.%s(\"%s\", %s.class, %s.class);", importUtils.formatJavaType(propertyType), mapKeyType, attributeType, utils.capitalizedAsConstant(relationship.getName()), propertyFactoryMethod, relationship.getName(), mapKeyType, attributeType ); } }
PropertyUtils { private String mapRelationshipDefinition(ObjRelationship relationship, boolean client) { StringUtils utils = StringUtils.getInstance(); String propertyType = getPropertyTypeForJavaClass(relationship); String propertyFactoryMethod = factoryMethodForPropertyType(propertyType); String mapKeyType = importUtils.formatJavaType(EntityUtils.getMapKeyTypeInternal(relationship)); String attributeType = getRelatedTypeName(relationship, client); return String.format("public static final %s<%s, %s> %s = PropertyFactory.%s(\"%s\", %s.class, %s.class);", importUtils.formatJavaType(propertyType), mapKeyType, attributeType, utils.capitalizedAsConstant(relationship.getName()), propertyFactoryMethod, relationship.getName(), mapKeyType, attributeType ); } PropertyUtils(ImportUtils importUtils);  PropertyUtils(ImportUtils importUtils,
                         AdhocObjectFactory adhocObjectFactory,
                         List<PropertyDescriptorCreator> propertyList,
                         Logger logger); }
PropertyUtils { private String mapRelationshipDefinition(ObjRelationship relationship, boolean client) { StringUtils utils = StringUtils.getInstance(); String propertyType = getPropertyTypeForJavaClass(relationship); String propertyFactoryMethod = factoryMethodForPropertyType(propertyType); String mapKeyType = importUtils.formatJavaType(EntityUtils.getMapKeyTypeInternal(relationship)); String attributeType = getRelatedTypeName(relationship, client); return String.format("public static final %s<%s, %s> %s = PropertyFactory.%s(\"%s\", %s.class, %s.class);", importUtils.formatJavaType(propertyType), mapKeyType, attributeType, utils.capitalizedAsConstant(relationship.getName()), propertyFactoryMethod, relationship.getName(), mapKeyType, attributeType ); } PropertyUtils(ImportUtils importUtils);  PropertyUtils(ImportUtils importUtils,
                         AdhocObjectFactory adhocObjectFactory,
                         List<PropertyDescriptorCreator> propertyList,
                         Logger logger); void addImportForPK(EntityUtils entityUtils); void addImport(ObjAttribute attribute); void addImport(EmbeddedAttribute attribute); void addImport(EmbeddableAttribute attribute); void addImport(ObjRelationship relationship); void addImport(ObjRelationship relationship, boolean client); String propertyDefinition(ObjEntity entity, DbAttribute attribute); String propertyDefinition(ObjAttribute attribute, boolean client); String propertyDefinition(ObjAttribute attribute); String propertyDefinition(EmbeddedAttribute attribute); String propertyDefinition(EmbeddableAttribute attribute); String propertyDefinition(ObjRelationship relationship, boolean client); String propertyDefinition(ObjRelationship relationship); PropertyDescriptor getPropertyDescriptor(String attrType); }
PropertyUtils { private String mapRelationshipDefinition(ObjRelationship relationship, boolean client) { StringUtils utils = StringUtils.getInstance(); String propertyType = getPropertyTypeForJavaClass(relationship); String propertyFactoryMethod = factoryMethodForPropertyType(propertyType); String mapKeyType = importUtils.formatJavaType(EntityUtils.getMapKeyTypeInternal(relationship)); String attributeType = getRelatedTypeName(relationship, client); return String.format("public static final %s<%s, %s> %s = PropertyFactory.%s(\"%s\", %s.class, %s.class);", importUtils.formatJavaType(propertyType), mapKeyType, attributeType, utils.capitalizedAsConstant(relationship.getName()), propertyFactoryMethod, relationship.getName(), mapKeyType, attributeType ); } PropertyUtils(ImportUtils importUtils);  PropertyUtils(ImportUtils importUtils,
                         AdhocObjectFactory adhocObjectFactory,
                         List<PropertyDescriptorCreator> propertyList,
                         Logger logger); void addImportForPK(EntityUtils entityUtils); void addImport(ObjAttribute attribute); void addImport(EmbeddedAttribute attribute); void addImport(EmbeddableAttribute attribute); void addImport(ObjRelationship relationship); void addImport(ObjRelationship relationship, boolean client); String propertyDefinition(ObjEntity entity, DbAttribute attribute); String propertyDefinition(ObjAttribute attribute, boolean client); String propertyDefinition(ObjAttribute attribute); String propertyDefinition(EmbeddedAttribute attribute); String propertyDefinition(EmbeddableAttribute attribute); String propertyDefinition(ObjRelationship relationship, boolean client); String propertyDefinition(ObjRelationship relationship); PropertyDescriptor getPropertyDescriptor(String attrType);  }