Skip to content

Commit

Permalink
Rename TestResourceScope.MATCHING_RESOURCE to MATCHING_RESOURCES
Browse files Browse the repository at this point in the history
The semantic is that all the test resources have to match so let's use
the plural form.
  • Loading branch information
gsmet committed Sep 4, 2024
1 parent 116c8a3 commit 7cc9328
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.quarkus.test.common;

import static io.quarkus.test.common.TestResourceScope.GLOBAL;
import static io.quarkus.test.common.TestResourceScope.MATCHING_RESOURCE;
import static io.quarkus.test.common.TestResourceScope.MATCHING_RESOURCES;
import static io.quarkus.test.common.TestResourceScope.RESTRICTED_TO_CLASS;

import java.io.Closeable;
Expand Down Expand Up @@ -539,7 +539,7 @@ public static boolean testResourcesRequireReload(Set<TestResourceComparisonInfo>
}

private static Set<TestResourceComparisonInfo> onlyMatchingResourceItems(Set<TestResourceComparisonInfo> set) {
return set.stream().filter(i -> i.scope == MATCHING_RESOURCE).collect(
return set.stream().filter(i -> i.scope == MATCHING_RESOURCES).collect(
Collectors.toSet());
}

Expand Down Expand Up @@ -848,7 +848,7 @@ public TestResourceClassEntry produce(AnnotationInstance annotation) {

@Override
public TestResourceScope scope(AnnotationInstance annotation) {
TestResourceScope scope = MATCHING_RESOURCE;
TestResourceScope scope = MATCHING_RESOURCES;
AnnotationValue restrict = annotation.value("scope");
if (restrict != null) {
scope = TestResourceScope.valueOf(restrict.asEnum());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ public enum TestResourceScope {
*/

/**
* Means that Quarkus will run the test in complete isolation, i.e. it will restart every time it finds such a resource
* Means that Quarkus will run the test in complete isolation, i.e. it will restart every time it finds such a resource.
*/
RESTRICTED_TO_CLASS,

/**
* Means that Quarkus will not restart when running consecutive tests that use the same resource
* Means that Quarkus will not restart when running consecutive tests that use the same set of resources.
*/
MATCHING_RESOURCE,
MATCHING_RESOURCES,

/**
* Means the resource applies to all tests in the testsuite
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@

/**
* Defines how Quarkus behaves with regard to the application of the resource to this test and the test-suite in general.
* The default is {@link TestResourceScope#MATCHING_RESOURCE} which means that if two tests are annotated with the same
* The default is {@link TestResourceScope#MATCHING_RESOURCES} which means that if two tests are annotated with the same
* {@link WithTestResource} annotation, no restart will take place between tests.
*/
TestResourceScope scope() default TestResourceScope.MATCHING_RESOURCE;
TestResourceScope scope() default TestResourceScope.MATCHING_RESOURCES;

@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,38 +38,38 @@ public void sameSingleRestrictedToClassResource() {
@Test
public void sameSingleMatchingResource() {
assertFalse(testResourcesRequireReload(
Set.of(new TestResourceComparisonInfo("test", MATCHING_RESOURCE)),
Set.of(new TestResourceComparisonInfo("test", MATCHING_RESOURCE))));
Set.of(new TestResourceComparisonInfo("test", MATCHING_RESOURCES)),
Set.of(new TestResourceComparisonInfo("test", MATCHING_RESOURCES))));
}

@Test
public void differentSingleMatchingResource() {
assertTrue(testResourcesRequireReload(
Set.of(new TestResourceComparisonInfo("test", MATCHING_RESOURCE)),
Set.of(new TestResourceComparisonInfo("test2", MATCHING_RESOURCE))));
Set.of(new TestResourceComparisonInfo("test", MATCHING_RESOURCES)),
Set.of(new TestResourceComparisonInfo("test2", MATCHING_RESOURCES))));
}

@Test
public void sameMultipleMatchingResource() {
assertFalse(testResourcesRequireReload(
Set.of(
new TestResourceComparisonInfo("test", MATCHING_RESOURCE),
new TestResourceComparisonInfo("test2", MATCHING_RESOURCE),
new TestResourceComparisonInfo("test", MATCHING_RESOURCES),
new TestResourceComparisonInfo("test2", MATCHING_RESOURCES),
new TestResourceComparisonInfo("test3", GLOBAL)),
Set.of(new TestResourceComparisonInfo("test3", GLOBAL),
new TestResourceComparisonInfo("test2", MATCHING_RESOURCE),
new TestResourceComparisonInfo("test", MATCHING_RESOURCE))));
new TestResourceComparisonInfo("test2", MATCHING_RESOURCES),
new TestResourceComparisonInfo("test", MATCHING_RESOURCES))));
}

@Test
public void differentMultipleMatchingResource() {
assertTrue(testResourcesRequireReload(
Set.of(
new TestResourceComparisonInfo("test", MATCHING_RESOURCE),
new TestResourceComparisonInfo("test2", MATCHING_RESOURCE),
new TestResourceComparisonInfo("test", MATCHING_RESOURCES),
new TestResourceComparisonInfo("test2", MATCHING_RESOURCES),
new TestResourceComparisonInfo("test3", GLOBAL)),
Set.of(new TestResourceComparisonInfo("test3", GLOBAL),
new TestResourceComparisonInfo("test2", MATCHING_RESOURCE),
new TestResourceComparisonInfo("TEST", MATCHING_RESOURCE))));
new TestResourceComparisonInfo("test2", MATCHING_RESOURCES),
new TestResourceComparisonInfo("TEST", MATCHING_RESOURCES))));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ private void quarkusWithTestResourceMock(ClassDescriptor mock,
WithTestResource withResourceMock = Mockito.mock(WithTestResource.class, withSettings().strictness(Strictness.LENIENT));
doReturn(managerClass).when(withResourceMock).value();
when(withResourceMock.scope()).thenReturn(
restrictToAnnotatedClass ? TestResourceScope.RESTRICTED_TO_CLASS : TestResourceScope.MATCHING_RESOURCE);
restrictToAnnotatedClass ? TestResourceScope.RESTRICTED_TO_CLASS : TestResourceScope.MATCHING_RESOURCES);
when(mock.findRepeatableAnnotations(WithTestResource.class)).thenReturn(List.of(withResourceMock));
}

Expand Down

0 comments on commit 7cc9328

Please sign in to comment.