de.hilling.junit.cdi.microprofile.TestConfigProducer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cdi-test-microprofile Show documentation
Show all versions of cdi-test-microprofile Show documentation
Support Microprofile Config in cdi-test
package de.hilling.junit.cdi.microprofile;
import de.hilling.junit.cdi.annotations.GlobalTestImplementation;
import de.hilling.junit.cdi.scope.TestSuiteScoped;
import io.smallrye.config.inject.ConfigProducerUtil;
import org.eclipse.microprofile.config.Config;
import org.eclipse.microprofile.config.inject.ConfigProperty;
import jakarta.enterprise.context.Dependent;
import jakarta.enterprise.inject.Produces;
import jakarta.enterprise.inject.spi.InjectionPoint;
import jakarta.inject.Inject;
import java.io.Serializable;
import java.util.*;
@TestSuiteScoped
public class TestConfigProducer implements Serializable {
@Inject
private Config config;
@GlobalTestImplementation
@Dependent
@Produces
@ConfigProperty
String produceStringConfigProperty(InjectionPoint ip) {
return ConfigProducerUtil.getValue(ip, config);
}
@GlobalTestImplementation
@Dependent
@Produces
@ConfigProperty
Long getLongValue(InjectionPoint ip) {
return ConfigProducerUtil.getValue(ip, config);
}
@GlobalTestImplementation
@Dependent
@Produces
@ConfigProperty
Integer getIntegerValue(InjectionPoint ip) {
return ConfigProducerUtil.getValue(ip, config);
}
@GlobalTestImplementation
@Dependent
@Produces
@ConfigProperty
Float produceFloatConfigProperty(InjectionPoint ip) {
return ConfigProducerUtil.getValue(ip, config);
}
@GlobalTestImplementation
@Dependent
@Produces
@ConfigProperty
Double produceDoubleConfigProperty(InjectionPoint ip) {
return ConfigProducerUtil.getValue(ip, config);
}
@GlobalTestImplementation
@Dependent
@Produces
@ConfigProperty
Boolean produceBooleanConfigProperty(InjectionPoint ip) {
return ConfigProducerUtil.getValue(ip, config);
}
@GlobalTestImplementation
@Dependent
@Produces
@ConfigProperty
Optional produceOptionalConfigValue(InjectionPoint ip) {
return ConfigProducerUtil.getValue(ip, config);
}
@GlobalTestImplementation
@Dependent
@Produces
@ConfigProperty
Set producesSetConfigProperty(InjectionPoint ip) {
return ConfigProducerUtil.getValue(ip, config);
}
@GlobalTestImplementation
@Dependent
@Produces
@ConfigProperty
List producesListConfigProperty(InjectionPoint ip) {
return ConfigProducerUtil.getValue(ip, config);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy