// Code generated by http://github.com/gojuno/minimock (v3.3.14). DO NOT EDIT.

package mocks

//go:generate minimock -i git.dmitriygnatenko.ru/dima/homethings/internal/api/v1/thing.ThingRepository -o thing_repository_minimock.go -n ThingRepositoryMock -p mocks

import (
	"context"
	"sync"
	mm_atomic "sync/atomic"
	mm_time "time"

	"git.dmitriygnatenko.ru/dima/homethings/internal/models"
	"github.com/gojuno/minimock/v3"
)

// ThingRepositoryMock implements thing.ThingRepository
type ThingRepositoryMock struct {
	t          minimock.Tester
	finishOnce sync.Once

	funcAdd          func(ctx context.Context, req models.AddThingRequest) (u1 uint64, err error)
	inspectFuncAdd   func(ctx context.Context, req models.AddThingRequest)
	afterAddCounter  uint64
	beforeAddCounter uint64
	AddMock          mThingRepositoryMockAdd

	funcDelete          func(ctx context.Context, id uint64) (err error)
	inspectFuncDelete   func(ctx context.Context, id uint64)
	afterDeleteCounter  uint64
	beforeDeleteCounter uint64
	DeleteMock          mThingRepositoryMockDelete

	funcGet          func(ctx context.Context, id uint64) (tp1 *models.Thing, err error)
	inspectFuncGet   func(ctx context.Context, id uint64)
	afterGetCounter  uint64
	beforeGetCounter uint64
	GetMock          mThingRepositoryMockGet

	funcGetAllByPlaceID          func(ctx context.Context, id uint64) (ta1 []models.Thing, err error)
	inspectFuncGetAllByPlaceID   func(ctx context.Context, id uint64)
	afterGetAllByPlaceIDCounter  uint64
	beforeGetAllByPlaceIDCounter uint64
	GetAllByPlaceIDMock          mThingRepositoryMockGetAllByPlaceID

	funcGetByPlaceID          func(ctx context.Context, id uint64) (ta1 []models.Thing, err error)
	inspectFuncGetByPlaceID   func(ctx context.Context, id uint64)
	afterGetByPlaceIDCounter  uint64
	beforeGetByPlaceIDCounter uint64
	GetByPlaceIDMock          mThingRepositoryMockGetByPlaceID

	funcSearch          func(ctx context.Context, search string) (ta1 []models.Thing, err error)
	inspectFuncSearch   func(ctx context.Context, search string)
	afterSearchCounter  uint64
	beforeSearchCounter uint64
	SearchMock          mThingRepositoryMockSearch

	funcUpdate          func(ctx context.Context, req models.UpdateThingRequest) (err error)
	inspectFuncUpdate   func(ctx context.Context, req models.UpdateThingRequest)
	afterUpdateCounter  uint64
	beforeUpdateCounter uint64
	UpdateMock          mThingRepositoryMockUpdate
}

// NewThingRepositoryMock returns a mock for thing.ThingRepository
func NewThingRepositoryMock(t minimock.Tester) *ThingRepositoryMock {
	m := &ThingRepositoryMock{t: t}

	if controller, ok := t.(minimock.MockController); ok {
		controller.RegisterMocker(m)
	}

	m.AddMock = mThingRepositoryMockAdd{mock: m}
	m.AddMock.callArgs = []*ThingRepositoryMockAddParams{}

	m.DeleteMock = mThingRepositoryMockDelete{mock: m}
	m.DeleteMock.callArgs = []*ThingRepositoryMockDeleteParams{}

	m.GetMock = mThingRepositoryMockGet{mock: m}
	m.GetMock.callArgs = []*ThingRepositoryMockGetParams{}

	m.GetAllByPlaceIDMock = mThingRepositoryMockGetAllByPlaceID{mock: m}
	m.GetAllByPlaceIDMock.callArgs = []*ThingRepositoryMockGetAllByPlaceIDParams{}

	m.GetByPlaceIDMock = mThingRepositoryMockGetByPlaceID{mock: m}
	m.GetByPlaceIDMock.callArgs = []*ThingRepositoryMockGetByPlaceIDParams{}

	m.SearchMock = mThingRepositoryMockSearch{mock: m}
	m.SearchMock.callArgs = []*ThingRepositoryMockSearchParams{}

	m.UpdateMock = mThingRepositoryMockUpdate{mock: m}
	m.UpdateMock.callArgs = []*ThingRepositoryMockUpdateParams{}

	t.Cleanup(m.MinimockFinish)

	return m
}

type mThingRepositoryMockAdd struct {
	optional           bool
	mock               *ThingRepositoryMock
	defaultExpectation *ThingRepositoryMockAddExpectation
	expectations       []*ThingRepositoryMockAddExpectation

	callArgs []*ThingRepositoryMockAddParams
	mutex    sync.RWMutex

	expectedInvocations uint64
}

// ThingRepositoryMockAddExpectation specifies expectation struct of the ThingRepository.Add
type ThingRepositoryMockAddExpectation struct {
	mock      *ThingRepositoryMock
	params    *ThingRepositoryMockAddParams
	paramPtrs *ThingRepositoryMockAddParamPtrs
	results   *ThingRepositoryMockAddResults
	Counter   uint64
}

// ThingRepositoryMockAddParams contains parameters of the ThingRepository.Add
type ThingRepositoryMockAddParams struct {
	ctx context.Context
	req models.AddThingRequest
}

// ThingRepositoryMockAddParamPtrs contains pointers to parameters of the ThingRepository.Add
type ThingRepositoryMockAddParamPtrs struct {
	ctx *context.Context
	req *models.AddThingRequest
}

// ThingRepositoryMockAddResults contains results of the ThingRepository.Add
type ThingRepositoryMockAddResults struct {
	u1  uint64
	err error
}

// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning
// the test will fail minimock's automatic final call check if the mocked method was not called at least once.
// Optional() makes method check to work in '0 or more' mode.
// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to
// catch the problems when the expected method call is totally skipped during test run.
func (mmAdd *mThingRepositoryMockAdd) Optional() *mThingRepositoryMockAdd {
	mmAdd.optional = true
	return mmAdd
}

// Expect sets up expected params for ThingRepository.Add
func (mmAdd *mThingRepositoryMockAdd) Expect(ctx context.Context, req models.AddThingRequest) *mThingRepositoryMockAdd {
	if mmAdd.mock.funcAdd != nil {
		mmAdd.mock.t.Fatalf("ThingRepositoryMock.Add mock is already set by Set")
	}

	if mmAdd.defaultExpectation == nil {
		mmAdd.defaultExpectation = &ThingRepositoryMockAddExpectation{}
	}

	if mmAdd.defaultExpectation.paramPtrs != nil {
		mmAdd.mock.t.Fatalf("ThingRepositoryMock.Add mock is already set by ExpectParams functions")
	}

	mmAdd.defaultExpectation.params = &ThingRepositoryMockAddParams{ctx, req}
	for _, e := range mmAdd.expectations {
		if minimock.Equal(e.params, mmAdd.defaultExpectation.params) {
			mmAdd.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmAdd.defaultExpectation.params)
		}
	}

	return mmAdd
}

// ExpectCtxParam1 sets up expected param ctx for ThingRepository.Add
func (mmAdd *mThingRepositoryMockAdd) ExpectCtxParam1(ctx context.Context) *mThingRepositoryMockAdd {
	if mmAdd.mock.funcAdd != nil {
		mmAdd.mock.t.Fatalf("ThingRepositoryMock.Add mock is already set by Set")
	}

	if mmAdd.defaultExpectation == nil {
		mmAdd.defaultExpectation = &ThingRepositoryMockAddExpectation{}
	}

	if mmAdd.defaultExpectation.params != nil {
		mmAdd.mock.t.Fatalf("ThingRepositoryMock.Add mock is already set by Expect")
	}

	if mmAdd.defaultExpectation.paramPtrs == nil {
		mmAdd.defaultExpectation.paramPtrs = &ThingRepositoryMockAddParamPtrs{}
	}
	mmAdd.defaultExpectation.paramPtrs.ctx = &ctx

	return mmAdd
}

// ExpectReqParam2 sets up expected param req for ThingRepository.Add
func (mmAdd *mThingRepositoryMockAdd) ExpectReqParam2(req models.AddThingRequest) *mThingRepositoryMockAdd {
	if mmAdd.mock.funcAdd != nil {
		mmAdd.mock.t.Fatalf("ThingRepositoryMock.Add mock is already set by Set")
	}

	if mmAdd.defaultExpectation == nil {
		mmAdd.defaultExpectation = &ThingRepositoryMockAddExpectation{}
	}

	if mmAdd.defaultExpectation.params != nil {
		mmAdd.mock.t.Fatalf("ThingRepositoryMock.Add mock is already set by Expect")
	}

	if mmAdd.defaultExpectation.paramPtrs == nil {
		mmAdd.defaultExpectation.paramPtrs = &ThingRepositoryMockAddParamPtrs{}
	}
	mmAdd.defaultExpectation.paramPtrs.req = &req

	return mmAdd
}

// Inspect accepts an inspector function that has same arguments as the ThingRepository.Add
func (mmAdd *mThingRepositoryMockAdd) Inspect(f func(ctx context.Context, req models.AddThingRequest)) *mThingRepositoryMockAdd {
	if mmAdd.mock.inspectFuncAdd != nil {
		mmAdd.mock.t.Fatalf("Inspect function is already set for ThingRepositoryMock.Add")
	}

	mmAdd.mock.inspectFuncAdd = f

	return mmAdd
}

// Return sets up results that will be returned by ThingRepository.Add
func (mmAdd *mThingRepositoryMockAdd) Return(u1 uint64, err error) *ThingRepositoryMock {
	if mmAdd.mock.funcAdd != nil {
		mmAdd.mock.t.Fatalf("ThingRepositoryMock.Add mock is already set by Set")
	}

	if mmAdd.defaultExpectation == nil {
		mmAdd.defaultExpectation = &ThingRepositoryMockAddExpectation{mock: mmAdd.mock}
	}
	mmAdd.defaultExpectation.results = &ThingRepositoryMockAddResults{u1, err}
	return mmAdd.mock
}

// Set uses given function f to mock the ThingRepository.Add method
func (mmAdd *mThingRepositoryMockAdd) Set(f func(ctx context.Context, req models.AddThingRequest) (u1 uint64, err error)) *ThingRepositoryMock {
	if mmAdd.defaultExpectation != nil {
		mmAdd.mock.t.Fatalf("Default expectation is already set for the ThingRepository.Add method")
	}

	if len(mmAdd.expectations) > 0 {
		mmAdd.mock.t.Fatalf("Some expectations are already set for the ThingRepository.Add method")
	}

	mmAdd.mock.funcAdd = f
	return mmAdd.mock
}

// When sets expectation for the ThingRepository.Add which will trigger the result defined by the following
// Then helper
func (mmAdd *mThingRepositoryMockAdd) When(ctx context.Context, req models.AddThingRequest) *ThingRepositoryMockAddExpectation {
	if mmAdd.mock.funcAdd != nil {
		mmAdd.mock.t.Fatalf("ThingRepositoryMock.Add mock is already set by Set")
	}

	expectation := &ThingRepositoryMockAddExpectation{
		mock:   mmAdd.mock,
		params: &ThingRepositoryMockAddParams{ctx, req},
	}
	mmAdd.expectations = append(mmAdd.expectations, expectation)
	return expectation
}

// Then sets up ThingRepository.Add return parameters for the expectation previously defined by the When method
func (e *ThingRepositoryMockAddExpectation) Then(u1 uint64, err error) *ThingRepositoryMock {
	e.results = &ThingRepositoryMockAddResults{u1, err}
	return e.mock
}

// Times sets number of times ThingRepository.Add should be invoked
func (mmAdd *mThingRepositoryMockAdd) Times(n uint64) *mThingRepositoryMockAdd {
	if n == 0 {
		mmAdd.mock.t.Fatalf("Times of ThingRepositoryMock.Add mock can not be zero")
	}
	mm_atomic.StoreUint64(&mmAdd.expectedInvocations, n)
	return mmAdd
}

func (mmAdd *mThingRepositoryMockAdd) invocationsDone() bool {
	if len(mmAdd.expectations) == 0 && mmAdd.defaultExpectation == nil && mmAdd.mock.funcAdd == nil {
		return true
	}

	totalInvocations := mm_atomic.LoadUint64(&mmAdd.mock.afterAddCounter)
	expectedInvocations := mm_atomic.LoadUint64(&mmAdd.expectedInvocations)

	return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
}

