Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/main/java/io/github/lambdatest/gradle/LambdaTestTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -157,18 +157,30 @@ public void runLambdaTest() {
// setter methods for the properties

public void setUsername(String username) {
if (username == null || username.trim().isEmpty()) {
throw new IllegalArgumentException("Username cannot be null or empty");
}
this.username = username;
}

public void setAccessKey(String accessKey) {
if (accessKey == null || accessKey.trim().isEmpty()) {
throw new IllegalArgumentException("Access key cannot be null or empty");
}
this.accessKey = accessKey;
}

public void setAppFilePath(String appFilePath) {
if (appFilePath == null || appFilePath.trim().isEmpty()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (appFilePath == null || appFilePath.trim().isEmpty()) {
if (appFilePath != null && appFilePath.trim().isEmpty()) {
throw new IllegalArgumentException("App file path cannot be empty");
}

appFilePath and testSuiteFilePath are not strictly necessary and are optional and adding these checks will break functionality.
Users can also provide pre-uploaded IDs instead of file paths. And, either appFilePath or testSuiteFilePath could be provided. With this code it will fail even when one of the path is provided.

Same for the other file. Do check other remaining possibilities/combinations.

throw new IllegalArgumentException("App file path cannot be null or empty");
}
this.appFilePath = appFilePath;
}

public void setTestSuiteFilePath(String testSuiteFilePath) {
if (testSuiteFilePath == null || testSuiteFilePath.trim().isEmpty()) {
throw new IllegalArgumentException("Test suite file path cannot be null or empty");
}
this.testSuiteFilePath = testSuiteFilePath;
}

Expand Down
12 changes: 12 additions & 0 deletions src/main/java/io/github/lambdatest/gradle/LambdaUploaderTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,18 +104,30 @@ public void uploadApkToLambdaTest() {

// Setter functions for the task
public void setUsername(String username) {
if (username == null || username.trim().isEmpty()) {
throw new IllegalArgumentException("Username cannot be null or empty");
}
this.username = username;
}

public void setAccessKey(String accessKey) {
if (accessKey == null || accessKey.trim().isEmpty()) {
throw new IllegalArgumentException("Access key cannot be null or empty");
}
this.accessKey = accessKey;
}

public void setAppFilePath(String appFilePath) {
if (appFilePath == null || appFilePath.trim().isEmpty()) {
throw new IllegalArgumentException("App file path cannot be null or empty");
}
this.appFilePath = appFilePath;
}

public void setTestSuiteFilePath(String testSuiteFilePath) {
if (testSuiteFilePath == null || testSuiteFilePath.trim().isEmpty()) {
throw new IllegalArgumentException("Test suite file path cannot be null or empty");
}
this.testSuiteFilePath = testSuiteFilePath;
}

Expand Down
Loading