FieldHelper { public static void addMetadataForRelationship(String typeClass, Field field) { if (TypeDto.ONE_TO_ONE_RELATIONSHIP.getTypeClass().equals(typeClass) || TypeDto.MANY_TO_ONE_RELATIONSHIP.getTypeClass().equals(typeClass)) { setMetadataForOneToOneRelationship(field); } else if (TypeDto.ONE_TO_MANY_RELATIONSHIP.getTypeClass().equals(typeClass)) { setMetadataForOneToManyRelationship(field); } else if (TypeDto.MANY_TO_MANY_RELATIONSHIP.getTypeClass().equals(typeClass)) { setMetadataForManyToManyRelationship(field, true); } } private  FieldHelper(); static void setField(Object current, String path, List value); static Map<String, Field> fieldMapByName(Collection<Field> fields); static void addOrUpdateMetadataForCombobox(Field field); static void addMetadataForRelationship(String typeClass, Field field); static void createMetadataForManyToManyRelationship(Field field, String relatedClass, String collectionType,
                                                               String relatedField, boolean isOwningSide); static void setMetadataForManyToManyRelationship(Field field, boolean isOwningSide);  }
@Test public void shouldAddMetadataForFields() { Entity entity = new Entity("SampleEntity"); Field field = new Field(entity, "sampleField", "Display Name", true, false, false, false, false, "default", "tooltip", "placeholder", new HashSet<Lookup>()); FieldHelper.addMetadataForRelationship(TypeDto.MANY_TO_MANY_RELATIONSHIP.getTypeClass(), field); assertEquals(field.getMetadata().size(), 4); field.getMetadata().clear(); FieldHelper.addMetadataForRelationship(TypeDto.ONE_TO_MANY_RELATIONSHIP.getTypeClass(), field); assertEquals(field.getMetadata().size(), 2); field.getMetadata().clear(); FieldHelper.addMetadataForRelationship(TypeDto.ONE_TO_ONE_RELATIONSHIP.getTypeClass(), field); assertEquals(field.getMetadata().size(), 1); }