3
3
import java .util .concurrent .locks .Lock ;
4
4
import java .util .concurrent .locks .ReentrantLock ;
5
5
6
+ import org .junit .jupiter .api .Assumptions ;
6
7
import org .junit .jupiter .api .extension .AfterAllCallback ;
7
8
import org .junit .jupiter .api .extension .AfterEachCallback ;
8
9
import org .junit .jupiter .api .extension .BeforeAllCallback ;
9
10
import org .junit .jupiter .api .extension .BeforeEachCallback ;
10
- import org .junit .jupiter .api .extension .ConditionEvaluationResult ;
11
- import org .junit .jupiter .api .extension .ExecutionCondition ;
12
11
import org .junit .jupiter .api .extension .ExtensionContext ;
13
12
import org .slf4j .Logger ;
14
13
import org .slf4j .LoggerFactory ;
22
21
*
23
22
* @author Aleksandr Gorshenin
24
23
*/
25
- public class GrpcTransportExtension extends ProxyGrpcTransport implements ExecutionCondition ,
26
- AfterAllCallback , AfterEachCallback , BeforeAllCallback , BeforeEachCallback {
24
+ public class GrpcTransportExtension extends ProxyGrpcTransport implements AfterAllCallback , AfterEachCallback ,
25
+ BeforeAllCallback , BeforeEachCallback {
27
26
private static final Logger logger = LoggerFactory .getLogger (GrpcTransportExtension .class );
28
27
29
28
private final Holder holder = new Holder ();
@@ -33,35 +32,31 @@ protected GrpcTransport origin() {
33
32
return holder .transport ();
34
33
}
35
34
36
- @ Override
37
- public ConditionEvaluationResult evaluateExecutionCondition (ExtensionContext context ) {
38
- if (!context .getTestInstance ().isPresent ()) {
39
- return ConditionEvaluationResult .enabled ("OK" );
40
- }
41
-
42
- if (!YdbHelperFactory .getInstance ().isEnabled ()) {
43
- return ConditionEvaluationResult .disabled ("Ydb helper is disabled" );
44
- }
45
- return ConditionEvaluationResult .enabled ("OK" );
35
+ private void ensureEnabled (String displayName ) {
36
+ Assumptions .assumeTrue (YdbHelperFactory .getInstance ().isEnabled (), "Ydb helper is disabled " + displayName );
46
37
}
47
38
48
39
@ Override
49
40
public void beforeAll (ExtensionContext ec ) throws Exception {
41
+ ensureEnabled (ec .getDisplayName ());
50
42
holder .before (ec );
51
43
}
52
44
53
45
@ Override
54
46
public void afterAll (ExtensionContext ec ) throws Exception {
47
+ ensureEnabled (ec .getDisplayName ());
55
48
holder .after (ec );
56
49
}
57
50
58
51
@ Override
59
52
public void beforeEach (ExtensionContext ec ) throws Exception {
53
+ ensureEnabled (ec .getDisplayName ());
60
54
holder .before (ec );
61
55
}
62
56
63
57
@ Override
64
58
public void afterEach (ExtensionContext ec ) throws Exception {
59
+ ensureEnabled (ec .getDisplayName ());
65
60
holder .after (ec );
66
61
}
67
62
0 commit comments