Skip to content

Commit

Permalink
Re-work
Browse files Browse the repository at this point in the history
  • Loading branch information
satyamsufi committed Mar 2, 2023
1 parent 59ac3cc commit 3833653
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 22 deletions.
4 changes: 2 additions & 2 deletions src/e2e-test/features/zendesksource/RunTimeWithMacros.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
12 changes: 6 additions & 6 deletions src/e2e-test/java/io/cdap/plugin/tests/hooks/TestSetupHooks.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 groupResponse = "";
public static String credentials = "";


@Before(order = 1, value = "@CREATE_GROUP")
Expand All @@ -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);
groupResponse = DataValidationHelper.createGroup(credentials, jsonBody);
}

@Before(order = 1, value = "@BQ_SINK")
Expand Down Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
Expand All @@ -47,4 +48,4 @@ public static void deleteGroup(String cred) {
.header("authorization", cred)
.delete(baseURI + "/groups/" + ZendeskPropertiesPageActions.uniqueId + ".json");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,14 @@ public static void selectDropdowWithMultipleOptionsForObjectsToSkip(List<String>

public static void verifyIfRecordCreatedInSinkForSingleObjectIsCorrect()
throws IOException, InterruptedException {
JsonObject expectedOutputAsJson = gson.fromJson(TestSetupHooks.testdata_Group, JsonObject.class);
JsonObject expectedOutputAsJson = gson.fromJson(TestSetupHooks.groupResponse, 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 {
Expand All @@ -116,12 +114,10 @@ public static void verifyIfRecordCreatedInSinkForMultipleObjectsAreCorrect(Strin
expectedOutput.add(line);
}
}

List<String> 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);
Expand All @@ -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) {
Expand Down
3 changes: 3 additions & 0 deletions src/e2e-test/resources/pluginParameters.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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<ValidationFailure> failures = ve.getFailures();
Expand Down Expand Up @@ -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<ValidationFailure> failures = ve.getFailures();
Expand Down

0 comments on commit 3833653

Please sign in to comment.