From 230dd4ec26053feaa6c69bcdbb10129417d20dcb Mon Sep 17 00:00:00 2001 From: satyamsufi Date: Thu, 2 Mar 2023 12:21:41 +0530 Subject: [PATCH] Re-work --- .../features/zendesksource/RunTimeWithMacros.feature | 4 ++-- .../io/cdap/plugin/tests/hooks/TestSetupHooks.java | 12 ++++++------ .../plugin/zendesk/actions/DataValidationHelper.java | 5 +++-- .../actions/ZendeskPropertiesPageActions.java | 10 +++------- src/e2e-test/resources/pluginParameters.properties | 3 +++ .../source/batch/ZendeskBatchSourceConfigTest.java | 10 +++++----- 6 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/e2e-test/features/zendesksource/RunTimeWithMacros.feature b/src/e2e-test/features/zendesksource/RunTimeWithMacros.feature index 1bdd748..97fbc58 100644 --- a/src/e2e-test/features/zendesksource/RunTimeWithMacros.feature +++ b/src/e2e-test/features/zendesksource/RunTimeWithMacros.feature @@ -17,7 +17,7 @@ @Regression Feature: Zendesk Source - Run time scenarios - @TS-ZD-RNTM-MACRO-01 @BQ_SINK @BQ_SINK_CLEANUP @TEST_DATA @DELETE_TEST_DATA + @TS-ZD-RNTM-MACRO-01 @BQ_SINK @BQ_SINK_CLEANUP @CREATE_GROUP @DELETE_GROUP Scenario: Verify user should be able to preview and deploy the pipeline when plugin is configured for a Non hierarchical Object with macros When Open Datafusion Project to configure pipeline And Select plugin: "Zendesk" from the plugins list as: "Source" @@ -71,7 +71,7 @@ Feature: Zendesk Source - Run time scenarios And Close the pipeline logs Then Validate record created in Sink application for Single object is equal to expected output file - @TS-ZD-RNTM-MACRO-02 @BQ_SINK @BQ_SINK_CLEANUP @TEST_DATA @DELETE_TEST_DATA + @TS-ZD-RNTM-MACRO-02 @BQ_SINK @BQ_SINK_CLEANUP @CREATE_GROUP @DELETE_GROUP Scenario: Verify user should be able to preview and deploy the pipeline when plugin is configured for Advanced Properties with macros When Open Datafusion Project to configure pipeline And Select plugin: "Zendesk" from the plugins list as: "Source" 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 fca4615..1a8732d 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 @@ -33,8 +33,8 @@ * Represents Test Setup and Clean up hooks. */ public class TestSetupHooks { - public static String testdata_Group = ""; - public static String cred = ""; + public static String testdataGroup = ""; + public static String credentials = ""; @Before(order = 1, value = "@CREATE_GROUP") @@ -44,9 +44,9 @@ public void createGroup() { String password = System.getenv("ZENDESK_PASSWORD"); String auth = email + ":" + password; String encodedAuth = encoder.encodeToString(auth.getBytes()); - cred = "Basic " + encodedAuth; + credentials = "Basic " + encodedAuth; String jsonBody = "{\"group\": {\"name\": \"My Group" + RandomStringUtils.randomAlphanumeric(10) + "\"}}"; - testdata_Group = DataValidationHelper.createGroup(cred, jsonBody); + testdataGroup = DataValidationHelper.createGroup(credentials, jsonBody); } @Before(order = 1, value = "@BQ_SINK") @@ -95,6 +95,6 @@ public void deleteMultiSourceTargetBQTable() throws IOException, InterruptedExce } @After(order = 2, value = "@DELETE_GROUP") public void deleteGroup() { - DataValidationHelper.deleteGroup(cred); - } + DataValidationHelper.deleteGroup(credentials); } +} diff --git a/src/e2e-test/java/io/cdap/plugin/zendesk/actions/DataValidationHelper.java b/src/e2e-test/java/io/cdap/plugin/zendesk/actions/DataValidationHelper.java index a2ee62b..b908d33 100644 --- a/src/e2e-test/java/io/cdap/plugin/zendesk/actions/DataValidationHelper.java +++ b/src/e2e-test/java/io/cdap/plugin/zendesk/actions/DataValidationHelper.java @@ -16,6 +16,7 @@ package io.cdap.plugin.zendesk.actions; +import io.cdap.e2e.utils.PluginPropertyUtils; import io.restassured.http.ContentType; import io.restassured.response.Response; import io.restassured.response.ResponseBody; @@ -26,7 +27,7 @@ * Zendesk utility - enhancements. */ public class DataValidationHelper { - private static String baseURI = "https://cloudsufi.zendesk.com/api/v2"; + private static String baseURI = PluginPropertyUtils.pluginProp("base.URI"); public static String createGroup(String cred, String jsonBody) { Response response = given() .header("authorization", cred) @@ -47,4 +48,4 @@ public static void deleteGroup(String cred) { .header("authorization", cred) .delete(baseURI + "/groups/" + ZendeskPropertiesPageActions.uniqueId + ".json"); } - } +} diff --git a/src/e2e-test/java/io/cdap/plugin/zendesk/actions/ZendeskPropertiesPageActions.java b/src/e2e-test/java/io/cdap/plugin/zendesk/actions/ZendeskPropertiesPageActions.java index f736e75..dbff8bd 100644 --- a/src/e2e-test/java/io/cdap/plugin/zendesk/actions/ZendeskPropertiesPageActions.java +++ b/src/e2e-test/java/io/cdap/plugin/zendesk/actions/ZendeskPropertiesPageActions.java @@ -96,16 +96,14 @@ public static void selectDropdowWithMultipleOptionsForObjectsToSkip(List public static void verifyIfRecordCreatedInSinkForSingleObjectIsCorrect() throws IOException, InterruptedException { - JsonObject expectedOutputAsJson = gson.fromJson(TestSetupHooks.testdata_Group, JsonObject.class); + JsonObject expectedOutputAsJson = gson.fromJson(TestSetupHooks.testdataGroup, JsonObject.class); JsonObject group = (JsonObject) expectedOutputAsJson.get("group"); - System.out.println(group); uniqueId = group.get("id").getAsBigInteger(); getBigQueryTableData(PluginPropertyUtils.pluginProp("dataset"), PluginPropertyUtils.pluginProp("bqtarget.table"), uniqueId); Assert.assertTrue(ZendeskPropertiesPageActions.compareValueOfBothResponses(group.toString(), bigQueryrows.get(0))); - } - + } public static void verifyIfRecordCreatedInSinkForMultipleObjectsAreCorrect(String expectedOutputFile) throws IOException, InterruptedException { @@ -116,12 +114,10 @@ public static void verifyIfRecordCreatedInSinkForMultipleObjectsAreCorrect(Strin expectedOutput.add(line); } } - List bigQueryDatasetTables = new ArrayList<>(); TableResult tablesSchema = ZendeskPropertiesPageActions.getTableNamesFromDataSet (PluginPropertyUtils.pluginProp("dataset")); tablesSchema.iterateAll().forEach(value -> bigQueryDatasetTables.add(value.get(0).getValue().toString())); - System.out.println(bigQueryDatasetTables.size()); for (int expectedRow = 0; expectedRow < expectedOutput.size(); expectedRow++) { JsonObject expectedOutputAsJson = gson.fromJson(expectedOutput.get(expectedRow), JsonObject.class); @@ -133,7 +129,7 @@ public static void verifyIfRecordCreatedInSinkForMultipleObjectsAreCorrect(Strin Assert.assertTrue(ZendeskPropertiesPageActions.compareValueOfBothResponses(expectedOutput.get(row), bigQueryrows.get(row))); } - } + } static boolean compareValueOfBothResponses(String zendeskResponse, String bigQueryResponse) { diff --git a/src/e2e-test/resources/pluginParameters.properties b/src/e2e-test/resources/pluginParameters.properties index d13ea1b..25a48c2 100644 --- a/src/e2e-test/resources/pluginParameters.properties +++ b/src/e2e-test/resources/pluginParameters.properties @@ -3,6 +3,9 @@ admin.email = ZENDESK_EMAIL admin.apitoken = ZENDESK_API_TOKEN password = ZENDESK_PASSWORD +#API +base.URI = https://cloudsufi.zendesk.com/api/v2 + #Valid Porperties admin.subdomain = cloudsufi objectstopull.group=Groups diff --git a/src/test/java/io/cdap/plugin/zendesk/source/batch/ZendeskBatchSourceConfigTest.java b/src/test/java/io/cdap/plugin/zendesk/source/batch/ZendeskBatchSourceConfigTest.java index 89dae30..b30eff6 100644 --- a/src/test/java/io/cdap/plugin/zendesk/source/batch/ZendeskBatchSourceConfigTest.java +++ b/src/test/java/io/cdap/plugin/zendesk/source/batch/ZendeskBatchSourceConfigTest.java @@ -41,7 +41,7 @@ public class ZendeskBatchSourceConfigTest { private static final String MOCK_STAGE = "mockStage"; - private static MockPipelineConfigurer pipelineConfigure = null; + private static MockPipelineConfigurer pipelineConfigurer = null; @Test public void testValidate() { @@ -352,8 +352,8 @@ public void testConfigurePipelineWithInvalidBasicParam() { ""); try { ZendeskBatchSource zendeskBatchSource = new ZendeskBatchSource(config); - pipelineConfigure = new MockPipelineConfigurer(null); - zendeskBatchSource.configurePipeline(pipelineConfigure); + pipelineConfigurer = new MockPipelineConfigurer(null); + zendeskBatchSource.configurePipeline(pipelineConfigurer); Assert.fail("Reference name validation should fail"); } catch (ValidationException ve) { List failures = ve.getFailures(); @@ -414,8 +414,8 @@ public void testConfigurePipelineMultiSourceWithInvalidBasicParam() { ""); try { ZendeskBatchMultiSource zendeskBatchMultiSource = new ZendeskBatchMultiSource(config); - pipelineConfigure = new MockPipelineConfigurer(null); - zendeskBatchMultiSource.configurePipeline(pipelineConfigure); + pipelineConfigurer = new MockPipelineConfigurer(null); + zendeskBatchMultiSource.configurePipeline(pipelineConfigurer); Assert.fail("Reference name validation should fail"); } catch (ValidationException ve) { List failures = ve.getFailures();