LCOV - code coverage report
Current view: top level - shared_model/validators/protobuf - proto_query_validator.hpp (source / functions) Hit Total Coverage
Test: coverage_cleared.info Lines: 11 11 100.0 %
Date: 2018-12-05 17:11:35 Functions: 7 7 100.0 %

          Line data    Source code
       1             : /**
       2             :  * Copyright Soramitsu Co., Ltd. All Rights Reserved.
       3             :  * SPDX-License-Identifier: Apache-2.0
       4             :  */
       5             : 
       6             : #ifndef IROHA_PROTO_QUERY_VALIDATOR_HPP
       7             : #define IROHA_PROTO_QUERY_VALIDATOR_HPP
       8             : 
       9             : #include "validators/abstract_validator.hpp"
      10             : 
      11             : #include "queries.pb.h"
      12             : 
      13             : namespace shared_model {
      14             :   namespace validation {
      15             : 
      16             :     class ProtoQueryValidator
      17             :         : public AbstractValidator<iroha::protocol::Query> {
      18             :      private:
      19             :       Answer validateProtoQuery(const iroha::protocol::Query &qry) const {
      20          15 :         Answer answer;
      21          15 :         if (qry.payload().query_case()
      22          15 :             == iroha::protocol::Query_Payload::QUERY_NOT_SET) {
      23           1 :           ReasonsGroupType reason;
      24           1 :           reason.first = "Undefined";
      25           1 :           reason.second.emplace_back("query is undefined");
      26           1 :           answer.addReason(std::move(reason));
      27           1 :         }
      28          15 :         return answer;
      29          15 :       }
      30             : 
      31             :      public:
      32             :       Answer validate(const iroha::protocol::Query &query) const override {
      33          15 :         return validateProtoQuery(query);
      34             :       }
      35             :     };
      36             : 
      37             :   }  // namespace validation
      38             : }  // namespace shared_model
      39             : 
      40             : #endif  // IROHA_PROTO_QUERY_VALIDATOR_HPP

Generated by: LCOV version 1.13