@@ -65,6 +65,8 @@ public class TestSetupHooks {
6565  public  static  String  gcsSourceBucketName  = StringUtils .EMPTY ;
6666  public  static  String  gcsTargetBucketName  = StringUtils .EMPTY ;
6767  public  static  String  bqTargetTable  = StringUtils .EMPTY ;
68+   public  static  String  bqmtTargetTable  = StringUtils .EMPTY ;
69+   public  static  String  bqmtTargetTable2  = StringUtils .EMPTY ;
6870  public  static  String  bqSourceTable  = StringUtils .EMPTY ;
6971  public  static  String  bqSourceTable2  = StringUtils .EMPTY ;
7072  public  static  String  bqTargetTable2  = StringUtils .EMPTY ;
@@ -294,16 +296,16 @@ public static void createTempSourceBQTable() throws IOException, InterruptedExce
294296    BeforeActions .scenario .write ("BQ source Table "  + bqSourceTable  + " created successfully" );
295297  }
296298
297-   @ After (order  = 1 , value  = "@BQ_SOURCE_TEST or @BQ_PARTITIONED_SOURCE_TEST or @BQ_SOURCE_DATATYPE_TEST or "  +
299+   @ After (order  = 2 , value  = "@BQ_SOURCE_TEST or @BQ_PARTITIONED_SOURCE_TEST or @BQ_SOURCE_DATATYPE_TEST or "  +
298300    "@BQ_INSERT_SOURCE_TEST or @BQ_UPDATE_SINK_TEST or @BQ_EXISTING_SOURCE_TEST or @BQ_EXISTING_SINK_TEST or "  +
299301    "@BQ_EXISTING_SOURCE_DATATYPE_TEST or @BQ_EXISTING_SINK_DATATYPE_TEST or @BQ_UPSERT_SOURCE_TEST or "  +
300302    "@BQ_NULL_MODE_SOURCE_TEST or @BQ_UPDATE_SOURCE_DEDUPE_TEST or @BQ_INSERT_INT_SOURCE_TEST or "  +
301-     "@BQ_TIME_SOURCE_TEST or @BQ_UPSERT_DEDUPE_SOURCE_TEST or @BQ_PRIMARY_RECORD_SOURCE_TEST" )
303+     "@BQ_TIME_SOURCE_TEST or @BQ_UPSERT_DEDUPE_SOURCE_TEST or @BQ_PRIMARY_RECORD_SOURCE_TEST or "  +
304+     "@BQ_SINGLE_SOURCE_BQMT_TEST" )
302305  public  static  void  deleteTempSourceBQTable () throws  IOException , InterruptedException  {
303306    BigQueryClient .dropBqQuery (bqSourceTable );
304307    PluginPropertyUtils .removePluginProp ("bqSourceTable" );
305308    BeforeActions .scenario .write ("BQ source Table "  + bqSourceTable  + " deleted successfully" );
306-     bqSourceTable  = StringUtils .EMPTY ;
307309  }
308310
309311  /** 
@@ -1554,20 +1556,22 @@ public static void emptyExistingBigTableInstanceAndTableName() {
15541556      bigtableExistingTargetTable  = StringUtils .EMPTY ;
15551557  }
15561558
1557-   @ Before (order  = 1 , value  = "@BQ_EXISTING_TARGET_TEST" )
1559+   @ Before (order  = 2 , value  = "@BQ_EXISTING_TARGET_TEST" )
15581560  public  static  void  createSinkTables () throws  IOException , InterruptedException  {
1559-     bqTargetTable  = PluginPropertyUtils .pluginProp ("bqTargetTable " );
1560-     bqTargetTable2  = PluginPropertyUtils .pluginProp ("bqTargetTable2 " );
1561-     io .cdap .e2e .utils .BigQueryClient .getSoleQueryResult ("create table `"  + datasetName  + "."  + bqTargetTable  + "` "  +
1561+     bqmtTargetTable  = PluginPropertyUtils .pluginProp ("bqmtTargetTable " );
1562+     bqmtTargetTable2  = PluginPropertyUtils .pluginProp ("bqmtTargetTable2 " );
1563+     io .cdap .e2e .utils .BigQueryClient .getSoleQueryResult ("create table `"  + datasetName  + "."  + bqmtTargetTable  + "` "  +
15621564                                                          "(ID INT64, tablename STRING,"  +
15631565                                                          "Price FLOAT64, Customer_Exists BOOL ) " );
15641566
1565-     io .cdap .e2e .utils .BigQueryClient .getSoleQueryResult ("create table `"  + datasetName  + "."  + bqTargetTable2  + "` "  +
1567+     io .cdap .e2e .utils .BigQueryClient .getSoleQueryResult ("create table `"  + datasetName  + "."  + bqmtTargetTable  + "` "  +
15661568                                                          "(ID INT64, tablename STRING,"  +
15671569                                                          "Price FLOAT64, Customer_Exists BOOL ) " );
15681570
1569-     PluginPropertyUtils .addPluginProp ("bqTargetTable" , bqTargetTable );
1570-     PluginPropertyUtils .addPluginProp ("bqTargetTable2" , bqTargetTable2 );
1571+     PluginPropertyUtils .addPluginProp ("bqmtTargetTable" , bqmtTargetTable );
1572+     PluginPropertyUtils .addPluginProp ("bqmtTargetTable2" , bqmtTargetTable2 );
1573+     BeforeActions .scenario .write ("BQ Target table - "  + bqmtTargetTable  + " created successfully" );
1574+     BeforeActions .scenario .write ("BQ Target table2 - "  + bqmtTargetTable2  + " created successfully" );
15711575  }
15721576  @ Before (order  = 1 , value  = "@BQ_SOURCE_UPDATE_TEST" )
15731577  public  static  void  createSourceTables () throws  IOException , InterruptedException  {
@@ -1602,48 +1606,87 @@ public static void createSourceTables() throws IOException, InterruptedException
16021606
16031607    PluginPropertyUtils .addPluginProp ("bqSourceTable" , bqSourceTable );
16041608    PluginPropertyUtils .addPluginProp ("bqSourceTable2" , bqSourceTable2 );
1609+     BeforeActions .scenario .write ("BQ Source table - "  + bqSourceTable  + " created successfully" );
1610+     BeforeActions .scenario .write ("BQ Source table2 - "  + bqSourceTable2  + " created successfully" );
1611+   }
1612+ 
1613+ //  @After(order = 1, value = "@BQ_DELETE_TABLES_TEST") 
1614+ //  public static void deleteAllBqTables() throws IOException, InterruptedException { 
1615+ //    BigQueryClient.dropBqQuery(bqSourceTable); 
1616+ //    BigQueryClient.dropBqQuery(bqSourceTable2); 
1617+ //    bqTargetTable = PluginPropertyUtils.pluginProp("bqTargetTable"); 
1618+ //    bqTargetTable2 = PluginPropertyUtils.pluginProp("bqTargetTable2"); 
1619+ //    BigQueryClient.dropBqQuery(bqTargetTable); 
1620+ //    BigQueryClient.dropBqQuery(bqTargetTable2); 
1621+ //    PluginPropertyUtils.removePluginProp("bqSourceTable"); 
1622+ //    PluginPropertyUtils.removePluginProp("bqSourceTable2"); 
1623+ //    BeforeActions.scenario.write("BQ source Table " + bqSourceTable + " deleted successfully"); 
1624+ //    BeforeActions.scenario.write("BQ source Table2 " + bqSourceTable2 + " deleted successfully"); 
1625+ //    BeforeActions.scenario.write("BQ target Table " + bqTargetTable + " deleted successfully"); 
1626+ //    BeforeActions.scenario.write("BQ target Table2 " + bqTargetTable2 + " deleted successfully"); 
1627+ //  } 
1628+ 
1629+   @ After (order  = 2 , value  = "@BQ_SINK_BQMT_TEST" )
1630+   public  static  void  deleteTargetBqmtTable () throws  IOException , InterruptedException  {
1631+     try  {
1632+       bqmtTargetTable  = PluginPropertyUtils .pluginProp ("bqmtTargetTable" );
1633+       BigQueryClient .dropBqQuery (bqmtTargetTable );
1634+       BeforeActions .scenario .write ("BQ Target table - "  + bqmtTargetTable  + " deleted successfully" );
1635+     } catch  (BigQueryException  e ) {
1636+       if  (e .getMessage ().contains ("Not found: Table" )) {
1637+         BeforeActions .scenario .write ("BQ Target Table "  + bqmtTargetTable  + " does not exist" );
1638+       } else  {
1639+         Assert .fail (e .getMessage ());
1640+       }
1641+     }
16051642  }
16061643
1607-   @ After (order  = 1 , value  = "@BQ_DELETE_TABLES_TEST" )
1608-   public  static  void  deleteAllBqTables () throws  IOException , InterruptedException  {
1609-     BigQueryClient .dropBqQuery (bqSourceTable );
1644+   @ After (order  = 1 , value  = "@BQ_SECONDARY_RECORD_SOURCE_TEST" )
1645+   public  static  void  deleteTempSource2BQTable () throws  IOException , InterruptedException  {
16101646    BigQueryClient .dropBqQuery (bqSourceTable2 );
1611-     bqTargetTable  = PluginPropertyUtils .pluginProp ("bqTargetTable" );
1612-     bqTargetTable2  = PluginPropertyUtils .pluginProp ("bqTargetTable2" );
1613-     BigQueryClient .dropBqQuery (bqTargetTable );
1614-     BigQueryClient .dropBqQuery (bqTargetTable2 );
1615-     PluginPropertyUtils .removePluginProp ("bqSourceTable" );
1647+     bqSourceTable2  = PluginPropertyUtils .pluginProp ("bqSourceTable2" );
16161648    PluginPropertyUtils .removePluginProp ("bqSourceTable2" );
1617-     BeforeActions .scenario .write ("BQ source Table "  + bqSourceTable  + " deleted successfully" );
16181649    BeforeActions .scenario .write ("BQ source Table2 "  + bqSourceTable2  + " deleted successfully" );
1619-     BeforeActions .scenario .write ("BQ target Table "  + bqTargetTable  + " deleted successfully" );
1620-     BeforeActions .scenario .write ("BQ target Table2 "  + bqTargetTable2  + " deleted successfully" );
16211650  }
16221651
1623-   @ After (order  = 1 , value  = "@BQ_SINK_BQMT_TEST " )
1624-   public  static  void  deleteTargetBqmtTable () throws  IOException , InterruptedException  {
1652+   @ After (order  = 2 , value  = "@BQ_TWO_SOURCE_BQMT_TEST or @BQ_SOURCE_UPDATE_TEST " )
1653+   public  static  void  deleteTwoSourceTables () throws  IOException , InterruptedException  {
16251654    try  {
1626-       bqTargetTable  = PluginPropertyUtils .pluginProp ("bqTargetTable" );
1627-       BigQueryClient .dropBqQuery (bqTargetTable );
16281655      BigQueryClient .dropBqQuery (bqSourceTable );
1629-       BeforeActions . scenario . write ( "BQ Target table - "  +  bqTargetTable  +  " deleted successfully" );
1656+       BigQueryClient . dropBqQuery ( bqSourceTable2 );
16301657      BeforeActions .scenario .write ("BQ Source table - "  + bqSourceTable  + " deleted successfully" );
1631-       bqTargetTable  = StringUtils .EMPTY ;
1658+       BeforeActions .scenario .write ("BQ Source table2 - "  + bqSourceTable2  + " deleted successfully" );
1659+       PluginPropertyUtils .removePluginProp ("bqSourceTable" );
1660+       PluginPropertyUtils .removePluginProp ("bqSourceTable2" );
1661+ 
16321662    } catch  (BigQueryException  e ) {
16331663      if  (e .getMessage ().contains ("Not found: Table" )) {
1634-         BeforeActions .scenario .write ("BQ Target Table "  + bqTargetTable  + " does not exist" );
16351664        BeforeActions .scenario .write ("BQ Source Table "  + bqSourceTable  + " does not exist" );
1665+         BeforeActions .scenario .write ("BQ Source Table2 "  + bqSourceTable2  + " does not exist" );
16361666      } else  {
16371667        Assert .fail (e .getMessage ());
16381668      }
16391669    }
16401670  }
16411671
1642-   @ After (order  = 1 , value  = "@BQ_SECONDARY_RECORD_SOURCE_TEST" )
1643-   public  static  void  deleteTempSource2BQTable () throws  IOException , InterruptedException  {
1644-     BigQueryClient .dropBqQuery (bqSourceTable2 );
1645-     bqSourceTable2  = PluginPropertyUtils .pluginProp ("bqSourceTable2" );
1646-     PluginPropertyUtils .removePluginProp ("bqSourceTable2" );
1647-     BeforeActions .scenario .write ("BQ source Table2 "  + bqSourceTable2  + " deleted successfully" );
1672+   @ After (order  = 2 , value  = "@BQ_TWO_SINK_BQMT_TEST" )
1673+   public  static  void  deleteTwoTargetTables () throws  IOException , InterruptedException  {
1674+     try  {
1675+       bqmtTargetTable  =  PluginPropertyUtils .pluginProp ("bqmtTargetTable" );
1676+       bqmtTargetTable2  =  PluginPropertyUtils .pluginProp ("bqmtTargetTable2" );
1677+       BigQueryClient .dropBqQuery (bqmtTargetTable );
1678+       BigQueryClient .dropBqQuery (bqmtTargetTable2 );
1679+       BeforeActions .scenario .write ("BQ Target table - "  + bqmtTargetTable  + " deleted successfully" );
1680+       BeforeActions .scenario .write ("BQ Target table2 - "  + bqmtTargetTable2  + " deleted successfully" );
1681+ 
1682+     } catch  (BigQueryException  e ) {
1683+       if  (e .getMessage ().contains ("Not found: Table" )) {
1684+         BeforeActions .scenario .write ("BQ Target Table "  + bqmtTargetTable  + " does not exist" );
1685+         BeforeActions .scenario .write ("BQ Target Table2 "  + bqmtTargetTable2  + " does not exist" );
1686+       } else  {
1687+         Assert .fail (e .getMessage ());
1688+       }
1689+     }
16481690  }
1691+ 
16491692}
0 commit comments