6
6
*/
7
7
package org .elasticsearch .xpack .core .watcher .actions .throttler ;
8
8
9
- import org .elasticsearch .license .XPackLicenseState ;
10
- import org .elasticsearch .license .XPackLicenseState .Feature ;
9
+ import org .elasticsearch .license .MockLicenseState ;
11
10
import org .elasticsearch .test .ESTestCase ;
11
+ import org .elasticsearch .xpack .core .watcher .WatcherConstants ;
12
12
import org .elasticsearch .xpack .core .watcher .execution .WatchExecutionContext ;
13
13
14
14
import static org .hamcrest .Matchers .is ;
@@ -25,8 +25,8 @@ public void testThrottleDueToAck() throws Exception {
25
25
when (periodThrottler .throttle ("_action" , ctx )).thenReturn (Throttler .Result .NO );
26
26
Throttler .Result expectedResult = Throttler .Result .throttle (Throttler .Type .ACK , "_reason" );
27
27
when (ackThrottler .throttle ("_action" , ctx )).thenReturn (expectedResult );
28
- XPackLicenseState licenseState = mock (XPackLicenseState .class );
29
- when (licenseState .checkFeature ( Feature . WATCHER )).thenReturn (true );
28
+ MockLicenseState licenseState = mock (MockLicenseState .class );
29
+ when (licenseState .isAllowed ( WatcherConstants . WATCHER_FEATURE )).thenReturn (true );
30
30
ActionThrottler throttler = new ActionThrottler (periodThrottler , ackThrottler , licenseState );
31
31
Throttler .Result result = throttler .throttle ("_action" , ctx );
32
32
assertThat (result , notNullValue ());
@@ -40,8 +40,8 @@ public void testThrottleDueToPeriod() throws Exception {
40
40
Throttler .Result expectedResult = Throttler .Result .throttle (Throttler .Type .PERIOD , "_reason" );
41
41
when (periodThrottler .throttle ("_action" , ctx )).thenReturn (expectedResult );
42
42
when (ackThrottler .throttle ("_action" , ctx )).thenReturn (Throttler .Result .NO );
43
- XPackLicenseState licenseState = mock (XPackLicenseState .class );
44
- when (licenseState .checkFeature ( Feature . WATCHER )).thenReturn (true );
43
+ MockLicenseState licenseState = mock (MockLicenseState .class );
44
+ when (licenseState .isAllowed ( WatcherConstants . WATCHER_FEATURE )).thenReturn (true );
45
45
ActionThrottler throttler = new ActionThrottler (periodThrottler , ackThrottler , licenseState );
46
46
Throttler .Result result = throttler .throttle ("_action" , ctx );
47
47
assertThat (result , notNullValue ());
@@ -56,8 +56,8 @@ public void testThrottleDueAckAndPeriod() throws Exception {
56
56
when (periodThrottler .throttle ("_action" , ctx )).thenReturn (periodResult );
57
57
Throttler .Result ackResult = Throttler .Result .throttle (Throttler .Type .ACK , "_reason_ack" );
58
58
when (ackThrottler .throttle ("_action" , ctx )).thenReturn (ackResult );
59
- XPackLicenseState licenseState = mock (XPackLicenseState .class );
60
- when (licenseState .checkFeature ( Feature . WATCHER )).thenReturn (true );
59
+ MockLicenseState licenseState = mock (MockLicenseState .class );
60
+ when (licenseState .isAllowed ( WatcherConstants . WATCHER_FEATURE )).thenReturn (true );
61
61
ActionThrottler throttler = new ActionThrottler (periodThrottler , ackThrottler , licenseState );
62
62
Throttler .Result result = throttler .throttle ("_action" , ctx );
63
63
assertThat (result , notNullValue ());
@@ -71,8 +71,8 @@ public void testNoThrottle() throws Exception {
71
71
WatchExecutionContext ctx = mock (WatchExecutionContext .class );
72
72
when (periodThrottler .throttle ("_action" , ctx )).thenReturn (Throttler .Result .NO );
73
73
when (ackThrottler .throttle ("_action" , ctx )).thenReturn (Throttler .Result .NO );
74
- XPackLicenseState licenseState = mock (XPackLicenseState .class );
75
- when (licenseState .checkFeature ( Feature . WATCHER )).thenReturn (true );
74
+ MockLicenseState licenseState = mock (MockLicenseState .class );
75
+ when (licenseState .isAllowed ( WatcherConstants . WATCHER_FEATURE )).thenReturn (true );
76
76
ActionThrottler throttler = new ActionThrottler (periodThrottler , ackThrottler , licenseState );
77
77
Throttler .Result result = throttler .throttle ("_action" , ctx );
78
78
assertThat (result , notNullValue ());
@@ -84,8 +84,8 @@ public void testWithoutPeriod() throws Exception {
84
84
WatchExecutionContext ctx = mock (WatchExecutionContext .class );
85
85
Throttler .Result ackResult = mock (Throttler .Result .class );
86
86
when (ackThrottler .throttle ("_action" , ctx )).thenReturn (ackResult );
87
- XPackLicenseState licenseState = mock (XPackLicenseState .class );
88
- when (licenseState .checkFeature ( Feature . WATCHER )).thenReturn (true );
87
+ MockLicenseState licenseState = mock (MockLicenseState .class );
88
+ when (licenseState .isAllowed ( WatcherConstants . WATCHER_FEATURE )).thenReturn (true );
89
89
ActionThrottler throttler = new ActionThrottler (null , ackThrottler , licenseState );
90
90
Throttler .Result result = throttler .throttle ("_action" , ctx );
91
91
assertThat (result , notNullValue ());
@@ -97,8 +97,8 @@ public void testThatRestrictedLicenseReturnsCorrectResult() throws Exception {
97
97
WatchExecutionContext ctx = mock (WatchExecutionContext .class );
98
98
Throttler .Result ackResult = mock (Throttler .Result .class );
99
99
when (ackThrottler .throttle ("_action" , ctx )).thenReturn (ackResult );
100
- XPackLicenseState licenseState = mock (XPackLicenseState .class );
101
- when (licenseState .checkFeature ( Feature . WATCHER )).thenReturn (false );
100
+ MockLicenseState licenseState = mock (MockLicenseState .class );
101
+ when (licenseState .isAllowed ( WatcherConstants . WATCHER_FEATURE )).thenReturn (false );
102
102
ActionThrottler throttler = new ActionThrottler (null , ackThrottler , licenseState );
103
103
Throttler .Result result = throttler .throttle ("_action" , ctx );
104
104
assertThat (result , notNullValue ());
0 commit comments