-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
95 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
core/deployment/src/test/java/io/quarkus/deployment/CapabilityTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package io.quarkus.deployment; | ||
|
||
import static java.util.function.Predicate.not; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.junit.jupiter.api.Assertions.fail; | ||
|
||
import java.lang.reflect.Field; | ||
import java.lang.reflect.Modifier; | ||
import java.util.stream.Stream; | ||
|
||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.Arguments; | ||
import org.junit.jupiter.params.provider.MethodSource; | ||
|
||
public class CapabilityTest { | ||
private static Stream<Arguments> capabilityFields() { | ||
Field[] declaredFields = Capability.class.getDeclaredFields(); | ||
return Stream.of(declaredFields) | ||
.filter(field -> Modifier.isStatic(field.getModifiers())) | ||
.filter(field -> field.getType().equals(String.class)) | ||
.map(CapabilityTest::getString) | ||
.filter(not(Capability.QUARKUS_PREFIX::equals)) | ||
.map(value -> Arguments.of(value)); | ||
} | ||
|
||
@ParameterizedTest | ||
@MethodSource("capabilityFields") | ||
void validateCapabilityString(String capabilityName) { | ||
assertThat(capabilityName).startsWith(Capability.QUARKUS_PREFIX + "."); | ||
assertThat(capabilityName).doesNotContain(".."); | ||
} | ||
|
||
private static String getString(Field field) { | ||
try { | ||
return (String) field.get(null); | ||
} catch (IllegalArgumentException | IllegalAccessException e) { | ||
fail(e); | ||
return ""; | ||
} | ||
} | ||
} |