Skip to content

Commit

Permalink
Renaming annotations (and fixed javadoc) to align with current MP ann…
Browse files Browse the repository at this point in the history
…otations.
  • Loading branch information
tomas-langer committed Aug 30, 2024
1 parent d391909 commit 3491e58
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,13 @@ private static void sourceMethods(ServiceRegistryConfig.Builder serviceRegistryC
}

private static void values(ServiceRegistryConfig.Builder serviceRegistryConfig, Class<?> testClass) {
TestConfig.Values annotation = testClass.getAnnotation(TestConfig.Values.class);
TestConfig.Block annotation = testClass.getAnnotation(TestConfig.Block.class);
if (annotation == null) {
return;
}
var mediaType = MediaTypes.detectExtensionType(annotation.format());
var mediaType = MediaTypes.detectExtensionType(annotation.type());
if (mediaType.isEmpty()) {
throw new TestException("No extension media type found for extension " + annotation.format() + ", for "
throw new TestException("No extension media type found for extension " + annotation.type() + ", for "
+ "annotation " + annotation.annotationType().getName());
}
var source = ConfigSources.create(annotation.value(), mediaType.get());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ private SetUpUtil() {
}

static List<TestConfig.File> file(Class<?> testClass) {
TestConfig.ConfigFiles annotation = testClass.getAnnotation(TestConfig.ConfigFiles.class);
TestConfig.Files annotation = testClass.getAnnotation(TestConfig.Files.class);
if (annotation == null) {
TestConfig.File file = testClass.getAnnotation(TestConfig.File.class);
if (file == null) {
Expand All @@ -39,7 +39,7 @@ static List<TestConfig.File> file(Class<?> testClass) {
}

static List<TestConfig.Value> value(Class<?> testClass) {
TestConfig.ConfigValues annotation = testClass.getAnnotation(TestConfig.ConfigValues.class);
TestConfig.Values annotation = testClass.getAnnotation(TestConfig.Values.class);
if (annotation == null) {
TestConfig.Value value = testClass.getAnnotation(TestConfig.Value.class);
if (value == null) {
Expand Down
23 changes: 12 additions & 11 deletions testing/testing/src/main/java/io/helidon/testing/TestConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ static void register(TestConfigSource source) {
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@Repeatable(ConfigValues.class)
@Repeatable(Values.class)
public @interface Value {
/**
* Key of the added configuration option.
Expand Down Expand Up @@ -128,7 +128,7 @@ static void register(TestConfigSource source) {
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface ConfigValues {
public @interface Values {
/**
* Config values.
*
Expand All @@ -138,24 +138,25 @@ static void register(TestConfigSource source) {
}

/**
* Custom configuration key/value pairs.
* Defines the configuration as a String in {@link #value()} for the
* given {@link #type()}.
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface Values {
public @interface Block {
/**
* Key of the added configuration option.
* Text block with configuration data.
*
* @return key
* @return configuration data
*/
String value();

/**
* Format of the value (file suffix).
* Type of the value (file suffix).
*
* @return format to use, defaults to {@code properties}
* @return type to use, defaults to {@code properties}
*/
String format() default "properties";
String type() default "properties";

/**
* Weight of this configuration option.
Expand All @@ -170,7 +171,7 @@ static void register(TestConfigSource source) {
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@Repeatable(ConfigFiles.class)
@Repeatable(Files.class)
public @interface File {
/**
* File path, relative to the module (either classpath, or file system path).
Expand All @@ -192,7 +193,7 @@ static void register(TestConfigSource source) {
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface ConfigFiles {
public @interface Files {
/**
* Config values.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
*/
@TestConfig.Value(key = "test.first", value = "first")
@TestConfig.Value(key = "test.second", value = "second")
@TestConfig.Values("""
@TestConfig.Block("""
test.first=wrong
test.third=third
test.fourth=fourth
Expand Down

0 comments on commit 3491e58

Please sign in to comment.