Skip to content

Commit

Permalink
Fixed checkstyle issues and minor fix
Browse files Browse the repository at this point in the history
  • Loading branch information
yjhawar committed Apr 11, 2023
1 parent 8106d03 commit 5294941
Show file tree
Hide file tree
Showing 15 changed files with 163 additions and 70 deletions.
22 changes: 16 additions & 6 deletions src/e2e-test/java/io.cdap.plugin/actions/ReplicationActions.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,14 @@

import io.cdap.e2e.pages.actions.CdfPipelineRunAction;
import io.cdap.e2e.pages.locators.CdfPipelineRunLocators;
import io.cdap.e2e.utils.*;
import io.cdap.e2e.utils.AssertionHelper;
import io.cdap.e2e.utils.ConstantsUtil;
import io.cdap.e2e.utils.ElementHelper;
import io.cdap.e2e.utils.PageHelper;
import io.cdap.e2e.utils.PluginPropertyUtils;
import io.cdap.e2e.utils.SeleniumDriver;
import io.cdap.e2e.utils.SeleniumHelper;
import io.cdap.e2e.utils.WaitHelper;
import io.cdap.plugin.locators.ReplicationLocators;
import io.cdap.plugin.utils.BigQuery;
import io.cdap.plugin.utils.OracleClient;
Expand All @@ -34,6 +41,9 @@
import java.util.Map;
import java.util.concurrent.TimeUnit;

/**
* Replication oracle Actions.
*/
public class ReplicationActions {
private static String parentWindow = StringUtils.EMPTY;
private static final String projectId = PluginPropertyUtils.pluginProp("projectId");
Expand All @@ -60,7 +70,7 @@ public static void clickOnOraclePlugin() {

public static void selectTable() {
String table = schemaName + "." + tableName;
WaitHelper.waitForElementToBeDisplayed(ReplicationLocators.selectTable(table),300);
WaitHelper.waitForElementToBeDisplayed(ReplicationLocators.selectTable(table), 300);
AssertionHelper.verifyElementDisplayed(ReplicationLocators.selectTable(table));
ElementHelper.clickOnElement(ReplicationLocators.selectTable(table));
}
Expand Down Expand Up @@ -120,7 +130,6 @@ public static void waitTillPipelineIsRunningAndCheckForErrors() throws Interrupt
}

public static void closeTheLogsAndClickOnStopButton() {
//As the logs get opened in a new window in this plugin so after closing them we have to switch to parent window.
SeleniumDriver.getDriver().switchTo().window(parentWindow);
//Stopping the pipeline
ElementHelper.clickOnElement(ReplicationLocators.stop);
Expand All @@ -133,7 +142,8 @@ public static void verifyTargetBigQueryRecordMatchesExpectedOracleRecord()
Assert.assertFalse(ElementHelper.isElementDisplayed(ReplicationLocators.error));

List<Map<String, Object>> sourceOracleRecords = OracleClient.getOracleRecordsAsMap(tableName, schemaName);
List<Map<String, Object>> targetBigQueryRecords = ValidationHelper.getBigQueryRecordsAsMap(projectId, database, tableName);
List<Map<String, Object>> targetBigQueryRecords =
ValidationHelper.getBigQueryRecordsAsMap(projectId, database, tableName);
ValidationHelper.validateRecords(sourceOracleRecords, targetBigQueryRecords);
}

Expand All @@ -151,8 +161,8 @@ public static void deleteRecordAndWait() throws SQLException, ClassNotFoundExcep
}

public static void updateRecordAndWait() throws SQLException, ClassNotFoundException, InterruptedException {
OracleClient.updateRow(tableName, schemaName, updateCondition, updatedValue );
OracleClient.updateRow(tableName, schemaName, updateCondition, updatedValue);
OracleClient.forceFlushCDC();
BigQuery.waitForFlush();
}
}
}
7 changes: 5 additions & 2 deletions src/e2e-test/java/io.cdap.plugin/actions/package-info.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023.
* Copyright © 2023 Cask Data, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
Expand All @@ -14,4 +14,7 @@
* the License.
*/

