LCOV - code coverage report
Current view: top level - shared_model/backend/protobuf/commands/impl - proto_create_role.cpp (source / functions) Hit Total Coverage
Test: coverage_cleared.info Lines: 17 18 94.4 %
Date: 2018-12-05 17:11:35 Functions: 11 28 39.3 %

          Line data    Source code
       1             : /**
       2             :  * Copyright Soramitsu Co., Ltd. All Rights Reserved.
       3             :  * SPDX-License-Identifier: Apache-2.0
       4             :  */
       5             : 
       6             : #include "backend/protobuf/commands/proto_create_role.hpp"
       7             : 
       8             : #include <boost/range/numeric.hpp>
       9             : #include "backend/protobuf/permissions.hpp"
      10             : 
      11             : namespace shared_model {
      12             :   namespace proto {
      13             : 
      14             :     template <typename CommandType>
      15             :     CreateRole::CreateRole(CommandType &&command)
      16        9679 :         : CopyableProto(std::forward<CommandType>(command)),
      17        9679 :           create_role_{proto_->create_role()},
      18             :           role_permissions_{[this] {
      19        3425 :             return boost::accumulate(
      20        3425 :                 create_role_.permissions(),
      21        3425 :                 interface::RolePermissionSet{},
      22             :                 [](auto &&acc, const auto &perm) {
      23       36707 :                   acc.set(permissions::fromTransport(
      24       36707 :                       static_cast<iroha::protocol::RolePermission>(perm)));
      25       36707 :                   return std::forward<decltype(acc)>(acc);
      26             :                 });
      27        9679 :           }} {}
      28             : 
      29             :     template CreateRole::CreateRole(CreateRole::TransportType &);
      30             :     template CreateRole::CreateRole(const CreateRole::TransportType &);
      31             :     template CreateRole::CreateRole(CreateRole::TransportType &&);
      32             : 
      33             :     CreateRole::CreateRole(const CreateRole &o) : CreateRole(o.proto_) {}
      34             : 
      35             :     CreateRole::CreateRole(CreateRole &&o) noexcept
      36        9679 :         : CreateRole(std::move(o.proto_)) {}
      37             : 
      38             :     const interface::types::RoleIdType &CreateRole::roleName() const {
      39        4250 :       return create_role_.role_name();
      40             :     }
      41             : 
      42             :     const interface::RolePermissionSet &CreateRole::rolePermissions() const {
      43        4250 :       return *role_permissions_;
      44             :     }
      45             : 
      46             :     std::string CreateRole::toString() const {
      47         339 :       return detail::PrettyStringBuilder()
      48         339 :           .init("CreateRole")
      49         339 :           .append("role_name", roleName())
      50         339 :           .appendAll(permissions::toString(rolePermissions()),
      51             :                      [](auto p) { return p; })
      52         339 :           .finalize();
      53           0 :     }
      54             : 
      55             :   }  // namespace proto
      56             : }  // namespace shared_model

Generated by: LCOV version 1.13