-
Notifications
You must be signed in to change notification settings - Fork 15
[CUS-11625] added nlps to fetch and update the tdp values. #368
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
...ng_through_columns_in_tdps/src/main/java/com/testsigma/addons/android/AddColumnToTDP.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| package com.testsigma.addons.android; | ||
|
|
||
| import com.testsigma.addons.util.TDPApiUtil; | ||
| import com.testsigma.sdk.AndroidAction; | ||
| import com.testsigma.sdk.ApplicationType; | ||
| import com.testsigma.sdk.Result; | ||
| import com.testsigma.sdk.annotation.Action; | ||
| import com.testsigma.sdk.annotation.TestData; | ||
| import org.openqa.selenium.NoSuchElementException; | ||
|
|
||
| @Action(actionText = "add new column column-name with default value default-value to TDP tdp-id" + | ||
| " using the apikey api-key", | ||
| description = "Adds a new parameter/column to an existing TDP with the specified default value for all rows.", | ||
| applicationType = ApplicationType.ANDROID, | ||
| useCustomScreenshot = false) | ||
| public class AddColumnToTDP extends AndroidAction { | ||
|
|
||
| @TestData(reference = "tdp-id") | ||
| private com.testsigma.sdk.TestData tdpId; | ||
| @TestData(reference = "column-name") | ||
| private com.testsigma.sdk.TestData columnName; | ||
| @TestData(reference = "default-value") | ||
| private com.testsigma.sdk.TestData defaultValue; | ||
| @TestData(reference = "api-key") | ||
| private com.testsigma.sdk.TestData apiKey; | ||
|
|
||
| @Override | ||
| public Result execute() throws NoSuchElementException { | ||
| logger.info("Initiating AddColumnToTDP execution"); | ||
| String tdpIdStr = tdpId.getValue().toString().trim(); | ||
| String colName = columnName.getValue().toString().trim(); | ||
| String defValue = defaultValue.getValue().toString().trim(); | ||
| String apiKeyStr = apiKey.getValue().toString().trim(); | ||
| logger.info("TDP ID: " + tdpIdStr + ", Column: " + colName + ", Default Value: " + defValue); | ||
| if (colName.isEmpty()) { | ||
| setErrorMessage("Column name cannot be empty"); | ||
| return Result.FAILED; | ||
| } | ||
| try { | ||
| TDPApiUtil.addTDPColumn(tdpIdStr, colName, defValue, apiKeyStr, logger); | ||
| logger.info("New column added to TDP successfully"); | ||
| setSuccessMessage("Successfully added new column <b>" + colName + "</b> with default value <b>" + defValue + "</b> to all rows in TDP"); | ||
| return Result.SUCCESS; | ||
| } catch (Exception e) { | ||
| logger.info("Error occurred while adding column to TDP: " + e.getMessage()); | ||
| setErrorMessage("Failed to add column to TDP: " + e.getMessage()); | ||
| return Result.FAILED; | ||
| } | ||
| } | ||
| } |
39 changes: 39 additions & 0 deletions
39
...ng_through_columns_in_tdps/src/main/java/com/testsigma/addons/android/AddNewRowToTDP.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| package com.testsigma.addons.android; | ||
|
|
||
| import com.testsigma.addons.util.TDPApiUtil; | ||
| import com.testsigma.sdk.AndroidAction; | ||
| import com.testsigma.sdk.ApplicationType; | ||
| import com.testsigma.sdk.Result; | ||
| import com.testsigma.sdk.annotation.Action; | ||
| import com.testsigma.sdk.annotation.TestData; | ||
| import org.openqa.selenium.NoSuchElementException; | ||
|
|
||
| @Action(actionText = "add new row row-name to TDP tdp-id using the apikey api-key", | ||
| description = "Adds a new row/set to an existing TDP with empty values for all existing parameters.", | ||
| applicationType = ApplicationType.ANDROID, | ||
| useCustomScreenshot = false) | ||
| public class AddNewRowToTDP extends AndroidAction { | ||
|
|
||
| @TestData(reference = "tdp-id") | ||
| private com.testsigma.sdk.TestData tdpId; | ||
| @TestData(reference = "row-name") | ||
| private com.testsigma.sdk.TestData rowName; | ||
| @TestData(reference = "api-key") | ||
| private com.testsigma.sdk.TestData apiKey; | ||
|
|
||
| @Override | ||
| public Result execute() throws NoSuchElementException { | ||
| logger.info("Initiating AddNewRowToTDP execution"); | ||
| String tdpIdStr = tdpId.getValue().toString().trim(); | ||
| String rowNameStr = rowName.getValue().toString().trim(); | ||
| String apiKeyStr = apiKey.getValue().toString().trim(); | ||
| try { | ||
| TDPApiUtil.addTDPRowWithEmptyData(tdpIdStr, rowNameStr, apiKeyStr, logger); | ||
| setSuccessMessage("Successfully added new row <b>" + rowNameStr + "</b> to TDP with empty parameter values"); | ||
| return Result.SUCCESS; | ||
| } catch (Exception e) { | ||
| setErrorMessage("Failed to add new row to TDP: " + e.getMessage()); | ||
| return Result.FAILED; | ||
| } | ||
| } | ||
| } |
56 changes: 56 additions & 0 deletions
56
...rough_columns_in_tdps/src/main/java/com/testsigma/addons/android/GetEntireRowFromTDP.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| package com.testsigma.addons.android; | ||
|
|
||
| import com.testsigma.addons.util.TDPApiUtil; | ||
| import com.testsigma.sdk.AndroidAction; | ||
| import com.testsigma.sdk.ApplicationType; | ||
| import com.testsigma.sdk.annotation.Action; | ||
| import com.testsigma.sdk.annotation.TestData; | ||
| import com.testsigma.sdk.annotation.RunTimeData; | ||
| import org.openqa.selenium.NoSuchElementException; | ||
|
|
||
| import java.util.Map; | ||
|
|
||
| @Action(actionText = "get entire row from TDP tdp-id for the set name set-name using the apikey api-key and" + | ||
| " store data in the run time variable runtime-variable", | ||
| description = "Get entire row from TDP", | ||
| applicationType = ApplicationType.ANDROID, | ||
| useCustomScreenshot = false) | ||
| public class GetEntireRowFromTDP extends AndroidAction { | ||
|
|
||
| @TestData(reference = "tdp-id") | ||
| private com.testsigma.sdk.TestData testData1; | ||
| @TestData(reference = "set-name") | ||
| private com.testsigma.sdk.TestData testData2; | ||
| @TestData(reference = "api-key") | ||
| private com.testsigma.sdk.TestData testData3; | ||
| @TestData(reference = "runtime-variable", isRuntimeVariable = true) | ||
| private com.testsigma.sdk.TestData testData4; | ||
| @RunTimeData | ||
| private com.testsigma.sdk.RunTimeData runTimeData; | ||
|
|
||
| @Override | ||
| public com.testsigma.sdk.Result execute() throws NoSuchElementException { | ||
| logger.info("Initiating execution"); | ||
| try { | ||
| String tdpId = testData1.getValue().toString(); | ||
| String setName = testData2.getValue().toString(); | ||
| String apiKey = testData3.getValue().toString(); | ||
| Map<String, String> parameterValues = TDPApiUtil.getTDPIterationData(tdpId, setName, apiKey, logger); | ||
| String resultVariable = ""; | ||
| for (Map.Entry<String, String> entry : parameterValues.entrySet()) { | ||
| String key = entry.getKey(); | ||
| if (key.equals("S.No.") || key.equals("ETF") || key.equals("Set Name")) continue; | ||
| resultVariable += entry.getValue() + ", "; | ||
| } | ||
| resultVariable = resultVariable.substring(0, resultVariable.length() - 2); | ||
| runTimeData.setValue(resultVariable); | ||
| runTimeData.setKey(testData4.getValue().toString()); | ||
| logger.info("Successfully retrieved and stored data for iteration: " + setName); | ||
| return com.testsigma.sdk.Result.SUCCESS; | ||
| } catch (Exception e) { | ||
| logger.warn("Error occurred while processing TDP data: " + e.getMessage()); | ||
| setErrorMessage("Error occurred while processing TDP data: " + e.getMessage()); | ||
| return com.testsigma.sdk.Result.FAILED; | ||
| } | ||
| } | ||
| } | ||
49 changes: 49 additions & 0 deletions
49
...through_columns_in_tdps/src/main/java/com/testsigma/addons/android/GetTDPColumncount.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| package com.testsigma.addons.android; | ||
|
|
||
| import com.testsigma.addons.util.TDPApiUtil; | ||
| import com.testsigma.sdk.AndroidAction; | ||
| import com.testsigma.sdk.ApplicationType; | ||
| import com.testsigma.sdk.annotation.Action; | ||
| import com.testsigma.sdk.annotation.TestData; | ||
| import com.testsigma.sdk.annotation.RunTimeData; | ||
|
|
||
| import java.util.Map; | ||
|
|
||
| @Action(actionText = "store total column count of TDP tdp-id for the set name set-name using the apikey" + | ||
| " api-key into variable column-count-variable", | ||
| description = "Get total column count of TDP", | ||
| applicationType = ApplicationType.ANDROID, | ||
| useCustomScreenshot = false) | ||
| public class GetTDPColumncount extends AndroidAction { | ||
|
|
||
| @TestData(reference = "tdp-id") | ||
| private com.testsigma.sdk.TestData testData1; | ||
| @TestData(reference = "set-name") | ||
| private com.testsigma.sdk.TestData testData2; | ||
| @TestData(reference = "api-key") | ||
| private com.testsigma.sdk.TestData testData3; | ||
| @TestData(reference = "column-count-variable", isRuntimeVariable = true) | ||
| private com.testsigma.sdk.TestData testData4; | ||
| @RunTimeData | ||
| private com.testsigma.sdk.RunTimeData runTimeData; | ||
|
|
||
| @Override | ||
| public com.testsigma.sdk.Result execute() { | ||
| logger.info("Initiating execution"); | ||
| try { | ||
| String tdpId = testData1.getValue().toString(); | ||
| String setName = testData2.getValue().toString(); | ||
| String apiKey = testData3.getValue().toString(); | ||
| Map<String, String> parameterValues = TDPApiUtil.getTDPIterationData(tdpId, setName, apiKey, logger); | ||
| int totalColumnCount = parameterValues.size(); | ||
| runTimeData.setKey(testData4.getValue().toString()); | ||
| runTimeData.setValue(String.valueOf(totalColumnCount)); | ||
| logger.info("Total column count: " + totalColumnCount); | ||
| return com.testsigma.sdk.Result.SUCCESS; | ||
| } catch (Exception e) { | ||
| logger.info("Error occurred while getting total column count of TDP: " + e.getMessage()); | ||
| setErrorMessage("Error occurred while getting total column count: " + e.getMessage()); | ||
| return com.testsigma.sdk.Result.FAILED; | ||
| } | ||
| } | ||
| } |
58 changes: 58 additions & 0 deletions
58
...ating_through_columns_in_tdps/src/main/java/com/testsigma/addons/android/GetTDPValue.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| package com.testsigma.addons.android; | ||
|
|
||
| import com.testsigma.addons.util.TDPApiUtil; | ||
| import com.testsigma.sdk.AndroidAction; | ||
| import com.testsigma.sdk.ApplicationType; | ||
| import com.testsigma.sdk.Result; | ||
| import com.testsigma.sdk.annotation.Action; | ||
| import com.testsigma.sdk.annotation.RunTimeData; | ||
| import com.testsigma.sdk.annotation.TestData; | ||
| import org.openqa.selenium.NoSuchElementException; | ||
|
|
||
| import java.util.Map; | ||
|
|
||
| @Action(actionText = "get TDP tdp-id value for set name set-name and parameter parameter-name" + | ||
| " using the apikey api-key and store in variable runtime-variable", | ||
| description = "Gets the value of a specific parameter/column for a given set name in the TDP" + | ||
| " and stores it in a runtime variable.", | ||
| applicationType = ApplicationType.ANDROID, | ||
| useCustomScreenshot = false) | ||
| public class GetTDPValue extends AndroidAction { | ||
|
|
||
| @TestData(reference = "tdp-id") | ||
| private com.testsigma.sdk.TestData tdpId; | ||
| @TestData(reference = "set-name") | ||
| private com.testsigma.sdk.TestData setName; | ||
| @TestData(reference = "parameter-name") | ||
| private com.testsigma.sdk.TestData parameterName; | ||
| @TestData(reference = "api-key") | ||
| private com.testsigma.sdk.TestData apiKey; | ||
| @TestData(reference = "runtime-variable", isRuntimeVariable = true) | ||
| private com.testsigma.sdk.TestData runtimeVariable; | ||
| @RunTimeData | ||
| private com.testsigma.sdk.RunTimeData runTimeData; | ||
|
|
||
| @Override | ||
| public Result execute() throws NoSuchElementException { | ||
| logger.info("Initiating GetTDPValue execution"); | ||
| String tdpIdStr = tdpId.getValue().toString().trim(); | ||
| String setNameStr = setName.getValue().toString().trim(); | ||
| String paramName = parameterName.getValue().toString().trim(); | ||
| String apiKeyStr = apiKey.getValue().toString().trim(); | ||
| try { | ||
| Map<String, String> parameterValues = TDPApiUtil.getTDPIterationData(tdpIdStr, setNameStr, apiKeyStr, logger); | ||
| if (!parameterValues.containsKey(paramName)) { | ||
| setErrorMessage("Parameter <b>" + paramName + "</b> not found in set <b>" + setNameStr + "</b>. Available parameters: " + parameterValues.keySet()); | ||
| return Result.FAILED; | ||
| } | ||
| String value = parameterValues.get(paramName); | ||
| runTimeData.setKey(runtimeVariable.getValue().toString()); | ||
| runTimeData.setValue(value); | ||
| setSuccessMessage("Successfully retrieved parameter <b>" + paramName + "</b> = <b>" + value + "</b> from set <b>" + setNameStr + "</b>"); | ||
| return Result.SUCCESS; | ||
| } catch (Exception e) { | ||
| setErrorMessage("Failed to get TDP value: " + e.getMessage()); | ||
| return Result.FAILED; | ||
| } | ||
| } | ||
| } |
39 changes: 39 additions & 0 deletions
39
...ough_columns_in_tdps/src/main/java/com/testsigma/addons/android/SetTDpIteratorToZero.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| package com.testsigma.addons.android; | ||
|
|
||
| import com.testsigma.sdk.AndroidAction; | ||
| import com.testsigma.sdk.ApplicationType; | ||
| import com.testsigma.sdk.annotation.Action; | ||
| import com.testsigma.sdk.annotation.TestData; | ||
| import com.testsigma.sdk.annotation.RunTimeData; | ||
|
|
||
| import java.util.Objects; | ||
|
|
||
| @Action(actionText = "set TDP iterator TDP_ITERATOR_KEY_NAME value to 0", | ||
| description = "Set TDP iterator TDP_ITERATOR_KEY_NAME to 0", | ||
| applicationType = ApplicationType.ANDROID, | ||
| useCustomScreenshot = false) | ||
| public class SetTDpIteratorToZero extends AndroidAction { | ||
|
|
||
| @TestData(reference = "TDP_ITERATOR_KEY_NAME", isRuntimeVariable = true) | ||
| private com.testsigma.sdk.TestData testData1; | ||
| @RunTimeData | ||
| private com.testsigma.sdk.RunTimeData runTimeData; | ||
|
|
||
| @Override | ||
| public com.testsigma.sdk.Result execute() { | ||
| logger.info("Initiating execution"); | ||
| if (!Objects.equals(testData1.getValue().toString(), "TDP_ITERATOR_KEY_NAME")) { | ||
| setErrorMessage("Don't change the TDP_ITERATOR_KEY_NAME variable name"); | ||
| return com.testsigma.sdk.Result.FAILED; | ||
| } | ||
| try { | ||
| runTimeData.setValue("0"); | ||
| runTimeData.setKey("TDP_ITERATOR_KEY_NAME"); | ||
| setSuccessMessage("Set TDP iterator TDP_ITERATOR_KEY_NAME to 0"); | ||
| return com.testsigma.sdk.Result.SUCCESS; | ||
| } catch (Exception e) { | ||
| setErrorMessage("Error occurred while setting runtime variable to 0: " + e.getMessage()); | ||
| return com.testsigma.sdk.Result.FAILED; | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
substringcan crash when no eligible columns are present.If all keys are filtered out,
resultVariableis empty andsubstring(0, -2)throws at runtime.Suggested fix
📝 Committable suggestion
🤖 Prompt for AI Agents