33import java .util .concurrent .locks .Lock ;
44import java .util .concurrent .locks .ReentrantLock ;
55
6+ import org .junit .jupiter .api .Assumptions ;
67import org .junit .jupiter .api .extension .AfterAllCallback ;
78import org .junit .jupiter .api .extension .AfterEachCallback ;
89import org .junit .jupiter .api .extension .BeforeAllCallback ;
910import org .junit .jupiter .api .extension .BeforeEachCallback ;
10- import org .junit .jupiter .api .extension .ConditionEvaluationResult ;
11- import org .junit .jupiter .api .extension .ExecutionCondition ;
1211import org .junit .jupiter .api .extension .ExtensionContext ;
1312import org .slf4j .Logger ;
1413import org .slf4j .LoggerFactory ;
2221 *
2322 * @author Aleksandr Gorshenin
2423 */
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 {
2726 private static final Logger logger = LoggerFactory .getLogger (GrpcTransportExtension .class );
2827
2928 private final Holder holder = new Holder ();
@@ -33,35 +32,31 @@ protected GrpcTransport origin() {
3332 return holder .transport ();
3433 }
3534
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 );
4637 }
4738
4839 @ Override
4940 public void beforeAll (ExtensionContext ec ) throws Exception {
41+ ensureEnabled (ec .getDisplayName ());
5042 holder .before (ec );
5143 }
5244
5345 @ Override
5446 public void afterAll (ExtensionContext ec ) throws Exception {
47+ ensureEnabled (ec .getDisplayName ());
5548 holder .after (ec );
5649 }
5750
5851 @ Override
5952 public void beforeEach (ExtensionContext ec ) throws Exception {
53+ ensureEnabled (ec .getDisplayName ());
6054 holder .before (ec );
6155 }
6256
6357 @ Override
6458 public void afterEach (ExtensionContext ec ) throws Exception {
59+ ensureEnabled (ec .getDisplayName ());
6560 holder .after (ec );
6661 }
6762
0 commit comments