// Add implements thing.ThingRepository
func (mmAdd *ThingRepositoryMock) Add(ctx context.Context, req models.AddThingRequest) (u1 uint64, err error) {
	mm_atomic.AddUint64(&mmAdd.beforeAddCounter, 1)
	defer mm_atomic.AddUint64(&mmAdd.afterAddCounter, 1)

	if mmAdd.inspectFuncAdd != nil {
		mmAdd.inspectFuncAdd(ctx, req)
	}

	mm_params := ThingRepositoryMockAddParams{ctx, req}

	// Record call args
	mmAdd.AddMock.mutex.Lock()
	mmAdd.AddMock.callArgs = append(mmAdd.AddMock.callArgs, &mm_params)
	mmAdd.AddMock.mutex.Unlock()

	for _, e := range mmAdd.AddMock.expectations {
		if minimock.Equal(*e.params, mm_params) {
			mm_atomic.AddUint64(&e.Counter, 1)
			return e.results.u1, e.results.err
		}
	}

	if mmAdd.AddMock.defaultExpectation != nil {
		mm_atomic.AddUint64(&mmAdd.AddMock.defaultExpectation.Counter, 1)
		mm_want := mmAdd.AddMock.defaultExpectation.params
		mm_want_ptrs := mmAdd.AddMock.defaultExpectation.paramPtrs

		mm_got := ThingRepositoryMockAddParams{ctx, req}

		if mm_want_ptrs != nil {

			if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
				mmAdd.t.Errorf("ThingRepositoryMock.Add got unexpected parameter ctx, want: %#v, got: %#v%s\n", *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
			}

			if mm_want_ptrs.req != nil && !minimock.Equal(*mm_want_ptrs.req, mm_got.req) {
				mmAdd.t.Errorf("ThingRepositoryMock.Add got unexpected parameter req, want: %#v, got: %#v%s\n", *mm_want_ptrs.req, mm_got.req, minimock.Diff(*mm_want_ptrs.req, mm_got.req))
			}

		} else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
			mmAdd.t.Errorf("ThingRepositoryMock.Add got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
		}

		mm_results := mmAdd.AddMock.defaultExpectation.results
		if mm_results == nil {
			mmAdd.t.Fatal("No results are set for the ThingRepositoryMock.Add")
		}
		return (*mm_results).u1, (*mm_results).err
	}
	if mmAdd.funcAdd != nil {
		return mmAdd.funcAdd(ctx, req)
	}
	mmAdd.t.Fatalf("Unexpected call to ThingRepositoryMock.Add. %v %v", ctx, req)
	return
}

// AddAfterCounter returns a count of finished ThingRepositoryMock.Add invocations
func (mmAdd *ThingRepositoryMock) AddAfterCounter() uint64 {
	return mm_atomic.LoadUint64(&mmAdd.afterAddCounter)
}

// AddBeforeCounter returns a count of ThingRepositoryMock.Add invocations
func (mmAdd *ThingRepositoryMock) AddBeforeCounter() uint64 {
	return mm_atomic.LoadUint64(&mmAdd.beforeAddCounter)
}

// Calls returns a list of arguments used in each call to ThingRepositoryMock.Add.
// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
func (mmAdd *mThingRepositoryMockAdd) Calls() []*ThingRepositoryMockAddParams {
	mmAdd.mutex.RLock()

	argCopy := make([]*ThingRepositoryMockAddParams, len(mmAdd.callArgs))
	copy(argCopy, mmAdd.callArgs)

	mmAdd.mutex.RUnlock()

	return argCopy
}

// MinimockAddDone returns true if the count of the Add invocations corresponds
// the number of defined expectations
func (m *ThingRepositoryMock) MinimockAddDone() bool {
	if m.AddMock.optional {
		// Optional methods provide '0 or more' call count restriction.
		return true
	}

	for _, e := range m.AddMock.expectations {
		if mm_atomic.LoadUint64(&e.Counter) < 1 {
			return false
		}
	}

	return m.AddMock.invocationsDone()
}

// MinimockAddInspect logs each unmet expectation
func (m *ThingRepositoryMock) MinimockAddInspect() {
	for _, e := range m.AddMock.expectations {
		if mm_atomic.LoadUint64(&e.Counter) < 1 {
			m.t.Errorf("Expected call to ThingRepositoryMock.Add with params: %#v", *e.params)
		}
	}

	afterAddCounter := mm_atomic.LoadUint64(&m.afterAddCounter)
	// if default expectation was set then invocations count should be greater than zero
	if m.AddMock.defaultExpectation != nil && afterAddCounter < 1 {
		if m.AddMock.defaultExpectation.params == nil {
			m.t.Error("Expected call to ThingRepositoryMock.Add")
		} else {
			m.t.Errorf("Expected call to ThingRepositoryMock.Add with params: %#v", *m.AddMock.defaultExpectation.params)
		}
	}
	// if func was set then invocations count should be greater than zero
	if m.funcAdd != nil && afterAddCounter < 1 {
		m.t.Error("Expected call to ThingRepositoryMock.Add")
	}

	if !m.AddMock.invocationsDone() && afterAddCounter > 0 {
		m.t.Errorf("Expected %d calls to ThingRepositoryMock.Add but found %d calls",
			mm_atomic.LoadUint64(&m.AddMock.expectedInvocations), afterAddCounter)
	}
}

type mThingRepositoryMockDelete struct {
	optional           bool
	mock               *ThingRepositoryMock
	defaultExpectation *ThingRepositoryMockDeleteExpectation
	expectations       []*ThingRepositoryMockDeleteExpectation

	callArgs []*ThingRepositoryMockDeleteParams
	mutex    sync.RWMutex

	expectedInvocations uint64
}

// ThingRepositoryMockDeleteExpectation specifies expectation struct of the ThingRepository.Delete
type ThingRepositoryMockDeleteExpectation struct {
	mock      *ThingRepositoryMock
	params    *ThingRepositoryMockDeleteParams
	paramPtrs *ThingRepositoryMockDeleteParamPtrs
	results   *ThingRepositoryMockDeleteResults
	Counter   uint64
}

// ThingRepositoryMockDeleteParams contains parameters of the ThingRepository.Delete
type ThingRepositoryMockDeleteParams struct {
	ctx context.Context
	id  uint64
}

// ThingRepositoryMockDeleteParamPtrs contains pointers to parameters of the ThingRepository.Delete
type ThingRepositoryMockDeleteParamPtrs struct {
	ctx *context.Context
	id  *uint64
}

// ThingRepositoryMockDeleteResults contains results of the ThingRepository.Delete
type ThingRepositoryMockDeleteResults struct {
	err error
}

// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning
// the test will fail minimock's automatic final call check if the mocked method was not called at least once.
// Optional() makes method check to work in '0 or more' mode.
// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to
// catch the problems when the expected method call is totally skipped during test run.
func (mmDelete *mThingRepositoryMockDelete) Optional() *mThingRepositoryMockDelete {
	mmDelete.optional = true
	return mmDelete
}

// Expect sets up expected params for ThingRepository.Delete
func (mmDelete *mThingRepositoryMockDelete) Expect(ctx context.Context, id uint64) *mThingRepositoryMockDelete {
	if mmDelete.mock.funcDelete != nil {
		mmDelete.mock.t.Fatalf("ThingRepositoryMock.Delete mock is already set by Set")
	}

	if mmDelete.defaultExpectation == nil {
		mmDelete.defaultExpectation = &ThingRepositoryMockDeleteExpectation{}
	}

	if mmDelete.defaultExpectation.paramPtrs != nil {
		mmDelete.mock.t.Fatalf("ThingRepositoryMock.Delete mock is already set by ExpectParams functions")
	}

	mmDelete.defaultExpectation.params = &ThingRepositoryMockDeleteParams{ctx, id}
	for _, e := range mmDelete.expectations {
		if minimock.Equal(e.params, mmDelete.defaultExpectation.params) {
			mmDelete.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmDelete.defaultExpectation.params)
		}
	}

	return mmDelete
}

// ExpectCtxParam1 sets up expected param ctx for ThingRepository.Delete
func (mmDelete *mThingRepositoryMockDelete) ExpectCtxParam1(ctx context.Context) *mThingRepositoryMockDelete {
	if mmDelete.mock.funcDelete != nil {
		mmDelete.mock.t.Fatalf("ThingRepositoryMock.Delete mock is already set by Set")
	}

	if mmDelete.defaultExpectation == nil {
		mmDelete.defaultExpectation = &ThingRepositoryMockDeleteExpectation{}
	}

	if mmDelete.defaultExpectation.params != nil {
		mmDelete.mock.t.Fatalf("ThingRepositoryMock.Delete mock is already set by Expect")
	}

	if mmDelete.defaultExpectation.paramPtrs == nil {
		mmDelete.defaultExpectation.paramPtrs = &ThingRepositoryMockDeleteParamPtrs{}
	}
	mmDelete.defaultExpectation.paramPtrs.ctx = &ctx

	return mmDelete
}

// ExpectIdParam2 sets up expected param id for ThingRepository.Delete
func (mmDelete *mThingRepositoryMockDelete) ExpectIdParam2(id uint64) *mThingRepositoryMockDelete {
	if mmDelete.mock.funcDelete != nil {
		mmDelete.mock.t.Fatalf("ThingRepositoryMock.Delete mock is already set by Set")
	}

	if mmDelete.defaultExpectation == nil {
		mmDelete.defaultExpectation = &ThingRepositoryMockDeleteExpectation{}
	}

	if mmDelete.defaultExpectation.params != nil {
		mmDelete.mock.t.Fatalf("ThingRepositoryMock.Delete mock is already set by Expect")
	}

	if mmDelete.defaultExpectation.paramPtrs == nil {
		mmDelete.defaultExpectation.paramPtrs = &ThingRepositoryMockDeleteParamPtrs{}
	}
	mmDelete.defaultExpectation.paramPtrs.id = &id

	return mmDelete
}

// Inspect accepts an inspector function that has same arguments as the ThingRepository.Delete
func (mmDelete *mThingRepositoryMockDelete) Inspect(f func(ctx context.Context, id uint64)) *mThingRepositoryMockDelete {
	if mmDelete.mock.inspectFuncDelete != nil {
		mmDelete.mock.t.Fatalf("Inspect function is already set for ThingRepositoryMock.Delete")
	}

	mmDelete.mock.inspectFuncDelete = f

	return mmDelete
}

// Return sets up results that will be returned by ThingRepository.Delete
func (mmDelete *mThingRepositoryMockDelete) Return(err error) *ThingRepositoryMock {
	if mmDelete.mock.funcDelete != nil {
		mmDelete.mock.t.Fatalf("ThingRepositoryMock.Delete mock is already set by Set")
	}

	if mmDelete.defaultExpectation == nil {
		mmDelete.defaultExpectation = &ThingRepositoryMockDeleteExpectation{mock: mmDelete.mock}
	}
	mmDelete.defaultExpectation.results = &ThingRepositoryMockDeleteResults{err}
	return mmDelete.mock
}

// Set uses given function f to mock the ThingRepository.Delete method
func (mmDelete *mThingRepositoryMockDelete) Set(f func(ctx context.Context, id uint64) (err error)) *ThingRepositoryMock {
	if mmDelete.defaultExpectation != nil {
		mmDelete.mock.t.Fatalf("Default expectation is already set for the ThingRepository.Delete method")
	}

	if len(mmDelete.expectations) > 0 {
		mmDelete.mock.t.Fatalf("Some expectations are already set for the ThingRepository.Delete method")
	}

	mmDelete.mock.funcDelete = f
	return mmDelete.mock
}

// When sets expectation for the ThingRepository.Delete which will trigger the result defined by the following
// Then helper
func (mmDelete *mThingRepositoryMockDelete) When(ctx context.Context, id uint64) *ThingRepositoryMockDeleteExpectation {
	if mmDelete.mock.funcDelete != nil {
		mmDelete.mock.t.Fatalf("ThingRepositoryMock.Delete mock is already set by Set")
	}

	expectation := &ThingRepositoryMockDeleteExpectation{
		mock:   mmDelete.mock,
		params: &ThingRepositoryMockDeleteParams{ctx, id},
	}
	mmDelete.expectations = append(mmDelete.expectations, expectation)
	return expectation
}

// Then sets up ThingRepository.Delete return parameters for the expectation previously defined by the When method
func (e *ThingRepositoryMockDeleteExpectation) Then(err error) *ThingRepositoryMock {
	e.results = &ThingRepositoryMockDeleteResults{err}
	return e.mock
}

// Times sets number of times ThingRepository.Delete should be invoked
func (mmDelete *mThingRepositoryMockDelete) Times(n uint64) *mThingRepositoryMockDelete {
	if n == 0 {
		mmDelete.mock.t.Fatalf("Times of ThingRepositoryMock.Delete mock can not be zero")
	}
	mm_atomic.StoreUint64(&mmDelete.expectedInvocations, n)
	return mmDelete
}

func (mmDelete *mThingRepositoryMockDelete) invocationsDone() bool {
	if len(mmDelete.expectations) == 0 && mmDelete.defaultExpectation == nil && mmDelete.mock.funcDelete == nil {
		return true
	}

	totalInvocations := mm_atomic.LoadUint64(&mmDelete.mock.afterDeleteCounter)
	expectedInvocations := mm_atomic.LoadUint64(&mmDelete.expectedInvocations)

	return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
}

