func (t *TestWorkflowEnvironment) SetOnChildWorkflowCompletedListener(
	listener func(workflowInfo *WorkflowInfo, result Value, err error)) *TestWorkflowEnvironment {
	t.impl.onChildWorkflowCompletedListener = listener
	return t
}
SetOnChildWorkflowCompletedListener sets a listener that will be called after a child workflow is completed.
Note: WorkflowInfo is defined in internal package, use public type workflow.Info instead.
package internal
import (
	"context"
	"fmt"
	"reflect"
	"time"
	"github.com/stretchr/testify/mock"
	"github.com/uber-go/tally"
	"go.uber.org/cadence/.gen/go/shared"
	"go.uber.org/zap"
)
type (
	EncodedValues struct {
		values        []byte
		dataConverter DataConverter
	}
	WorkflowTestSuite struct {
		logger   *zap.Logger
		scope    tally.Scope
		ctxProps []ContextPropagator
		header   *shared.Header
	}
	TestWorkflowEnvironment struct {
		mock.Mock
		impl *testWorkflowEnvironmentImpl
	}
	TestActivityEnvironment struct {
		impl *testWorkflowEnvironmentImpl
	}
	MockCallWrapper struct {
		call *mock.Call
		env  *TestWorkflowEnvironment
		runFn        func(args mock.Arguments)
		waitDuration func() time.Duration
	}
)
func newEncodedValues(values []byte, dc DataConverter) Values {
	if dc == nil {
		dc = getDefaultDataConverter()
	}
	return &EncodedValues{values, dc}
}
func (b EncodedValues) Get(valuePtr ...interface{}) error {
	if !b.HasValues() {
		return ErrNoData
	}
	return b.dataConverter.FromData(b.values, valuePtr...)
}
func (b EncodedValues) HasValues() bool {
	return b.values != nil
}
func (s *WorkflowTestSuite) NewTestWorkflowEnvironment() *TestWorkflowEnvironment {
	return &TestWorkflowEnvironment{impl: newTestWorkflowEnvironmentImpl(s, nil)}
}
func (s *WorkflowTestSuite) NewTestActivityEnvironment() *TestActivityEnvironment {
	return &TestActivityEnvironment{impl: newTestWorkflowEnvironmentImpl(s, nil)}
}
func (s *WorkflowTestSuite) SetLogger(logger *zap.Logger) {
	s.logger = logger
}
func (s *WorkflowTestSuite) GetLogger() *zap.Logger {
	return s.logger
}
func (s *WorkflowTestSuite) SetMetricsScope(scope tally.Scope) {
	s.scope = scope
}
func (s *WorkflowTestSuite) SetContextPropagators(ctxProps []ContextPropagator) {
	s.ctxProps = ctxProps
}
func (s *WorkflowTestSuite) SetHeader(header *shared.Header) {
	s.header = header
}
func (t *TestActivityEnvironment) RegisterActivity(a interface{}) {
	t.impl.RegisterActivity(a)
}
func (t *TestActivityEnvironment) RegisterActivityWithOptions(a interface{}, options RegisterActivityOptions) {
	t.impl.RegisterActivityWithOptions(a, options)
}
func (t *TestActivityEnvironment) ExecuteActivity(activityFn interface{}, args ...interface{}) (Value, error) {
	return t.impl.executeActivity(activityFn, args...)
}
func (t *TestActivityEnvironment) ExecuteLocalActivity(activityFn interface{}, args ...interface{}) (val Value, err error) {
	return t.impl.executeLocalActivity(activityFn, args...)
}
func (t *TestActivityEnvironment) SetWorkerOptions(options WorkerOptions) *TestActivityEnvironment {
	t.impl.setWorkerOptions(options)
	return t
}
func (t *TestActivityEnvironment) SetTestTimeout(idleTimeout time.Duration) *TestActivityEnvironment {
	t.impl.testTimeout = idleTimeout
	return t
}
func (t *TestActivityEnvironment) SetHeartbeatDetails(details interface{}) {
	t.impl.setHeartbeatDetails(details)
}
func (t *TestActivityEnvironment) SetWorkerStopChannel(c chan struct{}) {
	t.impl.setWorkerStopChannel(c)
}
func (t *TestWorkflowEnvironment) RegisterWorkflow(w interface{}) {
	t.impl.RegisterWorkflow(w)
}
func (t *TestWorkflowEnvironment) RegisterWorkflowWithOptions(w interface{}, options RegisterWorkflowOptions) {
	if len(t.ExpectedCalls) > 0 {
		panic("RegisterWorkflow calls cannot follow mock related ones like OnWorkflow or similar")
	}
	t.impl.RegisterWorkflowWithOptions(w, options)
}
func (t *TestWorkflowEnvironment) RegisterActivity(a interface{}) {
	t.impl.RegisterActivity(a)
}
func (t *TestWorkflowEnvironment) RegisterActivityWithOptions(a interface{}, options RegisterActivityOptions) {
	if len(t.ExpectedCalls) > 0 {
		panic("RegisterActivity calls cannot follow mock related ones like OnActivity or similar")
	}
	t.impl.RegisterActivityWithOptions(a, options)
}
func (t *TestWorkflowEnvironment) SetStartTime(startTime time.Time) {
	t.impl.setStartTime(startTime)
}
func (t *TestWorkflowEnvironment) OnActivity(activity interface{}, args ...interface{}) *MockCallWrapper {
	fType := reflect.TypeOf(activity)
	var call *mock.Call
	switch fType.Kind() {
	case reflect.Func:
		fnType := reflect.TypeOf(activity)
		if err := validateFnFormat(fnType, false); err != nil {
			panic(err)
		}
		fnName := getActivityFunctionName(t.impl.registry, activity)
		call = t.Mock.On(fnName, args...)
	case reflect.String:
		call = t.Mock.On(activity.(string), args...)
	default:
		panic("activity must be function or string")
	}
	return t.wrapCall(call)
}
var ErrMockStartChildWorkflowFailed = fmt.Errorf("start child workflow failed: %v", shared.ChildWorkflowExecutionFailedCauseWorkflowAlreadyRunning)
func (t *TestWorkflowEnvironment) OnWorkflow(workflow interface{}, args ...interface{}) *MockCallWrapper {
	fType := reflect.TypeOf(workflow)
	var call *mock.Call
	switch fType.Kind() {
	case reflect.Func:
		fnType := reflect.TypeOf(workflow)
		if err := validateFnFormat(fnType, true); err != nil {
			panic(err)
		}
		fnName := getWorkflowFunctionName(t.impl.registry, workflow)
		if alias, ok := t.impl.registry.getWorkflowAlias(fnName); ok {
			fnName = alias
		}
		call = t.Mock.On(fnName, args...)
	case reflect.String:
		call = t.Mock.On(workflow.(string), args...)
	default:
		panic("activity must be function or string")
	}
	return t.wrapCall(call)
}
const mockMethodForSignalExternalWorkflow = "workflow.SignalExternalWorkflow"
const mockMethodForRequestCancelExternalWorkflow = "workflow.RequestCancelExternalWorkflow"
const mockMethodForGetVersion = "workflow.GetVersion"
const mockMethodForUpsertSearchAttributes = "workflow.UpsertSearchAttributes"
func (t *TestWorkflowEnvironment) OnSignalExternalWorkflow(domainName, workflowID, runID, signalName, arg interface{}) *MockCallWrapper {
	call := t.Mock.On(mockMethodForSignalExternalWorkflow, domainName, workflowID, runID, signalName, arg)
	return t.wrapCall(call)
}
func (t *TestWorkflowEnvironment) OnRequestCancelExternalWorkflow(domainName, workflowID, runID string) *MockCallWrapper {
	call := t.Mock.On(mockMethodForRequestCancelExternalWorkflow, domainName, workflowID, runID)
	return t.wrapCall(call)
}
func (t *TestWorkflowEnvironment) OnGetVersion(changeID string, minSupported, maxSupported Version) *MockCallWrapper {
	call := t.Mock.On(getMockMethodForGetVersion(changeID), changeID, minSupported, maxSupported)
	return t.wrapCall(call)
}
func (t *TestWorkflowEnvironment) OnUpsertSearchAttributes(attributes map[string]interface{}) *MockCallWrapper {
	call := t.Mock.On(mockMethodForUpsertSearchAttributes, attributes)
	return t.wrapCall(call)
}
func (t *TestWorkflowEnvironment) wrapCall(call *mock.Call) *MockCallWrapper {
	callWrapper := &MockCallWrapper{call: call, env: t}
	call.Run(t.impl.getMockRunFn(callWrapper))
	return callWrapper
}
func (c *MockCallWrapper) Once() *MockCallWrapper {
	return c.Times(1)
}
func (c *MockCallWrapper) Twice() *MockCallWrapper {
	return c.Times(2)
}
func (c *MockCallWrapper) Times(i int) *MockCallWrapper {
	c.call.Times(i)
	return c
}
func (c *MockCallWrapper) Run(fn func(args mock.Arguments)) *MockCallWrapper {
	c.runFn = fn
	return c
}
func (c *MockCallWrapper) After(d time.Duration) *MockCallWrapper {
	c.waitDuration = func() time.Duration { return d }
	return c
}
func (c *MockCallWrapper) AfterFn(fn func() time.Duration) *MockCallWrapper {
	c.waitDuration = fn
	return c
}
func (c *MockCallWrapper) Return(returnArguments ...interface{}) *MockCallWrapper {
	c.call.Return(returnArguments...)
	return c
}
func (t *TestWorkflowEnvironment) ExecuteWorkflow(workflowFn interface{}, args ...interface{}) {
	t.impl.mock = &t.Mock
	t.impl.executeWorkflow(workflowFn, args...)
}
func (t *TestWorkflowEnvironment) Now() time.Time {
	return t.impl.Now()
}
func (t *TestWorkflowEnvironment) SetWorkerOptions(options WorkerOptions) *TestWorkflowEnvironment {
	t.impl.setWorkerOptions(options)
	return t
}
func (t *TestWorkflowEnvironment) SetWorkerStopChannel(c chan struct{}) {
	t.impl.setWorkerStopChannel(c)
}
func (t *TestWorkflowEnvironment) SetTestTimeout(idleTimeout time.Duration) *TestWorkflowEnvironment {
	t.impl.testTimeout = idleTimeout
	return t
}
func (t *TestWorkflowEnvironment) SetWorkflowTimeout(executionTimeout time.Duration) *TestWorkflowEnvironment {
	t.impl.executionTimeout = executionTimeout
	return t
}
func (t *TestWorkflowEnvironment) SetWorkflowCronSchedule(cron string) *TestWorkflowEnvironment {
	t.impl.setCronSchedule(cron)
	return t
}
func (t *TestWorkflowEnvironment) SetWorkflowCronMaxIterations(maxIterations int) *TestWorkflowEnvironment {
	t.impl.setCronMaxIterationas(maxIterations)
	return t
}
func (t *TestWorkflowEnvironment) SetOnActivityStartedListener(
	listener func(activityInfo *ActivityInfo, ctx context.Context, args Values)) *TestWorkflowEnvironment {
	t.impl.onActivityStartedListener = listener
	return t
}
func (t *TestWorkflowEnvironment) SetOnActivityCompletedListener(
	listener func(activityInfo *ActivityInfo, result Value, err error)) *TestWorkflowEnvironment {
	t.impl.onActivityCompletedListener = listener
	return t
}
func (t *TestWorkflowEnvironment) SetOnActivityCanceledListener(
	listener func(activityInfo *ActivityInfo)) *TestWorkflowEnvironment {
	t.impl.onActivityCanceledListener = listener
	return t
}
func (t *TestWorkflowEnvironment) SetOnActivityHeartbeatListener(
	listener func(activityInfo *ActivityInfo, details Values)) *TestWorkflowEnvironment {
	t.impl.onActivityHeartbeatListener = listener
	return t
}
func (t *TestWorkflowEnvironment) SetOnChildWorkflowStartedListener(
	listener func(workflowInfo *WorkflowInfo, ctx Context, args Values)) *TestWorkflowEnvironment {
	t.impl.onChildWorkflowStartedListener = listener
	return t
}