Skip to content

Commit

Permalink
Comment reviews about renamings
Browse files Browse the repository at this point in the history
Signed-off-by: Jorge Bescos Gascon <jorge.bescos.gascon@oracle.com>
  • Loading branch information
jbescos committed Apr 18, 2024
1 parent 47535a4 commit fb92215
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@
import org.eclipse.microprofile.config.spi.ConfigSource;

/**
* Defines the configuration as a String in {@link #content()} for the
* Defines the configuration as a String in {@link #value()} for the
* given type.
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE, ElementType.METHOD})
@Inherited
public @interface ConfigBlob {
public @interface AddConfigBlock {

/**
* Specifies the format type of the {@link #content()}.
* Specifies the format type of the {@link #value()}.
*
* It defaults to {@link Type#PROPERTIES}.
*
Expand All @@ -51,14 +51,14 @@
Type type() default Type.PROPERTIES;

/**
* Configuration content.
* Configuration value.
*
* @return String with content.
* @return String with value.
*/
String content();
String value();

/**
* Different formats of the configuration content.
* Different formats of the configuration.
*/
enum Type {

Expand All @@ -67,34 +67,34 @@ enum Type {
*/
PROPERTIES {
@Override
protected ConfigSource configSource(String content) {
Objects.requireNonNull(content);
protected ConfigSource configSource(String value) {
Objects.requireNonNull(value);
Properties p = new Properties();
try {
p.load(new StringReader(content));
p.load(new StringReader(value));
} catch (IOException e) {
throw new UncheckedIOException(e);
}
return MpConfigSources.create("PropertiesConfigBlob", p);
return MpConfigSources.create("PropertiesAddConfigBlock", p);
}
},
/**
* YAML format.
*/
YAML {
@Override
protected ConfigSource configSource(String content) {
Objects.requireNonNull(content);
return YamlMpConfigSource.create("YamlConfigBlob", new StringReader(content));
protected ConfigSource configSource(String value) {
Objects.requireNonNull(value);
return YamlMpConfigSource.create("YamlAddConfigBlock", new StringReader(value));
}
};

/**
* Create the ConfigSource given the content.
* Create the ConfigSource given the value.
*
* @param content
* @param value
* @return the configuration
*/
protected abstract ConfigSource configSource(String content);
protected abstract ConfigSource configSource(String value);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import io.helidon.config.yaml.mp.YamlMpConfigSource;
import io.helidon.microprofile.server.JaxRsCdiExtension;
import io.helidon.microprofile.server.ServerCdiExtension;
import io.helidon.microprofile.testing.junit5.ConfigBlob.Type;
import io.helidon.microprofile.testing.junit5.AddConfigBlock.Type;

import jakarta.enterprise.context.ApplicationScoped;
import jakarta.enterprise.context.Dependent;
Expand Down Expand Up @@ -118,7 +118,7 @@ public void beforeAll(ExtensionContext context) {
AddConfig[] configs = getAnnotations(testClass, AddConfig.class);
classLevelConfigMeta.addConfig(configs);
classLevelConfigMeta.configuration(testClass.getAnnotation(Configuration.class));
classLevelConfigMeta.configBlob(testClass.getAnnotation(ConfigBlob.class));
classLevelConfigMeta.addConfigBlock(testClass.getAnnotation(AddConfigBlock.class));
configProviderResolver = ConfigProviderResolver.instance();

AddExtension[] extensions = getAnnotations(testClass, AddExtension.class);
Expand Down Expand Up @@ -195,7 +195,7 @@ public void beforeEach(ExtensionContext context) throws Exception {
ConfigMeta methodLevelConfigMeta = classLevelConfigMeta.nextMethod();
methodLevelConfigMeta.addConfig(configs);
methodLevelConfigMeta.configuration(method.getAnnotation(Configuration.class));
methodLevelConfigMeta.configBlob(method.getAnnotation(ConfigBlob.class));
methodLevelConfigMeta.addConfigBlock(method.getAnnotation(AddConfigBlock.class));

configure(methodLevelConfigMeta);

Expand Down Expand Up @@ -324,7 +324,7 @@ private void configure(ConfigMeta configMeta) {
}
});
if (configMeta.type != null) {
builder.withSources(configMeta.type.configSource(configMeta.content));
builder.withSources(configMeta.type.configSource(configMeta.block));
}
config = builder
.withSources(MpConfigSources.create(configMeta.additionalKeys))
Expand Down Expand Up @@ -607,7 +607,7 @@ private static final class ConfigMeta {
private final Map<String, String> additionalKeys = new HashMap<>();
private final List<String> additionalSources = new ArrayList<>();
private Type type;
private String content;
private String block;
private boolean useExisting;
private String profile;

Expand Down Expand Up @@ -640,12 +640,12 @@ private void configuration(Configuration config) {
additionalKeys.put("mp.config.profile", profile);
}

private void configBlob(ConfigBlob config) {
private void addConfigBlock(AddConfigBlock config) {
if (config == null) {
return;
}
this.type = config.type();
this.content = config.content();
this.block = config.value();
}

ConfigMeta nextMethod() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@
import org.eclipse.microprofile.config.spi.ConfigSource;

/**
* Defines the configuration as a String in {@link #content()} for the
* Defines the configuration as a String in {@link #value()} for the
* given type.
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE, ElementType.METHOD})
@Inherited
public @interface ConfigBlob {
public @interface AddConfigBlock {

/**
* Specifies the format type of the {@link #content()}.
* Specifies the format type of the {@link #value()}.
*
* It defaults to {@link Type#PROPERTIES}.
*
Expand All @@ -51,14 +51,14 @@
Type type() default Type.PROPERTIES;

/**
* Configuration content.
* Configuration value.
*
* @return String with content.
* @return String with value.
*/
String content();
String value();

/**
* Different formats of the configuration content.
* Different formats of the configuration.
*/
enum Type {

Expand All @@ -67,34 +67,34 @@ enum Type {
*/
PROPERTIES {
@Override
protected ConfigSource configSource(String content) {
Objects.requireNonNull(content);
protected ConfigSource configSource(String value) {
Objects.requireNonNull(value);
Properties p = new Properties();
try {
p.load(new StringReader(content));
p.load(new StringReader(value));
} catch (IOException e) {
throw new UncheckedIOException(e);
}
return MpConfigSources.create("PropertiesConfigBlob", p);
return MpConfigSources.create("PropertiesAddConfigBlock", p);
}
},
/**
* YAML format.
*/
YAML {
@Override
protected ConfigSource configSource(String content) {
Objects.requireNonNull(content);
return YamlMpConfigSource.create("YamlConfigBlob", new StringReader(content));
protected ConfigSource configSource(String value) {
Objects.requireNonNull(value);
return YamlMpConfigSource.create("YamlAddConfigBlock", new StringReader(value));
}
};

/**
* Create the ConfigSource given the content.
* Create the ConfigSource given the value.
*
* @param content
* @param value
* @return the configuration
*/
protected abstract ConfigSource configSource(String content);
protected abstract ConfigSource configSource(String value);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import io.helidon.config.yaml.mp.YamlMpConfigSource;
import io.helidon.microprofile.server.JaxRsCdiExtension;
import io.helidon.microprofile.server.ServerCdiExtension;
import io.helidon.microprofile.testing.testng.ConfigBlob.Type;
import io.helidon.microprofile.testing.testng.AddConfigBlock.Type;

import jakarta.enterprise.context.ApplicationScoped;
import jakarta.enterprise.context.Dependent;
Expand Down Expand Up @@ -106,7 +106,7 @@ public void onBeforeClass(ITestClass iTestClass) {
AddConfig[] configs = getAnnotations(testClass, AddConfig.class);
classLevelConfigMeta.addConfig(configs);
classLevelConfigMeta.configuration(testClass.getAnnotation(Configuration.class));
classLevelConfigMeta.configBlob(testClass.getAnnotation(ConfigBlob.class));
classLevelConfigMeta.addConfigBlock(testClass.getAnnotation(AddConfigBlock.class));
configProviderResolver = ConfigProviderResolver.instance();

AddExtension[] extensions = getAnnotations(testClass, AddExtension.class);
Expand Down Expand Up @@ -173,7 +173,7 @@ public void onTestStart(ITestResult result) {
ConfigMeta methodLevelConfigMeta = classLevelConfigMeta.nextMethod();
methodLevelConfigMeta.addConfig(configs);
methodLevelConfigMeta.configuration(method.getAnnotation(Configuration.class));
methodLevelConfigMeta.configBlob(method.getAnnotation(ConfigBlob.class));
methodLevelConfigMeta.addConfigBlock(method.getAnnotation(AddConfigBlock.class));

configure(methodLevelConfigMeta);

Expand Down Expand Up @@ -337,7 +337,7 @@ private void configure(ConfigMeta configMeta) {
}
});
if (configMeta.type != null) {
builder.withSources(configMeta.type.configSource(configMeta.content));
builder.withSources(configMeta.type.configSource(configMeta.block));
}
config = builder
.withSources(MpConfigSources.create(configMeta.additionalKeys))
Expand Down Expand Up @@ -492,7 +492,7 @@ private static final class ConfigMeta {
private final Map<String, String> additionalKeys = new HashMap<>();
private final List<String> additionalSources = new ArrayList<>();
private Type type;
private String content;
private String block;
private boolean useExisting;
private String profile;

Expand Down Expand Up @@ -525,12 +525,12 @@ private void configuration(Configuration config) {
additionalKeys.put("mp.config.profile", profile);
}

private void configBlob(ConfigBlob config) {
private void addConfigBlock(AddConfigBlock config) {
if (config == null) {
return;
}
this.type = config.type();
this.content = config.content();
this.block = config.value();
}

ConfigMeta nextMethod() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@

import jakarta.inject.Inject;

import io.helidon.microprofile.testing.junit5.ConfigBlob;
import io.helidon.microprofile.testing.junit5.AddConfigBlock;
import io.helidon.microprofile.testing.junit5.HelidonTest;

import org.eclipse.microprofile.config.inject.ConfigProperty;
import org.junit.jupiter.api.Test;

@HelidonTest
@ConfigBlob(content = """
@AddConfigBlock("""
some.key1=some.value1
some.key2=some.value2
""")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@

import jakarta.inject.Inject;

import io.helidon.microprofile.testing.junit5.ConfigBlob;
import io.helidon.microprofile.testing.junit5.ConfigBlob.Type;
import io.helidon.microprofile.testing.junit5.AddConfigBlock;
import io.helidon.microprofile.testing.junit5.AddConfigBlock.Type;
import io.helidon.microprofile.testing.junit5.HelidonTest;

import org.eclipse.microprofile.config.inject.ConfigProperty;
import org.junit.jupiter.api.Test;

@HelidonTest
@ConfigBlob(type = Type.YAML, content = """
@AddConfigBlock(type = Type.YAML, value = """
another1:
key: "another1.value"
another2:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@

import jakarta.inject.Inject;

import io.helidon.microprofile.testing.testng.ConfigBlob;
import io.helidon.microprofile.testing.testng.AddConfigBlock;
import io.helidon.microprofile.testing.testng.HelidonTest;

import org.eclipse.microprofile.config.inject.ConfigProperty;
import org.testng.annotations.Test;

@HelidonTest
@ConfigBlob(content = """
@AddConfigBlock("""
some.key1=some.value1
some.key2=some.value2
""")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@

import jakarta.inject.Inject;

import io.helidon.microprofile.testing.testng.ConfigBlob;
import io.helidon.microprofile.testing.testng.ConfigBlob.Type;
import io.helidon.microprofile.testing.testng.AddConfigBlock;
import io.helidon.microprofile.testing.testng.AddConfigBlock.Type;
import io.helidon.microprofile.testing.testng.HelidonTest;

import org.eclipse.microprofile.config.inject.ConfigProperty;
import org.testng.annotations.Test;

@HelidonTest
@ConfigBlob(type = Type.YAML, content = """
@AddConfigBlock(type = Type.YAML, value = """
another1:
key: "another1.value"
another2:
Expand Down

0 comments on commit fb92215

Please sign in to comment.