-
Notifications
You must be signed in to change notification settings - Fork 22
/
StandModuleTest.cpp
115 lines (102 loc) · 5.04 KB
/
StandModuleTest.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#include "bootstrap/PersistenceContainer.h"
#include "controller/HandoffEventHandlerCollection.h"
#include "flightplan/FlightPlanEventHandlerCollection.h"
#include "integration/ExternalMessageEventHandler.h"
#include "integration/InboundIntegrationMessageHandler.h"
#include "integration/IntegrationPersistenceContainer.h"
#include "integration/IntegrationServer.h"
#include "plugin/FunctionCallEventHandler.h"
#include "push/PushEventProcessorCollection.h"
#include "stands/StandModule.h"
#include "tag/TagItemCollection.h"
using ::testing::NiceMock;
using ::testing::Return;
using ::testing::Test;
using UKControllerPlugin::Bootstrap::PersistenceContainer;
using UKControllerPlugin::Controller::HandoffEventHandlerCollection;
using UKControllerPlugin::Flightplan::FlightPlanEventHandlerCollection;
using UKControllerPlugin::Integration::ExternalMessageEventHandler;
using UKControllerPlugin::Integration::InboundIntegrationMessageHandler;
using UKControllerPlugin::Integration::IntegrationPersistenceContainer;
using UKControllerPlugin::Plugin::FunctionCallEventHandler;
using UKControllerPlugin::Push::PushEventProcessorCollection;
using UKControllerPlugin::Stands::BootstrapPlugin;
using UKControllerPlugin::Tag::TagItemCollection;
using UKControllerPluginTest::Dependency::MockDependencyLoader;
namespace UKControllerPluginTest::Stands {
class StandModuleTest : public Test
{
public:
StandModuleTest()
{
container.pushEventProcessors = std::make_shared<PushEventProcessorCollection>();
container.tagHandler = std::make_unique<TagItemCollection>();
container.flightplanHandler = std::make_unique<FlightPlanEventHandlerCollection>();
container.pluginFunctionHandlers = std::make_unique<FunctionCallEventHandler>();
container.externalEventHandler = std::make_shared<ExternalMessageEventHandler>(true);
container.integrationModuleContainer =
std::make_unique<IntegrationPersistenceContainer>(nullptr, nullptr, nullptr, nullptr);
container.integrationModuleContainer->inboundMessageHandler =
std::make_shared<InboundIntegrationMessageHandler>(nullptr);
nlohmann::json gatwick = nlohmann::json::array();
gatwick.push_back({
{"id", 1},
{"identifier", "31R"},
});
gatwick.push_back({
{"id", 2},
{"identifier", "35"},
});
nlohmann::json heathrow = nlohmann::json::array();
heathrow.push_back({
{"id", 3},
{"identifier", "76R"},
});
nlohmann::json dependency = {{"EGKK", gatwick}, {"EGLL", heathrow}};
EXPECT_CALL(this->dependencyLoader, LoadDependency("DEPENDENCY_STANDS", nlohmann::json::object()))
.Times(1)
.WillOnce(Return(dependency));
}
NiceMock<MockDependencyLoader> dependencyLoader;
PersistenceContainer container;
};
TEST_F(StandModuleTest, ItRegistersAssignedStandsTagItem)
{
BootstrapPlugin(this->container, this->dependencyLoader);
EXPECT_TRUE(this->container.tagHandler->HasHandlerForItemId(110));
}
TEST_F(StandModuleTest, ItRegistersForWebsocketEvents)
{
BootstrapPlugin(this->container, this->dependencyLoader);
EXPECT_EQ(1, this->container.pushEventProcessors->CountProcessorsForChannel("private-stand-assignments"));
}
TEST_F(StandModuleTest, ItRegistersForFlightplanEvents)
{
BootstrapPlugin(this->container, this->dependencyLoader);
EXPECT_EQ(1, this->container.flightplanHandler->CountHandlers());
}
TEST_F(StandModuleTest, ItRegistersTheStandAssignmentPopupMenuFunction)
{
BootstrapPlugin(this->container, this->dependencyLoader);
EXPECT_TRUE(this->container.pluginFunctionHandlers->HasTagFunction(9007));
EXPECT_EQ(1, this->container.pluginFunctionHandlers->CountCallbacks());
EXPECT_TRUE(this->container.pluginFunctionHandlers->HasCallbackFunction(5000));
}
TEST_F(StandModuleTest, ItRegistersTheStandAssignmentEditBoxFunction)
{
BootstrapPlugin(this->container, this->dependencyLoader);
EXPECT_TRUE(this->container.pluginFunctionHandlers->HasTagFunction(9008));
EXPECT_EQ(1, this->container.pluginFunctionHandlers->CountCallbacks());
EXPECT_TRUE(this->container.pluginFunctionHandlers->HasCallbackFunction(5000));
}
TEST_F(StandModuleTest, ItRegistersForExternalMessages)
{
BootstrapPlugin(this->container, this->dependencyLoader);
EXPECT_EQ(1, this->container.externalEventHandler->CountHandlers());
}
TEST_F(StandModuleTest, ItRegistersForIntegrationMessages)
{
BootstrapPlugin(this->container, this->dependencyLoader);
EXPECT_EQ(2, container.integrationModuleContainer->inboundMessageHandler->CountProcessors());
}
} // namespace UKControllerPluginTest::Stands