Source:
<code>public void testTableExists() throws Exception { try (Connection conn = DriverManager.getConnection(getUrl())) { ConnectionQueryServices cqs = conn.unwrap(PhoenixConnection.class).getQueryServices(); String tableName = "randomTable"; Table randomTable = cqs.getTable(Bytes.toBytes(tableName)); assertNotNull(randomTable); assertEquals(randomTable.getName(), TableName.valueOf(tableName)); try { cqs.getTableIfExists(Bytes.toBytes(tableName)); fail("Should have thrown TableNotFoundException"); } catch (TableNotFoundException e) { assertEquals(e.getTableName(), tableName); } String tableName1 = SchemaUtil.getTableName(schemaName, dataTableName); String ddl = "CREATE TABLE " + tableName1 + " (col1 INTEGER PRIMARY KEY, col2 INTEGER)"; conn.createStatement().execute(ddl); String tableName2 = SchemaUtil.getTableName(generateUniqueName(), generateUniqueName()); ddl = "CREATE TABLE " + tableName2 + " (col1 INTEGER PRIMARY KEY, col2 INTEGER)"; conn.createStatement().execute(ddl); Table table1 = cqs.getTable(Bytes.toBytes(tableName1)); assertNotNull(table1); try { cqs.getTableIfExists(Bytes.toBytes(tableName1)); } catch (TableNotFoundException e) { fail("Should not throw TableNotFoundException"); } disableAndDropNonSystemTables(); Table t1 = cqs.getTable(Bytes.toBytes(tableName1)); assertEquals(t1.getName().getNameAsString(), tableName1); Table t2 = cqs.getTable(Bytes.toBytes(tableName2)); assertEquals(t2.getName().getNameAsString(), tableName2); try { cqs.getTableIfExists(Bytes.toBytes(tableName1)); fail("Should have thrown TableNotFoundException"); } catch (TableNotFoundException e) { <START> assertEquals(e.getTableName(), tableName1); <END> } try { cqs.getTableIfExists(Bytes.toBytes(tableName2)); fail("Should have thrown TableNotFoundException"); } catch (TableNotFoundException e) { assertTrue(tableName2.contains(e.getTableName())); } } }</code><technical_language>nit: argument expected value</technical_language>

Target:
public void testTableExists() throws Exception { try (Connection conn = DriverManager.getConnection(getUrl())) { ConnectionQueryServices cqs = conn.unwrap(PhoenixConnection.class).getQueryServices(); String tableName = "randomTable"; Table randomTable = cqs.getTable(Bytes.toBytes(tableName)); assertNotNull(randomTable); assertEquals(randomTable.getName(), TableName.valueOf(tableName)); try { cqs.getTableIfExists(Bytes.toBytes(tableName)); fail("Should have thrown TableNotFoundException"); } catch (TableNotFoundException e) { assertEquals(tableName, e.getTableName()); } String fullTableName1 = SchemaUtil.getTableName(schemaName, dataTableName); String ddl = "CREATE TABLE " + fullTableName1 + " (col1 INTEGER PRIMARY KEY, col2 INTEGER)"; conn.createStatement().execute(ddl); String schemaName2 = generateUniqueName(); String tableName2 = generateUniqueName(); String fullTableName2 = SchemaUtil.getTableName(schemaName2, tableName2); ddl = "CREATE TABLE " + fullTableName2 + " (col1 INTEGER PRIMARY KEY, col2 INTEGER)"; conn.createStatement().execute(ddl); Table table1 = cqs.getTable(Bytes.toBytes(fullTableName1)); assertNotNull(table1); try { cqs.getTableIfExists(Bytes.toBytes(fullTableName1)); } catch (TableNotFoundException e) { fail("Should not throw TableNotFoundException"); } disableAndDropNonSystemTables(); Table t1 = cqs.getTable(Bytes.toBytes(fullTableName1)); assertEquals(t1.getName().getNameAsString(), fullTableName1); Table t2 = cqs.getTable(Bytes.toBytes(fullTableName2)); assertEquals(t2.getName().getNameAsString(), fullTableName2); try { cqs.getTableIfExists(Bytes.toBytes(fullTableName1)); fail("Should have thrown TableNotFoundException"); } catch (TableNotFoundException e) { assertEquals(dataTableName, e.getTableName()); assertEquals(schemaName, e.getSchemaName()); } try { cqs.getTableIfExists(Bytes.toBytes(fullTableName2)); fail("Should have thrown TableNotFoundException"); } catch (TableNotFoundException e) { assertEquals(tableName2, e.getTableName()); assertEquals(schemaName2, e.getSchemaName()); } } }