RelationCollisionUtil { protected Namer getOneToManyNamerFromConf(OneToManyConfig o2m, Namer fromEntityNamer) { if (o2m != null) { if (o2m.hasElementVar() && !o2m.hasVar()) { return new AccessorNamer(fromEntityNamer, o2m.getElementVar()); } if (o2m.hasElementVar() && o2m.hasVar()) { return new AccessorNamer(fromEntityNamer, o2m.getElementVar(), o2m.getVar()); } if (!o2m.hasElementVar() && o2m.hasVar()) { return new AccessorNamer(fromEntityNamer, fromEntityNamer.getVar(), o2m.getVar()); } } return null; }  void addVar(String entityType, String attributeVar); void removeVar(String entityType, String attributeVar); Namer getManyToOneNamer(Attribute fromAttribute, Namer targetEntityNamer); Namer getOneToManyNamer(ColumnConfig fromAttributeColumnConfig, Namer fromEntityNamer); Namer getManyToManyNamer(Namer fromEntityNamer, ColumnConfig pointsOnToEntity, Namer toEntityNamer); Namer getManyToOneIntermediateNamer(Namer fromEntityNamer, ColumnConfig pointsOnToEntity, Namer toEntityNamer); Namer getOneToManyIntermediateNamer(Namer fromEntityNamer, ColumnConfig pointsOnToEntity, Namer toEntityNamer); Namer getOneToOneNamer(Attribute fromAttribute, Namer targetEntityNamer); Namer getInverseOneToOneNamer(Attribute fromAttribute, Namer fromEntityNamer); String getClashSafeVar(String entityName, String javaField);  }
@Test public void oneToManyNamerFromConfComplete() { RelationCollisionUtil relationUtil = new RelationCollisionUtil(); Namer fromEntityNamer = getNamer("account", "Account"); Namer result = relationUtil.getOneToManyNamerFromConf(getOneToManyConfig("unAccount", "lesAccounts"), fromEntityNamer); assertThat(result.getVar()).isEqualTo("unAccount"); assertThat(result.getVars()).isEqualTo("lesAccounts"); assertThat(result.getType()).isEqualTo("Account"); }
@Test public void oneToManyNamerFromConfPluralOnly() { RelationCollisionUtil relationUtil = new RelationCollisionUtil(); Namer fromEntityNamer = getNamer("account", "Account"); Namer result = relationUtil.getOneToManyNamerFromConf(getOneToManyConfig(null, "lesAccounts"), fromEntityNamer); assertThat(result.getVar()).isEqualTo("account"); assertThat(result.getVars()).isEqualTo("lesAccounts"); assertThat(result.getType()).isEqualTo("Account"); }
@Test public void oneToManyNamerFromConfSingularOnly() { RelationCollisionUtil relationUtil = new RelationCollisionUtil(); Namer fromEntityNamer = getNamer("account", "Account"); Namer result = relationUtil.getOneToManyNamerFromConf(getOneToManyConfig("unAccount", null), fromEntityNamer); assertThat(result.getVar()).isEqualTo("unAccount"); assertThat(result.getVars()).isEqualTo("unAccounts"); assertThat(result.getType()).isEqualTo("Account"); }
@Test public void oneToManyNamerFromConfEmpty() { RelationCollisionUtil relationUtil = new RelationCollisionUtil(); Namer fromEntityNamer = getNamer("account", "Account"); Namer result = relationUtil.getOneToManyNamerFromConf(getOneToManyConfig(null, null), fromEntityNamer); assertThat(result).isNull(); }
@Test public void oneToManyNamerFromConfNull() { RelationCollisionUtil relationUtil = new RelationCollisionUtil(); Namer fromEntityNamer = getNamer("account", "Account"); Namer result = relationUtil.getOneToManyNamerFromConf(null, fromEntityNamer); assertThat(result).isNull(); }