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

import (
	"context"
	"sync"

	"github.com/go-logr/logr"
	"github.com/nginx/nginx-gateway-fabric/v2/internal/controller/state/resolver"
	v1 "k8s.io/api/core/v1"
	v1a "k8s.io/api/discovery/v1"
	"k8s.io/apimachinery/pkg/types"
)

type FakeServiceResolver struct {
	ResolveStub        func(context.Context, logr.Logger, types.NamespacedName, v1.ServicePort, []v1a.AddressType) ([]resolver.Endpoint, error)
	resolveMutex       sync.RWMutex
	resolveArgsForCall []struct {
		arg1 context.Context
		arg2 logr.Logger
		arg3 types.NamespacedName
		arg4 v1.ServicePort
		arg5 []v1a.AddressType
	}
	resolveReturns struct {
		result1 []resolver.Endpoint
		result2 error
	}
	resolveReturnsOnCall map[int]struct {
		result1 []resolver.Endpoint
		result2 error
	}
	invocations      map[string][][]interface{}
	invocationsMutex sync.RWMutex
}

func (fake *FakeServiceResolver) Resolve(arg1 context.Context, arg2 logr.Logger, arg3 types.NamespacedName, arg4 v1.ServicePort, arg5 []v1a.AddressType) ([]resolver.Endpoint, error) {
	var arg5Copy []v1a.AddressType
	if arg5 != nil {
		arg5Copy = make([]v1a.AddressType, len(arg5))
		copy(arg5Copy, arg5)
	}
	fake.resolveMutex.Lock()
	ret, specificReturn := fake.resolveReturnsOnCall[len(fake.resolveArgsForCall)]
	fake.resolveArgsForCall = append(fake.resolveArgsForCall, struct {
		arg1 context.Context
		arg2 logr.Logger
		arg3 types.NamespacedName
		arg4 v1.ServicePort
		arg5 []v1a.AddressType
	}{arg1, arg2, arg3, arg4, arg5Copy})
	stub := fake.ResolveStub
	fakeReturns := fake.resolveReturns
	fake.recordInvocation("Resolve", []interface{}{arg1, arg2, arg3, arg4, arg5Copy})
	fake.resolveMutex.Unlock()
	if stub != nil {
		return stub(arg1, arg2, arg3, arg4, arg5)
	}
	if specificReturn {
		return ret.result1, ret.result2
	}
	return fakeReturns.result1, fakeReturns.result2
}

func (fake *FakeServiceResolver) ResolveCallCount() int {
	fake.resolveMutex.RLock()
	defer fake.resolveMutex.RUnlock()
	return len(fake.resolveArgsForCall)
}

func (fake *FakeServiceResolver) ResolveCalls(stub func(context.Context, logr.Logger, types.NamespacedName, v1.ServicePort, []v1a.AddressType) ([]resolver.Endpoint, error)) {
	fake.resolveMutex.Lock()
	defer fake.resolveMutex.Unlock()
	fake.ResolveStub = stub
}

func (fake *FakeServiceResolver) ResolveArgsForCall(i int) (context.Context, logr.Logger, types.NamespacedName, v1.ServicePort, []v1a.AddressType) {
	fake.resolveMutex.RLock()
	defer fake.resolveMutex.RUnlock()
	argsForCall := fake.resolveArgsForCall[i]
	return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4, argsForCall.arg5
}

func (fake *FakeServiceResolver) ResolveReturns(result1 []resolver.Endpoint, result2 error) {
	fake.resolveMutex.Lock()
	defer fake.resolveMutex.Unlock()
	fake.ResolveStub = nil
	fake.resolveReturns = struct {
		result1 []resolver.Endpoint
		result2 error
	}{result1, result2}
}

func (fake *FakeServiceResolver) ResolveReturnsOnCall(i int, result1 []resolver.Endpoint, result2 error) {
	fake.resolveMutex.Lock()
	defer fake.resolveMutex.Unlock()
	fake.ResolveStub = nil
	if fake.resolveReturnsOnCall == nil {
		fake.resolveReturnsOnCall = make(map[int]struct {
			result1 []resolver.Endpoint
			result2 error
		})
	}
	fake.resolveReturnsOnCall[i] = struct {
		result1 []resolver.Endpoint
		result2 error
	}{result1, result2}
}

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

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

var _ resolver.ServiceResolver = new(FakeServiceResolver)
