From dcc46a5a6c6acc9acc955fb731723c2f0c15baf1 Mon Sep 17 00:00:00 2001 From: Harshdeep Singh Pruthi Date: Tue, 6 Aug 2024 17:16:03 +0530 Subject: [PATCH] e2e test fix after error prop using servicenowapiexception --- .../ServiceNowSinkPropertiesPageActions.java | 7 ++++--- .../stepsdesign/DesignTimeSteps.java | 5 +++-- .../io/cdap/plugin/tests/hooks/TestSetupHooks.java | 14 +++++++++----- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/e2e-test/java/io/cdap/plugin/servicenowsink/actions/ServiceNowSinkPropertiesPageActions.java b/src/e2e-test/java/io/cdap/plugin/servicenowsink/actions/ServiceNowSinkPropertiesPageActions.java index fdb04018..07748075 100644 --- a/src/e2e-test/java/io/cdap/plugin/servicenowsink/actions/ServiceNowSinkPropertiesPageActions.java +++ b/src/e2e-test/java/io/cdap/plugin/servicenowsink/actions/ServiceNowSinkPropertiesPageActions.java @@ -22,6 +22,7 @@ import io.cdap.e2e.utils.AssertionHelper; import io.cdap.e2e.utils.BigQueryClient; import io.cdap.e2e.utils.PluginPropertyUtils; +import io.cdap.plugin.servicenow.apiclient.ServiceNowAPIException; import io.cdap.plugin.servicenow.apiclient.ServiceNowTableAPIClientImpl; import io.cdap.plugin.servicenow.locators.ServiceNowPropertiesPage; import io.cdap.plugin.servicenow.source.ServiceNowSourceConfig; @@ -50,7 +51,7 @@ public class ServiceNowSinkPropertiesPageActions { private static Gson gson = new Gson(); public static void getRecordFromServiceNowTable(String query, String tableName) - throws OAuthProblemException, OAuthSystemException, IOException { + throws ServiceNowAPIException { config = new ServiceNowSourceConfig( "", "", "", "", "", System.getenv("SERVICE_NOW_CLIENT_ID"), @@ -65,7 +66,7 @@ public static void getRecordFromServiceNowTable(String query, String tableName) } public static void verifyIfRecordCreatedInServiceNowIsCorrect(String query, String tableName) - throws IOException, InterruptedException, OAuthProblemException, OAuthSystemException { + throws IOException, InterruptedException, ServiceNowAPIException { getRecordFromServiceNowTable(query, tableName); TableResult bigQueryTableData = getBigQueryTableData(TestSetupHooks.bqSourceDataset, TestSetupHooks.bqSourceTable); @@ -79,7 +80,7 @@ public static void verifyIfRecordCreatedInServiceNowIsCorrect(String query, Stri } public static void verifyIfRecordUpdatedInServiceNowIsCorrect(String query, String tableName) - throws IOException, InterruptedException, OAuthProblemException, OAuthSystemException { + throws IOException, InterruptedException, ServiceNowAPIException { getRecordFromServiceNowTable(query, tableName); TableResult bigQueryTableData = getBigQueryTableData(TestSetupHooks.bqSourceDataset, TestSetupHooks.bqSourceTable); diff --git a/src/e2e-test/java/io/cdap/plugin/servicenowsink/stepsdesign/DesignTimeSteps.java b/src/e2e-test/java/io/cdap/plugin/servicenowsink/stepsdesign/DesignTimeSteps.java index 5bef71f1..3252c526 100644 --- a/src/e2e-test/java/io/cdap/plugin/servicenowsink/stepsdesign/DesignTimeSteps.java +++ b/src/e2e-test/java/io/cdap/plugin/servicenowsink/stepsdesign/DesignTimeSteps.java @@ -17,6 +17,7 @@ package io.cdap.plugin.servicenowsink.stepsdesign; import io.cdap.e2e.utils.PluginPropertyUtils; +import io.cdap.plugin.servicenow.apiclient.ServiceNowAPIException; import io.cdap.plugin.servicenow.util.ServiceNowConstants; import io.cdap.plugin.servicenowsink.actions.ServiceNowSinkPropertiesPageActions; import io.cdap.plugin.tests.hooks.TestSetupHooks; @@ -36,7 +37,7 @@ public class DesignTimeSteps { @And("Verify If new record created in ServiceNow application for table {string} is correct") public void verifyIfNewRecordCreatedInServiceNowApplicationForTableIsCorrect(String tableName) - throws IOException, InterruptedException, OAuthProblemException, OAuthSystemException { + throws IOException, InterruptedException, ServiceNowAPIException { String tableValueFromPluginPropertiesFile = PluginPropertyUtils.pluginProp(tableName); switch (tableValueFromPluginPropertiesFile) { @@ -57,7 +58,7 @@ public void verifyIfNewRecordCreatedInServiceNowApplicationForTableIsCorrect(Str @Then("Verify If an updated record in ServiceNow application for table {string} is correct") public void verifyIfAnUpdatedRecordInServiceNowApplicationForTableIsCorrect(String tableName) - throws OAuthProblemException, OAuthSystemException, IOException, InterruptedException { + throws IOException, InterruptedException, ServiceNowAPIException { String tableValueFromPluginPropertiesFile = PluginPropertyUtils.pluginProp(tableName); query = ServiceNowConstants.SYSTEM_ID + "=" + TestSetupHooks.systemId; ServiceNowSinkPropertiesPageActions.verifyIfRecordUpdatedInServiceNowIsCorrect(query, diff --git a/src/e2e-test/java/io/cdap/plugin/tests/hooks/TestSetupHooks.java b/src/e2e-test/java/io/cdap/plugin/tests/hooks/TestSetupHooks.java index ee4e27a8..9858f005 100644 --- a/src/e2e-test/java/io/cdap/plugin/tests/hooks/TestSetupHooks.java +++ b/src/e2e-test/java/io/cdap/plugin/tests/hooks/TestSetupHooks.java @@ -19,6 +19,7 @@ import com.google.cloud.bigquery.BigQueryException; import io.cdap.e2e.utils.BigQueryClient; import io.cdap.e2e.utils.PluginPropertyUtils; +import io.cdap.plugin.servicenow.apiclient.ServiceNowAPIException; import io.cdap.plugin.servicenow.apiclient.ServiceNowTableAPIClientImpl; import io.cdap.plugin.servicenow.source.ServiceNowSourceConfig; import io.cdap.plugin.utils.enums.ApplicationInReportingMode; @@ -62,7 +63,7 @@ public static void initializeServiceNowSourceConfig() { } @Before(order = 2, value = "@SN_PRODUCT_CATALOG_ITEM") - public static void createRecordInProductCatalogItemTable() throws IOException { + public static void createRecordInProductCatalogItemTable() throws IOException, ServiceNowAPIException { BeforeActions.scenario.write("Create new record in Product Catalog Item table"); ServiceNowTableAPIClientImpl tableAPIClient = new ServiceNowTableAPIClientImpl(config.getConnection()); String uniqueId = "TestProductCatalogItem" + RandomStringUtils.randomAlphanumeric(10); @@ -72,7 +73,8 @@ public static void createRecordInProductCatalogItemTable() throws IOException { } @Before(order = 2, value = "@SN_RECEIVING_SLIP_LINE") - public static void createRecordInReceivingSlipLineTable() throws IOException { + public static void createRecordInReceivingSlipLineTable() + throws IOException, ServiceNowAPIException { BeforeActions.scenario.write("Create new record in Receiving Slip Line table"); ServiceNowTableAPIClientImpl tableAPIClient = new ServiceNowTableAPIClientImpl(config.getConnection()); String uniqueId = "TestReceivingSlipLine" + RandomStringUtils.randomAlphanumeric(10); @@ -82,7 +84,8 @@ public static void createRecordInReceivingSlipLineTable() throws IOException { } @Before(order = 2, value = "@SN_UPDATE_AGENT_ASSIST_RECOMMENDATION") - public static void updateRecordInAgentAssistRecommendationTable() throws IOException { + public static void updateRecordInAgentAssistRecommendationTable() + throws IOException, ServiceNowAPIException { BeforeActions.scenario.write("Create new record in Agent Assist Recommendation table"); ServiceNowTableAPIClientImpl tableAPIClient = new ServiceNowTableAPIClientImpl(config.getConnection()); String uniqueId = "TestAgentAssist" + RandomStringUtils.randomAlphanumeric(10); @@ -92,7 +95,8 @@ public static void updateRecordInAgentAssistRecommendationTable() throws IOExcep } @Before(order = 2, value = "@SN_UPDATE_VENDOR_CATALOG_ITEM") - public static void updateRecordInAgentVendorCatalogItem() throws IOException { + public static void updateRecordInAgentVendorCatalogItem() + throws IOException, ServiceNowAPIException { BeforeActions.scenario.write("Create new record in Vendor Catalog Item table"); ServiceNowTableAPIClientImpl tableAPIClient = new ServiceNowTableAPIClientImpl(config.getConnection()); String uniqueId = "TestVendorCatalog" + RandomStringUtils.randomAlphanumeric(10); @@ -102,7 +106,7 @@ public static void updateRecordInAgentVendorCatalogItem() throws IOException { } @Before(order = 2, value = "@SN_UPDATE_SERVICE_OFFERING") - public static void updateRecordInServiceOffering() throws IOException { + public static void updateRecordInServiceOffering() throws IOException, ServiceNowAPIException { BeforeActions.scenario.write("Create new record in Service Offering table"); ServiceNowTableAPIClientImpl tableAPIClient = new ServiceNowTableAPIClientImpl(config.getConnection()); String uniqueId = "TestServiceOffering" + RandomStringUtils.randomAlphanumeric(10);