hdfs-cat-mock.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. #ifndef LIBHDFSPP_TOOLS_HDFS_CAT_MOCK
  19. #define LIBHDFSPP_TOOLS_HDFS_CAT_MOCK
  20. #include <functional>
  21. #include <memory>
  22. #include <string>
  23. #include <vector>
  24. #include <gmock/gmock.h>
  25. #include "hdfs-cat.h"
  26. namespace hdfs::tools::test {
  27. /**
  28. * {@class CatMock} is an {@class Cat} whereby it mocks the
  29. * HandleHelp and HandlePath methods for testing their functionality.
  30. */
  31. class CatMock : public hdfs::tools::Cat {
  32. public:
  33. /**
  34. * {@inheritdoc}
  35. */
  36. CatMock(const int argc, char **argv) : Cat(argc, argv) {}
  37. // Abiding to the Rule of 5
  38. CatMock(const CatMock &) = delete;
  39. CatMock(CatMock &&) = delete;
  40. CatMock &operator=(const CatMock &) = delete;
  41. CatMock &operator=(CatMock &&) = delete;
  42. ~CatMock() override;
  43. /**
  44. * Defines the methods and the corresponding arguments that are expected
  45. * to be called on this instance of {@link HdfsTool} for the given test case.
  46. *
  47. * @param test_case An {@link std::function} object that points to the
  48. * function defining the test case
  49. * @param args The arguments that are passed to this test case
  50. */
  51. void SetExpectations(std::function<std::unique_ptr<CatMock>()> test_case,
  52. const std::vector<std::string> &args = {}) const;
  53. MOCK_METHOD(bool, HandleHelp, (), (const, override));
  54. MOCK_METHOD(bool, HandlePath, (const std::string &), (const, override));
  55. };
  56. } // namespace hdfs::tools::test
  57. #endif