Skip to content

Commit 6a61429

Browse files
[CUS-11625] added nlps to fetch and update the tdp values. (#368)
1 parent 5099e11 commit 6a61429

49 files changed

Lines changed: 2784 additions & 55 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

iterating_through_columns_in_tdps/pom.xml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<modelVersion>4.0.0</modelVersion>
77
<groupId>com.testsigma.addons</groupId>
88
<artifactId>iterating_through_columns_in_tdps</artifactId>
9-
<version>1.0.0</version>
9+
<version>1.0.6</version>
1010
<packaging>jar</packaging>
1111

1212
<properties>
@@ -71,7 +71,16 @@
7171
<artifactId>httpclient</artifactId>
7272
<version>4.5.14</version>
7373
</dependency>
74-
74+
<dependency>
75+
<groupId>org.apache.commons</groupId>
76+
<artifactId>commons-lang3</artifactId>
77+
<version>3.17.0</version>
78+
</dependency>
79+
<dependency>
80+
<groupId>com.squareup.okhttp3</groupId>
81+
<artifactId>okhttp</artifactId>
82+
<version>5.0.0-alpha.12</version>
83+
</dependency>
7584
</dependencies>
7685
<build>
7786
<finalName>iterating_through_columns_in_tdps</finalName>
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package com.testsigma.addons.android;
2+
3+
import com.testsigma.addons.util.TDPApiUtil;
4+
import com.testsigma.sdk.AndroidAction;
5+
import com.testsigma.sdk.ApplicationType;
6+
import com.testsigma.sdk.Result;
7+
import com.testsigma.sdk.annotation.Action;
8+
import com.testsigma.sdk.annotation.TestData;
9+
import org.openqa.selenium.NoSuchElementException;
10+
11+
@Action(actionText = "add new column column-name with default value default-value to TDP tdp-id" +
12+
" using the apikey api-key",
13+
description = "Adds a new parameter/column to an existing TDP with the specified default value for all rows.",
14+
applicationType = ApplicationType.ANDROID,
15+
useCustomScreenshot = false)
16+
public class AddColumnToTDP extends AndroidAction {
17+
18+
@TestData(reference = "tdp-id")
19+
private com.testsigma.sdk.TestData tdpId;
20+
@TestData(reference = "column-name")
21+
private com.testsigma.sdk.TestData columnName;
22+
@TestData(reference = "default-value")
23+
private com.testsigma.sdk.TestData defaultValue;
24+
@TestData(reference = "api-key")
25+
private com.testsigma.sdk.TestData apiKey;
26+
27+
@Override
28+
public Result execute() throws NoSuchElementException {
29+
logger.info("Initiating AddColumnToTDP execution");
30+
String tdpIdStr = tdpId.getValue().toString().trim();
31+
String colName = columnName.getValue().toString().trim();
32+
String defValue = defaultValue.getValue().toString().trim();
33+
String apiKeyStr = apiKey.getValue().toString().trim();
34+
logger.info("TDP ID: " + tdpIdStr + ", Column: " + colName + ", Default Value: " + defValue);
35+
if (colName.isEmpty()) {
36+
setErrorMessage("Column name cannot be empty");
37+
return Result.FAILED;
38+
}
39+
try {
40+
TDPApiUtil.addTDPColumn(tdpIdStr, colName, defValue, apiKeyStr, logger);
41+
logger.info("New column added to TDP successfully");
42+
setSuccessMessage("Successfully added new column <b>" + colName + "</b> with default value <b>" + defValue + "</b> to all rows in TDP");
43+
return Result.SUCCESS;
44+
} catch (Exception e) {
45+
logger.info("Error occurred while adding column to TDP: " + e.getMessage());
46+
setErrorMessage("Failed to add column to TDP: " + e.getMessage());
47+
return Result.FAILED;
48+
}
49+
}
50+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package com.testsigma.addons.android;
2+
3+
import com.testsigma.addons.util.TDPApiUtil;
4+
import com.testsigma.sdk.AndroidAction;
5+
import com.testsigma.sdk.ApplicationType;
6+
import com.testsigma.sdk.Result;
7+
import com.testsigma.sdk.annotation.Action;
8+
import com.testsigma.sdk.annotation.TestData;
9+
import org.openqa.selenium.NoSuchElementException;
10+
11+
@Action(actionText = "add new row row-name to TDP tdp-id using the apikey api-key",
12+
description = "Adds a new row/set to an existing TDP with empty values for all existing parameters.",
13+
applicationType = ApplicationType.ANDROID,
14+
useCustomScreenshot = false)
15+
public class AddNewRowToTDP extends AndroidAction {
16+
17+
@TestData(reference = "tdp-id")
18+
private com.testsigma.sdk.TestData tdpId;
19+
@TestData(reference = "row-name")
20+
private com.testsigma.sdk.TestData rowName;
21+
@TestData(reference = "api-key")
22+
private com.testsigma.sdk.TestData apiKey;
23+
24+
@Override
25+
public Result execute() throws NoSuchElementException {
26+
logger.info("Initiating AddNewRowToTDP execution");
27+
String tdpIdStr = tdpId.getValue().toString().trim();
28+
String rowNameStr = rowName.getValue().toString().trim();
29+
String apiKeyStr = apiKey.getValue().toString().trim();
30+
try {
31+
TDPApiUtil.addTDPRowWithEmptyData(tdpIdStr, rowNameStr, apiKeyStr, logger);
32+
setSuccessMessage("Successfully added new row <b>" + rowNameStr + "</b> to TDP with empty parameter values");
33+
return Result.SUCCESS;
34+
} catch (Exception e) {
35+
setErrorMessage("Failed to add new row to TDP: " + e.getMessage());
36+
return Result.FAILED;
37+
}
38+
}
39+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
package com.testsigma.addons.android;
2+
3+
import com.testsigma.addons.util.TDPApiUtil;
4+
import com.testsigma.sdk.AndroidAction;
5+
import com.testsigma.sdk.ApplicationType;
6+
import com.testsigma.sdk.annotation.Action;
7+
import com.testsigma.sdk.annotation.TestData;
8+
import com.testsigma.sdk.annotation.RunTimeData;
9+
import org.openqa.selenium.NoSuchElementException;
10+
11+
import java.util.Map;
12+
13+
@Action(actionText = "get entire row from TDP tdp-id for the set name set-name using the apikey api-key and" +
14+
" store data in the run time variable runtime-variable",
15+
description = "Get entire row from TDP",
16+
applicationType = ApplicationType.ANDROID,
17+
useCustomScreenshot = false)
18+
public class GetEntireRowFromTDP extends AndroidAction {
19+
20+
@TestData(reference = "tdp-id")
21+
private com.testsigma.sdk.TestData testData1;
22+
@TestData(reference = "set-name")
23+
private com.testsigma.sdk.TestData testData2;
24+
@TestData(reference = "api-key")
25+
private com.testsigma.sdk.TestData testData3;
26+
@TestData(reference = "runtime-variable", isRuntimeVariable = true)
27+
private com.testsigma.sdk.TestData testData4;
28+
@RunTimeData
29+
private com.testsigma.sdk.RunTimeData runTimeData;
30+
31+
@Override
32+
public com.testsigma.sdk.Result execute() throws NoSuchElementException {
33+
logger.info("Initiating execution");
34+
try {
35+
String tdpId = testData1.getValue().toString();
36+
String setName = testData2.getValue().toString();
37+
String apiKey = testData3.getValue().toString();
38+
Map<String, String> parameterValues = TDPApiUtil.getTDPIterationData(tdpId, setName, apiKey, logger);
39+
String resultVariable = "";
40+
for (Map.Entry<String, String> entry : parameterValues.entrySet()) {
41+
String key = entry.getKey();
42+
if (key.equals("S.No.") || key.equals("ETF") || key.equals("Set Name")) continue;
43+
resultVariable += entry.getValue() + ", ";
44+
}
45+
resultVariable = resultVariable.substring(0, resultVariable.length() - 2);
46+
runTimeData.setValue(resultVariable);
47+
runTimeData.setKey(testData4.getValue().toString());
48+
logger.info("Successfully retrieved and stored data for iteration: " + setName);
49+
return com.testsigma.sdk.Result.SUCCESS;
50+
} catch (Exception e) {
51+
logger.warn("Error occurred while processing TDP data: " + e.getMessage());
52+
setErrorMessage("Error occurred while processing TDP data: " + e.getMessage());
53+
return com.testsigma.sdk.Result.FAILED;
54+
}
55+
}
56+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package com.testsigma.addons.android;
2+
3+
import com.testsigma.addons.util.TDPApiUtil;
4+
import com.testsigma.sdk.AndroidAction;
5+
import com.testsigma.sdk.ApplicationType;
6+
import com.testsigma.sdk.annotation.Action;
7+
import com.testsigma.sdk.annotation.TestData;
8+
import com.testsigma.sdk.annotation.RunTimeData;
9+
10+
import java.util.Map;
11+
12+
@Action(actionText = "store total column count of TDP tdp-id for the set name set-name using the apikey" +
13+
" api-key into variable column-count-variable",
14+
description = "Get total column count of TDP",
15+
applicationType = ApplicationType.ANDROID,
16+
useCustomScreenshot = false)
17+
public class GetTDPColumncount extends AndroidAction {
18+
19+
@TestData(reference = "tdp-id")
20+
private com.testsigma.sdk.TestData testData1;
21+
@TestData(reference = "set-name")
22+
private com.testsigma.sdk.TestData testData2;
23+
@TestData(reference = "api-key")
24+
private com.testsigma.sdk.TestData testData3;
25+
@TestData(reference = "column-count-variable", isRuntimeVariable = true)
26+
private com.testsigma.sdk.TestData testData4;
27+
@RunTimeData
28+
private com.testsigma.sdk.RunTimeData runTimeData;
29+
30+
@Override
31+
public com.testsigma.sdk.Result execute() {
32+
logger.info("Initiating execution");
33+
try {
34+
String tdpId = testData1.getValue().toString();
35+
String setName = testData2.getValue().toString();
36+
String apiKey = testData3.getValue().toString();
37+
Map<String, String> parameterValues = TDPApiUtil.getTDPIterationData(tdpId, setName, apiKey, logger);
38+
int totalColumnCount = parameterValues.size();
39+
runTimeData.setKey(testData4.getValue().toString());
40+
runTimeData.setValue(String.valueOf(totalColumnCount));
41+
logger.info("Total column count: " + totalColumnCount);
42+
return com.testsigma.sdk.Result.SUCCESS;
43+
} catch (Exception e) {
44+
logger.info("Error occurred while getting total column count of TDP: " + e.getMessage());
45+
setErrorMessage("Error occurred while getting total column count: " + e.getMessage());
46+
return com.testsigma.sdk.Result.FAILED;
47+
}
48+
}
49+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package com.testsigma.addons.android;
2+
3+
import com.testsigma.addons.util.TDPApiUtil;
4+
import com.testsigma.sdk.AndroidAction;
5+
import com.testsigma.sdk.ApplicationType;
6+
import com.testsigma.sdk.Result;
7+
import com.testsigma.sdk.annotation.Action;
8+
import com.testsigma.sdk.annotation.RunTimeData;
9+
import com.testsigma.sdk.annotation.TestData;
10+
import org.openqa.selenium.NoSuchElementException;
11+
12+
import java.util.Map;
13+
14+
@Action(actionText = "get TDP tdp-id value for set name set-name and parameter parameter-name" +
15+
" using the apikey api-key and store in variable runtime-variable",
16+
description = "Gets the value of a specific parameter/column for a given set name in the TDP" +
17+
" and stores it in a runtime variable.",
18+
applicationType = ApplicationType.ANDROID,
19+
useCustomScreenshot = false)
20+
public class GetTDPValue extends AndroidAction {
21+
22+
@TestData(reference = "tdp-id")
23+
private com.testsigma.sdk.TestData tdpId;
24+
@TestData(reference = "set-name")
25+
private com.testsigma.sdk.TestData setName;
26+
@TestData(reference = "parameter-name")
27+
private com.testsigma.sdk.TestData parameterName;
28+
@TestData(reference = "api-key")
29+
private com.testsigma.sdk.TestData apiKey;
30+
@TestData(reference = "runtime-variable", isRuntimeVariable = true)
31+
private com.testsigma.sdk.TestData runtimeVariable;
32+
@RunTimeData
33+
private com.testsigma.sdk.RunTimeData runTimeData;
34+
35+
@Override
36+
public Result execute() throws NoSuchElementException {
37+
logger.info("Initiating GetTDPValue execution");
38+
String tdpIdStr = tdpId.getValue().toString().trim();
39+
String setNameStr = setName.getValue().toString().trim();
40+
String paramName = parameterName.getValue().toString().trim();
41+
String apiKeyStr = apiKey.getValue().toString().trim();
42+
try {
43+
Map<String, String> parameterValues = TDPApiUtil.getTDPIterationData(tdpIdStr, setNameStr, apiKeyStr, logger);
44+
if (!parameterValues.containsKey(paramName)) {
45+
setErrorMessage("Parameter <b>" + paramName + "</b> not found in set <b>" + setNameStr + "</b>. Available parameters: " + parameterValues.keySet());
46+
return Result.FAILED;
47+
}
48+
String value = parameterValues.get(paramName);
49+
runTimeData.setKey(runtimeVariable.getValue().toString());
50+
runTimeData.setValue(value);
51+
setSuccessMessage("Successfully retrieved parameter <b>" + paramName + "</b> = <b>" + value + "</b> from set <b>" + setNameStr + "</b>");
52+
return Result.SUCCESS;
53+
} catch (Exception e) {
54+
setErrorMessage("Failed to get TDP value: " + e.getMessage());
55+
return Result.FAILED;
56+
}
57+
}
58+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package com.testsigma.addons.android;
2+
3+
import com.testsigma.sdk.AndroidAction;
4+
import com.testsigma.sdk.ApplicationType;
5+
import com.testsigma.sdk.annotation.Action;
6+
import com.testsigma.sdk.annotation.TestData;
7+
import com.testsigma.sdk.annotation.RunTimeData;
8+
9+
import java.util.Objects;
10+
11+
@Action(actionText = "set TDP iterator TDP_ITERATOR_KEY_NAME value to 0",
12+
description = "Set TDP iterator TDP_ITERATOR_KEY_NAME to 0",
13+
applicationType = ApplicationType.ANDROID,
14+
useCustomScreenshot = false)
15+
public class SetTDpIteratorToZero extends AndroidAction {
16+
17+
@TestData(reference = "TDP_ITERATOR_KEY_NAME", isRuntimeVariable = true)
18+
private com.testsigma.sdk.TestData testData1;
19+
@RunTimeData
20+
private com.testsigma.sdk.RunTimeData runTimeData;
21+
22+
@Override
23+
public com.testsigma.sdk.Result execute() {
24+
logger.info("Initiating execution");
25+
if (!Objects.equals(testData1.getValue().toString(), "TDP_ITERATOR_KEY_NAME")) {
26+
setErrorMessage("Don't change the TDP_ITERATOR_KEY_NAME variable name");
27+
return com.testsigma.sdk.Result.FAILED;
28+
}
29+
try {
30+
runTimeData.setValue("0");
31+
runTimeData.setKey("TDP_ITERATOR_KEY_NAME");
32+
setSuccessMessage("Set TDP iterator TDP_ITERATOR_KEY_NAME to 0");
33+
return com.testsigma.sdk.Result.SUCCESS;
34+
} catch (Exception e) {
35+
setErrorMessage("Error occurred while setting runtime variable to 0: " + e.getMessage());
36+
return com.testsigma.sdk.Result.FAILED;
37+
}
38+
}
39+
}

0 commit comments

Comments
 (0)