package io.cdap.plugin.actions;
/**
* contains Actions methods.
*/
package io.cdap.plugin.actions;
21 changes: 5 additions & 16 deletions src/e2e-test/java/io.cdap.plugin/hooks/TestSetUpHooks.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,9 @@ public class TestSetUpHooks {
public static List<Map<String, Object>> sourceOracleRecords = new ArrayList<>();
public static String tableName = PluginPropertyUtils.pluginProp("sourceTable");
public static String schemaName = PluginPropertyUtils.pluginProp("schema");
public static String primaryKey = PluginPropertyUtils.pluginProp("primaryKey");
public static String datatypeColumns = PluginPropertyUtils.pluginProp("datatypeColumns");
public static String row1 = PluginPropertyUtils.pluginProp("datatypeValuesRow1");
public static String row2= PluginPropertyUtils.pluginProp("datatypeValuesRow2");
public static String row2 = PluginPropertyUtils.pluginProp("datatypeValuesRow2");

@Before(order = 1, value = "@ENV_VARIABLES")
public static void overridePropertiesFromEnvVarsIfProvided() {
Expand All @@ -59,7 +58,7 @@ public static void overridePropertiesFromEnvVarsIfProvided() {
PluginPropertyUtils.addPluginProp("password", password);
}
String port = System.getenv("ORACLE_PORT");
if (port!= null && !port.isEmpty()) {
if (port != null && !port.isEmpty()) {
PluginPropertyUtils.addPluginProp("port", port);
}
String oracleHost = System.getenv("ORACLE_HOST");
Expand All @@ -75,7 +74,7 @@ public static void overridePropertiesFromEnvVarsIfProvided() {

@Before(order = 2, value = "@ORACLE_SOURCE")
public static void createTable() throws SQLException, ClassNotFoundException {
OracleClient.createTable(tableName, schemaName, datatypeColumns, primaryKey);
OracleClient.createTable(tableName, schemaName, datatypeColumns);
}

@Before(order = 3, value = "@ORACLE_SOURCE")
Expand All @@ -97,16 +96,6 @@ public static void dropTables() throws SQLException, ClassNotFoundException {

@After(order = 1, value = "@BIGQUERY_DELETE")
public static void deleteTempTargetBQTable() throws IOException, InterruptedException {
try {
BigQueryClient.dropBqQuery(tableName);
BeforeActions.scenario.write("BQ Target table - " + tableName + " deleted successfully");
} catch (BigQueryException e) {
if (e.getMessage().contains("Not found: Table")) {
BeforeActions.scenario.write("BQ Target Table does not exist");
} else {
Assert.fail(e.getMessage());
}
}
BigQuery.deleteTable(tableName);
}

}
}
19 changes: 19 additions & 0 deletions src/e2e-test/java/io.cdap.plugin/hooks/package-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* Copyright (c) 2023.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
/**
* Represent Test Setup/Clean up hooks.
*/
package io.cdap.plugin.hooks;
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.How;

/**
* Oracle Plugin Locators.
*/
public class ReplicationLocators {
@FindBy(how = How.XPATH, using = "//*[contains(text(),'Next')]")
public static WebElement next;
@FindBy(how = How.XPATH, using ="//div[contains(text(),'Oracle')]")
@FindBy(how = How.XPATH, using = "//div[contains(text(),'Oracle')]")
public static WebElement oraclePlugin;
public static WebElement selectTable(String tableName) {
return SeleniumDriver.getDriver().findElement(By.xpath("//div[contains(text(),'" + tableName + "')]" +
Expand All @@ -46,4 +48,4 @@ public static WebElement selectTable(String tableName) {
@FindBy(how = How.XPATH, using = "//*[contains(text(),'Stopped')]")
public static WebElement stopped;
public static By start = By.xpath("//*[contains(@class, 'icon-play ')]");
}
}
6 changes: 4 additions & 2 deletions src/e2e-test/java/io.cdap.plugin/locators/package-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,7 @@
* License for the specific language governing permissions and limitations under
* the License.
*/

package io.cdap.plugin.locators;
/**
* contains CDF Oracle Replicator plugin locators.
*/
package io.cdap.plugin.locators;
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@

import java.io.IOException;
import java.sql.SQLException;

/**
* Contains Oracle replication test scenarios step definitions.
*/
public class StepDefinition implements CdfHelper {
@Given("Open DataFusion Project with replication to configure pipeline")
public void openDataFusionProjectWithReplicationToConfigurePipeline() throws IOException, InterruptedException {
Expand Down Expand Up @@ -92,7 +94,8 @@ public void triggerUpdateCdcEvent() throws IOException, InterruptedException, SQ
ReplicationActions.updateRecordAndWait(); //JCoException,
}
@Then("Verify expected Oracle records in target BigQuery table")
public void verifyExpectedOracleRecordsInTargetBigQueryTable() throws IOException, InterruptedException, SQLException, ClassNotFoundException {
public void verifyExpectedOracleRecordsInTargetBigQueryTable() throws
IOException, InterruptedException, SQLException, ClassNotFoundException {
ReplicationActions.verifyTargetBigQueryRecordMatchesExpectedOracleRecord();
}

Expand Down
19 changes: 19 additions & 0 deletions src/e2e-test/java/io.cdap.plugin/stepsdesign/package-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* Copyright (c) 2023.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
/**
* Contains Oracle replication test scenarios step definitions.
*/
package io.cdap.plugin.stepsdesign;
9 changes: 4 additions & 5 deletions src/e2e-test/java/io.cdap.plugin/tests/TestRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,11 @@
*/
@RunWith(Cucumber.class)
@CucumberOptions(
features = {"src/e2e-test/features"},
glue = {"stepsdesign", "io.cdap.plugin.stepsdesign"},
features = {"e2e-test/features"},
glue = {"stepsdesign", "io.cdap.plugin.stepsdesign", "io.cdap.plugin.hooks"},
tags = {"@Oracle"}, monochrome = true,
plugin = {"pretty", "html:target/cucumber-html-report/oracle",
"json:target/cucumber-reports/cucumber-oracle.json",
"junit:target/cucumber-reports/cucumber-oracle.xml"}
plugin = {"pretty", "html:target/cucumber-html-report", "json:target/cucumber-reports/cucumber.json",
"junit:target/cucumber-reports/cucumber.xml"}
)
public class TestRunner {
}
8 changes: 5 additions & 3 deletions src/e2e-test/java/io.cdap.plugin/utils/BigQuery.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,17 @@

import java.io.IOException;
import java.util.concurrent.TimeUnit;

/**
* Contains bq helper methods used in e2e tests.
*/
public class BigQuery {
public static void waitForFlush() throws InterruptedException {
int flushInterval = Integer.parseInt(PluginPropertyUtils.pluginProp("loadInterval"));
TimeUnit time = TimeUnit.SECONDS;
time.sleep(2 * flushInterval + 60);
}

public static void deleteTable(String tableName) throws IOException, InterruptedException{
public static void deleteTable(String tableName) throws IOException, InterruptedException {
try {
BigQueryClient.dropBqQuery(tableName);
BeforeActions.scenario.write("BQ Target table - " + tableName + " deleted successfully");
Expand All @@ -44,4 +46,4 @@ public static void deleteTable(String tableName) throws IOException, Interrupted
}
}
}
}
}
Loading

0 comments on commit 5294941

Please sign in to comment.