// Delete implements thing.ThingRepository
func (mmDelete *ThingRepositoryMock) Delete(ctx context.Context, id uint64) (err error) {
	mm_atomic.AddUint64(&mmDelete.beforeDeleteCounter, 1)
	defer mm_atomic.AddUint64(&mmDelete.afterDeleteCounter, 1)

	if mmDelete.inspectFuncDelete != nil {
		mmDelete.inspectFuncDelete(ctx, id)
	}

	mm_params := ThingRepositoryMockDeleteParams{ctx, id}

	// Record call args
	mmDelete.DeleteMock.mutex.Lock()
	mmDelete.DeleteMock.callArgs = append(mmDelete.DeleteMock.callArgs, &mm_params)
	mmDelete.DeleteMock.mutex.Unlock()

	for _, e := range mmDelete.DeleteMock.expectations {
		if minimock.Equal(*e.params, mm_params) {
			mm_atomic.AddUint64(&e.Counter, 1)
			return e.results.err
		}
	}

	if mmDelete.DeleteMock.defaultExpectation != nil {
		mm_atomic.AddUint64(&mmDelete.DeleteMock.defaultExpectation.Counter, 1)
		mm_want := mmDelete.DeleteMock.defaultExpectation.params
		mm_want_ptrs := mmDelete.DeleteMock.defaultExpectation.paramPtrs

		mm_got := ThingRepositoryMockDeleteParams{ctx, id}

		if mm_want_ptrs != nil {

			if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
				mmDelete.t.Errorf("ThingRepositoryMock.Delete got unexpected parameter ctx, want: %#v, got: %#v%s\n", *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
			}

			if mm_want_ptrs.id != nil && !minimock.Equal(*mm_want_ptrs.id, mm_got.id) {
				mmDelete.t.Errorf("ThingRepositoryMock.Delete got unexpected parameter id, want: %#v, got: %#v%s\n", *mm_want_ptrs.id, mm_got.id, minimock.Diff(*mm_want_ptrs.id, mm_got.id))
			}

		} else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
			mmDelete.t.Errorf("ThingRepositoryMock.Delete got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
		}

		mm_results := mmDelete.DeleteMock.defaultExpectation.results
		if mm_results == nil {
			mmDelete.t.Fatal("No results are set for the ThingRepositoryMock.Delete")
		}
		return (*mm_results).err
	}
	if mmDelete.funcDelete != nil {
		return mmDelete.funcDelete(ctx, id)
	}
	mmDelete.t.Fatalf("Unexpected call to ThingRepositoryMock.Delete. %v %v", ctx, id)
	return
}

// DeleteAfterCounter returns a count of finished ThingRepositoryMock.Delete invocations
func (mmDelete *ThingRepositoryMock) DeleteAfterCounter() uint64 {
	return mm_atomic.LoadUint64(&mmDelete.afterDeleteCounter)
}

// DeleteBeforeCounter returns a count of ThingRepositoryMock.Delete invocations
func (mmDelete *ThingRepositoryMock) DeleteBeforeCounter() uint64 {
	return mm_atomic.LoadUint64(&mmDelete.beforeDeleteCounter)
}

// Calls returns a list of arguments used in each call to ThingRepositoryMock.Delete.
// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
func (mmDelete *mThingRepositoryMockDelete) Calls() []*ThingRepositoryMockDeleteParams {
	mmDelete.mutex.RLock()

	argCopy := make([]*ThingRepositoryMockDeleteParams, len(mmDelete.callArgs))
	copy(argCopy, mmDelete.callArgs)

	mmDelete.mutex.RUnlock()

	return argCopy
}

// MinimockDeleteDone returns true if the count of the Delete invocations corresponds
// the number of defined expectations
func (m *ThingRepositoryMock) MinimockDeleteDone() bool {
	if m.DeleteMock.optional {
		// Optional methods provide '0 or more' call count restriction.
		return true
	}

	for _, e := range m.DeleteMock.expectations {
		if mm_atomic.LoadUint64(&e.Counter) < 1 {
			return false
		}
	}

	return m.DeleteMock.invocationsDone()
}

// MinimockDeleteInspect logs each unmet expectation
func (m *ThingRepositoryMock) MinimockDeleteInspect() {
	for _, e := range m.DeleteMock.expectations {
		if mm_atomic.LoadUint64(&e.Counter) < 1 {
			m.t.Errorf("Expected call to ThingRepositoryMock.Delete with params: %#v", *e.params)
		}
	}

	afterDeleteCounter := mm_atomic.LoadUint64(&m.afterDeleteCounter)
	// if default expectation was set then invocations count should be greater than zero
	if m.DeleteMock.defaultExpectation != nil && afterDeleteCounter < 1 {
		if m.DeleteMock.defaultExpectation.params == nil {
			m.t.Error("Expected call to ThingRepositoryMock.Delete")
		} else {
			m.t.Errorf("Expected call to ThingRepositoryMock.Delete with params: %#v", *m.DeleteMock.defaultExpectation.params)
		}
	}
	// if func was set then invocations count should be greater than zero
	if m.funcDelete != nil && afterDeleteCounter < 1 {
		m.t.Error("Expected call to ThingRepositoryMock.Delete")
	}

	if !m.DeleteMock.invocationsDone() && afterDeleteCounter > 0 {
		m.t.Errorf("Expected %d calls to ThingRepositoryMock.Delete but found %d calls",
			mm_atomic.LoadUint64(&m.DeleteMock.expectedInvocations), afterDeleteCounter)
	}
}

type mThingRepositoryMockGet struct {
	optional           bool
	mock               *ThingRepositoryMock
	defaultExpectation *ThingRepositoryMockGetExpectation
	expectations       []*ThingRepositoryMockGetExpectation

	callArgs []*ThingRepositoryMockGetParams
	mutex    sync.RWMutex

	expectedInvocations uint64
}

// ThingRepositoryMockGetExpectation specifies expectation struct of the ThingRepository.Get
type ThingRepositoryMockGetExpectation struct {
	mock      *ThingRepositoryMock
	params    *ThingRepositoryMockGetParams
	paramPtrs *ThingRepositoryMockGetParamPtrs
	results   *ThingRepositoryMockGetResults
	Counter   uint64
}

// ThingRepositoryMockGetParams contains parameters of the ThingRepository.Get
type ThingRepositoryMockGetParams struct {
	ctx context.Context
	id  uint64
}

// ThingRepositoryMockGetParamPtrs contains pointers to parameters of the ThingRepository.Get
type ThingRepositoryMockGetParamPtrs struct {
	ctx *context.Context
	id  *uint64
}

// ThingRepositoryMockGetResults contains results of the ThingRepository.Get
type ThingRepositoryMockGetResults struct {
	tp1 *models.Thing
	err error
}

// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning
// the test will fail minimock's automatic final call check if the mocked method was not called at least once.
// Optional() makes method check to work in '0 or more' mode.
// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to
// catch the problems when the expected method call is totally skipped during test run.
func (mmGet *mThingRepositoryMockGet) Optional() *mThingRepositoryMockGet {
	mmGet.optional = true
	return mmGet
}

// Expect sets up expected params for ThingRepository.Get
func (mmGet *mThingRepositoryMockGet) Expect(ctx context.Context, id uint64) *mThingRepositoryMockGet {
	if mmGet.mock.funcGet != nil {
		mmGet.mock.t.Fatalf("ThingRepositoryMock.Get mock is already set by Set")
	}

	if mmGet.defaultExpectation == nil {
		mmGet.defaultExpectation = &ThingRepositoryMockGetExpectation{}
	}

	if mmGet.defaultExpectation.paramPtrs != nil {
		mmGet.mock.t.Fatalf("ThingRepositoryMock.Get mock is already set by ExpectParams functions")
	}

	mmGet.defaultExpectation.params = &ThingRepositoryMockGetParams{ctx, id}
	for _, e := range mmGet.expectations {
		if minimock.Equal(e.params, mmGet.defaultExpectation.params) {
			mmGet.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGet.defaultExpectation.params)
		}
	}

	return mmGet
}

// ExpectCtxParam1 sets up expected param ctx for ThingRepository.Get
func (mmGet *mThingRepositoryMockGet) ExpectCtxParam1(ctx context.Context) *mThingRepositoryMockGet {
	if mmGet.mock.funcGet != nil {
		mmGet.mock.t.Fatalf("ThingRepositoryMock.Get mock is already set by Set")
	}

	if mmGet.defaultExpectation == nil {
		mmGet.defaultExpectation = &ThingRepositoryMockGetExpectation{}
	}

	if mmGet.defaultExpectation.params != nil {
		mmGet.mock.t.Fatalf("ThingRepositoryMock.Get mock is already set by Expect")
	}

	if mmGet.defaultExpectation.paramPtrs == nil {
		mmGet.defaultExpectation.paramPtrs = &ThingRepositoryMockGetParamPtrs{}
	}
	mmGet.defaultExpectation.paramPtrs.ctx = &ctx

	return mmGet
}

// ExpectIdParam2 sets up expected param id for ThingRepository.Get
func (mmGet *mThingRepositoryMockGet) ExpectIdParam2(id uint64) *mThingRepositoryMockGet {
	if mmGet.mock.funcGet != nil {
		mmGet.mock.t.Fatalf("ThingRepositoryMock.Get mock is already set by Set")
	}

	if mmGet.defaultExpectation == nil {
		mmGet.defaultExpectation = &ThingRepositoryMockGetExpectation{}
	}

	if mmGet.defaultExpectation.params != nil {
		mmGet.mock.t.Fatalf("ThingRepositoryMock.Get mock is already set by Expect")
	}

	if mmGet.defaultExpectation.paramPtrs == nil {
		mmGet.defaultExpectation.paramPtrs = &ThingRepositoryMockGetParamPtrs{}
	}
	mmGet.defaultExpectation.paramPtrs.id = &id

	return mmGet
}

// Inspect accepts an inspector function that has same arguments as the ThingRepository.Get
func (mmGet *mThingRepositoryMockGet) Inspect(f func(ctx context.Context, id uint64)) *mThingRepositoryMockGet {
	if mmGet.mock.inspectFuncGet != nil {
		mmGet.mock.t.Fatalf("Inspect function is already set for ThingRepositoryMock.Get")
	}

	mmGet.mock.inspectFuncGet = f

	return mmGet
}

// Return sets up results that will be returned by ThingRepository.Get
func (mmGet *mThingRepositoryMockGet) Return(tp1 *models.Thing, err error) *ThingRepositoryMock {
	if mmGet.mock.funcGet != nil {
		mmGet.mock.t.Fatalf("ThingRepositoryMock.Get mock is already set by Set")
	}

	if mmGet.defaultExpectation == nil {
		mmGet.defaultExpectation = &ThingRepositoryMockGetExpectation{mock: mmGet.mock}
	}
	mmGet.defaultExpectation.results = &ThingRepositoryMockGetResults{tp1, err}
	return mmGet.mock
}

// Set uses given function f to mock the ThingRepository.Get method
func (mmGet *mThingRepositoryMockGet) Set(f func(ctx context.Context, id uint64) (tp1 *models.Thing, err error)) *ThingRepositoryMock {
	if mmGet.defaultExpectation != nil {
		mmGet.mock.t.Fatalf("Default expectation is already set for the ThingRepository.Get method")
	}

	if len(mmGet.expectations) > 0 {
		mmGet.mock.t.Fatalf("Some expectations are already set for the ThingRepository.Get method")
	}

	mmGet.mock.funcGet = f
	return mmGet.mock
}

// When sets expectation for the ThingRepository.Get which will trigger the result defined by the following
// Then helper
func (mmGet *mThingRepositoryMockGet) When(ctx context.Context, id uint64) *ThingRepositoryMockGetExpectation {
	if mmGet.mock.funcGet != nil {
		mmGet.mock.t.Fatalf("ThingRepositoryMock.Get mock is already set by Set")
	}

	expectation := &ThingRepositoryMockGetExpectation{
		mock:   mmGet.mock,
		params: &ThingRepositoryMockGetParams{ctx, id},
	}
	mmGet.expectations = append(mmGet.expectations, expectation)
	return expectation
}

// Then sets up ThingRepository.Get return parameters for the expectation previously defined by the When method
func (e *ThingRepositoryMockGetExpectation) Then(tp1 *models.Thing, err error) *ThingRepositoryMock {
	e.results = &ThingRepositoryMockGetResults{tp1, err}
	return e.mock
}

// Times sets number of times ThingRepository.Get should be invoked
func (mmGet *mThingRepositoryMockGet) Times(n uint64) *mThingRepositoryMockGet {
	if n == 0 {
		mmGet.mock.t.Fatalf("Times of ThingRepositoryMock.Get mock can not be zero")
	}
	mm_atomic.StoreUint64(&mmGet.expectedInvocations, n)
	return mmGet
}

func (mmGet *mThingRepositoryMockGet) invocationsDone() bool {
	if len(mmGet.expectations) == 0 && mmGet.defaultExpectation == nil && mmGet.mock.funcGet == nil {
		return true
	}

	totalInvocations := mm_atomic.LoadUint64(&mmGet.mock.afterGetCounter)
	expectedInvocations := mm_atomic.LoadUint64(&mmGet.expectedInvocations)

	return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
}

