Skip to content

Commit cbffe05

Browse files
authored
Add Javadoc documentation to project (#18)
* Add javadoc comments to files * Remove some redundant exception throwing comments * Apply spotless formatter * Fix javadoc errors * Re-run spotless formatter * Add javadoc tag `@implNote`
1 parent fbfed3b commit cbffe05

File tree

8 files changed

+119
-0
lines changed

8 files changed

+119
-0
lines changed

build.gradle

+3
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,6 @@ spotless {
4141
}
4242
}
4343

44+
javadoc {
45+
options.tags = [ "implNote:a:Implementation Note:" ]
46+
}

src/main/java/io/github/lambdatest/gradle/AppUploader.java

+21
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@
55
import org.apache.logging.log4j.LogManager;
66
import org.apache.logging.log4j.Logger;
77

8+
/**
9+
* Handles the asynchronous upload of application files to the LambdaTest platform. This class
10+
* manages the upload process and returns the application ID for test execution.
11+
*
12+
* <p>Uses {@link UploaderUtil#uploadAndGetId(String, String, String)} for the actual file upload
13+
* process.
14+
*/
815
public class AppUploader {
916

1017
private static final Logger logger = LogManager.getLogger(AppUploader.class);
@@ -13,6 +20,13 @@ public class AppUploader {
1320
private String accessKey;
1421
private String appFilePath;
1522

23+
/**
24+
* Creates a new AppUploader instance with the specified credentials and file path.
25+
*
26+
* @param username The LambdaTest account username
27+
* @param accessKey The LambdaTest account access key
28+
* @param appFilePath The path to the application file to be uploaded
29+
*/
1630
public AppUploader(String username, String accessKey, String appFilePath) {
1731
if (username == null) throw new IllegalArgumentException("Username cannot be null");
1832
if (accessKey == null) throw new IllegalArgumentException("Access Key cannot be null");
@@ -23,6 +37,13 @@ public AppUploader(String username, String accessKey, String appFilePath) {
2337
this.appFilePath = appFilePath;
2438
}
2539

40+
/**
41+
* Uploads the application file asynchronously to LambdaTest.
42+
*
43+
* @implNote Uses CompletableFuture to perform the upload asynchronously, allowing parallel
44+
* processing of other tasks.
45+
* @return A CompletableFuture that resolves to the uploaded application's ID
46+
*/
2647
public CompletableFuture<String> uploadAppAsync() {
2748
return CompletableFuture.supplyAsync(
2849
() -> {

src/main/java/io/github/lambdatest/gradle/Constants.java

+5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
package io.github.lambdatest.gradle;
22

3+
/**
4+
* Constants used throughout the LambdaTest Gradle plugin. This utility class provides centralized
5+
* access to API endpoints and other constant values.
6+
*/
37
public class Constants {
8+
/** Private constructor to prevent instantiation of this utility class. */
49
private Constants() {
510
throw new UnsupportedOperationException(
611
"This is a utility class and cannot be instantiated");

src/main/java/io/github/lambdatest/gradle/LambdaTestPlugin.java

+9
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,17 @@
33
import org.gradle.api.Plugin;
44
import org.gradle.api.Project;
55

6+
/**
7+
* The main plugin class that integrates LambdaTest functionality into the Gradle build system. This
8+
* plugin adds the 'runLambdaTest' task to the project's task container.
9+
*/
610
public class LambdaTestPlugin implements Plugin<Project> {
711

12+
/**
13+
* Applies the plugin to the specified Gradle project, registering the LambdaTest task.
14+
*
15+
* @param project The Gradle project to which this plugin is being applied
16+
*/
817
@Override
918
public void apply(Project project) {
1019
// Register a new task named "runLambdaTest" and associate it with the LambdaTestTask class

src/main/java/io/github/lambdatest/gradle/LambdaTestTask.java

+18
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@
1111
import org.gradle.api.DefaultTask;
1212
import org.gradle.api.tasks.TaskAction;
1313

14+
/**
15+
* Main task class for the LambdaTest Gradle plugin that handles test execution on the LambdaTest
16+
* platform. This task manages the upload of applications and test suites, followed by test
17+
* execution with specified configurations.
18+
*
19+
* <p>This task coordinates between {@link AppUploader}, {@link TestSuiteUploader}, and {@link
20+
* TestExecutor} to manage the complete test execution lifecycle.
21+
*/
1422
public class LambdaTestTask extends DefaultTask {
1523

1624
private static final Logger logger = LogManager.getLogger(LambdaTestTask.class);
@@ -38,6 +46,16 @@ public class LambdaTestTask extends DefaultTask {
3846
private String testSuiteId;
3947
private Integer queueTimeout;
4048

49+
/**
50+
* Executes the LambdaTest task, which includes uploading the application and test suite,
51+
* followed by test execution on the LambdaTest platform.
52+
*
53+
* @implNote This method handles the task execution in three main phases: 1. Asynchronous upload
54+
* of the application using {@link AppUploader#uploadAppAsync()} 2. Asynchronous upload of
55+
* the test suite using {@link TestSuiteUploader#uploadTestSuiteAsync()} 3. Test execution
56+
* with {@link TestExecutor#executeTests(Map)}
57+
* @throws RuntimeException if any upload or test execution fails
58+
*/
4159
@TaskAction
4260
public void runLambdaTest() {
4361
logger.info("Starting LambdaTest task...");

src/main/java/io/github/lambdatest/gradle/TestExecutor.java

+25
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@
99
import org.apache.logging.log4j.LogManager;
1010
import org.apache.logging.log4j.Logger;
1111

12+
/**
13+
* Manages the execution of tests on the LambdaTest platform. This class handles the test execution
14+
* configuration and communication with the LambdaTest API.
15+
*
16+
* <p>Uses endpoints defined in {@link Constants} for API communication.
17+
*/
1218
public class TestExecutor {
1319
private static final Logger logger = LogManager.getLogger(TestExecutor.class);
1420

@@ -19,6 +25,16 @@ public class TestExecutor {
1925
private List<String> device;
2026
private Boolean isFlutter;
2127

28+
/**
29+
* Creates a new TestExecutor with the specified configuration.
30+
*
31+
* @param username The LambdaTest account username
32+
* @param accessKey The LambdaTest account access key
33+
* @param appId The ID of the uploaded application
34+
* @param testSuiteId The ID of the uploaded test suite
35+
* @param device List of target devices for test execution
36+
* @param isFlutter Boolean indicating if this is a Flutter application
37+
*/
2238
public TestExecutor(
2339
String username,
2440
String accessKey,
@@ -34,6 +50,15 @@ public TestExecutor(
3450
this.isFlutter = isFlutter;
3551
}
3652

53+
/**
54+
* Executes the tests on LambdaTest with the specified parameters.
55+
*
56+
* @implNote This method constructs the test capabilities and sends them to either {@link
57+
* Constants#BUILD_URL} or {@link Constants#FLUTTER_BUILD_URL} based on whether it's a
58+
* Flutter or standard application.
59+
* @param params Map of additional test execution parameters
60+
* @throws IOException if there's an error in communication with the LambdaTest API
61+
*/
3762
public void executeTests(Map<String, String> params) throws IOException {
3863
try {
3964
OkHttpClient client = new OkHttpClient();

src/main/java/io/github/lambdatest/gradle/TestSuiteUploader.java

+18
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
import org.apache.logging.log4j.LogManager;
66
import org.apache.logging.log4j.Logger;
77

8+
/**
9+
* Handles the asynchronous upload of test suite files to the LambdaTest platform. This class
10+
* manages the upload process and returns the test suite ID for test execution.
11+
*/
812
public class TestSuiteUploader {
913

1014
private static final Logger logger = LogManager.getLogger(TestSuiteUploader.class);
@@ -13,12 +17,26 @@ public class TestSuiteUploader {
1317
private String accessKey;
1418
private String testSuiteFilePath;
1519

20+
/**
21+
* Creates a new TestSuiteUploader instance with the specified credentials and file path.
22+
*
23+
* @param username The LambdaTest account username
24+
* @param accessKey The LambdaTest account access key
25+
* @param testSuiteFilePath The path to the test suite file to be uploaded
26+
*/
1627
public TestSuiteUploader(String username, String accessKey, String testSuiteFilePath) {
1728
this.username = username;
1829
this.accessKey = accessKey;
1930
this.testSuiteFilePath = testSuiteFilePath;
2031
}
2132

33+
/**
34+
* Uploads the test suite file asynchronously to LambdaTest.
35+
*
36+
* @implNote Uses CompletableFuture to perform the upload asynchronously, allowing parallel
37+
* processing of other tasks.
38+
* @return A CompletableFuture that resolves to the uploaded test suite's ID
39+
*/
2240
public CompletableFuture<String> uploadTestSuiteAsync() {
2341
return CompletableFuture.supplyAsync(
2442
() -> {

src/main/java/io/github/lambdatest/gradle/UploaderUtil.java

+20
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,34 @@
1212
import okhttp3.RequestBody;
1313
import okhttp3.Response;
1414

15+
/**
16+
* Utility class providing common upload functionality for the LambdaTest Gradle plugin. This class
17+
* handles the actual file upload process and response parsing.
18+
*
19+
* <p>This utility is used by both {@link AppUploader} and {@link TestSuiteUploader} to handle file
20+
* uploads to the LambdaTest platform.
21+
*/
1522
public final class UploaderUtil {
23+
/** Private constructor to prevent instantiation of this utility class. */
1624
private UploaderUtil() {
1725
throw new UnsupportedOperationException(
1826
"This is a utility class and cannot be instantiated");
1927
}
2028

29+
/**
30+
* Uploads a file to LambdaTest and returns its ID.
31+
*
32+
* @implNote This method sends the file to {@link Constants#API_URL} and handles the multipart
33+
* form data construction and response parsing.
34+
* @param username The LambdaTest account username
35+
* @param accessKey The LambdaTest account access key
36+
* @param filePath The path to the file to be uploaded
37+
* @return The ID of the uploaded file
38+
* @throws IOException if there's an error during file upload or response parsing
39+
*/
2140
public static String uploadAndGetId(String username, String accessKey, String filePath)
2241
throws IOException {
42+
2343
OkHttpClient client = new OkHttpClient();
2444

2545
MediaType mediaType = MediaType.parse("application/octet-stream");

0 commit comments

Comments
 (0)