1
1
package io .cdap .plugin .CloudMySql .stepsdesign ;
2
2
3
+ import io .cdap .e2e .pages .actions .CdfPipelineRunAction ;
4
+ import io .cdap .e2e .utils .BigQueryClient ;
3
5
import io .cdap .e2e .utils .CdfHelper ;
4
6
import io .cdap .e2e .utils .PluginPropertyUtils ;
5
7
import io .cdap .plugin .CloudMySqlClient ;
6
8
import io .cucumber .java .en .Then ;
7
9
import org .junit .Assert ;
8
10
import stepsdesign .BeforeActions ;
9
- import io .cdap .e2e . utils . PluginPropertyUtils ;
11
+ import io .cdap .plugin . CloudMySql . BQValidation ;
10
12
13
+ import java .io .IOException ;
11
14
import java .sql .SQLException ;
15
+ import java .text .ParseException ;
12
16
13
17
/**
14
18
* CloudSqlMySql Plugin related step design.
15
19
*/
16
20
public class CloudMysql implements CdfHelper {
17
-
18
21
@ Then ("Validate the values of records transferred to target table is equal to the values from source table" )
19
22
public void validateTheValuesOfRecordsTransferredToTargetTableIsEqualToTheValuesFromSourceTable ()
20
23
throws SQLException , ClassNotFoundException {
@@ -27,5 +30,37 @@ public void validateTheValuesOfRecordsTransferredToTargetTableIsEqualToTheValues
27
30
Assert .assertTrue ("Value of records transferred to the target table should be equal to the value " +
28
31
"of the records in the source table" , recordsMatched );
29
32
}
33
+
34
+ @ Then ("Validate the values of records transferred to target Big Query table is equal to the values from source table" )
35
+ public void validateTheValuesOfRecordsTransferredToTargetBigQueryTableIsEqualToTheValuesFromSourceTable ()
36
+ throws IOException , InterruptedException , IOException , SQLException , ClassNotFoundException , ParseException {
37
+ int targetBQRecordsCount = BigQueryClient .countBqQuery (PluginPropertyUtils .pluginProp ("bqTargetTable" ));
38
+ BeforeActions .scenario .write ("No of Records Transferred to BigQuery:" + targetBQRecordsCount );
39
+ Assert .assertEquals ("Out records should match with target BigQuery table records count" ,
40
+ CdfPipelineRunAction .getCountDisplayedOnSourcePluginAsRecordsOut (), targetBQRecordsCount );
41
+
42
+ boolean recordsMatched = BQValidation .validateDBAndBQRecordValues (
43
+ PluginPropertyUtils .pluginProp ("sourceTable" ),
44
+ PluginPropertyUtils .pluginProp ("bqTargetTable" ));
45
+ Assert .assertTrue ("Value of records transferred to the target table should be equal to the value " +
46
+ "of the records in the source table" , recordsMatched );
47
+ }
48
+
49
+ @ Then ("Validate the values of records transferred to target CloudSQLMySql table is equal to the values from source " +
50
+ "BigQuery table" )
51
+ public void validateTheValuesOfRecordsTransferredToTargetCloudSQLMySqlTableIsEqualToTheValuesFromSourceBigQueryTable ()
52
+ throws IOException , InterruptedException , IOException , SQLException , ClassNotFoundException , ParseException , ParseException {
53
+ int sourceBQRecordsCount = BigQueryClient .countBqQuery (PluginPropertyUtils .pluginProp ("bqSourceTable" ));
54
+ BeforeActions .scenario .write ("No of Records from source BigQuery table:" + sourceBQRecordsCount );
55
+ Assert .assertEquals ("Out records should match with target PostgreSQL table records count" ,
56
+ CdfPipelineRunAction .getCountDisplayedOnSourcePluginAsRecordsOut (), sourceBQRecordsCount );
57
+
58
+ boolean recordsMatched = BQValidation .validateBQAndDBRecordValues (
59
+ PluginPropertyUtils .pluginProp ("bqSourceTable" ),
60
+ PluginPropertyUtils .pluginProp ("targetTable" ));
61
+ Assert .assertTrue ("Value of records transferred to the target table should be equal to the value " +
62
+ "of the records in the source table" , recordsMatched );
63
+ }
64
+
30
65
}
31
66
0 commit comments