// Get implements thing.ThingRepository
func (mmGet *ThingRepositoryMock) Get(ctx context.Context, id uint64) (tp1 *models.Thing, err error) {
	mm_atomic.AddUint64(&mmGet.beforeGetCounter, 1)
	defer mm_atomic.AddUint64(&mmGet.afterGetCounter, 1)

	if mmGet.inspectFuncGet != nil {
		mmGet.inspectFuncGet(ctx, id)
	}

	mm_params := ThingRepositoryMockGetParams{ctx, id}

	// Record call args
	mmGet.GetMock.mutex.Lock()
	mmGet.GetMock.callArgs = append(mmGet.GetMock.callArgs, &mm_params)
	mmGet.GetMock.mutex.Unlock()

	for _, e := range mmGet.GetMock.expectations {
		if minimock.Equal(*e.params, mm_params) {
			mm_atomic.AddUint64(&e.Counter, 1)
			return e.results.tp1, e.results.err
		}
	}

	if mmGet.GetMock.defaultExpectation != nil {
		mm_atomic.AddUint64(&mmGet.GetMock.defaultExpectation.Counter, 1)
		mm_want := mmGet.GetMock.defaultExpectation.params
		mm_want_ptrs := mmGet.GetMock.defaultExpectation.paramPtrs

		mm_got := ThingRepositoryMockGetParams{ctx, id}

		if mm_want_ptrs != nil {

			if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
				mmGet.t.Errorf("ThingRepositoryMock.Get got unexpected parameter ctx, want: %#v, got: %#v%s\n", *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
			}

			if mm_want_ptrs.id != nil && !minimock.Equal(*mm_want_ptrs.id, mm_got.id) {
				mmGet.t.Errorf("ThingRepositoryMock.Get got unexpected parameter id, want: %#v, got: %#v%s\n", *mm_want_ptrs.id, mm_got.id, minimock.Diff(*mm_want_ptrs.id, mm_got.id))
			}

		} else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
			mmGet.t.Errorf("ThingRepositoryMock.Get got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
		}

		mm_results := mmGet.GetMock.defaultExpectation.results
		if mm_results == nil {
			mmGet.t.Fatal("No results are set for the ThingRepositoryMock.Get")
		}
		return (*mm_results).tp1, (*mm_results).err
	}
	if mmGet.funcGet != nil {
		return mmGet.funcGet(ctx, id)
	}
	mmGet.t.Fatalf("Unexpected call to ThingRepositoryMock.Get. %v %v", ctx, id)
	return
}

// GetAfterCounter returns a count of finished ThingRepositoryMock.Get invocations
func (mmGet *ThingRepositoryMock) GetAfterCounter() uint64 {
	return mm_atomic.LoadUint64(&mmGet.afterGetCounter)
}

// GetBeforeCounter returns a count of ThingRepositoryMock.Get invocations
func (mmGet *ThingRepositoryMock) GetBeforeCounter() uint64 {
	return mm_atomic.LoadUint64(&mmGet.beforeGetCounter)
}

// Calls returns a list of arguments used in each call to ThingRepositoryMock.Get.
// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
func (mmGet *mThingRepositoryMockGet) Calls() []*ThingRepositoryMockGetParams {
	mmGet.mutex.RLock()

	argCopy := make([]*ThingRepositoryMockGetParams, len(mmGet.callArgs))
	copy(argCopy, mmGet.callArgs)

	mmGet.mutex.RUnlock()

	return argCopy
}

// MinimockGetDone returns true if the count of the Get invocations corresponds
// the number of defined expectations
func (m *ThingRepositoryMock) MinimockGetDone() bool {
	if m.GetMock.optional {
		// Optional methods provide '0 or more' call count restriction.
		return true
	}

	for _, e := range m.GetMock.expectations {
		if mm_atomic.LoadUint64(&e.Counter) < 1 {
			return false
		}
	}

	return m.GetMock.invocationsDone()
}

// MinimockGetInspect logs each unmet expectation
func (m *ThingRepositoryMock) MinimockGetInspect() {
	for _, e := range m.GetMock.expectations {
		if mm_atomic.LoadUint64(&e.Counter) < 1 {
			m.t.Errorf("Expected call to ThingRepositoryMock.Get with params: %#v", *e.params)
		}
	}

	afterGetCounter := mm_atomic.LoadUint64(&m.afterGetCounter)
	// if default expectation was set then invocations count should be greater than zero
	if m.GetMock.defaultExpectation != nil && afterGetCounter < 1 {
		if m.GetMock.defaultExpectation.params == nil {
			m.t.Error("Expected call to ThingRepositoryMock.Get")
		} else {
			m.t.Errorf("Expected call to ThingRepositoryMock.Get with params: %#v", *m.GetMock.defaultExpectation.params)
		}
	}
	// if func was set then invocations count should be greater than zero
	if m.funcGet != nil && afterGetCounter < 1 {
		m.t.Error("Expected call to ThingRepositoryMock.Get")
	}

	if !m.GetMock.invocationsDone() && afterGetCounter > 0 {
		m.t.Errorf("Expected %d calls to ThingRepositoryMock.Get but found %d calls",
			mm_atomic.LoadUint64(&m.GetMock.expectedInvocations), afterGetCounter)
	}
}

type mThingRepositoryMockGetAllByPlaceID struct {
	optional           bool
	mock               *ThingRepositoryMock
	defaultExpectation *ThingRepositoryMockGetAllByPlaceIDExpectation
	expectations       []*ThingRepositoryMockGetAllByPlaceIDExpectation

	callArgs []*ThingRepositoryMockGetAllByPlaceIDParams
	mutex    sync.RWMutex

	expectedInvocations uint64
}

// ThingRepositoryMockGetAllByPlaceIDExpectation specifies expectation struct of the ThingRepository.GetAllByPlaceID
type ThingRepositoryMockGetAllByPlaceIDExpectation struct {
	mock      *ThingRepositoryMock
	params    *ThingRepositoryMockGetAllByPlaceIDParams
	paramPtrs *ThingRepositoryMockGetAllByPlaceIDParamPtrs
	results   *ThingRepositoryMockGetAllByPlaceIDResults
	Counter   uint64
}

// ThingRepositoryMockGetAllByPlaceIDParams contains parameters of the ThingRepository.GetAllByPlaceID
type ThingRepositoryMockGetAllByPlaceIDParams struct {
	ctx context.Context
	id  uint64
}

// ThingRepositoryMockGetAllByPlaceIDParamPtrs contains pointers to parameters of the ThingRepository.GetAllByPlaceID
type ThingRepositoryMockGetAllByPlaceIDParamPtrs struct {
	ctx *context.Context
	id  *uint64
}

// ThingRepositoryMockGetAllByPlaceIDResults contains results of the ThingRepository.GetAllByPlaceID
type ThingRepositoryMockGetAllByPlaceIDResults struct {
	ta1 []models.Thing
	err error
}

// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning
// the test will fail minimock's automatic final call check if the mocked method was not called at least once.
// Optional() makes method check to work in '0 or more' mode.
// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to
// catch the problems when the expected method call is totally skipped during test run.
func (mmGetAllByPlaceID *mThingRepositoryMockGetAllByPlaceID) Optional() *mThingRepositoryMockGetAllByPlaceID {
	mmGetAllByPlaceID.optional = true
	return mmGetAllByPlaceID
}

// Expect sets up expected params for ThingRepository.GetAllByPlaceID
func (mmGetAllByPlaceID *mThingRepositoryMockGetAllByPlaceID) Expect(ctx context.Context, id uint64) *mThingRepositoryMockGetAllByPlaceID {
	if mmGetAllByPlaceID.mock.funcGetAllByPlaceID != nil {
		mmGetAllByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetAllByPlaceID mock is already set by Set")
	}

	if mmGetAllByPlaceID.defaultExpectation == nil {
		mmGetAllByPlaceID.defaultExpectation = &ThingRepositoryMockGetAllByPlaceIDExpectation{}
	}

	if mmGetAllByPlaceID.defaultExpectation.paramPtrs != nil {
		mmGetAllByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetAllByPlaceID mock is already set by ExpectParams functions")
	}

	mmGetAllByPlaceID.defaultExpectation.params = &ThingRepositoryMockGetAllByPlaceIDParams{ctx, id}
	for _, e := range mmGetAllByPlaceID.expectations {
		if minimock.Equal(e.params, mmGetAllByPlaceID.defaultExpectation.params) {
			mmGetAllByPlaceID.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetAllByPlaceID.defaultExpectation.params)
		}
	}

	return mmGetAllByPlaceID
}

// ExpectCtxParam1 sets up expected param ctx for ThingRepository.GetAllByPlaceID
func (mmGetAllByPlaceID *mThingRepositoryMockGetAllByPlaceID) ExpectCtxParam1(ctx context.Context) *mThingRepositoryMockGetAllByPlaceID {
	if mmGetAllByPlaceID.mock.funcGetAllByPlaceID != nil {
		mmGetAllByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetAllByPlaceID mock is already set by Set")
	}

	if mmGetAllByPlaceID.defaultExpectation == nil {
		mmGetAllByPlaceID.defaultExpectation = &ThingRepositoryMockGetAllByPlaceIDExpectation{}
	}

	if mmGetAllByPlaceID.defaultExpectation.params != nil {
		mmGetAllByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetAllByPlaceID mock is already set by Expect")
	}

	if mmGetAllByPlaceID.defaultExpectation.paramPtrs == nil {
		mmGetAllByPlaceID.defaultExpectation.paramPtrs = &ThingRepositoryMockGetAllByPlaceIDParamPtrs{}
	}
	mmGetAllByPlaceID.defaultExpectation.paramPtrs.ctx = &ctx

	return mmGetAllByPlaceID
}

// ExpectIdParam2 sets up expected param id for ThingRepository.GetAllByPlaceID
func (mmGetAllByPlaceID *mThingRepositoryMockGetAllByPlaceID) ExpectIdParam2(id uint64) *mThingRepositoryMockGetAllByPlaceID {
	if mmGetAllByPlaceID.mock.funcGetAllByPlaceID != nil {
		mmGetAllByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetAllByPlaceID mock is already set by Set")
	}

	if mmGetAllByPlaceID.defaultExpectation == nil {
		mmGetAllByPlaceID.defaultExpectation = &ThingRepositoryMockGetAllByPlaceIDExpectation{}
	}

	if mmGetAllByPlaceID.defaultExpectation.params != nil {
		mmGetAllByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetAllByPlaceID mock is already set by Expect")
	}

	if mmGetAllByPlaceID.defaultExpectation.paramPtrs == nil {
		mmGetAllByPlaceID.defaultExpectation.paramPtrs = &ThingRepositoryMockGetAllByPlaceIDParamPtrs{}
	}
	mmGetAllByPlaceID.defaultExpectation.paramPtrs.id = &id

	return mmGetAllByPlaceID
}

// Inspect accepts an inspector function that has same arguments as the ThingRepository.GetAllByPlaceID
func (mmGetAllByPlaceID *mThingRepositoryMockGetAllByPlaceID) Inspect(f func(ctx context.Context, id uint64)) *mThingRepositoryMockGetAllByPlaceID {
	if mmGetAllByPlaceID.mock.inspectFuncGetAllByPlaceID != nil {
		mmGetAllByPlaceID.mock.t.Fatalf("Inspect function is already set for ThingRepositoryMock.GetAllByPlaceID")
	}

	mmGetAllByPlaceID.mock.inspectFuncGetAllByPlaceID = f

	return mmGetAllByPlaceID
}

// Return sets up results that will be returned by ThingRepository.GetAllByPlaceID
func (mmGetAllByPlaceID *mThingRepositoryMockGetAllByPlaceID) Return(ta1 []models.Thing, err error) *ThingRepositoryMock {
	if mmGetAllByPlaceID.mock.funcGetAllByPlaceID != nil {
		mmGetAllByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetAllByPlaceID mock is already set by Set")
	}

	if mmGetAllByPlaceID.defaultExpectation == nil {
		mmGetAllByPlaceID.defaultExpectation = &ThingRepositoryMockGetAllByPlaceIDExpectation{mock: mmGetAllByPlaceID.mock}
	}
	mmGetAllByPlaceID.defaultExpectation.results = &ThingRepositoryMockGetAllByPlaceIDResults{ta1, err}
	return mmGetAllByPlaceID.mock
}

// Set uses given function f to mock the ThingRepository.GetAllByPlaceID method
func (mmGetAllByPlaceID *mThingRepositoryMockGetAllByPlaceID) Set(f func(ctx context.Context, id uint64) (ta1 []models.Thing, err error)) *ThingRepositoryMock {
	if mmGetAllByPlaceID.defaultExpectation != nil {
		mmGetAllByPlaceID.mock.t.Fatalf("Default expectation is already set for the ThingRepository.GetAllByPlaceID method")
	}

	if len(mmGetAllByPlaceID.expectations) > 0 {
		mmGetAllByPlaceID.mock.t.Fatalf("Some expectations are already set for the ThingRepository.GetAllByPlaceID method")
	}

	mmGetAllByPlaceID.mock.funcGetAllByPlaceID = f
	return mmGetAllByPlaceID.mock
}

// When sets expectation for the ThingRepository.GetAllByPlaceID which will trigger the result defined by the following
// Then helper
func (mmGetAllByPlaceID *mThingRepositoryMockGetAllByPlaceID) When(ctx context.Context, id uint64) *ThingRepositoryMockGetAllByPlaceIDExpectation {
	if mmGetAllByPlaceID.mock.funcGetAllByPlaceID != nil {
		mmGetAllByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetAllByPlaceID mock is already set by Set")
	}

	expectation := &ThingRepositoryMockGetAllByPlaceIDExpectation{
		mock:   mmGetAllByPlaceID.mock,
		params: &ThingRepositoryMockGetAllByPlaceIDParams{ctx, id},
	}
	mmGetAllByPlaceID.expectations = append(mmGetAllByPlaceID.expectations, expectation)
	return expectation
}

