FieldHelper { public static void createMetadataForManyToManyRelationship(Field field, String relatedClass, String collectionType, String relatedField, boolean isOwningSide) { setMetadataForManyToManyRelationship(field, isOwningSide); field.setMetadataValue(RELATED_CLASS, relatedClass); field.setMetadataValue(RELATIONSHIP_COLLECTION_TYPE, collectionType); field.setMetadataValue(RELATED_FIELD, relatedField); } 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 shouldCreateAndSetMetadataForManyToManyRelationship() { 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.createMetadataForManyToManyRelationship(field, "org.motechproject.sample.Test", "java.util.Set", "relatedField", true); assertEquals(field.getMetadata().size(), 4); assertEquals(field.getMetadataValue(Constants.MetadataKeys.OWNING_SIDE), "true"); assertEquals(field.getMetadataValue(Constants.MetadataKeys.RELATED_FIELD), "relatedField"); assertEquals(field.getMetadataValue(Constants.MetadataKeys.RELATED_CLASS), "org.motechproject.sample.Test"); assertEquals(field.getMetadataValue(Constants.MetadataKeys.RELATIONSHIP_COLLECTION_TYPE), "java.util.Set"); }