// This file was generated by counterfeiter
package fakes

import (
	"database/sql"
	"sync"

	"code.cloudfoundry.org/app-autoscaler/src/autoscaler/db"
	"code.cloudfoundry.org/app-autoscaler/src/autoscaler/models"
)

type FakeInstanceMetricsDB struct {
	GetDBStatusStub        func() sql.DBStats
	getDBStatusMutex       sync.RWMutex
	getDBStatusArgsForCall []struct{}
	getDBStatusReturns     struct {
		result1 sql.DBStats
	}
	RetrieveInstanceMetricsStub        func(appid string, instanceIndex int, name string, start int64, end int64, orderType db.OrderType) ([]*models.AppInstanceMetric, error)
	retrieveInstanceMetricsMutex       sync.RWMutex
	retrieveInstanceMetricsArgsForCall []struct {
		appid         string
		instanceIndex int
		name          string
		start         int64
		end           int64
		orderType     db.OrderType
	}
	retrieveInstanceMetricsReturns struct {
		result1 []*models.AppInstanceMetric
		result2 error
	}
	SaveMetricStub        func(metric *models.AppInstanceMetric) error
	saveMetricMutex       sync.RWMutex
	saveMetricArgsForCall []struct {
		metric *models.AppInstanceMetric
	}
	saveMetricReturns struct {
		result1 error
	}
	SaveMetricsInBulkStub        func(metrics []*models.AppInstanceMetric) error
	saveMetricsInBulkMutex       sync.RWMutex
	saveMetricsInBulkArgsForCall []struct {
		metrics []*models.AppInstanceMetric
	}
	saveMetricsInBulkReturns struct {
		result1 error
	}
	PruneInstanceMetricsStub        func(before int64) error
	pruneInstanceMetricsMutex       sync.RWMutex
	pruneInstanceMetricsArgsForCall []struct {
		before int64
	}
	pruneInstanceMetricsReturns struct {
		result1 error
	}
	CloseStub        func() error
	closeMutex       sync.RWMutex
	closeArgsForCall []struct{}
	closeReturns     struct {
		result1 error
	}
	invocations      map[string][][]interface{}
	invocationsMutex sync.RWMutex
}

func (fake *FakeInstanceMetricsDB) GetDBStatus() sql.DBStats {
	fake.getDBStatusMutex.Lock()
	fake.getDBStatusArgsForCall = append(fake.getDBStatusArgsForCall, struct{}{})
	fake.recordInvocation("GetDBStatus", []interface{}{})
	fake.getDBStatusMutex.Unlock()
	if fake.GetDBStatusStub != nil {
		return fake.GetDBStatusStub()
	}
	return fake.getDBStatusReturns.result1
}

func (fake *FakeInstanceMetricsDB) GetDBStatusCallCount() int {
	fake.getDBStatusMutex.RLock()
	defer fake.getDBStatusMutex.RUnlock()
	return len(fake.getDBStatusArgsForCall)
}

func (fake *FakeInstanceMetricsDB) GetDBStatusReturns(result1 sql.DBStats) {
	fake.GetDBStatusStub = nil
	fake.getDBStatusReturns = struct {
		result1 sql.DBStats
	}{result1}
}

func (fake *FakeInstanceMetricsDB) RetrieveInstanceMetrics(appid string, instanceIndex int, name string, start int64, end int64, orderType db.OrderType) ([]*models.AppInstanceMetric, error) {
	fake.retrieveInstanceMetricsMutex.Lock()
	fake.retrieveInstanceMetricsArgsForCall = append(fake.retrieveInstanceMetricsArgsForCall, struct {
		appid         string
		instanceIndex int
		name          string
		start         int64
		end           int64
		orderType     db.OrderType
	}{appid, instanceIndex, name, start, end, orderType})
	fake.recordInvocation("RetrieveInstanceMetrics", []interface{}{appid, instanceIndex, name, start, end, orderType})
	fake.retrieveInstanceMetricsMutex.Unlock()
	if fake.RetrieveInstanceMetricsStub != nil {
		return fake.RetrieveInstanceMetricsStub(appid, instanceIndex, name, start, end, orderType)
	}
	return fake.retrieveInstanceMetricsReturns.result1, fake.retrieveInstanceMetricsReturns.result2
}