// Then sets up ThingRepository.GetAllByPlaceID return parameters for the expectation previously defined by the When method
func (e *ThingRepositoryMockGetAllByPlaceIDExpectation) Then(ta1 []models.Thing, err error) *ThingRepositoryMock {
	e.results = &ThingRepositoryMockGetAllByPlaceIDResults{ta1, err}
	return e.mock
}

// Times sets number of times ThingRepository.GetAllByPlaceID should be invoked
func (mmGetAllByPlaceID *mThingRepositoryMockGetAllByPlaceID) Times(n uint64) *mThingRepositoryMockGetAllByPlaceID {
	if n == 0 {
		mmGetAllByPlaceID.mock.t.Fatalf("Times of ThingRepositoryMock.GetAllByPlaceID mock can not be zero")
	}
	mm_atomic.StoreUint64(&mmGetAllByPlaceID.expectedInvocations, n)
	return mmGetAllByPlaceID
}

func (mmGetAllByPlaceID *mThingRepositoryMockGetAllByPlaceID) invocationsDone() bool {
	if len(mmGetAllByPlaceID.expectations) == 0 && mmGetAllByPlaceID.defaultExpectation == nil && mmGetAllByPlaceID.mock.funcGetAllByPlaceID == nil {
		return true
	}

	totalInvocations := mm_atomic.LoadUint64(&mmGetAllByPlaceID.mock.afterGetAllByPlaceIDCounter)
	expectedInvocations := mm_atomic.LoadUint64(&mmGetAllByPlaceID.expectedInvocations)

	return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
}

// GetAllByPlaceID implements thing.ThingRepository
func (mmGetAllByPlaceID *ThingRepositoryMock) GetAllByPlaceID(ctx context.Context, id uint64) (ta1 []models.Thing, err error) {
	mm_atomic.AddUint64(&mmGetAllByPlaceID.beforeGetAllByPlaceIDCounter, 1)
	defer mm_atomic.AddUint64(&mmGetAllByPlaceID.afterGetAllByPlaceIDCounter, 1)

	if mmGetAllByPlaceID.inspectFuncGetAllByPlaceID != nil {
		mmGetAllByPlaceID.inspectFuncGetAllByPlaceID(ctx, id)
	}

	mm_params := ThingRepositoryMockGetAllByPlaceIDParams{ctx, id}

	// Record call args
	mmGetAllByPlaceID.GetAllByPlaceIDMock.mutex.Lock()
	mmGetAllByPlaceID.GetAllByPlaceIDMock.callArgs = append(mmGetAllByPlaceID.GetAllByPlaceIDMock.callArgs, &mm_params)
	mmGetAllByPlaceID.GetAllByPlaceIDMock.mutex.Unlock()

	for _, e := range mmGetAllByPlaceID.GetAllByPlaceIDMock.expectations {
		if minimock.Equal(*e.params, mm_params) {
			mm_atomic.AddUint64(&e.Counter, 1)
			return e.results.ta1, e.results.err
		}
	}

	if mmGetAllByPlaceID.GetAllByPlaceIDMock.defaultExpectation != nil {
		mm_atomic.AddUint64(&mmGetAllByPlaceID.GetAllByPlaceIDMock.defaultExpectation.Counter, 1)
		mm_want := mmGetAllByPlaceID.GetAllByPlaceIDMock.defaultExpectation.params
		mm_want_ptrs := mmGetAllByPlaceID.GetAllByPlaceIDMock.defaultExpectation.paramPtrs

		mm_got := ThingRepositoryMockGetAllByPlaceIDParams{ctx, id}

		if mm_want_ptrs != nil {

			if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
				mmGetAllByPlaceID.t.Errorf("ThingRepositoryMock.GetAllByPlaceID got unexpected parameter ctx, want: %#v, got: %#v%s\n", *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
			}

			if mm_want_ptrs.id != nil && !minimock.Equal(*mm_want_ptrs.id, mm_got.id) {
				mmGetAllByPlaceID.t.Errorf("ThingRepositoryMock.GetAllByPlaceID got unexpected parameter id, want: %#v, got: %#v%s\n", *mm_want_ptrs.id, mm_got.id, minimock.Diff(*mm_want_ptrs.id, mm_got.id))
			}

		} else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
			mmGetAllByPlaceID.t.Errorf("ThingRepositoryMock.GetAllByPlaceID got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
		}

		mm_results := mmGetAllByPlaceID.GetAllByPlaceIDMock.defaultExpectation.results
		if mm_results == nil {
			mmGetAllByPlaceID.t.Fatal("No results are set for the ThingRepositoryMock.GetAllByPlaceID")
		}
		return (*mm_results).ta1, (*mm_results).err
	}
	if mmGetAllByPlaceID.funcGetAllByPlaceID != nil {
		return mmGetAllByPlaceID.funcGetAllByPlaceID(ctx, id)
	}
	mmGetAllByPlaceID.t.Fatalf("Unexpected call to ThingRepositoryMock.GetAllByPlaceID. %v %v", ctx, id)
	return
}

// GetAllByPlaceIDAfterCounter returns a count of finished ThingRepositoryMock.GetAllByPlaceID invocations
func (mmGetAllByPlaceID *ThingRepositoryMock) GetAllByPlaceIDAfterCounter() uint64 {
	return mm_atomic.LoadUint64(&mmGetAllByPlaceID.afterGetAllByPlaceIDCounter)
}

// GetAllByPlaceIDBeforeCounter returns a count of ThingRepositoryMock.GetAllByPlaceID invocations
func (mmGetAllByPlaceID *ThingRepositoryMock) GetAllByPlaceIDBeforeCounter() uint64 {
	return mm_atomic.LoadUint64(&mmGetAllByPlaceID.beforeGetAllByPlaceIDCounter)
}

// Calls returns a list of arguments used in each call to ThingRepositoryMock.GetAllByPlaceID.
// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
func (mmGetAllByPlaceID *mThingRepositoryMockGetAllByPlaceID) Calls() []*ThingRepositoryMockGetAllByPlaceIDParams {
	mmGetAllByPlaceID.mutex.RLock()

	argCopy := make([]*ThingRepositoryMockGetAllByPlaceIDParams, len(mmGetAllByPlaceID.callArgs))
	copy(argCopy, mmGetAllByPlaceID.callArgs)

	mmGetAllByPlaceID.mutex.RUnlock()

	return argCopy
}

// MinimockGetAllByPlaceIDDone returns true if the count of the GetAllByPlaceID invocations corresponds
// the number of defined expectations
func (m *ThingRepositoryMock) MinimockGetAllByPlaceIDDone() bool {
	if m.GetAllByPlaceIDMock.optional {
		// Optional methods provide '0 or more' call count restriction.
		return true
	}

	for _, e := range m.GetAllByPlaceIDMock.expectations {
		if mm_atomic.LoadUint64(&e.Counter) < 1 {
			return false
		}
	}

	return m.GetAllByPlaceIDMock.invocationsDone()
}

// MinimockGetAllByPlaceIDInspect logs each unmet expectation
func (m *ThingRepositoryMock) MinimockGetAllByPlaceIDInspect() {
	for _, e := range m.GetAllByPlaceIDMock.expectations {
		if mm_atomic.LoadUint64(&e.Counter) < 1 {
			m.t.Errorf("Expected call to ThingRepositoryMock.GetAllByPlaceID with params: %#v", *e.params)
		}
	}

	afterGetAllByPlaceIDCounter := mm_atomic.LoadUint64(&m.afterGetAllByPlaceIDCounter)
	// if default expectation was set then invocations count should be greater than zero
	if m.GetAllByPlaceIDMock.defaultExpectation != nil && afterGetAllByPlaceIDCounter < 1 {
		if m.GetAllByPlaceIDMock.defaultExpectation.params == nil {
			m.t.Error("Expected call to ThingRepositoryMock.GetAllByPlaceID")
		} else {
			m.t.Errorf("Expected call to ThingRepositoryMock.GetAllByPlaceID with params: %#v", *m.GetAllByPlaceIDMock.defaultExpectation.params)
		}
	}
	// if func was set then invocations count should be greater than zero
	if m.funcGetAllByPlaceID != nil && afterGetAllByPlaceIDCounter < 1 {
		m.t.Error("Expected call to ThingRepositoryMock.GetAllByPlaceID")
	}

	if !m.GetAllByPlaceIDMock.invocationsDone() && afterGetAllByPlaceIDCounter > 0 {
		m.t.Errorf("Expected %d calls to ThingRepositoryMock.GetAllByPlaceID but found %d calls",
			mm_atomic.LoadUint64(&m.GetAllByPlaceIDMock.expectedInvocations), afterGetAllByPlaceIDCounter)
	}
}

type mThingRepositoryMockGetByPlaceID struct {
	optional           bool
	mock               *ThingRepositoryMock
	defaultExpectation *ThingRepositoryMockGetByPlaceIDExpectation
	expectations       []*ThingRepositoryMockGetByPlaceIDExpectation

	callArgs []*ThingRepositoryMockGetByPlaceIDParams
	mutex    sync.RWMutex

	expectedInvocations uint64
}

// ThingRepositoryMockGetByPlaceIDExpectation specifies expectation struct of the ThingRepository.GetByPlaceID
type ThingRepositoryMockGetByPlaceIDExpectation struct {
	mock      *ThingRepositoryMock
	params    *ThingRepositoryMockGetByPlaceIDParams
	paramPtrs *ThingRepositoryMockGetByPlaceIDParamPtrs
	results   *ThingRepositoryMockGetByPlaceIDResults
	Counter   uint64
}

// ThingRepositoryMockGetByPlaceIDParams contains parameters of the ThingRepository.GetByPlaceID
type ThingRepositoryMockGetByPlaceIDParams struct {
	ctx context.Context
	id  uint64
}

// ThingRepositoryMockGetByPlaceIDParamPtrs contains pointers to parameters of the ThingRepository.GetByPlaceID
type ThingRepositoryMockGetByPlaceIDParamPtrs struct {
	ctx *context.Context
	id  *uint64
}

// ThingRepositoryMockGetByPlaceIDResults contains results of the ThingRepository.GetByPlaceID
type ThingRepositoryMockGetByPlaceIDResults struct {
	ta1 []models.Thing
	err error
}

// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning
// the test will fail minimock's automatic final call check if the mocked method was not called at least once.
// Optional() makes method check to work in '0 or more' mode.
// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to
// catch the problems when the expected method call is totally skipped during test run.
func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) Optional() *mThingRepositoryMockGetByPlaceID {
	mmGetByPlaceID.optional = true
	return mmGetByPlaceID
}

// Expect sets up expected params for ThingRepository.GetByPlaceID
func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) Expect(ctx context.Context, id uint64) *mThingRepositoryMockGetByPlaceID {
	if mmGetByPlaceID.mock.funcGetByPlaceID != nil {
		mmGetByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetByPlaceID mock is already set by Set")
	}

	if mmGetByPlaceID.defaultExpectation == nil {
		mmGetByPlaceID.defaultExpectation = &ThingRepositoryMockGetByPlaceIDExpectation{}
	}

	if mmGetByPlaceID.defaultExpectation.paramPtrs != nil {
		mmGetByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetByPlaceID mock is already set by ExpectParams functions")
	}

	mmGetByPlaceID.defaultExpectation.params = &ThingRepositoryMockGetByPlaceIDParams{ctx, id}
	for _, e := range mmGetByPlaceID.expectations {
		if minimock.Equal(e.params, mmGetByPlaceID.defaultExpectation.params) {
			mmGetByPlaceID.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmGetByPlaceID.defaultExpectation.params)
		}
	}

	return mmGetByPlaceID
}

// ExpectCtxParam1 sets up expected param ctx for ThingRepository.GetByPlaceID
func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) ExpectCtxParam1(ctx context.Context) *mThingRepositoryMockGetByPlaceID {
	if mmGetByPlaceID.mock.funcGetByPlaceID != nil {
		mmGetByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetByPlaceID mock is already set by Set")
	}

	if mmGetByPlaceID.defaultExpectation == nil {
		mmGetByPlaceID.defaultExpectation = &ThingRepositoryMockGetByPlaceIDExpectation{}
	}

	if mmGetByPlaceID.defaultExpectation.params != nil {
		mmGetByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetByPlaceID mock is already set by Expect")
	}

	if mmGetByPlaceID.defaultExpectation.paramPtrs == nil {
		mmGetByPlaceID.defaultExpectation.paramPtrs = &ThingRepositoryMockGetByPlaceIDParamPtrs{}
	}
	mmGetByPlaceID.defaultExpectation.paramPtrs.ctx = &ctx

	return mmGetByPlaceID
}

// ExpectIdParam2 sets up expected param id for ThingRepository.GetByPlaceID
func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) ExpectIdParam2(id uint64) *mThingRepositoryMockGetByPlaceID {
	if mmGetByPlaceID.mock.funcGetByPlaceID != nil {
		mmGetByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetByPlaceID mock is already set by Set")
	}

	if mmGetByPlaceID.defaultExpectation == nil {
		mmGetByPlaceID.defaultExpectation = &ThingRepositoryMockGetByPlaceIDExpectation{}
	}

	if mmGetByPlaceID.defaultExpectation.params != nil {
		mmGetByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetByPlaceID mock is already set by Expect")
	}

	if mmGetByPlaceID.defaultExpectation.paramPtrs == nil {
		mmGetByPlaceID.defaultExpectation.paramPtrs = &ThingRepositoryMockGetByPlaceIDParamPtrs{}
	}
	mmGetByPlaceID.defaultExpectation.paramPtrs.id = &id

	return mmGetByPlaceID
}

