hdfs-chmod-mock.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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_CHMOD_MOCK
  19. #define LIBHDFSPP_TOOLS_HDFS_CHMOD_MOCK
  20. #include <functional>
  21. #include <memory>
  22. #include <string>
  23. #include <vector>
  24. #include <gmock/gmock.h>
  25. #include "hdfs-chmod.h"
  26. namespace hdfs::tools::test {
  27. /**
  28. * {@class ChmodMock} is an {@class Chmod} whereby it mocks the
  29. * HandleHelp and HandlePath methods for testing their functionality.
  30. */
  31. class ChmodMock : public hdfs::tools::Chmod {
  32. public:
  33. /**
  34. * {@inheritdoc}
  35. */
  36. ChmodMock(const int argc, char **argv) : Chmod(argc, argv) {}
  37. // Abiding to the Rule of 5
  38. ChmodMock(const ChmodMock &) = delete;
  39. ChmodMock(ChmodMock &&) = delete;
  40. ChmodMock &operator=(const ChmodMock &) = delete;
  41. ChmodMock &operator=(ChmodMock &&) = delete;
  42. ~ChmodMock() 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<ChmodMock>()> test_case,
  52. const std::vector<std::string> &args = {}) const;
  53. MOCK_METHOD(bool, HandleHelp, (), (const, override));
  54. MOCK_METHOD(bool, HandlePath,
  55. (const std::string &, bool, const std::string &),
  56. (const, override));
  57. };
  58. } // namespace hdfs::tools::test
  59. #endif