func (fake *FakeInstanceMetricsDB) RetrieveInstanceMetricsCallCount() int {
	fake.retrieveInstanceMetricsMutex.RLock()
	defer fake.retrieveInstanceMetricsMutex.RUnlock()
	return len(fake.retrieveInstanceMetricsArgsForCall)
}

func (fake *FakeInstanceMetricsDB) RetrieveInstanceMetricsArgsForCall(i int) (string, int, string, int64, int64, db.OrderType) {
	fake.retrieveInstanceMetricsMutex.RLock()
	defer fake.retrieveInstanceMetricsMutex.RUnlock()
	return fake.retrieveInstanceMetricsArgsForCall[i].appid, fake.retrieveInstanceMetricsArgsForCall[i].instanceIndex, fake.retrieveInstanceMetricsArgsForCall[i].name, fake.retrieveInstanceMetricsArgsForCall[i].start, fake.retrieveInstanceMetricsArgsForCall[i].end, fake.retrieveInstanceMetricsArgsForCall[i].orderType
}

func (fake *FakeInstanceMetricsDB) RetrieveInstanceMetricsReturns(result1 []*models.AppInstanceMetric, result2 error) {
	fake.RetrieveInstanceMetricsStub = nil
	fake.retrieveInstanceMetricsReturns = struct {
		result1 []*models.AppInstanceMetric
		result2 error
	}{result1, result2}
}

func (fake *FakeInstanceMetricsDB) SaveMetric(metric *models.AppInstanceMetric) error {
	fake.saveMetricMutex.Lock()
	fake.saveMetricArgsForCall = append(fake.saveMetricArgsForCall, struct {
		metric *models.AppInstanceMetric
	}{metric})
	fake.recordInvocation("SaveMetric", []interface{}{metric})
	fake.saveMetricMutex.Unlock()
	if fake.SaveMetricStub != nil {
		return fake.SaveMetricStub(metric)
	}
	return fake.saveMetricReturns.result1
}

func (fake *FakeInstanceMetricsDB) SaveMetricCallCount() int {
	fake.saveMetricMutex.RLock()
	defer fake.saveMetricMutex.RUnlock()
	return len(fake.saveMetricArgsForCall)
}

func (fake *FakeInstanceMetricsDB) SaveMetricArgsForCall(i int) *models.AppInstanceMetric {
	fake.saveMetricMutex.RLock()
	defer fake.saveMetricMutex.RUnlock()
	return fake.saveMetricArgsForCall[i].metric
}

func (fake *FakeInstanceMetricsDB) SaveMetricReturns(result1 error) {
	fake.SaveMetricStub = nil
	fake.saveMetricReturns = struct {
		result1 error
	}{result1}
}

func (fake *FakeInstanceMetricsDB) SaveMetricsInBulk(metrics []*models.AppInstanceMetric) error {
	var metricsCopy []*models.AppInstanceMetric
	if metrics != nil {
		metricsCopy = make([]*models.AppInstanceMetric, len(metrics))
		copy(metricsCopy, metrics)
	}
	fake.saveMetricsInBulkMutex.Lock()
	fake.saveMetricsInBulkArgsForCall = append(fake.saveMetricsInBulkArgsForCall, struct {
		metrics []*models.AppInstanceMetric
	}{metricsCopy})
	fake.recordInvocation("SaveMetricsInBulk", []interface{}{metricsCopy})
	fake.saveMetricsInBulkMutex.Unlock()
	if fake.SaveMetricsInBulkStub != nil {
		return fake.SaveMetricsInBulkStub(metrics)
	}
	return fake.saveMetricsInBulkReturns.result1
}

func (fake *FakeInstanceMetricsDB) SaveMetricsInBulkCallCount() int {
	fake.saveMetricsInBulkMutex.RLock()
	defer fake.saveMetricsInBulkMutex.RUnlock()
	return len(fake.saveMetricsInBulkArgsForCall)
}