// Inspect accepts an inspector function that has same arguments as the ThingRepository.GetByPlaceID
func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) Inspect(f func(ctx context.Context, id uint64)) *mThingRepositoryMockGetByPlaceID {
	if mmGetByPlaceID.mock.inspectFuncGetByPlaceID != nil {
		mmGetByPlaceID.mock.t.Fatalf("Inspect function is already set for ThingRepositoryMock.GetByPlaceID")
	}

	mmGetByPlaceID.mock.inspectFuncGetByPlaceID = f

	return mmGetByPlaceID
}

// Return sets up results that will be returned by ThingRepository.GetByPlaceID
func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) Return(ta1 []models.Thing, err error) *ThingRepositoryMock {
	if mmGetByPlaceID.mock.funcGetByPlaceID != nil {
		mmGetByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetByPlaceID mock is already set by Set")
	}

	if mmGetByPlaceID.defaultExpectation == nil {
		mmGetByPlaceID.defaultExpectation = &ThingRepositoryMockGetByPlaceIDExpectation{mock: mmGetByPlaceID.mock}
	}
	mmGetByPlaceID.defaultExpectation.results = &ThingRepositoryMockGetByPlaceIDResults{ta1, err}
	return mmGetByPlaceID.mock
}

// Set uses given function f to mock the ThingRepository.GetByPlaceID method
func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) Set(f func(ctx context.Context, id uint64) (ta1 []models.Thing, err error)) *ThingRepositoryMock {
	if mmGetByPlaceID.defaultExpectation != nil {
		mmGetByPlaceID.mock.t.Fatalf("Default expectation is already set for the ThingRepository.GetByPlaceID method")
	}

	if len(mmGetByPlaceID.expectations) > 0 {
		mmGetByPlaceID.mock.t.Fatalf("Some expectations are already set for the ThingRepository.GetByPlaceID method")
	}

	mmGetByPlaceID.mock.funcGetByPlaceID = f
	return mmGetByPlaceID.mock
}

// When sets expectation for the ThingRepository.GetByPlaceID which will trigger the result defined by the following
// Then helper
func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) When(ctx context.Context, id uint64) *ThingRepositoryMockGetByPlaceIDExpectation {
	if mmGetByPlaceID.mock.funcGetByPlaceID != nil {
		mmGetByPlaceID.mock.t.Fatalf("ThingRepositoryMock.GetByPlaceID mock is already set by Set")
	}

	expectation := &ThingRepositoryMockGetByPlaceIDExpectation{
		mock:   mmGetByPlaceID.mock,
		params: &ThingRepositoryMockGetByPlaceIDParams{ctx, id},
	}
	mmGetByPlaceID.expectations = append(mmGetByPlaceID.expectations, expectation)
	return expectation
}

// Then sets up ThingRepository.GetByPlaceID return parameters for the expectation previously defined by the When method
func (e *ThingRepositoryMockGetByPlaceIDExpectation) Then(ta1 []models.Thing, err error) *ThingRepositoryMock {
	e.results = &ThingRepositoryMockGetByPlaceIDResults{ta1, err}
	return e.mock
}

// Times sets number of times ThingRepository.GetByPlaceID should be invoked
func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) Times(n uint64) *mThingRepositoryMockGetByPlaceID {
	if n == 0 {
		mmGetByPlaceID.mock.t.Fatalf("Times of ThingRepositoryMock.GetByPlaceID mock can not be zero")
	}
	mm_atomic.StoreUint64(&mmGetByPlaceID.expectedInvocations, n)
	return mmGetByPlaceID
}

func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) invocationsDone() bool {
	if len(mmGetByPlaceID.expectations) == 0 && mmGetByPlaceID.defaultExpectation == nil && mmGetByPlaceID.mock.funcGetByPlaceID == nil {
		return true
	}

	totalInvocations := mm_atomic.LoadUint64(&mmGetByPlaceID.mock.afterGetByPlaceIDCounter)
	expectedInvocations := mm_atomic.LoadUint64(&mmGetByPlaceID.expectedInvocations)

	return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
}

// GetByPlaceID implements thing.ThingRepository
func (mmGetByPlaceID *ThingRepositoryMock) GetByPlaceID(ctx context.Context, id uint64) (ta1 []models.Thing, err error) {
	mm_atomic.AddUint64(&mmGetByPlaceID.beforeGetByPlaceIDCounter, 1)
	defer mm_atomic.AddUint64(&mmGetByPlaceID.afterGetByPlaceIDCounter, 1)

	if mmGetByPlaceID.inspectFuncGetByPlaceID != nil {
		mmGetByPlaceID.inspectFuncGetByPlaceID(ctx, id)
	}

	mm_params := ThingRepositoryMockGetByPlaceIDParams{ctx, id}

	// Record call args
	mmGetByPlaceID.GetByPlaceIDMock.mutex.Lock()
	mmGetByPlaceID.GetByPlaceIDMock.callArgs = append(mmGetByPlaceID.GetByPlaceIDMock.callArgs, &mm_params)
	mmGetByPlaceID.GetByPlaceIDMock.mutex.Unlock()

	for _, e := range mmGetByPlaceID.GetByPlaceIDMock.expectations {
		if minimock.Equal(*e.params, mm_params) {
			mm_atomic.AddUint64(&e.Counter, 1)
			return e.results.ta1, e.results.err
		}
	}

	if mmGetByPlaceID.GetByPlaceIDMock.defaultExpectation != nil {
		mm_atomic.AddUint64(&mmGetByPlaceID.GetByPlaceIDMock.defaultExpectation.Counter, 1)
		mm_want := mmGetByPlaceID.GetByPlaceIDMock.defaultExpectation.params
		mm_want_ptrs := mmGetByPlaceID.GetByPlaceIDMock.defaultExpectation.paramPtrs

		mm_got := ThingRepositoryMockGetByPlaceIDParams{ctx, id}

		if mm_want_ptrs != nil {

			if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
				mmGetByPlaceID.t.Errorf("ThingRepositoryMock.GetByPlaceID got unexpected parameter ctx, want: %#v, got: %#v%s\n", *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
			}

			if mm_want_ptrs.id != nil && !minimock.Equal(*mm_want_ptrs.id, mm_got.id) {
				mmGetByPlaceID.t.Errorf("ThingRepositoryMock.GetByPlaceID got unexpected parameter id, want: %#v, got: %#v%s\n", *mm_want_ptrs.id, mm_got.id, minimock.Diff(*mm_want_ptrs.id, mm_got.id))
			}

		} else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
			mmGetByPlaceID.t.Errorf("ThingRepositoryMock.GetByPlaceID got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
		}

		mm_results := mmGetByPlaceID.GetByPlaceIDMock.defaultExpectation.results
		if mm_results == nil {
			mmGetByPlaceID.t.Fatal("No results are set for the ThingRepositoryMock.GetByPlaceID")
		}
		return (*mm_results).ta1, (*mm_results).err
	}
	if mmGetByPlaceID.funcGetByPlaceID != nil {
		return mmGetByPlaceID.funcGetByPlaceID(ctx, id)
	}
	mmGetByPlaceID.t.Fatalf("Unexpected call to ThingRepositoryMock.GetByPlaceID. %v %v", ctx, id)
	return
}

// GetByPlaceIDAfterCounter returns a count of finished ThingRepositoryMock.GetByPlaceID invocations
func (mmGetByPlaceID *ThingRepositoryMock) GetByPlaceIDAfterCounter() uint64 {
	return mm_atomic.LoadUint64(&mmGetByPlaceID.afterGetByPlaceIDCounter)
}

// GetByPlaceIDBeforeCounter returns a count of ThingRepositoryMock.GetByPlaceID invocations
func (mmGetByPlaceID *ThingRepositoryMock) GetByPlaceIDBeforeCounter() uint64 {
	return mm_atomic.LoadUint64(&mmGetByPlaceID.beforeGetByPlaceIDCounter)
}

// Calls returns a list of arguments used in each call to ThingRepositoryMock.GetByPlaceID.
// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
func (mmGetByPlaceID *mThingRepositoryMockGetByPlaceID) Calls() []*ThingRepositoryMockGetByPlaceIDParams {
	mmGetByPlaceID.mutex.RLock()

	argCopy := make([]*ThingRepositoryMockGetByPlaceIDParams, len(mmGetByPlaceID.callArgs))
	copy(argCopy, mmGetByPlaceID.callArgs)

	mmGetByPlaceID.mutex.RUnlock()

	return argCopy
}

// MinimockGetByPlaceIDDone returns true if the count of the GetByPlaceID invocations corresponds
// the number of defined expectations
func (m *ThingRepositoryMock) MinimockGetByPlaceIDDone() bool {
	if m.GetByPlaceIDMock.optional {
		// Optional methods provide '0 or more' call count restriction.
		return true
	}

	for _, e := range m.GetByPlaceIDMock.expectations {
		if mm_atomic.LoadUint64(&e.Counter) < 1 {
			return false
		}
	}

	return m.GetByPlaceIDMock.invocationsDone()
}

// MinimockGetByPlaceIDInspect logs each unmet expectation
func (m *ThingRepositoryMock) MinimockGetByPlaceIDInspect() {
	for _, e := range m.GetByPlaceIDMock.expectations {
		if mm_atomic.LoadUint64(&e.Counter) < 1 {
			m.t.Errorf("Expected call to ThingRepositoryMock.GetByPlaceID with params: %#v", *e.params)
		}
	}

	afterGetByPlaceIDCounter := mm_atomic.LoadUint64(&m.afterGetByPlaceIDCounter)
	// if default expectation was set then invocations count should be greater than zero
	if m.GetByPlaceIDMock.defaultExpectation != nil && afterGetByPlaceIDCounter < 1 {
		if m.GetByPlaceIDMock.defaultExpectation.params == nil {
			m.t.Error("Expected call to ThingRepositoryMock.GetByPlaceID")
		} else {
			m.t.Errorf("Expected call to ThingRepositoryMock.GetByPlaceID with params: %#v", *m.GetByPlaceIDMock.defaultExpectation.params)
		}
	}
	// if func was set then invocations count should be greater than zero
	if m.funcGetByPlaceID != nil && afterGetByPlaceIDCounter < 1 {
		m.t.Error("Expected call to ThingRepositoryMock.GetByPlaceID")
	}

	if !m.GetByPlaceIDMock.invocationsDone() && afterGetByPlaceIDCounter > 0 {
		m.t.Errorf("Expected %d calls to ThingRepositoryMock.GetByPlaceID but found %d calls",
			mm_atomic.LoadUint64(&m.GetByPlaceIDMock.expectedInvocations), afterGetByPlaceIDCounter)
	}
}

type mThingRepositoryMockSearch struct {
	optional           bool
	mock               *ThingRepositoryMock
	defaultExpectation *ThingRepositoryMockSearchExpectation
	expectations       []*ThingRepositoryMockSearchExpectation

	callArgs []*ThingRepositoryMockSearchParams
	mutex    sync.RWMutex

	expectedInvocations uint64
}

// ThingRepositoryMockSearchExpectation specifies expectation struct of the ThingRepository.Search
type ThingRepositoryMockSearchExpectation struct {
	mock      *ThingRepositoryMock
	params    *ThingRepositoryMockSearchParams
	paramPtrs *ThingRepositoryMockSearchParamPtrs
	results   *ThingRepositoryMockSearchResults
	Counter   uint64
}

// ThingRepositoryMockSearchParams contains parameters of the ThingRepository.Search
type ThingRepositoryMockSearchParams struct {
	ctx    context.Context
	search string
}

// ThingRepositoryMockSearchParamPtrs contains pointers to parameters of the ThingRepository.Search
type ThingRepositoryMockSearchParamPtrs struct {
	ctx    *context.Context
	search *string
}

// ThingRepositoryMockSearchResults contains results of the ThingRepository.Search
type ThingRepositoryMockSearchResults struct {
	ta1 []models.Thing
	err error
}

// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning
// the test will fail minimock's automatic final call check if the mocked method was not called at least once.
// Optional() makes method check to work in '0 or more' mode.
// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to
// catch the problems when the expected method call is totally skipped during test run.
func (mmSearch *mThingRepositoryMockSearch) Optional() *mThingRepositoryMockSearch {
	mmSearch.optional = true
	return mmSearch
}

// Expect sets up expected params for ThingRepository.Search
func (mmSearch *mThingRepositoryMockSearch) Expect(ctx context.Context, search string) *mThingRepositoryMockSearch {
	if mmSearch.mock.funcSearch != nil {
		mmSearch.mock.t.Fatalf("ThingRepositoryMock.Search mock is already set by Set")
	}

	if mmSearch.defaultExpectation == nil {
		mmSearch.defaultExpectation = &ThingRepositoryMockSearchExpectation{}
	}

	if mmSearch.defaultExpectation.paramPtrs != nil {
		mmSearch.mock.t.Fatalf("ThingRepositoryMock.Search mock is already set by ExpectParams functions")
	}

	mmSearch.defaultExpectation.params = &ThingRepositoryMockSearchParams{ctx, search}
	for _, e := range mmSearch.expectations {
		if minimock.Equal(e.params, mmSearch.defaultExpectation.params) {
			mmSearch.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmSearch.defaultExpectation.params)
		}
	}

	return mmSearch
}

