@Test void getSqlCreateJunctionTableIndex() { EntityType entityType = when(mock(EntityType.class).getId()).thenReturn("entity").getMock(); when(entityType.getId()).thenReturn("entityTypeId"); Attribute attr = when(mock(Attribute.class).getName()).thenReturn("attr").getMock(); when(attr.getIdentifier()).thenReturn("attrId"); Attribute idxAttr = when(mock(Attribute.class).getName()).thenReturn("idAttr").getMock(); when(idxAttr.getIdentifier()).thenReturn("idAttrId"); when(entityType.getIdAttribute()).thenReturn(idxAttr); assertEquals( "CREATE INDEX \"entityType#c34894ba_attr_idAttr_idx\" ON \"entityTypeId#c34894ba_attr\" (\"idAttr\")", PostgreSqlQueryGenerator.getSqlCreateJunctionTableIndex(entityType, attr)); }
static String getSqlCreateJunctionTableIndex(EntityType entityType, Attribute attr) { Attribute idAttr = entityType.getIdAttribute(); String junctionTableName = getJunctionTableName(entityType, attr); String junctionTableIndexName = getJunctionTableIndexName(entityType, attr, idAttr); String idxColumnName = getColumnName(idAttr); return "CREATE INDEX " + junctionTableIndexName + " ON " + junctionTableName + " (" + idxColumnName + ')'; }
PostgreSqlQueryGenerator { static String getSqlCreateJunctionTableIndex(EntityType entityType, Attribute attr) { Attribute idAttr = entityType.getIdAttribute(); String junctionTableName = getJunctionTableName(entityType, attr); String junctionTableIndexName = getJunctionTableIndexName(entityType, attr, idAttr); String idxColumnName = getColumnName(idAttr); return "CREATE INDEX " + junctionTableIndexName + " ON " + junctionTableName + " (" + idxColumnName + ')'; } }
PostgreSqlQueryGenerator { static String getSqlCreateJunctionTableIndex(EntityType entityType, Attribute attr) { Attribute idAttr = entityType.getIdAttribute(); String junctionTableName = getJunctionTableName(entityType, attr); String junctionTableIndexName = getJunctionTableIndexName(entityType, attr, idAttr); String idxColumnName = getColumnName(idAttr); return "CREATE INDEX " + junctionTableIndexName + " ON " + junctionTableName + " (" + idxColumnName + ')'; } private  PostgreSqlQueryGenerator(); }
PostgreSqlQueryGenerator { static String getSqlCreateJunctionTableIndex(EntityType entityType, Attribute attr) { Attribute idAttr = entityType.getIdAttribute(); String junctionTableName = getJunctionTableName(entityType, attr); String junctionTableIndexName = getJunctionTableIndexName(entityType, attr, idAttr); String idxColumnName = getColumnName(idAttr); return "CREATE INDEX " + junctionTableIndexName + " ON " + junctionTableName + " (" + idxColumnName + ')'; } private  PostgreSqlQueryGenerator();  }
PostgreSqlQueryGenerator { static String getSqlCreateJunctionTableIndex(EntityType entityType, Attribute attr) { Attribute idAttr = entityType.getIdAttribute(); String junctionTableName = getJunctionTableName(entityType, attr); String junctionTableIndexName = getJunctionTableIndexName(entityType, attr, idAttr); String idxColumnName = getColumnName(idAttr); return "CREATE INDEX " + junctionTableIndexName + " ON " + junctionTableName + " (" + idxColumnName + ')'; } private  PostgreSqlQueryGenerator();   }