Skip to content

Commit 04b2acf

Browse files
author
Marvin Zhang
committed
refactor: Rename 'data' to 'payload' in IPCMessage class for clarity
- Updated the IPCMessage class to replace the 'data' field with 'payload' for improved readability and consistency. - Adjusted the constructor and getter method to reflect the new naming convention. - Enhanced unit tests to verify the presence of 'payload' in the output, ensuring that the changes do not affect functionality.
1 parent 46adfe1 commit 04b2acf

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/main/java/io/crawlab/sdk/entity/IPCMessage.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ public String toString() {
2121
}
2222

2323
private final String type;
24-
private final Object data;
24+
private final Object payload;
2525
protected final Boolean ipc = true;
2626

27-
public IPCMessage(MessageType type, Object data) {
27+
public IPCMessage(MessageType type, Object payload) {
2828
this.type = type.toString().toLowerCase();
29-
this.data = data;
29+
this.payload = payload;
3030
}
3131

3232
public String toJSON() {
@@ -42,8 +42,8 @@ public String getType() {
4242
return type;
4343
}
4444

45-
public Object getData() {
46-
return data;
45+
public Object getPayload() {
46+
return payload;
4747
}
4848

4949
public Boolean getIpc() {

src/test/java/io/crawlab/sdk/CrawlabSDKTest.java

+2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ void testSaveItemWithMap() {
2424
String output = outputStreamCaptor.toString().trim();
2525

2626
assertTrue(output.contains("\"type\":\"data\""));
27+
assertTrue(output.contains("\"payload\":["));
2728
assertTrue(output.contains("\"name\":\"John\""));
2829
assertTrue(output.contains("\"age\":25"));
2930
assertTrue(output.contains("\"ipc\":true"));
@@ -36,6 +37,7 @@ void testSaveItemWithClass() {
3637
String output = outputStreamCaptor.toString().trim();
3738

3839
assertTrue(output.contains("\"type\":\"data\""));
40+
assertTrue(output.contains("\"payload\":["));
3941
assertTrue(output.contains("\"name\":\"John\""));
4042
assertTrue(output.contains("\"age\":25"));
4143
assertTrue(output.contains("\"ipc\":true"));

0 commit comments

Comments
 (0)