// ExpectCtxParam1 sets up expected param ctx for ThingRepository.Search
func (mmSearch *mThingRepositoryMockSearch) ExpectCtxParam1(ctx context.Context) *mThingRepositoryMockSearch {
	if mmSearch.mock.funcSearch != nil {
		mmSearch.mock.t.Fatalf("ThingRepositoryMock.Search mock is already set by Set")
	}

	if mmSearch.defaultExpectation == nil {
		mmSearch.defaultExpectation = &ThingRepositoryMockSearchExpectation{}
	}

	if mmSearch.defaultExpectation.params != nil {
		mmSearch.mock.t.Fatalf("ThingRepositoryMock.Search mock is already set by Expect")
	}

	if mmSearch.defaultExpectation.paramPtrs == nil {
		mmSearch.defaultExpectation.paramPtrs = &ThingRepositoryMockSearchParamPtrs{}
	}
	mmSearch.defaultExpectation.paramPtrs.ctx = &ctx

	return mmSearch
}

// ExpectSearchParam2 sets up expected param search for ThingRepository.Search
func (mmSearch *mThingRepositoryMockSearch) ExpectSearchParam2(search string) *mThingRepositoryMockSearch {
	if mmSearch.mock.funcSearch != nil {
		mmSearch.mock.t.Fatalf("ThingRepositoryMock.Search mock is already set by Set")
	}

	if mmSearch.defaultExpectation == nil {
		mmSearch.defaultExpectation = &ThingRepositoryMockSearchExpectation{}
	}

	if mmSearch.defaultExpectation.params != nil {
		mmSearch.mock.t.Fatalf("ThingRepositoryMock.Search mock is already set by Expect")
	}

	if mmSearch.defaultExpectation.paramPtrs == nil {
		mmSearch.defaultExpectation.paramPtrs = &ThingRepositoryMockSearchParamPtrs{}
	}
	mmSearch.defaultExpectation.paramPtrs.search = &search

	return mmSearch
}

// Inspect accepts an inspector function that has same arguments as the ThingRepository.Search
func (mmSearch *mThingRepositoryMockSearch) Inspect(f func(ctx context.Context, search string)) *mThingRepositoryMockSearch {
	if mmSearch.mock.inspectFuncSearch != nil {
		mmSearch.mock.t.Fatalf("Inspect function is already set for ThingRepositoryMock.Search")
	}

	mmSearch.mock.inspectFuncSearch = f

	return mmSearch
}

// Return sets up results that will be returned by ThingRepository.Search
func (mmSearch *mThingRepositoryMockSearch) Return(ta1 []models.Thing, err error) *ThingRepositoryMock {
	if mmSearch.mock.funcSearch != nil {
		mmSearch.mock.t.Fatalf("ThingRepositoryMock.Search mock is already set by Set")
	}

	if mmSearch.defaultExpectation == nil {
		mmSearch.defaultExpectation = &ThingRepositoryMockSearchExpectation{mock: mmSearch.mock}
	}
	mmSearch.defaultExpectation.results = &ThingRepositoryMockSearchResults{ta1, err}
	return mmSearch.mock
}

// Set uses given function f to mock the ThingRepository.Search method
func (mmSearch *mThingRepositoryMockSearch) Set(f func(ctx context.Context, search string) (ta1 []models.Thing, err error)) *ThingRepositoryMock {
	if mmSearch.defaultExpectation != nil {
		mmSearch.mock.t.Fatalf("Default expectation is already set for the ThingRepository.Search method")
	}

	if len(mmSearch.expectations) > 0 {
		mmSearch.mock.t.Fatalf("Some expectations are already set for the ThingRepository.Search method")
	}

	mmSearch.mock.funcSearch = f
	return mmSearch.mock
}

// When sets expectation for the ThingRepository.Search which will trigger the result defined by the following
// Then helper
func (mmSearch *mThingRepositoryMockSearch) When(ctx context.Context, search string) *ThingRepositoryMockSearchExpectation {
	if mmSearch.mock.funcSearch != nil {
		mmSearch.mock.t.Fatalf("ThingRepositoryMock.Search mock is already set by Set")
	}

	expectation := &ThingRepositoryMockSearchExpectation{
		mock:   mmSearch.mock,
		params: &ThingRepositoryMockSearchParams{ctx, search},
	}
	mmSearch.expectations = append(mmSearch.expectations, expectation)
	return expectation
}

// Then sets up ThingRepository.Search return parameters for the expectation previously defined by the When method
func (e *ThingRepositoryMockSearchExpectation) Then(ta1 []models.Thing, err error) *ThingRepositoryMock {
	e.results = &ThingRepositoryMockSearchResults{ta1, err}
	return e.mock
}

// Times sets number of times ThingRepository.Search should be invoked
func (mmSearch *mThingRepositoryMockSearch) Times(n uint64) *mThingRepositoryMockSearch {
	if n == 0 {
		mmSearch.mock.t.Fatalf("Times of ThingRepositoryMock.Search mock can not be zero")
	}
	mm_atomic.StoreUint64(&mmSearch.expectedInvocations, n)
	return mmSearch
}

func (mmSearch *mThingRepositoryMockSearch) invocationsDone() bool {
	if len(mmSearch.expectations) == 0 && mmSearch.defaultExpectation == nil && mmSearch.mock.funcSearch == nil {
		return true
	}

	totalInvocations := mm_atomic.LoadUint64(&mmSearch.mock.afterSearchCounter)
	expectedInvocations := mm_atomic.LoadUint64(&mmSearch.expectedInvocations)

	return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
}

// Search implements thing.ThingRepository
func (mmSearch *ThingRepositoryMock) Search(ctx context.Context, search string) (ta1 []models.Thing, err error) {
	mm_atomic.AddUint64(&mmSearch.beforeSearchCounter, 1)
	defer mm_atomic.AddUint64(&mmSearch.afterSearchCounter, 1)

	if mmSearch.inspectFuncSearch != nil {
		mmSearch.inspectFuncSearch(ctx, search)
	}

	mm_params := ThingRepositoryMockSearchParams{ctx, search}

	// Record call args
	mmSearch.SearchMock.mutex.Lock()
	mmSearch.SearchMock.callArgs = append(mmSearch.SearchMock.callArgs, &mm_params)
	mmSearch.SearchMock.mutex.Unlock()

	for _, e := range mmSearch.SearchMock.expectations {
		if minimock.Equal(*e.params, mm_params) {
			mm_atomic.AddUint64(&e.Counter, 1)
			return e.results.ta1, e.results.err
		}
	}

	if mmSearch.SearchMock.defaultExpectation != nil {
		mm_atomic.AddUint64(&mmSearch.SearchMock.defaultExpectation.Counter, 1)
		mm_want := mmSearch.SearchMock.defaultExpectation.params
		mm_want_ptrs := mmSearch.SearchMock.defaultExpectation.paramPtrs

		mm_got := ThingRepositoryMockSearchParams{ctx, search}

		if mm_want_ptrs != nil {

			if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
				mmSearch.t.Errorf("ThingRepositoryMock.Search got unexpected parameter ctx, want: %#v, got: %#v%s\n", *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
			}

			if mm_want_ptrs.search != nil && !minimock.Equal(*mm_want_ptrs.search, mm_got.search) {
				mmSearch.t.Errorf("ThingRepositoryMock.Search got unexpected parameter search, want: %#v, got: %#v%s\n", *mm_want_ptrs.search, mm_got.search, minimock.Diff(*mm_want_ptrs.search, mm_got.search))
			}

		} else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
			mmSearch.t.Errorf("ThingRepositoryMock.Search got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
		}

		mm_results := mmSearch.SearchMock.defaultExpectation.results
		if mm_results == nil {
			mmSearch.t.Fatal("No results are set for the ThingRepositoryMock.Search")
		}
		return (*mm_results).ta1, (*mm_results).err
	}
	if mmSearch.funcSearch != nil {
		return mmSearch.funcSearch(ctx, search)
	}
	mmSearch.t.Fatalf("Unexpected call to ThingRepositoryMock.Search. %v %v", ctx, search)
	return
}

// SearchAfterCounter returns a count of finished ThingRepositoryMock.Search invocations
func (mmSearch *ThingRepositoryMock) SearchAfterCounter() uint64 {
	return mm_atomic.LoadUint64(&mmSearch.afterSearchCounter)
}

// SearchBeforeCounter returns a count of ThingRepositoryMock.Search invocations
func (mmSearch *ThingRepositoryMock) SearchBeforeCounter() uint64 {
	return mm_atomic.LoadUint64(&mmSearch.beforeSearchCounter)
}

// Calls returns a list of arguments used in each call to ThingRepositoryMock.Search.
// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
func (mmSearch *mThingRepositoryMockSearch) Calls() []*ThingRepositoryMockSearchParams {
	mmSearch.mutex.RLock()

	argCopy := make([]*ThingRepositoryMockSearchParams, len(mmSearch.callArgs))
	copy(argCopy, mmSearch.callArgs)

	mmSearch.mutex.RUnlock()

	return argCopy
}

// MinimockSearchDone returns true if the count of the Search invocations corresponds
// the number of defined expectations
func (m *ThingRepositoryMock) MinimockSearchDone() bool {
	if m.SearchMock.optional {
		// Optional methods provide '0 or more' call count restriction.
		return true
	}

	for _, e := range m.SearchMock.expectations {
		if mm_atomic.LoadUint64(&e.Counter) < 1 {
			return false
		}
	}

	return m.SearchMock.invocationsDone()
}

// MinimockSearchInspect logs each unmet expectation
func (m *ThingRepositoryMock) MinimockSearchInspect() {
	for _, e := range m.SearchMock.expectations {
		if mm_atomic.LoadUint64(&e.Counter) < 1 {
			m.t.Errorf("Expected call to ThingRepositoryMock.Search with params: %#v", *e.params)
		}
	}

	afterSearchCounter := mm_atomic.LoadUint64(&m.afterSearchCounter)
	// if default expectation was set then invocations count should be greater than zero
	if m.SearchMock.defaultExpectation != nil && afterSearchCounter < 1 {
		if m.SearchMock.defaultExpectation.params == nil {
			m.t.Error("Expected call to ThingRepositoryMock.Search")
		} else {
			m.t.Errorf("Expected call to ThingRepositoryMock.Search with params: %#v", *m.SearchMock.defaultExpectation.params)
		}
	}
	// if func was set then invocations count should be greater than zero
	if m.funcSearch != nil && afterSearchCounter < 1 {
		m.t.Error("Expected call to ThingRepositoryMock.Search")
	}

	if !m.SearchMock.invocationsDone() && afterSearchCounter > 0 {
		m.t.Errorf("Expected %d calls to ThingRepositoryMock.Search but found %d calls",
			mm_atomic.LoadUint64(&m.SearchMock.expectedInvocations), afterSearchCounter)
	}
}

type mThingRepositoryMockUpdate struct {
	optional           bool
	mock               *ThingRepositoryMock
	defaultExpectation *ThingRepositoryMockUpdateExpectation
	expectations       []*ThingRepositoryMockUpdateExpectation

	callArgs []*ThingRepositoryMockUpdateParams
	mutex    sync.RWMutex

	expectedInvocations uint64
}

// ThingRepositoryMockUpdateExpectation specifies expectation struct of the ThingRepository.Update
type ThingRepositoryMockUpdateExpectation struct {
	mock      *ThingRepositoryMock
	params    *ThingRepositoryMockUpdateParams
	paramPtrs *ThingRepositoryMockUpdateParamPtrs
	results   *ThingRepositoryMockUpdateResults
	Counter   uint64
}

// ThingRepositoryMockUpdateParams contains parameters of the ThingRepository.Update
type ThingRepositoryMockUpdateParams struct {
	ctx context.Context
	req models.UpdateThingRequest
}

// ThingRepositoryMockUpdateParamPtrs contains pointers to parameters of the ThingRepository.Update
type ThingRepositoryMockUpdateParamPtrs struct {
	ctx *context.Context
	req *models.UpdateThingRequest
}

// ThingRepositoryMockUpdateResults contains results of the ThingRepository.Update
type ThingRepositoryMockUpdateResults struct {
	err error
}

// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning
// the test will fail minimock's automatic final call check if the mocked method was not called at least once.
// Optional() makes method check to work in '0 or more' mode.
// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to
// catch the problems when the expected method call is totally skipped during test run.
func (mmUpdate *mThingRepositoryMockUpdate) Optional() *mThingRepositoryMockUpdate {
	mmUpdate.optional = true
	return mmUpdate
}

