Skip to content

Commit 6f8b933

Browse files
clean code and documentation
1 parent 7fa324f commit 6f8b933

File tree

10 files changed

+49
-45
lines changed

10 files changed

+49
-45
lines changed

.github/workflows/publish.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ jobs:
1313
- name: Set up Java for publishing to Maven Central Repository
1414
uses: actions/setup-java@v3
1515
with:
16-
java-version: '11'
17-
distribution: 'adopt'
16+
java-version: "11"
17+
distribution: "adopt"
1818
server-id: ossrh
1919
server-username: ${{ secrets.OSSRH_USERNAME }}
2020
server-password: ${{ secrets.OSSRH_PASSWORD }}
@@ -37,5 +37,5 @@ jobs:
3737
- name: Set up Java for publishing to GitHub Packages
3838
uses: actions/setup-java@v3
3939
with:
40-
java-version: '11'
41-
distribution: 'adopt'
40+
java-version: "11"
41+
distribution: "adopt"

src/main/java/com/contentstack/cms/Parametron.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import org.jetbrains.annotations.NotNull;
44

55
import java.util.HashMap;
6+
import java.util.Map;
67

78
/**
89
* The interface Parametron.

src/main/java/com/contentstack/cms/marketplace/apps/App.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public App addHeader(@NotNull String key, @NotNull String value) {
117117
*/
118118
@SuppressWarnings("unchecked")
119119
@Override
120-
public App addParams(@NotNull HashMap params) {
120+
public App addParams(@NotNull HashMap params) {
121121
this.params.putAll(params);
122122
return this;
123123
}

src/main/java/com/contentstack/cms/marketplace/installations/webhook/Webhook.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public Call<ResponseBody> fetchExecutionLogs(String executionId) {
8383
* unique identifier of an
8484
* execution. It is used to identify a specific execution
8585
* that needs to be retried.
86-
* @return The method is returning a `Call<ResponseBody>` object.
86+
* @return Call object.
8787
*/
8888
public Call<ResponseBody> retryExecution(@NotNull String executionId) {
8989
validateInstallationId();
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
/**
2-
* Useful to access contentstack's app components
2+
* Useful to access contentstack's app/manifest components
33
*/
44
package com.contentstack.cms.marketplace;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
/**
2-
* Useful to access contentstack's app components
2+
* Useful to access contentstack's app request components
33
*/
44
package com.contentstack.cms.marketplace.request;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
/**
2-
* Useful to access contentstack's organizations
2+
* Useful to access contentstack's organization component
33
*/
44
package com.contentstack.cms.organization;

src/main/java/com/contentstack/cms/stack/Stack.java

Lines changed: 33 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -39,58 +39,66 @@ public Stack(@NotNull Retrofit client) {
3939
}
4040

4141
/**
42-
* Sets header for the request
43-
*
44-
* @param key
45-
* header key for the request
46-
* @param value
47-
* header value for the request
42+
* The addHeader function adds a key-value pair to the headers map and returns
43+
* the updated Stack
44+
* object.
45+
*
46+
* @param key A string representing the key of the header. It is marked
47+
* as @NotNull, which means it
48+
* cannot be null and must be provided.
49+
* @param value The value parameter is of type Object, which means it can accept
50+
* any type of object as
51+
* its value.
52+
* @return The method is returning a Stack object.
4853
*/
4954
public Stack addHeader(@NotNull String key, @NotNull Object value) {
5055
this.headers.put(key, value);
5156
return this;
5257
}
5358

5459
/**
55-
* Sets header for the request
56-
*
57-
* @param key
58-
* header key for the request
59-
* @param value
60-
* header value for the request
60+
* The addParam function adds a key-value pair to a stack and returns the
61+
* updated stack.
62+
*
63+
* @param key A string representing the key for the parameter.
64+
* @param value The value parameter is of type Object, which means it can accept
65+
* any type of object as
66+
* its value.
67+
* @return The method is returning a reference to the current instance of the
68+
* Stack object.
6169
*/
6270
public Stack addParam(@NotNull String key, @NotNull Object value) {
6371
this.params.put(key, value);
6472
return this;
6573
}
6674

6775
/**
68-
* Sets header for the request
69-
*
70-
* @param key
71-
* header key for the request
76+
* The function removes a parameter from a stack and returns the modified stack.
77+
*
78+
* @param key The parameter "key" is of type String and is marked with
79+
* the @NotNull annotation,
80+
* indicating that it cannot be null.
81+
* @return The method is returning a Stack object.
7282
*/
7383
public Stack removeParam(@NotNull String key) {
7484
this.params.remove(key);
7585
return this;
7686
}
7787

7888
/**
79-
* To clear all the query params
89+
* The function clears the parameters in a stack and returns the modified stack.
90+
*
91+
* @return The method is returning a reference to the current instance of the
92+
* Stack object.
8093
*/
8194
protected Stack clearParams() {
8295
this.params.clear();
8396
return this;
8497
}
8598

86-
/**
87-
* Instantiates a new Stack.
88-
*
89-
* @param client
90-
* the contentstack client
91-
* @param headers
92-
* Required headers to get the {@link Stack} information
93-
*/
99+
// The above code is defining a constructor for a class called "Stack". The
100+
// constructor takes two
101+
// parameters: a Retrofit client and a map of headers.
94102
public Stack(@NotNull Retrofit client, @NotNull Map<String, Object> headers) {
95103
this.headers = new HashMap<>();
96104
this.client = client;

src/test/java/com/contentstack/cms/Utils.java

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
package com.contentstack.cms;
22

3-
import com.contentstack.cms.core.Util;
4-
import com.contentstack.cms.stack.Stack;
53
import com.google.gson.Gson;
64
import com.google.gson.JsonObject;
7-
import io.github.cdimascio.dotenv.Dotenv;
85
import okhttp3.ResponseBody;
96
import org.json.simple.JSONObject;
107
import org.json.simple.parser.JSONParser;
@@ -14,26 +11,22 @@
1411
import java.io.File;
1512
import java.io.FileReader;
1613
import java.io.IOException;
17-
import java.util.HashMap;
1814
import java.util.logging.Logger;
1915

2016
public class Utils {
2117

22-
2318
private final static Logger log = Logger.getLogger(Utils.class.getName());
2419

25-
2620
public static JsonObject toJson(Response<ResponseBody> response) throws IOException {
2721
assert response.body() != null;
2822
return new Gson().fromJson(response.body().string(), JsonObject.class);
2923
}
3024

31-
3225
/**
3326
* This is used to convert json sting to the JSONObject
3427
*
3528
* @param jsonString
36-
* the json sting you want to convert as JSONObject
29+
* the json sting you want to convert as JSONObject
3730
* @return JSONObject the request body
3831
*/
3932
public static JSONObject createJSONObject(String jsonString) {
@@ -50,11 +43,13 @@ public static JSONObject createJSONObject(String jsonString) {
5043
}
5144

5245
/**
53-
* This is used to read json file from the local machine. We are referring the files from the project's resource
46+
* This is used to read json file from the local machine. We are referring the
47+
* files from the project's resource
5448
* itself 'String path = "src/test/resources/" + file;'
5549
*
5650
* @param file
57-
* The file is the path of type string from where JSON File has to read
51+
* The file is the path of type string from where JSON File has to
52+
* read
5853
* @return JSONObject the request body
5954
*/
6055

src/test/java/com/contentstack/cms/user/UserMockTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ void test_mock_testcase_update_user() {
7979
mockJsonObject = Utils.readJson("mockuser/updateuser.json");
8080
Assertions.assertEquals("Profile updated successfully.", mockJsonObject.get("notice"));
8181
mockJsonObject = (JSONObject) mockJsonObject.get("user");
82-
Set allKeys = mockJsonObject.keySet();
82+
Set<String> allKeys = mockJsonObject.keySet();
8383
logger.finest(mockJsonObject.toJSONString());
8484
String[] keyArray = {
8585
"org_uid",

0 commit comments

Comments
 (0)