Skip to content

Commit 955c34e

Browse files
committed
JVMCBC-1667 TEST: Make IgnoreWhen Repeatable
Motivation ---------- Prerequisite for using IgnoreWhen as a meta-annotation. Modifications ------------- Annotate `IgnoreWhen` as `Repeatable`, and add the necessary container annotation. Modify ClusterInvocationProvider.evaluateExecutionCondition to process a list of IgnoreWhen annotations instead of just zero/one. Change-Id: Idaf223a543ffe5607c4267472802f8aec227c115 Reviewed-on: https://review.couchbase.org/c/couchbase-jvm-clients/+/230063 Tested-by: Build Bot <[email protected]> Reviewed-by: Michael Reiche <[email protected]>
1 parent 5e560ab commit 955c34e

File tree

3 files changed

+33
-5
lines changed

3 files changed

+33
-5
lines changed

test-utils/src/main/java/com/couchbase/client/test/ClusterInvocationProvider.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import org.junit.jupiter.api.extension.ParameterResolver;
2424
import org.junit.platform.commons.support.AnnotationSupport;
2525

26-
import java.util.Optional;
26+
import java.util.List;
2727

2828
/**
2929
* This invocation provider starts and stops the couchbase cluster before and after
@@ -81,10 +81,9 @@ public Object resolveParameter(final ParameterContext pCtx, final ExtensionConte
8181
public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext context) {
8282
TestCluster testCluster = accessAndMaybeInitTestCluster(context);
8383

84-
Optional<IgnoreWhen> annotation = AnnotationSupport
85-
.findAnnotation(context.getElement(), IgnoreWhen.class);
86-
if (annotation.isPresent()) {
87-
IgnoreWhen found = annotation.get();
84+
List<IgnoreWhen> annotations = AnnotationSupport
85+
.findRepeatableAnnotations(context.getElement(), IgnoreWhen.class);
86+
for (IgnoreWhen found : annotations) {
8887
for (ClusterType type : found.clusterTypes()) {
8988
if (testCluster.type().equals(type)) {
9089
return ConditionEvaluationResult.disabled("Test disabled on this ClusterType ("

test-utils/src/main/java/com/couchbase/client/test/IgnoreWhen.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,14 @@
1616
package com.couchbase.client.test;
1717

1818
import java.lang.annotation.ElementType;
19+
import java.lang.annotation.Repeatable;
1920
import java.lang.annotation.Retention;
2021
import java.lang.annotation.RetentionPolicy;
2122
import java.lang.annotation.Target;
2223

2324
@Target({ ElementType.ANNOTATION_TYPE, ElementType.METHOD, ElementType.TYPE })
2425
@Retention(RetentionPolicy.RUNTIME)
26+
@Repeatable(IgnoreWhenContainer.class)
2527
public @interface IgnoreWhen {
2628
ClusterType[] clusterTypes() default {};
2729

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Copyright (c) 2025 Couchbase, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.couchbase.client.test;
17+
18+
import java.lang.annotation.ElementType;
19+
import java.lang.annotation.Retention;
20+
import java.lang.annotation.RetentionPolicy;
21+
import java.lang.annotation.Target;
22+
23+
@Target({ ElementType.ANNOTATION_TYPE, ElementType.METHOD, ElementType.TYPE })
24+
@Retention(RetentionPolicy.RUNTIME)
25+
public @interface IgnoreWhenContainer {
26+
IgnoreWhen[] value();
27+
}

0 commit comments

Comments
 (0)