// Expect sets up expected params for ThingRepository.Update
func (mmUpdate *mThingRepositoryMockUpdate) Expect(ctx context.Context, req models.UpdateThingRequest) *mThingRepositoryMockUpdate {
	if mmUpdate.mock.funcUpdate != nil {
		mmUpdate.mock.t.Fatalf("ThingRepositoryMock.Update mock is already set by Set")
	}

	if mmUpdate.defaultExpectation == nil {
		mmUpdate.defaultExpectation = &ThingRepositoryMockUpdateExpectation{}
	}

	if mmUpdate.defaultExpectation.paramPtrs != nil {
		mmUpdate.mock.t.Fatalf("ThingRepositoryMock.Update mock is already set by ExpectParams functions")
	}

	mmUpdate.defaultExpectation.params = &ThingRepositoryMockUpdateParams{ctx, req}
	for _, e := range mmUpdate.expectations {
		if minimock.Equal(e.params, mmUpdate.defaultExpectation.params) {
			mmUpdate.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmUpdate.defaultExpectation.params)
		}
	}

	return mmUpdate
}

// ExpectCtxParam1 sets up expected param ctx for ThingRepository.Update
func (mmUpdate *mThingRepositoryMockUpdate) ExpectCtxParam1(ctx context.Context) *mThingRepositoryMockUpdate {
	if mmUpdate.mock.funcUpdate != nil {
		mmUpdate.mock.t.Fatalf("ThingRepositoryMock.Update mock is already set by Set")
	}

	if mmUpdate.defaultExpectation == nil {
		mmUpdate.defaultExpectation = &ThingRepositoryMockUpdateExpectation{}
	}

	if mmUpdate.defaultExpectation.params != nil {
		mmUpdate.mock.t.Fatalf("ThingRepositoryMock.Update mock is already set by Expect")
	}

	if mmUpdate.defaultExpectation.paramPtrs == nil {
		mmUpdate.defaultExpectation.paramPtrs = &ThingRepositoryMockUpdateParamPtrs{}
	}
	mmUpdate.defaultExpectation.paramPtrs.ctx = &ctx

	return mmUpdate
}

// ExpectReqParam2 sets up expected param req for ThingRepository.Update
func (mmUpdate *mThingRepositoryMockUpdate) ExpectReqParam2(req models.UpdateThingRequest) *mThingRepositoryMockUpdate {
	if mmUpdate.mock.funcUpdate != nil {
		mmUpdate.mock.t.Fatalf("ThingRepositoryMock.Update mock is already set by Set")
	}

	if mmUpdate.defaultExpectation == nil {
		mmUpdate.defaultExpectation = &ThingRepositoryMockUpdateExpectation{}
	}

	if mmUpdate.defaultExpectation.params != nil {
		mmUpdate.mock.t.Fatalf("ThingRepositoryMock.Update mock is already set by Expect")
	}

	if mmUpdate.defaultExpectation.paramPtrs == nil {
		mmUpdate.defaultExpectation.paramPtrs = &ThingRepositoryMockUpdateParamPtrs{}
	}
	mmUpdate.defaultExpectation.paramPtrs.req = &req

	return mmUpdate
}

// Inspect accepts an inspector function that has same arguments as the ThingRepository.Update
func (mmUpdate *mThingRepositoryMockUpdate) Inspect(f func(ctx context.Context, req models.UpdateThingRequest)) *mThingRepositoryMockUpdate {
	if mmUpdate.mock.inspectFuncUpdate != nil {
		mmUpdate.mock.t.Fatalf("Inspect function is already set for ThingRepositoryMock.Update")
	}

	mmUpdate.mock.inspectFuncUpdate = f

	return mmUpdate
}

// Return sets up results that will be returned by ThingRepository.Update
func (mmUpdate *mThingRepositoryMockUpdate) Return(err error) *ThingRepositoryMock {
	if mmUpdate.mock.funcUpdate != nil {
		mmUpdate.mock.t.Fatalf("ThingRepositoryMock.Update mock is already set by Set")
	}

	if mmUpdate.defaultExpectation == nil {
		mmUpdate.defaultExpectation = &ThingRepositoryMockUpdateExpectation{mock: mmUpdate.mock}
	}
	mmUpdate.defaultExpectation.results = &ThingRepositoryMockUpdateResults{err}
	return mmUpdate.mock
}

// Set uses given function f to mock the ThingRepository.Update method
func (mmUpdate *mThingRepositoryMockUpdate) Set(f func(ctx context.Context, req models.UpdateThingRequest) (err error)) *ThingRepositoryMock {
	if mmUpdate.defaultExpectation != nil {
		mmUpdate.mock.t.Fatalf("Default expectation is already set for the ThingRepository.Update method")
	}

	if len(mmUpdate.expectations) > 0 {
		mmUpdate.mock.t.Fatalf("Some expectations are already set for the ThingRepository.Update method")
	}

	mmUpdate.mock.funcUpdate = f
	return mmUpdate.mock
}

// When sets expectation for the ThingRepository.Update which will trigger the result defined by the following
// Then helper
func (mmUpdate *mThingRepositoryMockUpdate) When(ctx context.Context, req models.UpdateThingRequest) *ThingRepositoryMockUpdateExpectation {
	if mmUpdate.mock.funcUpdate != nil {
		mmUpdate.mock.t.Fatalf("ThingRepositoryMock.Update mock is already set by Set")
	}

	expectation := &ThingRepositoryMockUpdateExpectation{
		mock:   mmUpdate.mock,
		params: &ThingRepositoryMockUpdateParams{ctx, req},
	}
	mmUpdate.expectations = append(mmUpdate.expectations, expectation)
	return expectation
}

// Then sets up ThingRepository.Update return parameters for the expectation previously defined by the When method
func (e *ThingRepositoryMockUpdateExpectation) Then(err error) *ThingRepositoryMock {
	e.results = &ThingRepositoryMockUpdateResults{err}
	return e.mock
}

// Times sets number of times ThingRepository.Update should be invoked
func (mmUpdate *mThingRepositoryMockUpdate) Times(n uint64) *mThingRepositoryMockUpdate {
	if n == 0 {
		mmUpdate.mock.t.Fatalf("Times of ThingRepositoryMock.Update mock can not be zero")
	}
	mm_atomic.StoreUint64(&mmUpdate.expectedInvocations, n)
	return mmUpdate
}

func (mmUpdate *mThingRepositoryMockUpdate) invocationsDone() bool {
	if len(mmUpdate.expectations) == 0 && mmUpdate.defaultExpectation == nil && mmUpdate.mock.funcUpdate == nil {
		return true
	}

	totalInvocations := mm_atomic.LoadUint64(&mmUpdate.mock.afterUpdateCounter)
	expectedInvocations := mm_atomic.LoadUint64(&mmUpdate.expectedInvocations)

	return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
}

// Update implements thing.ThingRepository
func (mmUpdate *ThingRepositoryMock) Update(ctx context.Context, req models.UpdateThingRequest) (err error) {
	mm_atomic.AddUint64(&mmUpdate.beforeUpdateCounter, 1)
	defer mm_atomic.AddUint64(&mmUpdate.afterUpdateCounter, 1)

	if mmUpdate.inspectFuncUpdate != nil {
		mmUpdate.inspectFuncUpdate(ctx, req)
	}

	mm_params := ThingRepositoryMockUpdateParams{ctx, req}

	// Record call args
	mmUpdate.UpdateMock.mutex.Lock()
	mmUpdate.UpdateMock.callArgs = append(mmUpdate.UpdateMock.callArgs, &mm_params)
	mmUpdate.UpdateMock.mutex.Unlock()

	for _, e := range mmUpdate.UpdateMock.expectations {
		if minimock.Equal(*e.params, mm_params) {
			mm_atomic.AddUint64(&e.Counter, 1)
			return e.results.err
		}
	}

	if mmUpdate.UpdateMock.defaultExpectation != nil {
		mm_atomic.AddUint64(&mmUpdate.UpdateMock.defaultExpectation.Counter, 1)
		mm_want := mmUpdate.UpdateMock.defaultExpectation.params
		mm_want_ptrs := mmUpdate.UpdateMock.defaultExpectation.paramPtrs

		mm_got := ThingRepositoryMockUpdateParams{ctx, req}

		if mm_want_ptrs != nil {

			if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
				mmUpdate.t.Errorf("ThingRepositoryMock.Update got unexpected parameter ctx, want: %#v, got: %#v%s\n", *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
			}

			if mm_want_ptrs.req != nil && !minimock.Equal(*mm_want_ptrs.req, mm_got.req) {
				mmUpdate.t.Errorf("ThingRepositoryMock.Update got unexpected parameter req, want: %#v, got: %#v%s\n", *mm_want_ptrs.req, mm_got.req, minimock.Diff(*mm_want_ptrs.req, mm_got.req))
			}

		} else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
			mmUpdate.t.Errorf("ThingRepositoryMock.Update got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
		}

		mm_results := mmUpdate.UpdateMock.defaultExpectation.results
		if mm_results == nil {
			mmUpdate.t.Fatal("No results are set for the ThingRepositoryMock.Update")
		}
		return (*mm_results).err
	}
	if mmUpdate.funcUpdate != nil {
		return mmUpdate.funcUpdate(ctx, req)
	}
	mmUpdate.t.Fatalf("Unexpected call to ThingRepositoryMock.Update. %v %v", ctx, req)
	return
}

// UpdateAfterCounter returns a count of finished ThingRepositoryMock.Update invocations
func (mmUpdate *ThingRepositoryMock) UpdateAfterCounter() uint64 {
	return mm_atomic.LoadUint64(&mmUpdate.afterUpdateCounter)
}

// UpdateBeforeCounter returns a count of ThingRepositoryMock.Update invocations
func (mmUpdate *ThingRepositoryMock) UpdateBeforeCounter() uint64 {
	return mm_atomic.LoadUint64(&mmUpdate.beforeUpdateCounter)
}

// Calls returns a list of arguments used in each call to ThingRepositoryMock.Update.
// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
func (mmUpdate *mThingRepositoryMockUpdate) Calls() []*ThingRepositoryMockUpdateParams {
	mmUpdate.mutex.RLock()

	argCopy := make([]*ThingRepositoryMockUpdateParams, len(mmUpdate.callArgs))
	copy(argCopy, mmUpdate.callArgs)

	mmUpdate.mutex.RUnlock()

	return argCopy
}

// MinimockUpdateDone returns true if the count of the Update invocations corresponds
// the number of defined expectations
func (m *ThingRepositoryMock) MinimockUpdateDone() bool {
	if m.UpdateMock.optional {
		// Optional methods provide '0 or more' call count restriction.
		return true
	}

	for _, e := range m.UpdateMock.expectations {
		if mm_atomic.LoadUint64(&e.Counter) < 1 {
			return false
		}
	}

	return m.UpdateMock.invocationsDone()
}

// MinimockUpdateInspect logs each unmet expectation
func (m *ThingRepositoryMock) MinimockUpdateInspect() {
	for _, e := range m.UpdateMock.expectations {
		if mm_atomic.LoadUint64(&e.Counter) < 1 {
			m.t.Errorf("Expected call to ThingRepositoryMock.Update with params: %#v", *e.params)
		}
	}

	afterUpdateCounter := mm_atomic.LoadUint64(&m.afterUpdateCounter)
	// if default expectation was set then invocations count should be greater than zero
	if m.UpdateMock.defaultExpectation != nil && afterUpdateCounter < 1 {
		if m.UpdateMock.defaultExpectation.params == nil {
			m.t.Error("Expected call to ThingRepositoryMock.Update")
		} else {
			m.t.Errorf("Expected call to ThingRepositoryMock.Update with params: %#v", *m.UpdateMock.defaultExpectation.params)
		}
	}
	// if func was set then invocations count should be greater than zero
	if m.funcUpdate != nil && afterUpdateCounter < 1 {
		m.t.Error("Expected call to ThingRepositoryMock.Update")
	}

	if !m.UpdateMock.invocationsDone() && afterUpdateCounter > 0 {
		m.t.Errorf("Expected %d calls to ThingRepositoryMock.Update but found %d calls",
			mm_atomic.LoadUint64(&m.UpdateMock.expectedInvocations), afterUpdateCounter)
	}
}

// MinimockFinish checks that all mocked methods have been called the expected number of times
func (m *ThingRepositoryMock) MinimockFinish() {
	m.finishOnce.Do(func() {
		if !m.minimockDone() {
			m.MinimockAddInspect()

			m.MinimockDeleteInspect()

			m.MinimockGetInspect()

			m.MinimockGetAllByPlaceIDInspect()

			m.MinimockGetByPlaceIDInspect()

			m.MinimockSearchInspect()

			m.MinimockUpdateInspect()
		}
	})
}

// MinimockWait waits for all mocked methods to be called the expected number of times
func (m *ThingRepositoryMock) MinimockWait(timeout mm_time.Duration) {
	timeoutCh := mm_time.After(timeout)
	for {
		if m.minimockDone() {
			return
		}
		select {
		case <-timeoutCh:
			m.MinimockFinish()
			return
		case <-mm_time.After(10 * mm_time.Millisecond):
		}
	}
}

func (m *ThingRepositoryMock) minimockDone() bool {
	done := true
	return done &&
		m.MinimockAddDone() &&
		m.MinimockDeleteDone() &&
		m.MinimockGetDone() &&
		m.MinimockGetAllByPlaceIDDone() &&
		m.MinimockGetByPlaceIDDone() &&
		m.MinimockSearchDone() &&
		m.MinimockUpdateDone()
}