func (fake *FakeInstanceMetricsDB) SaveMetricsInBulkArgsForCall(i int) []*models.AppInstanceMetric {
	fake.saveMetricsInBulkMutex.RLock()
	defer fake.saveMetricsInBulkMutex.RUnlock()
	return fake.saveMetricsInBulkArgsForCall[i].metrics
}

func (fake *FakeInstanceMetricsDB) SaveMetricsInBulkReturns(result1 error) {
	fake.SaveMetricsInBulkStub = nil
	fake.saveMetricsInBulkReturns = struct {
		result1 error
	}{result1}
}

func (fake *FakeInstanceMetricsDB) PruneInstanceMetrics(before int64) error {
	fake.pruneInstanceMetricsMutex.Lock()
	fake.pruneInstanceMetricsArgsForCall = append(fake.pruneInstanceMetricsArgsForCall, struct {
		before int64
	}{before})
	fake.recordInvocation("PruneInstanceMetrics", []interface{}{before})
	fake.pruneInstanceMetricsMutex.Unlock()
	if fake.PruneInstanceMetricsStub != nil {
		return fake.PruneInstanceMetricsStub(before)
	}
	return fake.pruneInstanceMetricsReturns.result1
}

func (fake *FakeInstanceMetricsDB) PruneInstanceMetricsCallCount() int {
	fake.pruneInstanceMetricsMutex.RLock()
	defer fake.pruneInstanceMetricsMutex.RUnlock()
	return len(fake.pruneInstanceMetricsArgsForCall)
}

func (fake *FakeInstanceMetricsDB) PruneInstanceMetricsArgsForCall(i int) int64 {
	fake.pruneInstanceMetricsMutex.RLock()
	defer fake.pruneInstanceMetricsMutex.RUnlock()
	return fake.pruneInstanceMetricsArgsForCall[i].before
}

func (fake *FakeInstanceMetricsDB) PruneInstanceMetricsReturns(result1 error) {
	fake.PruneInstanceMetricsStub = nil
	fake.pruneInstanceMetricsReturns = struct {
		result1 error
	}{result1}
}

func (fake *FakeInstanceMetricsDB) Close() error {
	fake.closeMutex.Lock()
	fake.closeArgsForCall = append(fake.closeArgsForCall, struct{}{})
	fake.recordInvocation("Close", []interface{}{})
	fake.closeMutex.Unlock()
	if fake.CloseStub != nil {
		return fake.CloseStub()
	}
	return fake.closeReturns.result1
}

func (fake *FakeInstanceMetricsDB) CloseCallCount() int {
	fake.closeMutex.RLock()
	defer fake.closeMutex.RUnlock()
	return len(fake.closeArgsForCall)
}

func (fake *FakeInstanceMetricsDB) CloseReturns(result1 error) {
	fake.CloseStub = nil
	fake.closeReturns = struct {
		result1 error
	}{result1}
}

func (fake *FakeInstanceMetricsDB) Invocations() map[string][][]interface{} {
	fake.invocationsMutex.RLock()
	defer fake.invocationsMutex.RUnlock()
	fake.getDBStatusMutex.RLock()
	defer fake.getDBStatusMutex.RUnlock()
	fake.retrieveInstanceMetricsMutex.RLock()
	defer fake.retrieveInstanceMetricsMutex.RUnlock()
	fake.saveMetricMutex.RLock()
	defer fake.saveMetricMutex.RUnlock()
	fake.saveMetricsInBulkMutex.RLock()
	defer fake.saveMetricsInBulkMutex.RUnlock()
	fake.pruneInstanceMetricsMutex.RLock()
	defer fake.pruneInstanceMetricsMutex.RUnlock()
	fake.closeMutex.RLock()
	defer fake.closeMutex.RUnlock()
	return fake.invocations
}

func (fake *FakeInstanceMetricsDB) 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 _ db.InstanceMetricsDB = new(FakeInstanceMetricsDB)
