// Code generated by counterfeiter. DO NOT EDIT.
package throttlefakes

import (
	"sync"

	"code.cloudfoundry.org/guardian/gardener"
	"code.cloudfoundry.org/guardian/throttle"
	lager "code.cloudfoundry.org/lager/v3"
)

type FakeMetricsSource struct {
	CollectMetricsStub        func(lager.Logger) (map[string]gardener.ActualContainerMetrics, error)
	collectMetricsMutex       sync.RWMutex
	collectMetricsArgsForCall []struct {
		arg1 lager.Logger
	}
	collectMetricsReturns struct {
		result1 map[string]gardener.ActualContainerMetrics
		result2 error
	}
	collectMetricsReturnsOnCall map[int]struct {
		result1 map[string]gardener.ActualContainerMetrics
		result2 error
	}
	invocations      map[string][][]interface{}
	invocationsMutex sync.RWMutex
}

func (fake *FakeMetricsSource) CollectMetrics(arg1 lager.Logger) (map[string]gardener.ActualContainerMetrics, error) {
	fake.collectMetricsMutex.Lock()
	ret, specificReturn := fake.collectMetricsReturnsOnCall[len(fake.collectMetricsArgsForCall)]
	fake.collectMetricsArgsForCall = append(fake.collectMetricsArgsForCall, struct {
		arg1 lager.Logger
	}{arg1})
	stub := fake.CollectMetricsStub
	fakeReturns := fake.collectMetricsReturns
	fake.recordInvocation("CollectMetrics", []interface{}{arg1})
	fake.collectMetricsMutex.Unlock()
	if stub != nil {
		return stub(arg1)
	}
	if specificReturn {
		return ret.result1, ret.result2
	}
	return fakeReturns.result1, fakeReturns.result2
}

func (fake *FakeMetricsSource) CollectMetricsCallCount() int {
	fake.collectMetricsMutex.RLock()
	defer fake.collectMetricsMutex.RUnlock()
	return len(fake.collectMetricsArgsForCall)
}

func (fake *FakeMetricsSource) CollectMetricsCalls(stub func(lager.Logger) (map[string]gardener.ActualContainerMetrics, error)) {
	fake.collectMetricsMutex.Lock()
	defer fake.collectMetricsMutex.Unlock()
	fake.CollectMetricsStub = stub
}

func (fake *FakeMetricsSource) CollectMetricsArgsForCall(i int) lager.Logger {
	fake.collectMetricsMutex.RLock()
	defer fake.collectMetricsMutex.RUnlock()
	argsForCall := fake.collectMetricsArgsForCall[i]
	return argsForCall.arg1
}

func (fake *FakeMetricsSource) CollectMetricsReturns(result1 map[string]gardener.ActualContainerMetrics, result2 error) {
	fake.collectMetricsMutex.Lock()
	defer fake.collectMetricsMutex.Unlock()
	fake.CollectMetricsStub = nil
	fake.collectMetricsReturns = struct {
		result1 map[string]gardener.ActualContainerMetrics
		result2 error
	}{result1, result2}
}

func (fake *FakeMetricsSource) CollectMetricsReturnsOnCall(i int, result1 map[string]gardener.ActualContainerMetrics, result2 error) {
	fake.collectMetricsMutex.Lock()
	defer fake.collectMetricsMutex.Unlock()
	fake.CollectMetricsStub = nil
	if fake.collectMetricsReturnsOnCall == nil {
		fake.collectMetricsReturnsOnCall = make(map[int]struct {
			result1 map[string]gardener.ActualContainerMetrics
			result2 error
		})
	}
	fake.collectMetricsReturnsOnCall[i] = struct {
		result1 map[string]gardener.ActualContainerMetrics
		result2 error
	}{result1, result2}
}

func (fake *FakeMetricsSource) Invocations() map[string][][]interface{} {
	fake.invocationsMutex.RLock()
	defer fake.invocationsMutex.RUnlock()
	fake.collectMetricsMutex.RLock()
	defer fake.collectMetricsMutex.RUnlock()
	copiedInvocations := map[string][][]interface{}{}
	for key, value := range fake.invocations {
		copiedInvocations[key] = value
	}
	return copiedInvocations
}

func (fake *FakeMetricsSource) recordInvocation(key string, args []interface{}) {
	fake.invocationsMutex.Lock()
	defer fake.invocationsMutex.Unlock()
	if fake.invocations == nil {
		fake.invocations = map[string][][]interface{}{}
	}
	if fake.invocations[key] == nil {
		fake.invocations[key] = [][]interface{}{}
	}
	fake.invocations[key] = append(fake.invocations[key], args)
}

var _ throttle.MetricsSource = new(FakeMetricsSource)
