All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.hilling.junit.cdi.microprofile.TestConfigProducer Maven / Gradle / Ivy

There is a newer version: 5.0.2
Show newest version
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