@Test public void shouldThrowIfTableMappingDoesNotExist() throws TableMappingNotFoundException { when(resultSet.size()).thenReturn(0); expectedException.expect(TableMappingNotFoundException.class); expectedException.expectMessage("The table a_test_namespace__ThisIsAVeryLongTableNameThatWillExceed"); oracleTableNameUnmapper.getShortTableNameFromMappingTable(connectionSupplier, TEST_PREFIX, TABLE_REF); }
@SuppressWarnings("checkstyle:NestedTryDepth") public String getShortTableNameFromMappingTable( ConnectionSupplier connectionSupplier, String tablePrefix, TableReference tableRef) throws TableMappingNotFoundException { String fullTableName = tablePrefix + DbKvs.internalTableName(tableRef); try { return unmappingCache.get(fullTableName, () -> { SqlConnection conn = connectionSupplier.get(); AgnosticResultSet results = conn.selectResultSetUnregisteredQuery( "SELECT short_table_name " + "FROM " + AtlasDbConstants.ORACLE_NAME_MAPPING_TABLE + " WHERE table_name = ?", fullTableName); if (results.size() == 0) { throw new TableMappingNotFoundException( "The table " + fullTableName + " does not have a mapping." + "This might be because the table does not exist."); } return Iterables.getOnlyElement(results.rows()).getString("short_table_name"); }); } catch (ExecutionException e) { throw new TableMappingNotFoundException(e.getCause()); } }
OracleTableNameUnmapper { @SuppressWarnings("checkstyle:NestedTryDepth") public String getShortTableNameFromMappingTable( ConnectionSupplier connectionSupplier, String tablePrefix, TableReference tableRef) throws TableMappingNotFoundException { String fullTableName = tablePrefix + DbKvs.internalTableName(tableRef); try { return unmappingCache.get(fullTableName, () -> { SqlConnection conn = connectionSupplier.get(); AgnosticResultSet results = conn.selectResultSetUnregisteredQuery( "SELECT short_table_name " + "FROM " + AtlasDbConstants.ORACLE_NAME_MAPPING_TABLE + " WHERE table_name = ?", fullTableName); if (results.size() == 0) { throw new TableMappingNotFoundException( "The table " + fullTableName + " does not have a mapping." + "This might be because the table does not exist."); } return Iterables.getOnlyElement(results.rows()).getString("short_table_name"); }); } catch (ExecutionException e) { throw new TableMappingNotFoundException(e.getCause()); } } }
OracleTableNameUnmapper { @SuppressWarnings("checkstyle:NestedTryDepth") public String getShortTableNameFromMappingTable( ConnectionSupplier connectionSupplier, String tablePrefix, TableReference tableRef) throws TableMappingNotFoundException { String fullTableName = tablePrefix + DbKvs.internalTableName(tableRef); try { return unmappingCache.get(fullTableName, () -> { SqlConnection conn = connectionSupplier.get(); AgnosticResultSet results = conn.selectResultSetUnregisteredQuery( "SELECT short_table_name " + "FROM " + AtlasDbConstants.ORACLE_NAME_MAPPING_TABLE + " WHERE table_name = ?", fullTableName); if (results.size() == 0) { throw new TableMappingNotFoundException( "The table " + fullTableName + " does not have a mapping." + "This might be because the table does not exist."); } return Iterables.getOnlyElement(results.rows()).getString("short_table_name"); }); } catch (ExecutionException e) { throw new TableMappingNotFoundException(e.getCause()); } } OracleTableNameUnmapper(); }
OracleTableNameUnmapper { @SuppressWarnings("checkstyle:NestedTryDepth") public String getShortTableNameFromMappingTable( ConnectionSupplier connectionSupplier, String tablePrefix, TableReference tableRef) throws TableMappingNotFoundException { String fullTableName = tablePrefix + DbKvs.internalTableName(tableRef); try { return unmappingCache.get(fullTableName, () -> { SqlConnection conn = connectionSupplier.get(); AgnosticResultSet results = conn.selectResultSetUnregisteredQuery( "SELECT short_table_name " + "FROM " + AtlasDbConstants.ORACLE_NAME_MAPPING_TABLE + " WHERE table_name = ?", fullTableName); if (results.size() == 0) { throw new TableMappingNotFoundException( "The table " + fullTableName + " does not have a mapping." + "This might be because the table does not exist."); } return Iterables.getOnlyElement(results.rows()).getString("short_table_name"); }); } catch (ExecutionException e) { throw new TableMappingNotFoundException(e.getCause()); } } OracleTableNameUnmapper(); @SuppressWarnings("checkstyle:NestedTryDepth") String getShortTableNameFromMappingTable(
            ConnectionSupplier connectionSupplier,
            String tablePrefix,
            TableReference tableRef); void clearCacheForTable(String fullTableName); }
OracleTableNameUnmapper { @SuppressWarnings("checkstyle:NestedTryDepth") public String getShortTableNameFromMappingTable( ConnectionSupplier connectionSupplier, String tablePrefix, TableReference tableRef) throws TableMappingNotFoundException { String fullTableName = tablePrefix + DbKvs.internalTableName(tableRef); try { return unmappingCache.get(fullTableName, () -> { SqlConnection conn = connectionSupplier.get(); AgnosticResultSet results = conn.selectResultSetUnregisteredQuery( "SELECT short_table_name " + "FROM " + AtlasDbConstants.ORACLE_NAME_MAPPING_TABLE + " WHERE table_name = ?", fullTableName); if (results.size() == 0) { throw new TableMappingNotFoundException( "The table " + fullTableName + " does not have a mapping." + "This might be because the table does not exist."); } return Iterables.getOnlyElement(results.rows()).getString("short_table_name"); }); } catch (ExecutionException e) { throw new TableMappingNotFoundException(e.getCause()); } } OracleTableNameUnmapper(); @SuppressWarnings("checkstyle:NestedTryDepth") String getShortTableNameFromMappingTable(
            ConnectionSupplier connectionSupplier,
            String tablePrefix,
            TableReference tableRef); void clearCacheForTable(String fullTableName);  }