@Test void getSqlCreateForeignKeySelfReferencing() { Attribute idAttr = when(mock(Attribute.class).getName()).thenReturn("idAttr").getMock(); when(idAttr.getIdentifier()).thenReturn("idAttrId"); when(idAttr.getDataType()).thenReturn(STRING); EntityType entityType = when(mock(EntityType.class).getId()).thenReturn("entity").getMock(); when(entityType.getId()).thenReturn("entityTypeId"); when(entityType.getIdAttribute()).thenReturn(idAttr); Attribute refAttr = when(mock(Attribute.class).getName()).thenReturn("attr").getMock(); when(refAttr.getIdentifier()).thenReturn("refAttrId"); when(refAttr.getDataType()).thenReturn(XREF); when(refAttr.getRefEntity()).thenReturn(entityType); String expectedSql = "ALTER TABLE \"entityTypeId#c34894ba\" ADD CONSTRAINT \"entityTypeId#c34894ba_attr_fkey\" FOREIGN KEY (\"attr\") REFERENCES \"entityTypeId#c34894ba\"(\"idAttr\") DEFERRABLE INITIALLY DEFERRED"; assertEquals(expectedSql, PostgreSqlQueryGenerator.getSqlCreateForeignKey(entityType, refAttr)); }
static String getSqlCreateForeignKey(EntityType entityType, Attribute attr) { return "ALTER TABLE " + getTableName(entityType) + " ADD " + getSqlForeignKey(entityType, attr); }
PostgreSqlQueryGenerator { static String getSqlCreateForeignKey(EntityType entityType, Attribute attr) { return "ALTER TABLE " + getTableName(entityType) + " ADD " + getSqlForeignKey(entityType, attr); } }
PostgreSqlQueryGenerator { static String getSqlCreateForeignKey(EntityType entityType, Attribute attr) { return "ALTER TABLE " + getTableName(entityType) + " ADD " + getSqlForeignKey(entityType, attr); } private  PostgreSqlQueryGenerator(); }
PostgreSqlQueryGenerator { static String getSqlCreateForeignKey(EntityType entityType, Attribute attr) { return "ALTER TABLE " + getTableName(entityType) + " ADD " + getSqlForeignKey(entityType, attr); } private  PostgreSqlQueryGenerator();  }
PostgreSqlQueryGenerator { static String getSqlCreateForeignKey(EntityType entityType, Attribute attr) { return "ALTER TABLE " + getTableName(entityType) + " ADD " + getSqlForeignKey(entityType, attr); } private  PostgreSqlQueryGenerator();   }