stream_subscription_installer_test.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License").
5  * You may not use this file except in compliance with the License.
6  * A copy of the License is located at
7  *
8  * http://aws.amazon.com/apache2.0
9  *
10  * or in the "license" file accompanying this file. This file is distributed
11  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12  * express or implied. See the License for the specific language governing
13  * permissions and limitations under the License.
14  */
15 
17 #include <gtest/gtest.h>
18 
19 using namespace Aws::Kinesis;
20 
22 {
23 public:
24  void Uninstall(const std::string & topic_name) override {}
25  void PutInstaller(KinesisStreamInputType input_type, const SubscriberSetupFn& setup_fun)
26  {
27  installers_.insert({input_type, setup_fun});
28  }
29 };
30 
31 TEST(StreamSubscriptionInstallerSuite, streamSubscriptionInstallerTest)
32 {
34 
35  KinesisStreamInputType input_type;
36  StreamSubscriptionDescriptor descriptor{input_type, std::string("topic_name"),
37  std::string("stream_name"), 10,
38  std::string("rekognition_topic_name"), std::string("rekognition_data_stream")
39  };
40 
41  StreamSubscriptionDescriptor incomplete_descriptor = descriptor;
42  incomplete_descriptor.topic_name = "";
43  auto status = test_subject.Install(incomplete_descriptor);
44  EXPECT_EQ(KINESIS_MANAGER_STATUS_INVALID_INPUT, status);
45 
46  incomplete_descriptor = descriptor;
47  incomplete_descriptor.stream_name = "";
48  status = test_subject.Install(incomplete_descriptor);
49  EXPECT_EQ(KINESIS_MANAGER_STATUS_INVALID_INPUT, status);
50 
51  status = test_subject.Install(descriptor);
53 
54  bool setup_called = false;
55  SubscriberSetupFn setup_fun = [&setup_called](const StreamSubscriptionDescriptor & descriptor) {
56  setup_called = true;
57  return true;
58  };
59  test_subject.PutInstaller(descriptor.input_type, setup_fun);
60  status = test_subject.Install(descriptor);
61  EXPECT_EQ(KINESIS_MANAGER_STATUS_SUCCESS, status);
62  EXPECT_TRUE(setup_called);
63 }
64 
65 int main(int argc, char ** argv)
66 {
67  testing::InitGoogleTest(&argc, argv);
68  return RUN_ALL_TESTS();
69 }
void Uninstall(const std::string &topic_name) override
int main(int argc, char **argv)
std::function< bool(const StreamSubscriptionDescriptor &descriptor)> SubscriberSetupFn
const char * topic_name
Definition: common.h:76
TEST(StreamSubscriptionInstallerSuite, streamSubscriptionInstallerTest)
virtual KinesisManagerStatus Install(const StreamSubscriptionDescriptor &descriptor) const
int KinesisStreamInputType
Definition: common.h:57
void PutInstaller(KinesisStreamInputType input_type, const SubscriberSetupFn &setup_fun)


kinesis_manager
Author(s): AWS RoboMaker
autogenerated on Thu Mar 4 2021 03:28:41