|
@@ -1011,7 +1011,9 @@ TEST(Head, FileTooSmall) {
|
|
message["file"] = file;
|
|
message["file"] = file;
|
|
|
|
|
|
std::vector<char> bytes;
|
|
std::vector<char> bytes;
|
|
- EXPECT_CALL(fileManager, getBytesFromFile(testing::_, testing::_)).Times(2).WillRepeatedly(testing::Return(std::make_pair(bytes, FileManager::Error::file_too_small)));
|
|
+ EXPECT_CALL(fileManager, getBytesFromFile(testing::_, testing::_))
|
|
|
|
+ .Times(2)
|
|
|
|
+ .WillRepeatedly(testing::Return(std::make_pair(bytes, FileManager::Error::file_too_small)));
|
|
|
|
|
|
JsonCommander::Response response = jsonCommander.execute(message);
|
|
JsonCommander::Response response = jsonCommander.execute(message);
|
|
|
|
|
|
@@ -1724,4 +1726,112 @@ TEST(ExtendedListData, InvalidRequest) {
|
|
EXPECT_TRUE(response.json["error"].asString().compare("") != 0);
|
|
EXPECT_TRUE(response.json["error"].asString().compare("") != 0);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+TEST(Queue, InvalidRequest) {
|
|
|
|
+ FileManagerMock fileManager;
|
|
|
|
+
|
|
|
|
+ JsonCommander jsonCommander(fileManager);
|
|
|
|
+
|
|
|
|
+ const std::string command = "queue";
|
|
|
|
+ Json::Value message;
|
|
|
|
+ message["command"] = command;
|
|
|
|
+ message["file"] = 5;
|
|
|
|
+
|
|
|
|
+ JsonCommander::Response response = jsonCommander.execute(message);
|
|
|
|
+ EXPECT_TRUE(response.action == JsonCommander::Action::closeAndSend);
|
|
|
|
+ EXPECT_EQ(response.json["command"].asString(), command);
|
|
|
|
+ EXPECT_FALSE(response.json["accept"].asBool());
|
|
|
|
+ EXPECT_EQ(response.json["file"].asString(), "");
|
|
|
|
+ EXPECT_TRUE(response.json["error"].asString().compare("") != 0);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+TEST(Queue, PushToQueueFailed) {
|
|
|
|
+ FileManagerMock fileManager;
|
|
|
|
+
|
|
|
|
+ JsonCommander jsonCommander(fileManager);
|
|
|
|
+
|
|
|
|
+ const std::string command = "queue";
|
|
|
|
+ Json::Value message;
|
|
|
|
+ message["command"] = command;
|
|
|
|
+ message["file"] = "negative";
|
|
|
|
+
|
|
|
|
+ JsonCommander::Response response = jsonCommander.execute(message);
|
|
|
|
+ EXPECT_TRUE(response.action == JsonCommander::Action::send);
|
|
|
|
+ EXPECT_EQ(response.json["command"].asString(), command);
|
|
|
|
+ EXPECT_FALSE(response.json["accept"].asBool());
|
|
|
|
+ EXPECT_EQ(response.json["file"].asString(), "negative");
|
|
|
|
+ EXPECT_TRUE(response.json["error"].asString().compare("") != 0);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+TEST(Queue, Positive) {
|
|
|
|
+ FileManagerMock fileManager;
|
|
|
|
+
|
|
|
|
+ JsonCommander jsonCommander(fileManager);
|
|
|
|
+
|
|
|
|
+ const std::string command = "queue";
|
|
|
|
+ Json::Value message;
|
|
|
|
+ message["command"] = command;
|
|
|
|
+ message["file"] = "positive";
|
|
|
|
+
|
|
|
|
+ JsonCommander::Response response = jsonCommander.execute(message);
|
|
|
|
+ EXPECT_TRUE(response.action == JsonCommander::Action::send);
|
|
|
|
+ EXPECT_EQ(response.json["command"].asString(), command);
|
|
|
|
+ EXPECT_TRUE(response.json["accept"].asBool());
|
|
|
|
+ EXPECT_EQ(response.json["file"].asString(), "positive");
|
|
|
|
+ EXPECT_EQ(response.json["error"].asString(), "");
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+TEST(Dequeue, InvalidRequest) {
|
|
|
|
+ FileManagerMock fileManager;
|
|
|
|
+
|
|
|
|
+ JsonCommander jsonCommander(fileManager);
|
|
|
|
+
|
|
|
|
+ const std::string command = "dequeue";
|
|
|
|
+ Json::Value message;
|
|
|
|
+ message["command"] = command;
|
|
|
|
+ message["file"] = 5;
|
|
|
|
+
|
|
|
|
+ JsonCommander::Response response = jsonCommander.execute(message);
|
|
|
|
+ EXPECT_TRUE(response.action == JsonCommander::Action::closeAndSend);
|
|
|
|
+ EXPECT_EQ(response.json["command"].asString(), command);
|
|
|
|
+ EXPECT_FALSE(response.json["accept"].asBool());
|
|
|
|
+ EXPECT_EQ(response.json["file"].asString(), "");
|
|
|
|
+ EXPECT_TRUE(response.json["error"].asString().compare("") != 0);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+TEST(Dequeue, QueueRemoveFailed) {
|
|
|
|
+ FileManagerMock fileManager;
|
|
|
|
+
|
|
|
|
+ JsonCommander jsonCommander(fileManager);
|
|
|
|
+
|
|
|
|
+ const std::string command = "dequeue";
|
|
|
|
+ Json::Value message;
|
|
|
|
+ message["command"] = command;
|
|
|
|
+ message["file"] = "negative";
|
|
|
|
+
|
|
|
|
+ JsonCommander::Response response = jsonCommander.execute(message);
|
|
|
|
+ EXPECT_TRUE(response.action == JsonCommander::Action::send);
|
|
|
|
+ EXPECT_EQ(response.json["command"].asString(), command);
|
|
|
|
+ EXPECT_FALSE(response.json["accept"].asBool());
|
|
|
|
+ EXPECT_EQ(response.json["file"].asString(), "negative");
|
|
|
|
+ EXPECT_TRUE(response.json["error"].asString().compare("") != 0);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+TEST(Dequeue, Positive) {
|
|
|
|
+ FileManagerMock fileManager;
|
|
|
|
+
|
|
|
|
+ JsonCommander jsonCommander(fileManager);
|
|
|
|
+
|
|
|
|
+ const std::string command = "dequeue";
|
|
|
|
+ Json::Value message;
|
|
|
|
+ message["command"] = command;
|
|
|
|
+ message["file"] = "positive";
|
|
|
|
+
|
|
|
|
+ JsonCommander::Response response = jsonCommander.execute(message);
|
|
|
|
+ EXPECT_TRUE(response.action == JsonCommander::Action::send);
|
|
|
|
+ EXPECT_EQ(response.json["command"].asString(), command);
|
|
|
|
+ EXPECT_TRUE(response.json["accept"].asBool());
|
|
|
|
+ EXPECT_EQ(response.json["file"].asString(), "positive");
|
|
|
|
+ EXPECT_EQ(response.json["error"].asString(), "");
|
|
|
|
+}
|
|
|
|
+
|
|
}
|
|
}
|