Skip to content

Commit 8313163

Browse files
authored
Bugfix: Fix the issue caused by serializing (#649)
<!-- Please provide brief information about the PR, what it contains & its purpose, new behaviors after the change. And let us know here if you need any help: https://github.com/microsoft/HydraLab/issues/new --> ## Description <!-- A few words to explain your changes --> ### Linked GitHub issue ID: # ## Pull Request Checklist <!-- Put an x in the boxes that apply. This is simply a reminder of what we are going to look for before merging your code. --> - [x] Tests for the changes have been added (for bug fixes / features) - [x] Code compiles correctly with all tests are passed. - [x] I've read the [contributing guide](https://github.com/microsoft/HydraLab/blob/main/CONTRIBUTING.md#making-changes-to-the-code) and followed the recommended practices. - [ ] [Wikis](https://github.com/microsoft/HydraLab/wiki) or [README](https://github.com/microsoft/HydraLab/blob/main/README.md) have been reviewed and added / updated if needed (for bug fixes / features) ### Does this introduce a breaking change? *If this introduces a breaking change for Hydra Lab users, please describe the impact and migration path.* - [x] Yes - [ ] No ## How you tested it *Please make sure the change is tested, you can test it by adding UTs, do local test and share the screenshots, etc.* Please check the type of change your PR introduces: - [x] Bugfix - [ ] Feature - [ ] Technical design - [ ] Build related changes - [ ] Refactoring (no functional changes, no api changes) - [ ] Code style update (formatting, renaming) or Documentation content changes - [ ] Other (please describe): ### Feature UI screenshots or Technical design diagrams *If this is a relatively large or complex change, kick it off by drawing the tech design with PlantUML and explaining why you chose the solution you did and what alternatives you considered, etc...*
1 parent 489def3 commit 8313163

2 files changed

Lines changed: 25 additions & 5 deletions

File tree

common/src/main/java/com/microsoft/hydralab/common/entity/common/Task.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ public class Task implements Serializable {
8585
@Transient
8686
private boolean disableRecording = false;
8787

88+
@Transient
89+
@Deprecated
90+
private List<TestRun> deviceTestResults = taskRunList;
91+
8892
public synchronized void addTestedDeviceResult(TestRun deviceTestResult) {
8993
taskRunList.add(deviceTestResult);
9094
}
@@ -213,11 +217,6 @@ public interface TriggerType {
213217
String Schedule = "Schedule";
214218
}
215219

216-
@Deprecated
217-
public List<TestRun> getDeviceTestResults() {
218-
return taskRunList;
219-
}
220-
221220
@Deprecated
222221
public int getTestDevicesCount() {
223222
return deviceCount;

common/src/test/java/com/microsoft/hydralab/common/util/SerializeUtilTest.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import com.alibaba.fastjson.JSONArray;
44
import com.alibaba.fastjson.JSONObject;
55
import com.microsoft.hydralab.common.entity.common.Message;
6+
import com.microsoft.hydralab.common.entity.common.Task;
7+
import com.microsoft.hydralab.common.entity.common.TestRun;
68
import com.microsoft.hydralab.common.test.BaseTest;
79
import org.junit.jupiter.api.Assertions;
810
import org.junit.jupiter.api.Test;
@@ -54,4 +56,23 @@ void testJsonArraySerialize() {
5456
Assertions.assertEquals(str1, str2, "Serialize error!");
5557
Assertions.assertEquals(str1, str3, "Serialize error!");
5658
}
59+
60+
@Test
61+
void testConvertTask(){
62+
Task task = new Task();
63+
TestRun testRun = new TestRun();
64+
testRun.setTestTaskId("testTaskId");
65+
task.setErrorMsg("testErrorMsg");
66+
task.setDeviceCount(2);
67+
task.getTaskRunList().add(testRun);
68+
Message msg = new Message();
69+
msg.setBody(task);
70+
byte[] data = SerializeUtil.messageToByteArr(msg);
71+
Message msg2 = SerializeUtil.byteArrToMessage(data);
72+
Assertions.assertTrue(msg2.getBody() instanceof Task, "Serialize error!");
73+
Assertions.assertTrue("testTaskId".equals(((Task) msg2.getBody()).getTaskRunList().get(0).getTestTaskId()), "Serialize error!");
74+
Assertions.assertTrue("testErrorMsg".equals(((Task) msg2.getBody()).getErrorMsg()), "Serialize error!");
75+
Assertions.assertTrue(2 == ((Task) msg2.getBody()).getDeviceCount(), "Serialize error!");
76+
77+
}
5778
}

0 commit comments

Comments
 (0)