AnalyticsIndex { public String getIndexName( AnalyticsTableType tableType ) { String columnName = StringUtils.join( this.getColumns(), "_" ); return quote( PREFIX_INDEX + removeQuote( columnName ) + "_" + shortenTableName( this.getTable(), tableType ) + "_" + CodeGenerator.generateCode( 5 ) ); } AnalyticsIndex( String table, List<String> columns, String type ); String getIndexName( AnalyticsTableType tableType ); boolean hasType(); String getTable(); List<String> getColumns(); String getType(); @Override int hashCode(); @Override boolean equals( Object object ); static final String PREFIX_INDEX; }
@Test public void testGetIndexName() { AnalyticsIndex indexA = new AnalyticsIndex( "analytics_2017_temp", Lists.newArrayList( quote( "quarterly" ) ), null ); AnalyticsIndex indexB = new AnalyticsIndex( "analytics_2018_temp", Lists.newArrayList( quote( "ax" ), quote( "co" ) ), null ); AnalyticsIndex indexC = new AnalyticsIndex( "analytics_2019_temp", Lists.newArrayList( quote( "YtbsuPPo010" ) ), null ); assertTrue( indexA.getIndexName( AnalyticsTableType.DATA_VALUE ).startsWith( QUOTE + "in_quarterly_ax_2017_" ) ); assertTrue( indexB.getIndexName( AnalyticsTableType.DATA_VALUE ).startsWith( QUOTE + "in_ax_co_ax_2018_" ) ); assertTrue( indexC.getIndexName( AnalyticsTableType.DATA_VALUE ).startsWith( QUOTE + "in_YtbsuPPo010_ax_2019_" ) ); }