aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/capabilities
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/capabilities')
-rw-r--r--src/plugins/capabilities/CapabilitiesFactory.cpp57
-rw-r--r--src/plugins/capabilities/CapabilitiesFactory.h63
-rw-r--r--src/plugins/capabilities/CapabilityMessagingService.cpp117
-rw-r--r--src/plugins/capabilities/CapabilityMessagingService.h82
-rw-r--r--src/plugins/capabilities/communication/include/PhoneControlCapability.h52
-rw-r--r--src/plugins/capabilities/communication/include/PhoneControlMessages.h128
-rw-r--r--src/plugins/capabilities/communication/src/PhoneControlCapability.cpp42
-rw-r--r--src/plugins/capabilities/core/include/MessageChannel.h68
-rw-r--r--src/plugins/capabilities/core/include/PublisherForwarder.h73
-rw-r--r--src/plugins/capabilities/core/include/SubscriberForwarder.h84
-rw-r--r--src/plugins/capabilities/core/src/MessageChannel.cpp51
-rw-r--r--src/plugins/capabilities/core/src/PublisherForwarder.cpp69
-rw-r--r--src/plugins/capabilities/core/src/SubscriberForwarder.cpp139
-rw-r--r--src/plugins/capabilities/guimetadata/include/GuiMetadataCapability.h52
-rw-r--r--src/plugins/capabilities/guimetadata/include/GuiMetadataMessages.h50
-rw-r--r--src/plugins/capabilities/guimetadata/src/GuiMetadataCapability.cpp42
-rw-r--r--src/plugins/capabilities/navigation/include/NavigationCapability.h52
-rw-r--r--src/plugins/capabilities/navigation/include/NavigationMessages.h48
-rw-r--r--src/plugins/capabilities/navigation/src/NavigationCapability.cpp42
-rw-r--r--src/plugins/capabilities/test/CapabilityMessagingServiceTest.cpp96
-rw-r--r--src/plugins/capabilities/test/PublisherForwarderTest.cpp116
-rw-r--r--src/plugins/capabilities/test/SubscriberForwarderTest.cpp262
22 files changed, 0 insertions, 1785 deletions
diff --git a/src/plugins/capabilities/CapabilitiesFactory.cpp b/src/plugins/capabilities/CapabilitiesFactory.cpp
deleted file mode 100644
index 2f92519..0000000
--- a/src/plugins/capabilities/CapabilitiesFactory.cpp
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright 2018-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License").
- * You may not use this file except in compliance with the License.
- * A copy of the License is located at
- *
- * http://aws.amazon.com/apache2.0/
- *
- * or in the "license" file accompanying this file. This file is distributed
- * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-#include "capabilities/CapabilitiesFactory.h"
-
-#include "capabilities/communication/include/PhoneControlCapability.h"
-#include "capabilities/guimetadata/include/GuiMetadataCapability.h"
-#include "capabilities/navigation/include/NavigationCapability.h"
-
-static string TAG = "vshl::core::CapabilitiesFactory";
-
-using Level = vshl::utilities::logging::Logger::Level;
-
-namespace vshl {
-namespace capabilities {
-
-// Create CapabilitiesFactory
-std::unique_ptr<CapabilitiesFactory> CapabilitiesFactory::create() {
- auto capabilitiesFactory = std::unique_ptr<CapabilitiesFactory>(new CapabilitiesFactory());
- return capabilitiesFactory;
-}
-
-std::shared_ptr<common::interfaces::ICapability> CapabilitiesFactory::getGuiMetadata() {
- if (!mGuiMetadata) {
- mGuiMetadata = vshl::capabilities::guimetadata::GuiMetadata::create();
- }
- return mGuiMetadata;
-}
-
-std::shared_ptr<common::interfaces::ICapability> CapabilitiesFactory::getPhoneControl() {
- if (!mPhoneControl) {
- mPhoneControl = vshl::capabilities::phonecontrol::PhoneControl::create();
- }
- return mPhoneControl;
-}
-
-std::shared_ptr<common::interfaces::ICapability> CapabilitiesFactory::getNavigation() {
- if (!mNavigation) {
- mNavigation = vshl::capabilities::navigation::Navigation::create();
- }
- return mNavigation;
-}
-
-} // namespace capabilities
-} // namespace vshl \ No newline at end of file
diff --git a/src/plugins/capabilities/CapabilitiesFactory.h b/src/plugins/capabilities/CapabilitiesFactory.h
deleted file mode 100644
index b73909b..0000000
--- a/src/plugins/capabilities/CapabilitiesFactory.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright 2018-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License").
- * You may not use this file except in compliance with the License.
- * A copy of the License is located at
- *
- * http://aws.amazon.com/apache2.0/
- *
- * or in the "license" file accompanying this file. This file is distributed
- * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-#ifndef VSHL_CAPABILITIES_CAPABILITIESFACTORY_H_
-#define VSHL_CAPABILITIES_CAPABILITIESFACTORY_H_
-
-#include <memory>
-
-#include "interfaces/capabilities/ICapability.h"
-#include "utilities/logging/Logger.h"
-
-using namespace std;
-
-namespace vshl {
-namespace capabilities {
-/*
- * Factory for creating different capability objects.
- */
-class CapabilitiesFactory {
-public:
- // Create CapabilitiesFactory
- static std::unique_ptr<CapabilitiesFactory> create();
-
- // GUI Metadata capability
- std::shared_ptr<common::interfaces::ICapability> getGuiMetadata();
-
- // Phone call control capability
- std::shared_ptr<common::interfaces::ICapability> getPhoneControl();
-
- // Navigation capability
- std::shared_ptr<common::interfaces::ICapability> getNavigation();
-
- // Destructor
- ~CapabilitiesFactory() = default;
-
-private:
- // Constructor
- CapabilitiesFactory() = default;
-
- // Capabilities
- shared_ptr<vshl::common::interfaces::ICapability> mGuiMetadata;
- shared_ptr<vshl::common::interfaces::ICapability> mPhoneControl;
- shared_ptr<vshl::common::interfaces::ICapability> mNavigation;
-
- // Logger
- unique_ptr<vshl::utilities::logging::Logger> mLogger;
-};
-
-} // namespace capabilities
-} // namespace vshl
-
-#endif // VSHL_CAPABILITIES_CAPABILITIESFACTORY_H_
diff --git a/src/plugins/capabilities/CapabilityMessagingService.cpp b/src/plugins/capabilities/CapabilityMessagingService.cpp
deleted file mode 100644
index 91b5f2b..0000000
--- a/src/plugins/capabilities/CapabilityMessagingService.cpp
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Copyright 2018-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License").
- * You may not use this file except in compliance with the License.
- * A copy of the License is located at
- *
- * http://aws.amazon.com/apache2.0/
- *
- * or in the "license" file accompanying this file. This file is distributed
- * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-#include "capabilities/CapabilityMessagingService.h"
-
-#include "capabilities/core/include/PublisherForwarder.h"
-#include "capabilities/core/include/SubscriberForwarder.h"
-
-static string TAG = "vshl::capabilities::CapabilityMessagingService";
-
-using Level = vshl::common::interfaces::ILogger::Level;
-
-namespace vshl {
-namespace capabilities {
-
-// Create a CapabilityMessagingService.
-unique_ptr<CapabilityMessagingService> CapabilityMessagingService::create(
- shared_ptr<vshl::common::interfaces::ILogger> logger,
- shared_ptr<vshl::common::interfaces::IAFBApi> afbApi) {
- if (logger == nullptr) {
- return nullptr;
- }
-
- if (afbApi == nullptr) {
- logger->log(Level::ERROR, TAG, "Failed to create CapabilityMessagingService: AFB API null");
- return nullptr;
- }
-
- auto capabilityMessageService =
- std::unique_ptr<CapabilityMessagingService>(new CapabilityMessagingService(logger, afbApi));
- return capabilityMessageService;
-}
-
-CapabilityMessagingService::~CapabilityMessagingService() {
- mMessageChannelsMap.clear();
-}
-
-CapabilityMessagingService::CapabilityMessagingService(
- shared_ptr<vshl::common::interfaces::ILogger> logger,
- shared_ptr<vshl::common::interfaces::IAFBApi> afbApi) :
- mAfbApi(afbApi),
- mLogger(logger) {
-}
-
-// Subscribe to capability specific messages.
-bool CapabilityMessagingService::subscribe(
- vshl::common::interfaces::IAFBRequest& request,
- shared_ptr<common::interfaces::ICapability> capability,
- const string action) {
- auto capabilityName = capability->getName();
-
- if (capabilityName.empty()) {
- mLogger->log(Level::ERROR, TAG, "Failed to subscribe to message. Invalid input.");
- return false;
- }
-
- auto messageChannel = getMessageChannel(capability);
- return messageChannel->subscribe(request, action);
-}
-
-// Publish capability messages.
-bool CapabilityMessagingService::publish(
- shared_ptr<common::interfaces::ICapability> capability,
- const string action,
- const string payload) {
- auto capabilityName = capability->getName();
-
- if (capabilityName.empty()) {
- mLogger->log(Level::ERROR, TAG, "Failed to publish message. Invalid input.");
- return false;
- }
-
- auto messageChannelIt = mMessageChannelsMap.find(capabilityName);
- if (messageChannelIt == mMessageChannelsMap.end()) {
- mLogger->log(
- Level::ERROR,
- TAG,
- "Failed to publish message. Message channel doesn't exist for capability " + capabilityName);
- return false;
- }
-
- return messageChannelIt->second->publish(action, payload);
-}
-
-shared_ptr<vshl::capabilities::core::MessageChannel> CapabilityMessagingService::getMessageChannel(
- shared_ptr<common::interfaces::ICapability> capability) {
- auto capabilityName = capability->getName();
-
- if (capabilityName.empty()) {
- mLogger->log(Level::ERROR, TAG, "Failed to create message channel. Invalid input.");
- return nullptr;
- }
-
- auto messageChannelIt = mMessageChannelsMap.find(capabilityName);
- if (messageChannelIt == mMessageChannelsMap.end()) {
- mLogger->log(Level::INFO, TAG, "Creating new message channel for capability: " + capabilityName);
- auto messageChannel = vshl::capabilities::core::MessageChannel::create(mLogger, mAfbApi, capability);
- mMessageChannelsMap.insert(make_pair(capabilityName, messageChannel));
- return messageChannel;
- }
-
- return messageChannelIt->second;
-}
-
-} // namespace capabilities
-} // namespace vshl
diff --git a/src/plugins/capabilities/CapabilityMessagingService.h b/src/plugins/capabilities/CapabilityMessagingService.h
deleted file mode 100644
index 535e806..0000000
--- a/src/plugins/capabilities/CapabilityMessagingService.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright 2018-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License").
- * You may not use this file except in compliance with the License.
- * A copy of the License is located at
- *
- * http://aws.amazon.com/apache2.0/
- *
- * or in the "license" file accompanying this file. This file is distributed
- * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-#ifndef VSHL_CAPABILITIES_CAPABILITYMESSAGINGSERVICE_H_
-#define VSHL_CAPABILITIES_CAPABILITYMESSAGINGSERVICE_H_
-
-#include <memory>
-#include <string>
-#include <unordered_map>
-
-#include "capabilities/core/include/MessageChannel.h"
-#include "interfaces/afb/IAFBApi.h"
-#include "interfaces/capabilities/ICapability.h"
-#include "interfaces/utilities/logging/ILogger.h"
-
-using namespace std;
-
-namespace vshl {
-namespace capabilities {
-/*
- * This hosts service APIs that clients can use to subscribe and
- * forward capability messages. Each capability has a name and
- * direction (upstream/downstream). Upstream messages are from
- * voiceagents to Apps and downstream messages are Apps to voiceagents.
- * This class will use a factory to create publisher and subcribers for
- * each capability and create assiociations between them.
- */
-class CapabilityMessagingService {
-public:
- // Create a CapabilityMessagingService.
- static std::unique_ptr<CapabilityMessagingService>
- create(shared_ptr<vshl::common::interfaces::ILogger> logger,
- shared_ptr<vshl::common::interfaces::IAFBApi> afbApi);
-
- // Subscribe to capability specific messages.
- bool subscribe(vshl::common::interfaces::IAFBRequest &request,
- shared_ptr<common::interfaces::ICapability> capability,
- const string action);
-
- // Publish capability messages.
- bool publish(shared_ptr<common::interfaces::ICapability> capability,
- const string action, const string payload);
-
- // Destructor
- ~CapabilityMessagingService();
-
-private:
- // Constructor
- CapabilityMessagingService(
- shared_ptr<vshl::common::interfaces::ILogger> logger,
- shared_ptr<vshl::common::interfaces::IAFBApi> afbApi);
-
- // Binding API reference
- shared_ptr<vshl::common::interfaces::IAFBApi> mAfbApi;
-
- // Create a message channel for the capability.
- shared_ptr<vshl::capabilities::core::MessageChannel>
- getMessageChannel(shared_ptr<common::interfaces::ICapability> capability);
-
- // Map of capabilities to message channels.
- unordered_map<string, shared_ptr<vshl::capabilities::core::MessageChannel>>
- mMessageChannelsMap;
-
- // Logger
- shared_ptr<vshl::common::interfaces::ILogger> mLogger;
-};
-
-} // namespace capabilities
-} // namespace vshl
-
-#endif // VSHL_CAPABILITIES_CAPABILITYMESSAGINGSERVICE_H_
diff --git a/src/plugins/capabilities/communication/include/PhoneControlCapability.h b/src/plugins/capabilities/communication/include/PhoneControlCapability.h
deleted file mode 100644
index 55ada8d..0000000
--- a/src/plugins/capabilities/communication/include/PhoneControlCapability.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright 2018-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License").
- * You may not use this file except in compliance with the License.
- * A copy of the License is located at
- *
- * http://aws.amazon.com/apache2.0/
- *
- * or in the "license" file accompanying this file. This file is distributed
- * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-#ifndef VSHL_CAPABILITIES_PHONECONTROL_CAPABILITY_H_
-#define VSHL_CAPABILITIES_PHONECONTROL_CAPABILITY_H_
-
-#include <memory>
-
-#include "interfaces/capabilities/ICapability.h"
-
-namespace vshl {
-namespace capabilities {
-namespace phonecontrol {
-
-/*
- * PhoneControl capability. Calls are initiated in the endpoint.
- */
-class PhoneControl : public common::interfaces::ICapability {
-public:
- // Create a PhoneControl.
- static std::shared_ptr<PhoneControl> create();
-
- ~PhoneControl() = default;
-
-protected:
- string getName() const override;
-
- list<string> getUpstreamMessages() const override;
-
- list<string> getDownstreamMessages() const override;
-
-private:
- PhoneControl() = default;
-};
-
-} // namespace phonecontrol
-} // namespace capabilities
-} // namespace vshl
-
-#endif // VSHL_CAPABILITIES_PHONECONTROL_CAPABILITY_H_
diff --git a/src/plugins/capabilities/communication/include/PhoneControlMessages.h b/src/plugins/capabilities/communication/include/PhoneControlMessages.h
deleted file mode 100644
index 4c68455..0000000
--- a/src/plugins/capabilities/communication/include/PhoneControlMessages.h
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Copyright 2018-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License").
- * You may not use this file except in compliance with the License.
- * A copy of the License is located at
- *
- * http://aws.amazon.com/apache2.0/
- *
- * or in the "license" file accompanying this file. This file is distributed
- * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-#ifndef VSHL_CAPABILITIES_PHONECONTROL_MESSAGES_H_
-#define VSHL_CAPABILITIES_PHONECONTROL_MESSAGES_H_
-
-#include <list>
-#include <string>
-
-using namespace std;
-
-namespace vshl {
-namespace capabilities {
-namespace phonecontrol {
-
-static string NAME = "phonecontrol";
-
-// Supported actions from VA -> Apps
-/* Dial message sent from VA to app handling the calling.
- *
- * Payload
- * {
- * "callId": "{{STRING}}",
- * "callee": {
- * "details": "{{STRING}}",
- * "defaultAddress": {
- * "protocol": "{{STRING}}",
- * "format": "{{STRING}}",
- * "value": "{{STRING}}"
- * },
- * "alternativeAddresses": [{
- * "protocol": "{{STRING}}",
- * "format": "{{STRING}}",
- * "value": {{STRING}}
- * }]
- * }
- * }
- * }
- *
- * callId (required): A unique identifier for the call
- * callee (required): The destination of the outgoing call
- * callee.details (optional): Descriptive information about the callee
- * callee.defaultAddress (required): The default address to use for calling the callee
- * callee.alternativeAddresses (optional): An array of alternate addresses for the existing callee
- * address.protocol (required): The protocol for this address of the callee (e.g. PSTN, SIP, H323, etc.)
- * address.format (optional): The format for this address of the callee (e.g. E.164, E.163, E.123, DIN5008, etc.)
- * address.value (required): The address of the callee.
- *
- */
-static string PHONECONTROL_DIAL = "dial";
-
-// Supported actions from Apps -> VA
-/*
- * App notifies the voiceagents of a change in connection state of a calling device.
- *
- * Payload
- * {
- * "state" : "{{STRING}}" // CONNECTED or DISCONNECTED
- * }
- */
-static string PHONECONTROL_CONNECTIONSTATE_CHANGED = "connection_state_changed";
-/*
- * App notifies the voiceagents that call is activated
- *
- * callId must match the one that is sent by VA with DIAL message above.
- *
- * Payload
- * {
- * "callId" : "{{STRING}}"
- * }
- */
-static string PHONECONTROL_CALL_ACTIVATED = "call_activated";
-/*
- * App notifies the voiceagents of an error in initiating or maintaining a
- * call on a calling device
- *
- * callId must match the one that is sent by VA with DIAL message above.
- * error: below status codes.
- * 4xx: Validation failure for the input from the DIAL message
- * 500: Internal error on the platform unrelated to the cellular network
- * 503: Error on the platform related to the cellular network
- *
- * Payload
- * {
- * "callId" : "{{STRING}}"
- * "error" : "{{STRING}}"
- * }
- */
-static string PHONECONTROL_CALL_FAILED = "call_failed";
-/*
- * App notifies the voiceagents that call is terminated
- *
- * callId must match the one that is sent by VA with DIAL message above.
- *
- * Payload
- * {
- * "callId" : "{{STRING}}"
- * }
- */
-static string PHONECONTROL_CALL_TERMINATED = "call_terminated";
-
-// List of actions that are delivered from VA -> Apps
-static list<string> PHONECONTROL_UPSTREAM_ACTIONS = {
- PHONECONTROL_DIAL,
-};
-
-// List of actions that are delivered from Apps -> VA
-static list<string> PHONECONTROL_DOWNSTREAM_ACTIONS = {PHONECONTROL_CONNECTIONSTATE_CHANGED,
- PHONECONTROL_CALL_ACTIVATED,
- PHONECONTROL_CALL_FAILED,
- PHONECONTROL_CALL_TERMINATED};
-
-} // namespace phonecontrol
-} // namespace capabilities
-} // namespace vshl
-
-#endif // VSHL_CAPABILITIES_PHONECONTROL_MESSAGES_H_
diff --git a/src/plugins/capabilities/communication/src/PhoneControlCapability.cpp b/src/plugins/capabilities/communication/src/PhoneControlCapability.cpp
deleted file mode 100644
index 6a74d5a..0000000
--- a/src/plugins/capabilities/communication/src/PhoneControlCapability.cpp
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright 2018-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License").
- * You may not use this file except in compliance with the License.
- * A copy of the License is located at
- *
- * http://aws.amazon.com/apache2.0/
- *
- * or in the "license" file accompanying this file. This file is distributed
- * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-#include "capabilities/communication/include/PhoneControlCapability.h"
-#include "capabilities/communication/include/PhoneControlMessages.h"
-
-namespace vshl {
-namespace capabilities {
-namespace phonecontrol {
-
-// Create a phonecontrol.
-shared_ptr<PhoneControl> PhoneControl::create() {
- auto phonecontrol = std::shared_ptr<PhoneControl>(new PhoneControl());
- return phonecontrol;
-}
-
-string PhoneControl::getName() const {
- return NAME;
-}
-
-list<string> PhoneControl::getUpstreamMessages() const {
- return PHONECONTROL_UPSTREAM_ACTIONS;
-}
-
-list<string> PhoneControl::getDownstreamMessages() const {
- return PHONECONTROL_DOWNSTREAM_ACTIONS;
-}
-
-} // namespace phonecontrol
-} // namespace capabilities
-} // namespace vshl
diff --git a/src/plugins/capabilities/core/include/MessageChannel.h b/src/plugins/capabilities/core/include/MessageChannel.h
deleted file mode 100644
index 504e241..0000000
--- a/src/plugins/capabilities/core/include/MessageChannel.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright 2018-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License").
- * You may not use this file except in compliance with the License.
- * A copy of the License is located at
- *
- * http://aws.amazon.com/apache2.0/
- *
- * or in the "license" file accompanying this file. This file is distributed
- * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-#ifndef VSHL_CAPABILITIES_CORE_MESSAGECHANNEL_H_
-#define VSHL_CAPABILITIES_CORE_MESSAGECHANNEL_H_
-
-#include <memory>
-
-#include "capabilities/core/include/PublisherForwarder.h"
-#include "capabilities/core/include/SubscriberForwarder.h"
-#include "interfaces/afb/IAFBApi.h"
-#include "interfaces/capabilities/ICapability.h"
-#include "interfaces/utilities/logging/ILogger.h"
-
-using namespace std;
-
-namespace vshl {
-namespace capabilities {
-namespace core {
-/*
- * MessageChannel has one end as publisher forwarder and the other end
- * as subscriber forwarder.
- */
-class MessageChannel {
-public:
- // Create a MessageChannel.
- static std::shared_ptr<MessageChannel>
- create(shared_ptr<vshl::common::interfaces::ILogger> logger,
- shared_ptr<vshl::common::interfaces::IAFBApi> afbApi,
- shared_ptr<vshl::common::interfaces::ICapability> capability);
-
- // Sends the message
- bool publish(const string action, const string payload);
-
- // Subscribe
- bool subscribe(vshl::common::interfaces::IAFBRequest &request,
- const string action);
-
- // Destructor
- virtual ~MessageChannel() = default;
-
-private:
- // Constructor
- MessageChannel(shared_ptr<vshl::common::interfaces::ILogger> logger,
- shared_ptr<vshl::common::interfaces::IAFBApi> afbApi,
- shared_ptr<vshl::common::interfaces::ICapability> capability);
-
- // Forwarders
- shared_ptr<PublisherForwarder> mPublisherForwarder;
- shared_ptr<SubscriberForwarder> mSubscriberForwarder;
-};
-
-} // namespace core
-} // namespace capabilities
-} // namespace vshl
-
-#endif // VSHL_CAPABILITIES_CORE_MESSAGECHANNEL_H_
diff --git a/src/plugins/capabilities/core/include/PublisherForwarder.h b/src/plugins/capabilities/core/include/PublisherForwarder.h
deleted file mode 100644
index 9cc89b5..0000000
--- a/src/plugins/capabilities/core/include/PublisherForwarder.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright 2018-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License").
- * You may not use this file except in compliance with the License.
- * A copy of the License is located at
- *
- * http://aws.amazon.com/apache2.0/
- *
- * or in the "license" file accompanying this file. This file is distributed
- * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-#ifndef VSHL_CAPABILITIES_CORE_PUBLISHERFORWARDER_H_
-#define VSHL_CAPABILITIES_CORE_PUBLISHERFORWARDER_H_
-
-#include <memory>
-
-#include "capabilities/core/include/SubscriberForwarder.h"
-
-#include "interfaces/afb/IAFBApi.h"
-#include "interfaces/capabilities/ICapability.h"
-#include "interfaces/utilities/logging/ILogger.h"
-
-using namespace std;
-
-namespace vshl {
-namespace capabilities {
-namespace core {
-/*
- * This class is responsible for forwarding the messages to be published
- * to subscriber forwarder. Subscriber forwarder will deliver the messages
- * as AFB Events to all the subscribed clients.
- * There is one PublisherForwarder and one SubscriberForwarder per capability.
- */
-class PublisherForwarder {
-public:
- // Create a PublisherForwarder.
- static std::shared_ptr<PublisherForwarder> create(
- shared_ptr<vshl::common::interfaces::ILogger> logger,
- shared_ptr<vshl::common::interfaces::ICapability> capability);
-
- // Connect a subscriber forwarder to this publisher forwarder
- void setSubscriberForwarder(shared_ptr<SubscriberForwarder> subscriberForwarder);
-
- // Forward message to the subscriber forwarder
- bool forwardMessage(const string action, const string payload);
-
- // Destructor
- ~PublisherForwarder();
-
-private:
- // Constructor
- PublisherForwarder(
- shared_ptr<vshl::common::interfaces::ILogger> logger,
- shared_ptr<vshl::common::interfaces::ICapability> capability);
-
- // Subscriber forwarder connected to this publisher forwarder.
- shared_ptr<SubscriberForwarder> mSubscriberForwarder;
-
- // Capability
- shared_ptr<vshl::common::interfaces::ICapability> mCapability;
-
- // Logger
- shared_ptr<vshl::common::interfaces::ILogger> mLogger;
-};
-
-} // namespace core
-} // namespace capabilities
-} // namespace vshl
-
-#endif // VSHL_CAPABILITIES_CORE_PUBLISHERFORWARDER_H_
diff --git a/src/plugins/capabilities/core/include/SubscriberForwarder.h b/src/plugins/capabilities/core/include/SubscriberForwarder.h
deleted file mode 100644
index 94c04bf..0000000
--- a/src/plugins/capabilities/core/include/SubscriberForwarder.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright 2018-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License").
- * You may not use this file except in compliance with the License.
- * A copy of the License is located at
- *
- * http://aws.amazon.com/apache2.0/
- *
- * or in the "license" file accompanying this file. This file is distributed
- * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-#ifndef VSHL_CAPABILITIES_CORE_SUBSCRIBERFORWARDER_H_
-#define VSHL_CAPABILITIES_CORE_SUBSCRIBERFORWARDER_H_
-
-#include <memory>
-#include <string>
-#include <unordered_map>
-
-#include "interfaces/afb/IAFBApi.h"
-#include "interfaces/capabilities/ICapability.h"
-#include "interfaces/utilities/logging/ILogger.h"
-
-using namespace std;
-
-namespace vshl {
-namespace capabilities {
-namespace core {
-/*
- * This class is responsible for forwarding the messages publishing
- * to the actual clients using AFB.
- */
-class SubscriberForwarder {
-public:
- // Create a SubscriberForwarder.
- static std::shared_ptr<SubscriberForwarder>
- create(shared_ptr<vshl::common::interfaces::ILogger> logger,
- shared_ptr<vshl::common::interfaces::IAFBApi> afbApi,
- shared_ptr<vshl::common::interfaces::ICapability> capability);
-
- // Publish a capability message to the actual client.
- bool forwardMessage(const string action, const string payload);
-
- // Subscribe
- bool subscribe(vshl::common::interfaces::IAFBRequest &request,
- const string action);
-
- // Destructor
- ~SubscriberForwarder();
-
-private:
- // Constructor
- SubscriberForwarder(
- shared_ptr<vshl::common::interfaces::ILogger> logger,
- shared_ptr<vshl::common::interfaces::IAFBApi> afbApi,
- shared_ptr<vshl::common::interfaces::ICapability> capability);
-
- // Creates both upstream and downstream events
- void createEvents();
-
- // Binding API reference
- shared_ptr<vshl::common::interfaces::IAFBApi> mAfbApi;
-
- // Capability
- shared_ptr<vshl::common::interfaces::ICapability> mCapability;
-
- // Maps of capability action events to its corresponding Event object.
- // Event name maps to Action Name
- unordered_map<string, shared_ptr<common::interfaces::IAFBApi::IAFBEvent>>
- mUpstreamEventsMap;
- unordered_map<string, shared_ptr<common::interfaces::IAFBApi::IAFBEvent>>
- mDownstreamEventsMap;
-
- // Logger
- shared_ptr<vshl::common::interfaces::ILogger> mLogger;
-};
-
-} // namespace core
-} // namespace capabilities
-} // namespace vshl
-
-#endif // VSHL_CAPABILITIES_CORE_SUBSCRIBERFORWARDER_H_
diff --git a/src/plugins/capabilities/core/src/MessageChannel.cpp b/src/plugins/capabilities/core/src/MessageChannel.cpp
deleted file mode 100644
index eaa1349..0000000
--- a/src/plugins/capabilities/core/src/MessageChannel.cpp
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright 2018-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License").
- * You may not use this file except in compliance with the License.
- * A copy of the License is located at
- *
- * http://aws.amazon.com/apache2.0/
- *
- * or in the "license" file accompanying this file. This file is distributed
- * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-#include "capabilities/core/include/MessageChannel.h"
-
-namespace vshl {
-namespace capabilities {
-namespace core {
-
-// Create a MessageChannel.
-std::shared_ptr<MessageChannel> MessageChannel::create(
- shared_ptr<vshl::common::interfaces::ILogger> logger,
- shared_ptr<vshl::common::interfaces::IAFBApi> api,
- shared_ptr<vshl::common::interfaces::ICapability> capability) {
- auto messageChannel = std::shared_ptr<MessageChannel>(new MessageChannel(logger, api, capability));
- return messageChannel;
-}
-
-MessageChannel::MessageChannel(
- shared_ptr<vshl::common::interfaces::ILogger> logger,
- shared_ptr<vshl::common::interfaces::IAFBApi> api,
- shared_ptr<vshl::common::interfaces::ICapability> capability) {
- // Subscriber forwarder
- mSubscriberForwarder = SubscriberForwarder::create(logger, api, capability);
- // Publisher forwarder
- mPublisherForwarder = PublisherForwarder::create(logger, capability);
- mPublisherForwarder->setSubscriberForwarder(mSubscriberForwarder);
-}
-
-bool MessageChannel::publish(const string action, const string payload) {
- return mPublisherForwarder->forwardMessage(action, payload);
-}
-
-bool MessageChannel::subscribe(vshl::common::interfaces::IAFBRequest& request, const string action) {
- return mSubscriberForwarder->subscribe(request, action);
-}
-
-} // namespace core
-} // namespace capabilities
-} // namespace vshl
diff --git a/src/plugins/capabilities/core/src/PublisherForwarder.cpp b/src/plugins/capabilities/core/src/PublisherForwarder.cpp
deleted file mode 100644
index 81de6a0..0000000
--- a/src/plugins/capabilities/core/src/PublisherForwarder.cpp
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright 2018-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License").
- * You may not use this file except in compliance with the License.
- * A copy of the License is located at
- *
- * http://aws.amazon.com/apache2.0/
- *
- * or in the "license" file accompanying this file. This file is distributed
- * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-#include "capabilities/core/include/PublisherForwarder.h"
-
-static string TAG = "vshl::capabilities::PublisherForwarder";
-
-using Level = vshl::common::interfaces::ILogger::Level;
-
-namespace vshl {
-namespace capabilities {
-namespace core {
-
-// Create a PublisherForwarder.
-std::shared_ptr<PublisherForwarder> PublisherForwarder::create(
- shared_ptr<vshl::common::interfaces::ILogger> logger,
- shared_ptr<vshl::common::interfaces::ICapability> capability) {
- if (logger == nullptr) {
- return nullptr;
- }
-
- if (capability == nullptr) {
- logger->log(Level::ERROR, TAG, "Failed to create PublisherForwarder: Capability null");
- return nullptr;
- }
-
- auto publisherForwarder = std::shared_ptr<PublisherForwarder>(new PublisherForwarder(logger, capability));
- return publisherForwarder;
-}
-
-// Constructor
-PublisherForwarder::PublisherForwarder(
- shared_ptr<vshl::common::interfaces::ILogger> logger,
- shared_ptr<vshl::common::interfaces::ICapability> capability) {
- mCapability = capability;
- mLogger = logger;
-}
-
-// Destructor
-PublisherForwarder::~PublisherForwarder() {
-}
-
-void PublisherForwarder::setSubscriberForwarder(shared_ptr<SubscriberForwarder> subscriberForwarder) {
- mSubscriberForwarder = subscriberForwarder;
-}
-
-bool PublisherForwarder::forwardMessage(const string action, const string payload) {
- if (!mSubscriberForwarder) {
- mLogger->log(Level::ERROR, TAG, "Failed to forward message for capability: " + mCapability->getName());
- return false;
- }
-
- return mSubscriberForwarder->forwardMessage(action, payload);
-}
-
-} // namespace core
-} // namespace capabilities
-} // namespace vshl
diff --git a/src/plugins/capabilities/core/src/SubscriberForwarder.cpp b/src/plugins/capabilities/core/src/SubscriberForwarder.cpp
deleted file mode 100644
index ea42305..0000000
--- a/src/plugins/capabilities/core/src/SubscriberForwarder.cpp
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * Copyright 2018-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License").
- * You may not use this file except in compliance with the License.
- * A copy of the License is located at
- *
- * http://aws.amazon.com/apache2.0/
- *
- * or in the "license" file accompanying this file. This file is distributed
- * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-#include "capabilities/core/include/SubscriberForwarder.h"
-
-static string TAG = "vshl::capabilities::SubscriberForwarder";
-
-using Level = vshl::common::interfaces::ILogger::Level;
-
-namespace vshl {
-namespace capabilities {
-namespace core {
-
-// Create a SubscriberForwarder.
-std::shared_ptr<SubscriberForwarder> SubscriberForwarder::create(
- shared_ptr<vshl::common::interfaces::ILogger> logger,
- shared_ptr<vshl::common::interfaces::IAFBApi> afbApi,
- shared_ptr<vshl::common::interfaces::ICapability> capability) {
- if (logger == nullptr) {
- return nullptr;
- }
-
- if (afbApi == nullptr) {
- logger->log(Level::ERROR, TAG, "Failed to create SubscriberForwarder: AFB API null");
- return nullptr;
- }
-
- if (capability == nullptr) {
- logger->log(Level::ERROR, TAG, "Failed to create SubscriberForwarder: Capability null");
- return nullptr;
- }
-
- auto subscriberForwarder =
- std::shared_ptr<SubscriberForwarder>(new SubscriberForwarder(logger, afbApi, capability));
- return subscriberForwarder;
-}
-
-SubscriberForwarder::SubscriberForwarder(
- shared_ptr<vshl::common::interfaces::ILogger> logger,
- shared_ptr<vshl::common::interfaces::IAFBApi> afbApi,
- shared_ptr<vshl::common::interfaces::ICapability> capability) :
- mAfbApi(afbApi),
- mLogger(logger),
- mCapability(capability) {
- createEvents();
-}
-
-SubscriberForwarder::~SubscriberForwarder() {
- mUpstreamEventsMap.clear();
- mDownstreamEventsMap.clear();
-}
-
-void SubscriberForwarder::createEvents() {
- if (!mCapability) {
- mLogger->log(Level::NOTICE, TAG, "Create Events failed. No capability assigned.");
- return;
- }
-
- // Upstream events
- auto upstreamEvents = mCapability->getUpstreamMessages();
- for (auto upstreamEventName : upstreamEvents) {
- auto it = mUpstreamEventsMap.find(upstreamEventName);
- if (it == mUpstreamEventsMap.end() && mAfbApi) {
- // create a new event and add it to the map.
- shared_ptr<common::interfaces::IAFBApi::IAFBEvent> event = mAfbApi->createEvent(upstreamEventName);
- if (event == nullptr) {
- mLogger->log(Level::ERROR, TAG, "Failed to create upstream event: " + upstreamEventName);
- } else {
- mUpstreamEventsMap.insert(make_pair(upstreamEventName, event));
- }
- }
- }
-
- // Downstream events
- auto downstreamEvents = mCapability->getDownstreamMessages();
- for (auto downstreamEventName : downstreamEvents) {
- auto it = mDownstreamEventsMap.find(downstreamEventName);
- if (it == mDownstreamEventsMap.end() && mAfbApi) {
- // create a new event and add it to the map.
- shared_ptr<common::interfaces::IAFBApi::IAFBEvent> event = mAfbApi->createEvent(downstreamEventName);
- if (event == nullptr) {
- mLogger->log(Level::ERROR, TAG, "Failed to create downstream event: " + downstreamEventName);
- } else {
- mDownstreamEventsMap.insert(make_pair(downstreamEventName, event));
- }
- }
- }
-}
-
-bool SubscriberForwarder::forwardMessage(const string action, const string payload) {
- auto upstreamEventIt = mUpstreamEventsMap.find(action);
- if (upstreamEventIt != mUpstreamEventsMap.end()) {
- mLogger->log(Level::NOTICE, TAG, "Publishing upstream event: " + action);
- upstreamEventIt->second->publishEvent(json_object_new_string(payload.c_str()));
- return true;
- }
-
- auto downstreamEventIt = mDownstreamEventsMap.find(action);
- if (downstreamEventIt != mDownstreamEventsMap.end()) {
- mLogger->log(Level::NOTICE, TAG, "Publishing downstream event: " + action);
- downstreamEventIt->second->publishEvent(json_object_new_string(payload.c_str()));
- return true;
- }
-
- mLogger->log(Level::NOTICE, TAG, "Failed to publish upstream event: " + action);
- return false;
-}
-
-bool SubscriberForwarder::subscribe(vshl::common::interfaces::IAFBRequest& request, const string action) {
- auto upstreamEventIt = mUpstreamEventsMap.find(action);
- if (upstreamEventIt != mUpstreamEventsMap.end()) {
- mLogger->log(Level::NOTICE, TAG, "Subscribing to upstream event: " + action);
- return upstreamEventIt->second->subscribe(request);
- }
-
- auto downstreamEventIt = mDownstreamEventsMap.find(action);
- if (downstreamEventIt != mDownstreamEventsMap.end()) {
- mLogger->log(Level::NOTICE, TAG, "Subscribing to downstream event: " + action);
- return downstreamEventIt->second->subscribe(request);
- }
-
- mLogger->log(Level::NOTICE, TAG, "Failed to subscribe to upstream event: " + action);
- return false;
-}
-
-} // namespace core
-} // namespace capabilities
-} // namespace vshl
diff --git a/src/plugins/capabilities/guimetadata/include/GuiMetadataCapability.h b/src/plugins/capabilities/guimetadata/include/GuiMetadataCapability.h
deleted file mode 100644
index 199f49a..0000000
--- a/src/plugins/capabilities/guimetadata/include/GuiMetadataCapability.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright 2018-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License").
- * You may not use this file except in compliance with the License.
- * A copy of the License is located at
- *
- * http://aws.amazon.com/apache2.0/
- *
- * or in the "license" file accompanying this file. This file is distributed
- * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-#ifndef VSHL_CAPABILITIES_GUIMETADATA_CAPABILITY_H_
-#define VSHL_CAPABILITIES_GUIMETADATA_CAPABILITY_H_
-
-#include <memory>
-
-#include "interfaces/capabilities/ICapability.h"
-
-namespace vshl {
-namespace capabilities {
-namespace guimetadata {
-
-/*
- * GuiMetadata capability
- */
-class GuiMetadata : public common::interfaces::ICapability {
-public:
- // Create a GuiMetadata.
- static std::shared_ptr<GuiMetadata> create();
-
- ~GuiMetadata() = default;
-
-protected:
- string getName() const override;
-
- list<string> getUpstreamMessages() const override;
-
- list<string> getDownstreamMessages() const override;
-
-private:
- GuiMetadata() = default;
-};
-
-} // namespace guimetadata
-} // namespace capabilities
-} // namespace vshl
-
-#endif // VSHL_CAPABILITIES_GUIMETADATA_CAPABILITY_H_
diff --git a/src/plugins/capabilities/guimetadata/include/GuiMetadataMessages.h b/src/plugins/capabilities/guimetadata/include/GuiMetadataMessages.h
deleted file mode 100644
index 783b401..0000000
--- a/src/plugins/capabilities/guimetadata/include/GuiMetadataMessages.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright 2018-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License").
- * You may not use this file except in compliance with the License.
- * A copy of the License is located at
- *
- * http://aws.amazon.com/apache2.0/
- *
- * or in the "license" file accompanying this file. This file is distributed
- * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-#ifndef VSHL_CAPABILITIES_GUIMETADATA_ACTIONS_H_
-#define VSHL_CAPABILITIES_GUIMETADATA_ACTIONS_H_
-
-#include <list>
-#include <string>
-
-using namespace std;
-
-namespace vshl {
-namespace capabilities {
-namespace guimetadata {
-
-static string NAME = "guimetadata";
-
-// Supported actions from VA -> Apps
-static string GUIMETADATA_RENDER_TEMPLATE = "render_template";
-static string GUIMETADATA_CLEAR_TEMPLATE = "clear_template";
-static string GUIMETADATA_RENDER_PLAYER_INFO = "render_player_info";
-static string GUIMETADATA_CLEAR_PLAYER_INFO = "clear_player_info";
-
-// Supported actions from Apps -> VA
-
-// List of actions that are delivered from VA -> Apps
-static list<string> GUIMETADATA_UPSTREAM_ACTIONS = {GUIMETADATA_RENDER_TEMPLATE,
- GUIMETADATA_CLEAR_TEMPLATE,
- GUIMETADATA_RENDER_PLAYER_INFO,
- GUIMETADATA_CLEAR_PLAYER_INFO};
-
-// List of actions that are delivered from Apps -> VA
-static list<string> GUIMETADATA_DOWNSTREAM_ACTIONS = {};
-
-} // namespace guimetadata
-} // namespace capabilities
-} // namespace vshl
-
-#endif // VSHL_CAPABILITIES_GUIMETADATA_ACTIONS_H_
diff --git a/src/plugins/capabilities/guimetadata/src/GuiMetadataCapability.cpp b/src/plugins/capabilities/guimetadata/src/GuiMetadataCapability.cpp
deleted file mode 100644
index 106fe99..0000000
--- a/src/plugins/capabilities/guimetadata/src/GuiMetadataCapability.cpp
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright 2018-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License").
- * You may not use this file except in compliance with the License.
- * A copy of the License is located at
- *
- * http://aws.amazon.com/apache2.0/
- *
- * or in the "license" file accompanying this file. This file is distributed
- * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-#include "capabilities/guimetadata/include/GuiMetadataCapability.h"
-#include "capabilities/guimetadata/include/GuiMetadataMessages.h"
-
-namespace vshl {
-namespace capabilities {
-namespace guimetadata {
-
-// Create a GuiMetadata.
-shared_ptr<GuiMetadata> GuiMetadata::create() {
- auto guiMetadata = std::shared_ptr<GuiMetadata>(new GuiMetadata());
- return guiMetadata;
-}
-
-string GuiMetadata::getName() const {
- return NAME;
-}
-
-list<string> GuiMetadata::getUpstreamMessages() const {
- return GUIMETADATA_UPSTREAM_ACTIONS;
-}
-
-list<string> GuiMetadata::getDownstreamMessages() const {
- return GUIMETADATA_DOWNSTREAM_ACTIONS;
-}
-
-} // namespace guimetadata
-} // namespace capabilities
-} // namespace vshl
diff --git a/src/plugins/capabilities/navigation/include/NavigationCapability.h b/src/plugins/capabilities/navigation/include/NavigationCapability.h
deleted file mode 100644
index 66109d5..0000000
--- a/src/plugins/capabilities/navigation/include/NavigationCapability.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright 2018-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License").
- * You may not use this file except in compliance with the License.
- * A copy of the License is located at
- *
- * http://aws.amazon.com/apache2.0/
- *
- * or in the "license" file accompanying this file. This file is distributed
- * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-#ifndef VSHL_CAPABILITIES_NAVIGATION_CAPABILITY_H_
-#define VSHL_CAPABILITIES_NAVIGATION_CAPABILITY_H_
-
-#include <memory>
-
-#include "interfaces/capabilities/ICapability.h"
-
-namespace vshl {
-namespace capabilities {
-namespace navigation {
-
-/*
- * Navigation capability
- */
-class Navigation : public common::interfaces::ICapability {
-public:
- // Create a Navigation.
- static std::shared_ptr<Navigation> create();
-
- ~Navigation() = default;
-
-protected:
- string getName() const override;
-
- list<string> getUpstreamMessages() const override;
-
- list<string> getDownstreamMessages() const override;
-
-private:
- Navigation() = default;
-};
-
-} // namespace navigation
-} // namespace capabilities
-} // namespace vshl
-
-#endif // VSHL_CAPABILITIES_NAVIGATION_CAPABILITY_H_
diff --git a/src/plugins/capabilities/navigation/include/NavigationMessages.h b/src/plugins/capabilities/navigation/include/NavigationMessages.h
deleted file mode 100644
index aed9b9e..0000000
--- a/src/plugins/capabilities/navigation/include/NavigationMessages.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright 2018-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License").
- * You may not use this file except in compliance with the License.
- * A copy of the License is located at
- *
- * http://aws.amazon.com/apache2.0/
- *
- * or in the "license" file accompanying this file. This file is distributed
- * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-#ifndef VSHL_CAPABILITIES_NAVIGATION_ACTIONS_H_
-#define VSHL_CAPABILITIES_NAVIGATION_ACTIONS_H_
-
-#include <list>
-#include <string>
-
-using namespace std;
-
-namespace vshl {
-namespace capabilities {
-namespace navigation {
-
-static string NAME = "navigation";
-
-// Supported actions from VA -> Apps
-static string NAVIGATION_SET_DESTINATION = "set_destination";
-static string NAVIGATION_CANCEL = "cancel_navigation";
-
-// Supported actions from Apps -> VA
-
-// List of actions that are delivered from VA -> Apps
-static list<string> NAVIGATION_UPSTREAM_ACTIONS = {
- NAVIGATION_SET_DESTINATION,
- NAVIGATION_CANCEL,
-};
-
-// List of actions that are delivered from Apps -> VA
-static list<string> NAVIGATION_DOWNSTREAM_ACTIONS = {};
-
-} // namespace navigation
-} // namespace capabilities
-} // namespace vshl
-
-#endif // VSHL_CAPABILITIES_NAVIGATION_ACTIONS_H_
diff --git a/src/plugins/capabilities/navigation/src/NavigationCapability.cpp b/src/plugins/capabilities/navigation/src/NavigationCapability.cpp
deleted file mode 100644
index d4a5119..0000000
--- a/src/plugins/capabilities/navigation/src/NavigationCapability.cpp
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright 2018-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License").
- * You may not use this file except in compliance with the License.
- * A copy of the License is located at
- *
- * http://aws.amazon.com/apache2.0/
- *
- * or in the "license" file accompanying this file. This file is distributed
- * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-#include "capabilities/navigation/include/NavigationCapability.h"
-#include "capabilities/navigation/include/NavigationMessages.h"
-
-namespace vshl {
-namespace capabilities {
-namespace navigation {
-
-// Create a Navigation.
-shared_ptr<Navigation> Navigation::create() {
- auto navigation = std::shared_ptr<Navigation>(new Navigation());
- return navigation;
-}
-
-string Navigation::getName() const {
- return NAME;
-}
-
-list<string> Navigation::getUpstreamMessages() const {
- return NAVIGATION_UPSTREAM_ACTIONS;
-}
-
-list<string> Navigation::getDownstreamMessages() const {
- return NAVIGATION_DOWNSTREAM_ACTIONS;
-}
-
-} // namespace navigation
-} // namespace capabilities
-} // namespace vshl
diff --git a/src/plugins/capabilities/test/CapabilityMessagingServiceTest.cpp b/src/plugins/capabilities/test/CapabilityMessagingServiceTest.cpp
deleted file mode 100644
index 741a8aa..0000000
--- a/src/plugins/capabilities/test/CapabilityMessagingServiceTest.cpp
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright 2018-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License").
- * You may not use this file except in compliance with the License.
- * A copy of the License is located at
- *
- * http://aws.amazon.com/apache2.0/
- *
- * or in the "license" file accompanying this file. This file is distributed
- * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-#include <gtest/gtest.h>
-
-#include "capabilities/CapabilityMessagingService.h"
-
-#include "test/common/ConsoleLogger.h"
-#include "test/mocks/AFBApiMock.h"
-#include "test/mocks/AFBEventMock.h"
-#include "test/mocks/AFBRequestMock.h"
-#include "test/mocks/CapabilityMock.h"
-
-using namespace vshl::common::interfaces;
-using namespace vshl::capabilities;
-using namespace vshl::test::common;
-
-namespace vshl {
-namespace test {
-
-class CapabilityMessagingServiceTest : public ::testing::Test {
-protected:
- void SetUp() override {
- mConsoleLogger = std::make_shared<ConsoleLogger>();
- mAfbApi = std::make_shared<::testing::NiceMock<AFBApiMock>>();
- }
-
- std::shared_ptr<::testing::NiceMock<AFBApiMock>> mAfbApi;
- std::shared_ptr<ConsoleLogger> mConsoleLogger;
-};
-
-TEST_F(CapabilityMessagingServiceTest, failsInitializationOnInvalidParams) {
- auto service = CapabilityMessagingService::create(mConsoleLogger, nullptr);
- ASSERT_EQ(service, nullptr);
-
- service = CapabilityMessagingService::create(nullptr, mAfbApi);
- ASSERT_EQ(service, nullptr);
-}
-
-TEST_F(CapabilityMessagingServiceTest, initializesSuccessfully) {
- auto service = CapabilityMessagingService::create(mConsoleLogger, mAfbApi);
- ASSERT_NE(service, nullptr);
-}
-
-TEST_F(CapabilityMessagingServiceTest, canSubscribeAndPublishCapabilityEvents) {
- auto service = CapabilityMessagingService::create(mConsoleLogger, mAfbApi);
-
- auto capability = std::make_shared<::testing::NiceMock<CapabilityMock>>();
- std::list<std::string> upstreamEvents({"up-ev1", "up-ev2"});
- std::list<std::string> downstreamEvents({"down-ev1", "down-ev2"});
- std::string capabilityName = "weather";
-
- ON_CALL(*capability, getName()).WillByDefault(::testing::Return(capabilityName));
- ON_CALL(*capability, getUpstreamMessages()).WillByDefault(::testing::Return(upstreamEvents));
- ON_CALL(*capability, getDownstreamMessages()).WillByDefault(::testing::Return(downstreamEvents));
-
- // We don't care if and how many times subscribe method is called on event.
- std::shared_ptr<AFBEventMock> mockEvent(new ::testing::NiceMock<AFBEventMock>());
- ON_CALL(*mockEvent, subscribe(::testing::_)).WillByDefault(::testing::Return(true));
- ON_CALL(*mockEvent, publishEvent(::testing::_)).WillByDefault(::testing::Return(true));
- auto eventCreator = [mockEvent](const std::string& eventName) -> std::shared_ptr<IAFBApi::IAFBEvent> {
- mockEvent->setName(eventName);
- return mockEvent;
- };
-
- ON_CALL(*mAfbApi, createEvent(::testing::_)).WillByDefault(::testing::Invoke(eventCreator));
-
- auto request = std::make_shared<::testing::StrictMock<AFBRequestMock>>();
- std::string payload = "The answer to life the universe and everything = 42";
-
- bool result = service->publish(capability, *upstreamEvents.begin(), payload);
- ASSERT_FALSE(result); // Without subscribing to the event. Publish should fail.
-
- result = service->subscribe(*request, capability, *upstreamEvents.begin());
- ASSERT_TRUE(result);
-
- result = service->subscribe(*request, capability, *downstreamEvents.begin());
- ASSERT_TRUE(result);
-
- result = service->publish(capability, *downstreamEvents.begin(), payload);
- ASSERT_TRUE(result);
-}
-
-} // namespace test
-} // namespace vshl \ No newline at end of file
diff --git a/src/plugins/capabilities/test/PublisherForwarderTest.cpp b/src/plugins/capabilities/test/PublisherForwarderTest.cpp
deleted file mode 100644
index d0ba319..0000000
--- a/src/plugins/capabilities/test/PublisherForwarderTest.cpp
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Copyright 2018-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License").
- * You may not use this file except in compliance with the License.
- * A copy of the License is located at
- *
- * http://aws.amazon.com/apache2.0/
- *
- * or in the "license" file accompanying this file. This file is distributed
- * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-#include <gtest/gtest.h>
-
-#include "capabilities/core/include/PublisherForwarder.h"
-#include "capabilities/core/include/SubscriberForwarder.h"
-
-#include "test/common/ConsoleLogger.h"
-#include "test/mocks/AFBApiMock.h"
-#include "test/mocks/AFBEventMock.h"
-#include "test/mocks/CapabilityMock.h"
-
-using namespace vshl::common::interfaces;
-using namespace vshl::capabilities::core;
-using namespace vshl::test::common;
-
-namespace vshl {
-namespace test {
-
-class PublisherForwarderTest : public ::testing::Test {
-protected:
- void SetUp() override {
- mConsoleLogger = std::make_shared<ConsoleLogger>();
- mAfbApi = std::make_shared<::testing::StrictMock<AFBApiMock>>();
-
- mEventCreatorFn = [](const std::string& eventName) -> std::shared_ptr<IAFBApi::IAFBEvent> {
- std::shared_ptr<AFBEventMock> mockEvent(new ::testing::StrictMock<AFBEventMock>());
- mockEvent->setName(eventName);
- return mockEvent;
- };
- }
-
- std::shared_ptr<SubscriberForwarder> createSubscriberForwarder(
- std::shared_ptr<::testing::StrictMock<CapabilityMock>> capability) {
- EXPECT_CALL(*capability, getUpstreamMessages()).Times(1);
- EXPECT_CALL(*capability, getDownstreamMessages()).Times(1);
-
- return SubscriberForwarder::create(mConsoleLogger, mAfbApi, capability);
- }
-
- std::shared_ptr<PublisherForwarder> createPublisherForwarder(
- std::shared_ptr<::testing::StrictMock<CapabilityMock>> capability) {
- return PublisherForwarder::create(mConsoleLogger, capability);
- }
-
- std::shared_ptr<::testing::StrictMock<AFBApiMock>> mAfbApi;
- std::shared_ptr<ConsoleLogger> mConsoleLogger;
- std::function<std::shared_ptr<IAFBApi::IAFBEvent>(const std::string&)> mEventCreatorFn;
- std::shared_ptr<::testing::StrictMock<AFBEventMock>> mAfbEventMock;
-};
-
-TEST_F(PublisherForwarderTest, failsInitializationOnInvalidParams) {
- auto capability = std::make_shared<::testing::StrictMock<CapabilityMock>>();
-
- auto forwarder = PublisherForwarder::create(mConsoleLogger, nullptr);
- ASSERT_EQ(forwarder, nullptr);
-
- forwarder = PublisherForwarder::create(nullptr, capability);
- ASSERT_EQ(forwarder, nullptr);
-}
-
-TEST_F(PublisherForwarderTest, initializesCorrectly) {
- auto capability = std::make_shared<::testing::StrictMock<CapabilityMock>>();
- auto forwarder = createPublisherForwarder(capability);
-
- ASSERT_NE(forwarder, nullptr);
-}
-
-TEST_F(PublisherForwarderTest, canForwardMessages) {
- std::shared_ptr<AFBEventMock> mockEvent(new ::testing::StrictMock<AFBEventMock>());
- ON_CALL(*mockEvent, publishEvent(::testing::_)).WillByDefault(::testing::Return(true));
- EXPECT_CALL(*mockEvent, publishEvent(::testing::_)).Times(4);
- auto eventCreator = [mockEvent](const std::string& eventName) -> std::shared_ptr<IAFBApi::IAFBEvent> {
- return mockEvent;
- };
-
- ON_CALL(*mAfbApi, createEvent(::testing::_)).WillByDefault(::testing::Invoke(eventCreator));
- EXPECT_CALL(*mAfbApi, createEvent(::testing::_)).Times(4);
-
- auto capability = std::make_shared<::testing::StrictMock<CapabilityMock>>();
- std::list<std::string> upstreamEvents({"up-ev1", "up-ev2"});
- std::list<std::string> downstreamEvents({"down-ev1", "down-ev2"});
- ON_CALL(*capability, getUpstreamMessages()).WillByDefault(::testing::Return(upstreamEvents));
- ON_CALL(*capability, getDownstreamMessages()).WillByDefault(::testing::Return(downstreamEvents));
-
- auto publisherForwarder = createPublisherForwarder(capability);
- ASSERT_NE(publisherForwarder, nullptr);
-
- auto subscriberForwarder = createSubscriberForwarder(capability);
- ASSERT_NE(subscriberForwarder, nullptr);
-
- std::string payload = "The answer to life the universe and everything = 42";
- publisherForwarder->setSubscriberForwarder(subscriberForwarder);
-
- auto itCapability = downstreamEvents.begin();
- ASSERT_TRUE(publisherForwarder->forwardMessage(*itCapability++, payload));
- ASSERT_TRUE(publisherForwarder->forwardMessage(*itCapability++, payload));
- itCapability = upstreamEvents.begin();
- ASSERT_TRUE(publisherForwarder->forwardMessage(*itCapability++, payload));
- ASSERT_TRUE(publisherForwarder->forwardMessage(*itCapability++, payload));
-}
-
-} // namespace test
-} // namespace vshl \ No newline at end of file
diff --git a/src/plugins/capabilities/test/SubscriberForwarderTest.cpp b/src/plugins/capabilities/test/SubscriberForwarderTest.cpp
deleted file mode 100644
index ff438df..0000000
--- a/src/plugins/capabilities/test/SubscriberForwarderTest.cpp
+++ /dev/null
@@ -1,262 +0,0 @@
-/*
- * Copyright 2018-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License").
- * You may not use this file except in compliance with the License.
- * A copy of the License is located at
- *
- * http://aws.amazon.com/apache2.0/
- *
- * or in the "license" file accompanying this file. This file is distributed
- * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-#include <gtest/gtest.h>
-
-#include "capabilities/core/include/SubscriberForwarder.h"
-
-#include "test/common/ConsoleLogger.h"
-#include "test/mocks/AFBApiMock.h"
-#include "test/mocks/AFBEventMock.h"
-#include "test/mocks/AFBRequestMock.h"
-#include "test/mocks/CapabilityMock.h"
-
-using namespace vshl::common::interfaces;
-using namespace vshl::capabilities::core;
-using namespace vshl::test::common;
-
-namespace vshl {
-namespace test {
-
-class SubscriberForwarderTest : public ::testing::Test {
-protected:
- void SetUp() override {
- mConsoleLogger = std::make_shared<ConsoleLogger>();
- mAfbApi = std::make_shared<::testing::StrictMock<AFBApiMock>>();
-
- mEventCreatorFn = [](const std::string& eventName) -> std::shared_ptr<IAFBApi::IAFBEvent> {
- std::shared_ptr<AFBEventMock> mockEvent(new ::testing::StrictMock<AFBEventMock>());
- mockEvent->setName(eventName);
- return mockEvent;
- };
- }
-
- std::shared_ptr<SubscriberForwarder> createSubscriberForwarder(
- std::shared_ptr<::testing::StrictMock<CapabilityMock>> capability) {
- EXPECT_CALL(*capability, getUpstreamMessages()).Times(1);
- EXPECT_CALL(*capability, getDownstreamMessages()).Times(1);
-
- return SubscriberForwarder::create(mConsoleLogger, mAfbApi, capability);
- }
-
- std::shared_ptr<::testing::StrictMock<AFBApiMock>> mAfbApi;
- std::shared_ptr<ConsoleLogger> mConsoleLogger;
- std::function<std::shared_ptr<IAFBApi::IAFBEvent>(const std::string&)> mEventCreatorFn;
- std::shared_ptr<::testing::StrictMock<AFBEventMock>> mAfbEventMock;
-};
-
-TEST_F(SubscriberForwarderTest, failsInitializationOnInvalidParams) {
- auto capability = std::make_shared<::testing::StrictMock<CapabilityMock>>();
-
- auto forwarder = SubscriberForwarder::create(mConsoleLogger, mAfbApi, nullptr);
- ASSERT_EQ(forwarder, nullptr);
-
- forwarder = SubscriberForwarder::create(mConsoleLogger, nullptr, capability);
- ASSERT_EQ(forwarder, nullptr);
-
- forwarder = SubscriberForwarder::create(nullptr, mAfbApi, capability);
- ASSERT_EQ(forwarder, nullptr);
-}
-
-TEST_F(SubscriberForwarderTest, initializesCorrectly) {
- auto capability = std::make_shared<::testing::StrictMock<CapabilityMock>>();
- auto forwarder = createSubscriberForwarder(capability);
-
- ASSERT_NE(forwarder, nullptr);
-}
-
-TEST_F(SubscriberForwarderTest, createsEventsOnInitialization) {
- ON_CALL(*mAfbApi, createEvent(::testing::_)).WillByDefault(::testing::Invoke(mEventCreatorFn));
-
- std::list<std::string> upstreamEvents({"up-ev1", "up-ev2"});
- std::list<std::string> downstreamEvents({"down-ev1", "down-ev2"});
-
- auto capability = std::make_shared<::testing::StrictMock<CapabilityMock>>();
- ON_CALL(*capability, getUpstreamMessages()).WillByDefault(::testing::Return(upstreamEvents));
- ON_CALL(*capability, getDownstreamMessages()).WillByDefault(::testing::Return(downstreamEvents));
-
- auto itCapability = upstreamEvents.begin();
- EXPECT_CALL(*mAfbApi, createEvent(*itCapability)).Times(1);
- itCapability++;
- EXPECT_CALL(*mAfbApi, createEvent(*itCapability)).Times(1);
-
- itCapability = downstreamEvents.begin();
- EXPECT_CALL(*mAfbApi, createEvent(*itCapability)).Times(1);
- itCapability++;
- EXPECT_CALL(*mAfbApi, createEvent(*itCapability)).Times(1);
-
- auto forwarder = createSubscriberForwarder(capability);
- ASSERT_NE(forwarder, nullptr);
-}
-
-TEST_F(SubscriberForwarderTest, canNotSubscribeToNonExistentEvents) {
- ON_CALL(*mAfbApi, createEvent(::testing::_)).WillByDefault(::testing::Invoke(mEventCreatorFn));
- EXPECT_CALL(*mAfbApi, createEvent(::testing::_)).Times(4);
-
- std::list<std::string> upstreamEvents({"up-ev1", "up-ev2"});
- std::list<std::string> downstreamEvents({"down-ev1", "down-ev2"});
-
- auto capability = std::make_shared<::testing::StrictMock<CapabilityMock>>();
- ON_CALL(*capability, getUpstreamMessages()).WillByDefault(::testing::Return(upstreamEvents));
- ON_CALL(*capability, getDownstreamMessages()).WillByDefault(::testing::Return(downstreamEvents));
-
- auto forwarder = createSubscriberForwarder(capability);
- ASSERT_NE(forwarder, nullptr);
-
- auto nonExistentEvents = std::list<std::string>({"non", "existent", "events"});
- auto itCapability = nonExistentEvents.begin();
- auto request = std::make_shared<::testing::StrictMock<AFBRequestMock>>();
- ASSERT_FALSE(forwarder->subscribe(*request, *itCapability++));
- ASSERT_FALSE(forwarder->subscribe(*request, *itCapability++));
- ASSERT_FALSE(forwarder->subscribe(*request, *itCapability++));
-}
-
-TEST_F(SubscriberForwarderTest, canNotSubscribeOnEventCreationFailure) {
- // Fail the event creation and return null event.
- ON_CALL(*mAfbApi, createEvent(::testing::_)).WillByDefault(::testing::Return(nullptr));
- EXPECT_CALL(*mAfbApi, createEvent(::testing::_)).Times(4);
-
- std::list<std::string> upstreamEvents({"up-ev1", "up-ev2"});
- std::list<std::string> downstreamEvents({"down-ev1", "down-ev2"});
-
- auto capability = std::make_shared<::testing::StrictMock<CapabilityMock>>();
- ON_CALL(*capability, getUpstreamMessages()).WillByDefault(::testing::Return(upstreamEvents));
- ON_CALL(*capability, getDownstreamMessages()).WillByDefault(::testing::Return(downstreamEvents));
-
- auto forwarder = createSubscriberForwarder(capability);
- ASSERT_NE(forwarder, nullptr);
-
- auto itCapability = downstreamEvents.begin();
- auto request = std::make_shared<::testing::StrictMock<AFBRequestMock>>();
- std::string payload = "The answer to life the universe and everything = 42";
- ASSERT_FALSE(forwarder->subscribe(*request, *itCapability++));
- ASSERT_FALSE(forwarder->subscribe(*request, *itCapability++));
- itCapability = upstreamEvents.begin();
- ASSERT_FALSE(forwarder->subscribe(*request, *itCapability++));
- ASSERT_FALSE(forwarder->subscribe(*request, *itCapability++));
-}
-
-TEST_F(SubscriberForwarderTest, canSubscribeToEvents) {
- std::shared_ptr<AFBEventMock> mockEvent(new ::testing::StrictMock<AFBEventMock>());
- ON_CALL(*mockEvent, subscribe(::testing::_)).WillByDefault(::testing::Return(true));
- EXPECT_CALL(*mockEvent, subscribe(::testing::_)).Times(4);
- auto eventCreator = [mockEvent](const std::string& eventName) -> std::shared_ptr<IAFBApi::IAFBEvent> {
- return mockEvent;
- };
-
- ON_CALL(*mAfbApi, createEvent(::testing::_)).WillByDefault(::testing::Invoke(eventCreator));
- EXPECT_CALL(*mAfbApi, createEvent(::testing::_)).Times(4);
-
- std::list<std::string> upstreamEvents({"up-ev1", "up-ev2"});
- std::list<std::string> downstreamEvents({"down-ev1", "down-ev2"});
-
- auto capability = std::make_shared<::testing::StrictMock<CapabilityMock>>();
- ON_CALL(*capability, getUpstreamMessages()).WillByDefault(::testing::Return(upstreamEvents));
- ON_CALL(*capability, getDownstreamMessages()).WillByDefault(::testing::Return(downstreamEvents));
-
- auto forwarder = createSubscriberForwarder(capability);
- ASSERT_NE(forwarder, nullptr);
-
- auto itCapability = downstreamEvents.begin();
- auto request = std::make_shared<::testing::StrictMock<AFBRequestMock>>();
- ASSERT_TRUE(forwarder->subscribe(*request, *itCapability++));
- ASSERT_TRUE(forwarder->subscribe(*request, *itCapability));
- itCapability = upstreamEvents.begin();
- ASSERT_TRUE(forwarder->subscribe(*request, *itCapability++));
- ASSERT_TRUE(forwarder->subscribe(*request, *itCapability));
-}
-
-TEST_F(SubscriberForwarderTest, canNotPublishNonExistentEvents) {
- std::shared_ptr<AFBEventMock> mockEvent(new ::testing::StrictMock<AFBEventMock>());
- EXPECT_CALL(*mockEvent, publishEvent(::testing::_)).Times(0);
- auto eventCreator = [mockEvent](const std::string& eventName) -> std::shared_ptr<IAFBApi::IAFBEvent> {
- return mockEvent;
- };
-
- ON_CALL(*mAfbApi, createEvent(::testing::_)).WillByDefault(::testing::Invoke(eventCreator));
- EXPECT_CALL(*mAfbApi, createEvent(::testing::_)).Times(4);
-
- std::list<std::string> upstreamEvents({"up-ev1", "up-ev2"});
- std::list<std::string> downstreamEvents({"down-ev1", "down-ev2"});
-
- auto capability = std::make_shared<::testing::StrictMock<CapabilityMock>>();
- ON_CALL(*capability, getUpstreamMessages()).WillByDefault(::testing::Return(upstreamEvents));
- ON_CALL(*capability, getDownstreamMessages()).WillByDefault(::testing::Return(downstreamEvents));
-
- auto forwarder = createSubscriberForwarder(capability);
- ASSERT_NE(forwarder, nullptr);
-
- auto nonExistentEvents = std::list<std::string>({"non", "existent", "events"});
- auto itCapability = nonExistentEvents.begin();
- ASSERT_FALSE(forwarder->forwardMessage(*itCapability++, "My-Payload"));
- ASSERT_FALSE(forwarder->forwardMessage(*itCapability++, "My-Payload"));
- ASSERT_FALSE(forwarder->forwardMessage(*itCapability++, "My-Payload"));
-}
-
-TEST_F(SubscriberForwarderTest, canNotPublishOnEventCreationFailure) {
- // Fail the event creation and return null event.
- ON_CALL(*mAfbApi, createEvent(::testing::_)).WillByDefault(::testing::Return(nullptr));
- EXPECT_CALL(*mAfbApi, createEvent(::testing::_)).Times(4);
-
- std::list<std::string> upstreamEvents({"up-ev1", "up-ev2"});
- std::list<std::string> downstreamEvents({"down-ev1", "down-ev2"});
-
- auto capability = std::make_shared<::testing::StrictMock<CapabilityMock>>();
- ON_CALL(*capability, getUpstreamMessages()).WillByDefault(::testing::Return(upstreamEvents));
- ON_CALL(*capability, getDownstreamMessages()).WillByDefault(::testing::Return(downstreamEvents));
-
- auto forwarder = createSubscriberForwarder(capability);
- ASSERT_NE(forwarder, nullptr);
-
- auto itCapability = downstreamEvents.begin();
- std::string payload = "The answer to life the universe and everything = 42";
- ASSERT_FALSE(forwarder->forwardMessage(*itCapability++, payload));
- ASSERT_FALSE(forwarder->forwardMessage(*itCapability++, payload));
- itCapability = upstreamEvents.begin();
- ASSERT_FALSE(forwarder->forwardMessage(*itCapability++, payload));
- ASSERT_FALSE(forwarder->forwardMessage(*itCapability++, payload));
-}
-
-TEST_F(SubscriberForwarderTest, canPublishEvents) {
- std::shared_ptr<AFBEventMock> mockEvent(new ::testing::StrictMock<AFBEventMock>());
- ON_CALL(*mockEvent, publishEvent(::testing::_)).WillByDefault(::testing::Return(true));
- EXPECT_CALL(*mockEvent, publishEvent(::testing::_)).Times(4);
- auto eventCreator = [mockEvent](const std::string& eventName) -> std::shared_ptr<IAFBApi::IAFBEvent> {
- return mockEvent;
- };
-
- ON_CALL(*mAfbApi, createEvent(::testing::_)).WillByDefault(::testing::Invoke(eventCreator));
- EXPECT_CALL(*mAfbApi, createEvent(::testing::_)).Times(4);
-
- std::list<std::string> upstreamEvents({"up-ev1", "up-ev2"});
- std::list<std::string> downstreamEvents({"down-ev1", "down-ev2"});
-
- auto capability = std::make_shared<::testing::StrictMock<CapabilityMock>>();
- ON_CALL(*capability, getUpstreamMessages()).WillByDefault(::testing::Return(upstreamEvents));
- ON_CALL(*capability, getDownstreamMessages()).WillByDefault(::testing::Return(downstreamEvents));
-
- auto forwarder = createSubscriberForwarder(capability);
- ASSERT_NE(forwarder, nullptr);
-
- auto itCapability = downstreamEvents.begin();
- std::string payload = "The answer to life the universe and everything = 42";
- ASSERT_TRUE(forwarder->forwardMessage(*itCapability++, payload));
- ASSERT_TRUE(forwarder->forwardMessage(*itCapability++, payload));
- itCapability = upstreamEvents.begin();
- ASSERT_TRUE(forwarder->forwardMessage(*itCapability++, payload));
- ASSERT_TRUE(forwarder->forwardMessage(*itCapability++, payload));
-}
-
-} // namespace test
-} // namespace vshl \ No newline at end of file