-
Notifications
You must be signed in to change notification settings - Fork 202
/
interceptorContainerStub.go
95 lines (78 loc) · 2.22 KB
/
interceptorContainerStub.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
package testscommon
import (
"github.com/ElrondNetwork/elrond-go/p2p"
"github.com/ElrondNetwork/elrond-go/process"
)
// InterceptorsContainerStub -
type InterceptorsContainerStub struct {
IterateCalled func(handler func(key string, interceptor process.Interceptor) bool)
GetCalled func(string) (process.Interceptor, error)
AddCalled func(key string, interceptor process.Interceptor) error
AddMultipleCalled func(keys []string, interceptors []process.Interceptor) error
ReplaceCalled func(key string, interceptor process.Interceptor) error
RemoveCalled func(key string)
LenCalled func() int
CloseCalled func() error
}
// Iterate -
func (ics *InterceptorsContainerStub) Iterate(handler func(key string, interceptor process.Interceptor) bool) {
if ics.IterateCalled != nil {
ics.IterateCalled(handler)
}
}
// Get -
func (ics *InterceptorsContainerStub) Get(topic string) (process.Interceptor, error) {
if ics.GetCalled != nil {
return ics.GetCalled(topic)
}
return &InterceptorStub{
ProcessReceivedMessageCalled: func(message p2p.MessageP2P) error {
return nil
},
}, nil
}
// Add -
func (ics *InterceptorsContainerStub) Add(key string, interceptor process.Interceptor) error {
if ics.AddCalled != nil {
return ics.AddCalled(key, interceptor)
}
return nil
}
// AddMultiple -
func (ics *InterceptorsContainerStub) AddMultiple(keys []string, interceptors []process.Interceptor) error {
if ics.AddMultipleCalled != nil {
return ics.AddMultipleCalled(keys, interceptors)
}
return nil
}
// Replace -
func (ics *InterceptorsContainerStub) Replace(key string, interceptor process.Interceptor) error {
if ics.ReplaceCalled != nil {
return ics.ReplaceCalled(key, interceptor)
}
return nil
}
// Remove -
func (ics *InterceptorsContainerStub) Remove(key string) {
if ics.RemoveCalled != nil {
ics.RemoveCalled(key)
}
}
// Len -
func (ics *InterceptorsContainerStub) Len() int {
if ics.LenCalled != nil {
return ics.LenCalled()
}
return 0
}
// Close -
func (ics *InterceptorsContainerStub) Close() error {
if ics.CloseCalled != nil {
return ics.CloseCalled()
}
return nil
}
// IsInterfaceNil -
func (ics *InterceptorsContainerStub) IsInterfaceNil() bool {
return ics == nil
}