1 #include <gtest/gtest.h>
23 std::string json =
"{\"session\":{\"type\":5,\"tmode\":1,\"time_max\":750,\"port\":8080,\"user\":\"admin\",\"password\":\"42\",\"shell\":\"bash\",\"environment\":[{\"LINES\":\"80\",\"HOSTNAME\":\"node22\"}]},\"command\":\"sort\",\"input\":\"def\\nabc\\n123\\n\",\"files\":[{\"name\":\"file1\",\"data\":\"test content of file1\\n\",\"action\":13},{\"name\":\"file2\",\"data\":\"test content of file2\\n\",\"action\":1}]}";
26 ASSERT_FALSE(taskRequestSetExecute.
isError());
28 ASSERT_TRUE(taskRequestSetExecute.
getErrorMsg().empty());
30 ASSERT_EQ(taskRequestSetExecute.
getInputStream(),
"def\nabc\n123\n");
46 ASSERT_EQ(taskRequestSetExecute.
getFileItem(0).
data,
"test content of file1\n");
49 ASSERT_EQ(taskRequestSetExecute.
getFileItem(1).
data,
"test content of file2\n");
50 printSuccess(
"Unserialize DRCETaskRequestSetExecute");
53 ASSERT_TRUE(taskRequestSetExecute.
serialize(newJson));
54 ASSERT_FALSE(taskRequestSetExecute.
isError());
56 ASSERT_TRUE(taskRequestSetExecute.
getErrorMsg().empty());
57 printSuccess(
"Serialize DRCETaskRequestSetExecute");
60 ASSERT_FALSE(taskRequestSetExecuteRes.
isError());
62 ASSERT_TRUE(taskRequestSetExecuteRes.
getErrorMsg().empty());
64 ASSERT_EQ(taskRequestSetExecuteRes.
getInputStream(),
"def\nabc\n123\n");
80 ASSERT_EQ(taskRequestSetExecuteRes.
getFileItem(0).
data,
"test content of file1\n");
83 ASSERT_EQ(taskRequestSetExecuteRes.
getFileItem(1).
data,
"test content of file2\n");
84 printSuccess(
"Test Serialize/Unserialize SetTaskToExecuteRequest");
91 taskRequestCheckState.
setCheckType(DRCETaskRequestCheckState::CheckType::ctExtended);
92 ASSERT_TRUE(taskRequestCheckState.
serialize(json));
93 ASSERT_FALSE(taskRequestCheckState.
isError());
95 ASSERT_TRUE(taskRequestCheckState.
getErrorMsg().empty());
96 printSuccess(
"DRCETaskRequestCheckState serialize");
99 ASSERT_FALSE(taskRequestCheckStateRes.
isError());
101 ASSERT_TRUE(taskRequestCheckStateRes.
getErrorMsg().empty());
102 printSuccess(
"DRCETaskRequestCheckState unserialize");
105 printSuccess(
"Test Serialize/Unserialize DRCETaskRequestSetExecute");
112 taskRequestGetData.
setFetchType(DRCETaskRequestGetData::FetchType::ftNotDeleteDataAfterFetch);
113 ASSERT_TRUE(taskRequestGetData.
serialize(json));
114 ASSERT_FALSE(taskRequestGetData.
isError());
116 ASSERT_TRUE(taskRequestGetData.
getErrorMsg().empty());
117 printSuccess(
"DRCETaskRequestGetData serialize");
120 ASSERT_FALSE(taskRequestGetDataRes.
isError());
122 ASSERT_TRUE(taskRequestGetDataRes.
getErrorMsg().empty());
123 printSuccess(
"DRCETaskRequestGetData unserialize");
126 printSuccess(
"Test Serialize/Unserialize DRCETaskRequestGetData");
133 taskRequestTerminate.
setAlgorithmType(DRCETaskRequestTerminate::AlgorithmType::atDefault);
137 ASSERT_TRUE(taskRequestTerminate.
serialize(json));
138 ASSERT_FALSE(taskRequestTerminate.
isError());
140 ASSERT_TRUE(taskRequestTerminate.
getErrorMsg().empty());
141 printSuccess(
"DRCETaskRequestTerminate serialize");
146 ASSERT_FALSE(taskRequestTerminateRes.
isError());
148 ASSERT_TRUE(taskRequestTerminateRes.
getErrorMsg().empty());
149 printSuccess(
"DRCETaskRequestTerminate unserialize");
155 printSuccess(
"Test Serialize/Unserialize DRCETaskRequestTerminate");