Sha256: ee65ceef51e2edc4402c10f9c7f2bc0c568de89d4e89d961fb7555b147e5ed8b

Contents?: true

Size: 1.91 KB

Versions: 11

Compression:

Stored size: 1.91 KB

Contents

require 'pact_broker/repositories'
require 'pact_broker/api/decorators/verification_decorator'
require 'pact_broker/verifications/summary_for_consumer_version'

module PactBroker

  module Verifications
    module Service

      extend self

      extend PactBroker::Repositories
      extend PactBroker::Services

      def next_number_for pact
        verification_repository.verification_count_for_pact(pact) + 1
      end

      def create next_verification_number, params, pact
        PactBroker.logger.info "Creating verification #{next_verification_number} for pact_id=#{pact.id} from params #{params}"
        verification = PactBroker::Domain::Verification.new
        PactBroker::Api::Decorators::VerificationDecorator.new(verification).from_hash(params)
        verification.number = next_verification_number
        verification_repository.create(verification, pact)
      end

      def errors params
        contract = PactBroker::Api::Contracts::VerificationContract.new(PactBroker::Domain::Verification.new)
        contract.validate(params)
        contract.errors
      end

      def find params
        verification_repository.find(params.fetch(:consumer_name), params.fetch(:provider_name), params.fetch(:pact_version_sha), params.fetch(:verification_number))
      end

      def find_latest_verifications_for_consumer_version params
        verification_repository.find_latest_verifications_for_consumer_version params[:consumer_name], params[:consumer_version_number]
      end

      def find_latest_verification_for consumer, provider
        verification_repository.find_latest_verification_for consumer.name, provider.name
      end

      def verification_summary_for_consumer_version params
        verifications = find_latest_verifications_for_consumer_version(params)
        pacts = pact_service.find_by_consumer_version(params)
        SummaryForConsumerVersion.new(verifications, pacts)
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
pact_broker-2.2.0 lib/pact_broker/verifications/service.rb
pact_broker-2.1.1 lib/pact_broker/verifications/service.rb
pact_broker-2.1.0 lib/pact_broker/verifications/service.rb
pact_broker-2.0.5 lib/pact_broker/verifications/service.rb
pact_broker-2.0.4 lib/pact_broker/verifications/service.rb
pact_broker-2.0.3 lib/pact_broker/verifications/service.rb
pact_broker-2.0.2 lib/pact_broker/verifications/service.rb
pact_broker-2.0.1 lib/pact_broker/verifications/service.rb
pact_broker-2.0.0 lib/pact_broker/verifications/service.rb
pact_broker-2.0.0.beta.8 lib/pact_broker/verifications/service.rb
pact_broker-2.0.0.beta.7 lib/pact_broker/verifications/service.rb