diff --git a/inject-generator/src/main/java/io/avaje/inject/generator/InjectProcessor.java b/inject-generator/src/main/java/io/avaje/inject/generator/InjectProcessor.java index 673bdbae3..43f3fd0cd 100644 --- a/inject-generator/src/main/java/io/avaje/inject/generator/InjectProcessor.java +++ b/inject-generator/src/main/java/io/avaje/inject/generator/InjectProcessor.java @@ -97,7 +97,6 @@ public synchronized void init(ProcessingEnvironment processingEnv) { * Loads provider files generated by avaje-inject-maven-plugin */ void loadProvidedFiles() { - pluginFileProvided.addAll(lines("avaje-plugin-provides.txt")); lines("avaje-module-dependencies.csv").stream() .filter(s -> s.contains("|") && !s.startsWith("External Module Type")) .distinct() diff --git a/inject-generator/src/main/java/io/avaje/inject/generator/LoadServices.java b/inject-generator/src/main/java/io/avaje/inject/generator/LoadServices.java index d001a80f3..a4e5ec057 100644 --- a/inject-generator/src/main/java/io/avaje/inject/generator/LoadServices.java +++ b/inject-generator/src/main/java/io/avaje/inject/generator/LoadServices.java @@ -1,6 +1,5 @@ package io.avaje.inject.generator; -import io.avaje.inject.spi.Module; import io.avaje.inject.spi.*; import java.util.ArrayList; @@ -14,8 +13,6 @@ private LoadServices() {} static List loadModules(ClassLoader classLoader) { List modules = new ArrayList<>(); - // load using older Module - ServiceLoader.load(Module.class, classLoader).forEach(modules::add); // load newer AvajeModule final var iterator = ServiceLoader.load(InjectExtension.class, classLoader).iterator(); while (iterator.hasNext()) { @@ -33,8 +30,6 @@ static List loadModules(ClassLoader classLoader) { static List loadPlugins(ClassLoader classLoader) { List plugins = new ArrayList<>(); - ServiceLoader.load(Plugin.class, classLoader).forEach(plugins::add); - final var iterator = ServiceLoader.load(InjectExtension.class, classLoader).iterator(); while (iterator.hasNext()) { try { diff --git a/inject-generator/src/main/java/module-info.java b/inject-generator/src/main/java/module-info.java index 4dbf08f88..8d0464df3 100644 --- a/inject-generator/src/main/java/module-info.java +++ b/inject-generator/src/main/java/module-info.java @@ -10,10 +10,6 @@ requires static io.avaje.spi; uses io.avaje.inject.spi.InjectExtension; - uses io.avaje.inject.spi.Plugin; - uses io.avaje.inject.spi.Module; - uses io.avaje.inject.spi.InjectPlugin; - uses io.avaje.inject.spi.AvajeModule; provides javax.annotation.processing.Processor with io.avaje.inject.generator.InjectProcessor; } diff --git a/inject-gradle-plugin/src/main/java/io/avaje/inject/plugin/AvajeInjectPlugin.java b/inject-gradle-plugin/src/main/java/io/avaje/inject/plugin/AvajeInjectPlugin.java index 6b923ac09..6df151078 100644 --- a/inject-gradle-plugin/src/main/java/io/avaje/inject/plugin/AvajeInjectPlugin.java +++ b/inject-gradle-plugin/src/main/java/io/avaje/inject/plugin/AvajeInjectPlugin.java @@ -6,8 +6,6 @@ import io.avaje.inject.spi.AvajeModule; import io.avaje.inject.spi.InjectPlugin; import io.avaje.inject.spi.InjectExtension; -import io.avaje.inject.spi.Module; -import io.avaje.inject.spi.Plugin; import org.gradle.api.Project; import org.gradle.api.Task; @@ -65,7 +63,6 @@ private FileWriter createFileWriter(String dir, String file) throws IOException private void writeProvidedPlugins(ClassLoader classLoader, FileWriter pluginWriter) throws IOException { final List plugins = new ArrayList<>(); - ServiceLoader.load(Plugin.class, classLoader).forEach(plugins::add); ServiceLoader.load(InjectExtension.class, classLoader).stream() .map(Provider::get) .filter(InjectPlugin.class::isInstance) @@ -122,7 +119,6 @@ private static URL[] createClassPath(Project project) { private void writeModuleCSV(ClassLoader classLoader, FileWriter moduleWriter) throws IOException { final List avajeModules = new ArrayList<>(); - ServiceLoader.load(Module.class, classLoader).forEach(avajeModules::add); ServiceLoader.load(InjectExtension.class, classLoader).stream() .map(Provider::get) .filter(AvajeModule.class::isInstance) diff --git a/inject-maven-plugin/src/main/java/io/avaje/inject/mojo/AutoProvidesMojo.java b/inject-maven-plugin/src/main/java/io/avaje/inject/mojo/AutoProvidesMojo.java index cecc73f8d..2f15349e0 100644 --- a/inject-maven-plugin/src/main/java/io/avaje/inject/mojo/AutoProvidesMojo.java +++ b/inject-maven-plugin/src/main/java/io/avaje/inject/mojo/AutoProvidesMojo.java @@ -31,8 +31,6 @@ import io.avaje.inject.spi.AvajeModule; import io.avaje.inject.spi.InjectExtension; import io.avaje.inject.spi.InjectPlugin; -import io.avaje.inject.spi.Module; -import io.avaje.inject.spi.Plugin; /** * Plugin that generates target/avaje-module-provides.txt and @@ -98,7 +96,6 @@ private void writeProvidedPlugins(URLClassLoader newClassLoader, FileWriter plug final Log log = getLog(); final List plugins = new ArrayList<>(); - ServiceLoader.load(Plugin.class, newClassLoader).forEach(plugins::add); ServiceLoader.load(InjectExtension.class, newClassLoader).stream() .map(Provider::get) .filter(InjectPlugin.class::isInstance) @@ -132,7 +129,6 @@ private void writeProvidedPlugins(URLClassLoader newClassLoader, FileWriter plug private void writeModuleCSV(ClassLoader newClassLoader, FileWriter moduleWriter) throws IOException { final Log log = getLog(); final List avajeModules = new ArrayList<>(); - ServiceLoader.load(Module.class, newClassLoader).forEach(avajeModules::add); ServiceLoader.load(InjectExtension.class, newClassLoader).stream() .map(Provider::get) .filter(AvajeModule.class::isInstance) diff --git a/inject/src/main/java/io/avaje/inject/BeanScopeBuilder.java b/inject/src/main/java/io/avaje/inject/BeanScopeBuilder.java index cad20dc36..e20c265d8 100644 --- a/inject/src/main/java/io/avaje/inject/BeanScopeBuilder.java +++ b/inject/src/main/java/io/avaje/inject/BeanScopeBuilder.java @@ -8,7 +8,6 @@ import io.avaje.inject.spi.AvajeModule; import io.avaje.inject.spi.ConfigPropertyPlugin; -import io.avaje.inject.spi.PropertyRequiresPlugin; /** * Build a bean scope with options for shutdown hook and supplying external dependencies. @@ -79,15 +78,6 @@ public interface BeanScopeBuilder { */ BeanScopeBuilder modules(AvajeModule... modules); - /** - * Return the PropertyRequiresPlugin used for this scope. This is useful for plugins that want to - * use the scopes wiring properties. - * - * @deprecated use {@link #configPlugin()} instead - */ - @Deprecated(forRemoval = true) - PropertyRequiresPlugin propertyPlugin(); - /** * Set the ConfigPropertyPlugin used for this scope. This is serviceloaded automatically of not set * diff --git a/inject/src/main/java/io/avaje/inject/DBeanScopeBuilder.java b/inject/src/main/java/io/avaje/inject/DBeanScopeBuilder.java index 6c3660ff8..71f209dc2 100644 --- a/inject/src/main/java/io/avaje/inject/DBeanScopeBuilder.java +++ b/inject/src/main/java/io/avaje/inject/DBeanScopeBuilder.java @@ -25,7 +25,6 @@ import io.avaje.inject.spi.ConfigPropertyPlugin; import io.avaje.inject.spi.EnrichBean; import io.avaje.inject.spi.ModuleOrdering; -import io.avaje.inject.spi.PropertyRequiresPlugin; import io.avaje.inject.spi.SuppliedBean; import jakarta.inject.Provider; @@ -68,14 +67,6 @@ public BeanScopeBuilder modules(AvajeModule... modules) { return this; } - @Override - public PropertyRequiresPlugin propertyPlugin() { - if (propertyPlugin == null) { - propertyPlugin = defaultPropertyPlugin(); - } - return propertyPlugin; - } - @Override public void configPlugin(ConfigPropertyPlugin propertyPlugin) { this.propertyPlugin = propertyPlugin; diff --git a/inject/src/main/java/io/avaje/inject/DServiceLoader.java b/inject/src/main/java/io/avaje/inject/DServiceLoader.java index 534ac5c6d..3b2408099 100644 --- a/inject/src/main/java/io/avaje/inject/DServiceLoader.java +++ b/inject/src/main/java/io/avaje/inject/DServiceLoader.java @@ -1,7 +1,6 @@ package io.avaje.inject; import io.avaje.inject.spi.*; -import io.avaje.inject.spi.Module; import java.util.ArrayList; import java.util.List; @@ -30,9 +29,6 @@ final class DServiceLoader { propertyPlugin = (ConfigPropertyPlugin) spi; } } - // older plugins and modules - ServiceLoader.load(Plugin.class, classLoader).forEach(plugins::add); - ServiceLoader.load(Module.class, classLoader).forEach(modules::add); } List plugins() { diff --git a/inject/src/main/java/io/avaje/inject/spi/Builder.java b/inject/src/main/java/io/avaje/inject/spi/Builder.java index 2a25089b2..d81c21f21 100644 --- a/inject/src/main/java/io/avaje/inject/spi/Builder.java +++ b/inject/src/main/java/io/avaje/inject/spi/Builder.java @@ -56,22 +56,6 @@ default boolean isBeanAbsent(Type... types) { return isBeanAbsent(null, types); } - /** - * @deprecated use {@link #isBeanAbsent(String, Type...)} - */ - @Deprecated(forRemoval = true) - default boolean isAddBeanFor(String name, Type... types) { - return isBeanAbsent(name, types); - } - - /** - * @deprecated use {@link #isBeanAbsent(Type...)} instead - */ - @Deprecated(forRemoval = true) - default boolean isAddBeanFor(Type... types) { - return isBeanAbsent(types); - } - /** * Register the next bean as having Primary priority. * Highest priority, will be used over any other matching beans. diff --git a/inject/src/main/java/io/avaje/inject/spi/ConfigPropertyPlugin.java b/inject/src/main/java/io/avaje/inject/spi/ConfigPropertyPlugin.java index 29850b0b4..d8ae10ee5 100644 --- a/inject/src/main/java/io/avaje/inject/spi/ConfigPropertyPlugin.java +++ b/inject/src/main/java/io/avaje/inject/spi/ConfigPropertyPlugin.java @@ -12,32 +12,27 @@ * System#getProperty(String)} and {@link System#getenv(String)}. */ @NullMarked -public interface ConfigPropertyPlugin extends InjectExtension, PropertyRequiresPlugin { +public interface ConfigPropertyPlugin extends InjectExtension { /** * Return a configuration value that might not exist. */ - @Override Optional get(String property); /** * Return true if the property is defined. */ - @Override boolean contains(String property); /** Return true if the property is not defined. */ - @Override default boolean missing(String property) { return !contains(property); } /** Return true if the property is equal to the given value. */ - @Override boolean equalTo(String property, String value); /** Return true if the property is not defined or not equal to the given value. */ - @Override default boolean notEqualTo(String property, String value) { return !equalTo(property, value); } diff --git a/inject/src/main/java/io/avaje/inject/spi/Module.java b/inject/src/main/java/io/avaje/inject/spi/Module.java deleted file mode 100644 index 1a2a8605b..000000000 --- a/inject/src/main/java/io/avaje/inject/spi/Module.java +++ /dev/null @@ -1,103 +0,0 @@ -package io.avaje.inject.spi; - -import java.lang.reflect.Type; - -import io.avaje.inject.InjectModule; - -/** - * A Module that can be included in BeanScope. - * - * @deprecated migrate to {@link AvajeModule} - */ -@Deprecated(forRemoval = true) -public interface Module extends AvajeModule { - - /** - * Return the set of types this module explicitly provides to other modules. - */ - @Override - default Class[] provides() { - return EMPTY_CLASSES; - } - - /** - * Return the types this module needs to be provided externally or via other modules. - */ - @Override - default Class[] requires() { - return EMPTY_CLASSES; - } - - /** - * Return the packages this module needs to be provided via other modules. - */ - @Override - default Class[] requiresPackages() { - return EMPTY_CLASSES; - } - - /** - * Return the classes that this module provides that we allow other modules to auto depend on. - *

- * This is a convenience when using multiple modules that is otherwise controlled manually by - * explicitly using {@link InjectModule#provides()}. - */ - @Override - default Class[] autoProvides() { - return EMPTY_CLASSES; - } - - /** - * Return the aspects that this module provides. - *

- * This is a convenience when using multiple modules that we otherwise manually specify via - * {@link InjectModule#provides()}. - */ - @Override - default Class[] autoProvidesAspects() { - return EMPTY_CLASSES; - } - - /** - * These are the classes that this module requires for wiring that are provided by other - * external modules (that are in the classpath at compile time). - *

- * This is a convenience when using multiple modules that is otherwise controlled manually by - * explicitly using {@link InjectModule#requires()} or {@link InjectModule#requiresPackages()}. - */ - @Override - default Class[] autoRequires() { - return EMPTY_CLASSES; - } - - /** - * These are the apects that this module requires whose implementations are provided by other external - * modules (that are in the classpath at compile time). - */ - @Override - default Class[] autoRequiresAspects() { - return EMPTY_CLASSES; - } - - /** - * Return public classes of the beans that would be registered by this module. - *

- * This method allows code to use reflection to inspect the modules classes - * before the module is wired. This method is not required for DI wiring. - */ - @Override - Class[] classes(); - - /** - * Build all the beans. - */ - @Override - void build(Builder builder); - - /** - * Marker for custom scoped modules. - */ - interface Custom extends Module { - - } -} diff --git a/inject/src/main/java/io/avaje/inject/spi/Plugin.java b/inject/src/main/java/io/avaje/inject/spi/Plugin.java deleted file mode 100644 index 313be4ee1..000000000 --- a/inject/src/main/java/io/avaje/inject/spi/Plugin.java +++ /dev/null @@ -1,39 +0,0 @@ -package io.avaje.inject.spi; - -import io.avaje.inject.BeanScopeBuilder; - -import java.lang.reflect.Type; - -/** - * A Plugin that can be applied when creating a bean scope. - * - *

Typically, a plugin might provide a default dependency via {@link - * BeanScopeBuilder#provideDefault(Type, java.util.function.Supplier)}. - * - * @deprecated migrate to {@link InjectPlugin} - */ -@Deprecated(forRemoval = true) -public interface Plugin extends InjectPlugin { - - /** - * Apply the plugin to the scope builder. - */ - @Override - void apply(BeanScopeBuilder builder); - - /** - * Return the classes that the plugin provides. - */ - @Override - default Class[] provides() { - return EMPTY_CLASSES; - } - - /** - * Return the aspect classes that the plugin provides. - */ - @Override - default Class[] providesAspects() { - return EMPTY_CLASSES; - } -} diff --git a/inject/src/main/java/io/avaje/inject/spi/PropertyRequiresPlugin.java b/inject/src/main/java/io/avaje/inject/spi/PropertyRequiresPlugin.java deleted file mode 100644 index f7f03c5e4..000000000 --- a/inject/src/main/java/io/avaje/inject/spi/PropertyRequiresPlugin.java +++ /dev/null @@ -1,43 +0,0 @@ -package io.avaje.inject.spi; - -import java.util.Optional; - -import org.jspecify.annotations.NullMarked; - -/** - * Plugin interface which contains the application properties used for wiring. Used with {@link - * io.avaje.inject.RequiresProperty} and {@link io.avaje.inject.Profile}. - * - *

The plugin is loaded via ServiceLoader and defaults to an implementation that uses {@link - * System#getProperty(String)} and {@link System#getenv(String)}. - * - * @deprecated use ConfigPropertyPlugin Instead - */ -@NullMarked -@Deprecated(forRemoval = true) -public interface PropertyRequiresPlugin extends InjectExtension { - - /** - * Return a configuration value that might not exist. - */ - Optional get(String property); - - /** - * Return true if the property is defined. - */ - boolean contains(String property); - - /** Return true if the property is not defined. */ - default boolean missing(String property) { - return !contains(property); - } - - /** Return true if the property is equal to the given value. */ - boolean equalTo(String property, String value); - - /** Return true if the property is not defined or not equal to the given value. */ - default boolean notEqualTo(String property, String value) { - return !equalTo(property, value); - } - -} diff --git a/inject/src/main/java/module-info.java b/inject/src/main/java/module-info.java index b39a0ce88..cabe97d3d 100644 --- a/inject/src/main/java/module-info.java +++ b/inject/src/main/java/module-info.java @@ -12,7 +12,4 @@ requires static transitive org.jspecify; uses io.avaje.inject.spi.InjectExtension; - uses io.avaje.inject.spi.Module; - uses io.avaje.inject.spi.Plugin; - } diff --git a/inject/src/test/java/io/avaje/inject/LegacyBeanScopeBuilderTest.java b/inject/src/test/java/io/avaje/inject/LegacyBeanScopeBuilderTest.java deleted file mode 100644 index a245bb049..000000000 --- a/inject/src/test/java/io/avaje/inject/LegacyBeanScopeBuilderTest.java +++ /dev/null @@ -1,338 +0,0 @@ -package io.avaje.inject; - -import static io.avaje.inject.spi.AvajeModule.EMPTY_CLASSES; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Type; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.stream.Collectors; - -import org.junit.jupiter.api.Test; - -import io.avaje.inject.spi.AvajeModule; -import io.avaje.inject.spi.Builder; -import io.avaje.inject.spi.Module; - -@SuppressWarnings("all") -class LegacyBeanScopeBuilderTest { - - @Test - void depends_providedByParent() { - DBeanScopeBuilder.FactoryOrder factoryOrder = - new DBeanScopeBuilder.FactoryOrder( - new TDBeanScope(MyFeature.class), Collections.emptySet(), false); - factoryOrder.add(bc("1", EMPTY_CLASSES, of(MyFeature.class))); - factoryOrder.orderModules(); - - assertThat(names(factoryOrder.factories())).containsExactly("1"); - } - - @Test - void depends_notProvidedByParent_expect_IllegalStateException() { - DBeanScopeBuilder.FactoryOrder factoryOrder = - new DBeanScopeBuilder.FactoryOrder( - new TDBeanScope(FeatureA.class), Collections.emptySet(), false); - factoryOrder.add(bc("1", EMPTY_CLASSES, of(MyFeature.class))); - assertThatThrownBy(factoryOrder::orderModules) - .isInstanceOf(IllegalStateException.class) - .hasMessageContaining( - "Module [io.avaje.inject.LegacyBeanScopeBuilderTest$TDModule] has unsatisfied requires [io.avaje.inject.LegacyBeanScopeBuilderTest$MyFeature]"); - } - - @Test - void noDepends() { - DBeanScopeBuilder.FactoryOrder factoryOrder = - new DBeanScopeBuilder.FactoryOrder(null, Collections.emptySet(), true); - factoryOrder.add(bc("1", EMPTY_CLASSES, EMPTY_CLASSES)); - factoryOrder.add(bc("2", EMPTY_CLASSES, EMPTY_CLASSES)); - factoryOrder.add(bc("3", EMPTY_CLASSES, EMPTY_CLASSES)); - factoryOrder.orderModules(); - - assertThat(names(factoryOrder.factories())).containsExactly("1", "2", "3"); - } - - @Test - void providedFirst() { - DBeanScopeBuilder.FactoryOrder factoryOrder = - new DBeanScopeBuilder.FactoryOrder(null, Collections.emptySet(), true); - factoryOrder.add(bc("two", EMPTY_CLASSES, EMPTY_CLASSES)); - factoryOrder.add(bc("one", of(Mod3.class), EMPTY_CLASSES)); - factoryOrder.orderModules(); - - assertThat(names(factoryOrder.factories())).containsExactly("one", "two"); - } - - @Test - void name_depends() { - DBeanScopeBuilder.FactoryOrder factoryOrder = - new DBeanScopeBuilder.FactoryOrder(null, Collections.emptySet(), true); - factoryOrder.add(bc("two", EMPTY_CLASSES, of(Mod3.class))); - factoryOrder.add(bc("one", EMPTY_CLASSES, EMPTY_CLASSES)); - factoryOrder.orderModules(); - - assertThat(names(factoryOrder.factories())).containsExactly("one", "two"); - } - - @Test - void name_depends4() { - DBeanScopeBuilder.FactoryOrder factoryOrder = - new DBeanScopeBuilder.FactoryOrder(null, Collections.emptySet(), true); - factoryOrder.add(bc("1", EMPTY_CLASSES, of(Mod3.class))); - factoryOrder.add(bc("2", EMPTY_CLASSES, of(Mod4.class))); - factoryOrder.add(bc("3", of(Mod3.class), of(Mod4.class))); - factoryOrder.add(bc("4", of(Mod4.class), null)); - - factoryOrder.orderModules(); - - assertThat(names(factoryOrder.factories())).containsExactly("4", "2", "3", "1"); - } - - @Test - void nameFeature_depends() { - DBeanScopeBuilder.FactoryOrder factoryOrder = - new DBeanScopeBuilder.FactoryOrder(null, Collections.emptySet(), true); - factoryOrder.add(bc("1", of(FeatureA.class), of(Mod3.class))); - factoryOrder.add(bc("2", EMPTY_CLASSES, of(Mod4.class, FeatureA.class))); - factoryOrder.add(bc("3", of(Mod3.class), of(Mod4.class))); - factoryOrder.add(bc("4", of(Mod4.class), null)); - - factoryOrder.orderModules(); - - assertThat(names(factoryOrder.factories())).containsExactly("4", "3", "1", "2"); - } - - @Test - void feature_depends() { - DBeanScopeBuilder.FactoryOrder factoryOrder = - new DBeanScopeBuilder.FactoryOrder(null, Collections.emptySet(), true); - factoryOrder.add(bc("two", EMPTY_CLASSES, of(MyFeature.class))); - factoryOrder.add(bc("one", of(MyFeature.class), null)); - factoryOrder.orderModules(); - - assertThat(names(factoryOrder.factories())).containsExactly("one", "two"); - } - - @Test - void feature_depends2() { - DBeanScopeBuilder.FactoryOrder factoryOrder = - new DBeanScopeBuilder.FactoryOrder(null, Collections.emptySet(), true); - factoryOrder.add(bc("two", EMPTY_CLASSES, of(MyFeature.class))); - factoryOrder.add(bc("one", of(MyFeature.class), EMPTY_CLASSES)); - factoryOrder.add(bc("three", of(MyFeature.class), EMPTY_CLASSES)); - factoryOrder.orderModules(); - - assertThat(names(factoryOrder.factories())).containsExactly("one", "three", "two"); - } - - @Test - void name_requiresPackage() { - DBeanScopeBuilder.FactoryOrder factoryOrder = - new DBeanScopeBuilder.FactoryOrder(null, Collections.emptySet(), true); - factoryOrder.add(bc("1", EMPTY_CLASSES, new Class[0], of(Mod3.class))); - factoryOrder.add(bc("2", EMPTY_CLASSES, new Class[0], of(Mod4.class))); - factoryOrder.add(bc("3", of(Mod3.class), new Class[0], of(Mod4.class))); - factoryOrder.add(bc("4", of(Mod4.class), new Class[0])); - - factoryOrder.orderModules(); - - assertThat(names(factoryOrder.factories())).containsExactly("4", "2", "3", "1"); - } - - @Test - void name_requiresPackage_mixed() { - DBeanScopeBuilder.FactoryOrder factoryOrder = - new DBeanScopeBuilder.FactoryOrder(null, Collections.emptySet(), true); - factoryOrder.add(bc("1", EMPTY_CLASSES, new Class[0], of(Mod3.class))); - factoryOrder.add(bc("2", EMPTY_CLASSES, of(Mod4.class), new Class[0])); - factoryOrder.add(bc("3", of(Mod3.class), new Class[0], of(Mod4.class))); - factoryOrder.add(bc("4", of(Mod4.class), new Class[0])); - - factoryOrder.orderModules(); - - assertThat(names(factoryOrder.factories())).containsExactly("4", "2", "3", "1"); - } - - @Test - void missingRequiresPackage_expect_unsatisfiedRequiresPackages() { - DBeanScopeBuilder.FactoryOrder factoryOrder = - new DBeanScopeBuilder.FactoryOrder(null, Collections.emptySet(), false); - factoryOrder.add(bc("1", EMPTY_CLASSES, new Class[0], of(Mod3.class))); - factoryOrder.add(bc("2", EMPTY_CLASSES, of(Mod4.class), new Class[0])); - factoryOrder.add(bc("4", of(Mod4.class), new Class[0])); - - assertThatThrownBy(factoryOrder::orderModules) - .isInstanceOf(IllegalStateException.class) - .hasMessageContaining( - "has unsatisfied requiresPackages [io.avaje.inject.LegacyBeanScopeBuilderTest$Mod3] "); - } - - @Test - void missingRequires_expect_unsatisfiedRequires() { - DBeanScopeBuilder.FactoryOrder factoryOrder = - new DBeanScopeBuilder.FactoryOrder(null, Collections.emptySet(), false); - factoryOrder.add(bc("1", EMPTY_CLASSES, of(Mod3.class), new Class[0])); - factoryOrder.add(bc("2", EMPTY_CLASSES, of(Mod4.class), new Class[0])); - factoryOrder.add(bc("4", of(Mod4.class), new Class[0])); - - assertThatThrownBy(factoryOrder::orderModules) - .isInstanceOf(IllegalStateException.class) - .hasMessageContaining( - "has unsatisfied requires [io.avaje.inject.LegacyBeanScopeBuilderTest$Mod3] "); - } - - private List names(List factories) { - return factories.stream().map(AvajeModule::toString).collect(Collectors.toList()); - } - - private TDModule bc(String name, Class[] provides, Class[] requires) { - return bc(name, provides, requires, new Class[0]); - } - - private TDModule bc( - String name, Class[] provides, Class[] requires, Class[] requiresPkg) { - return new TDModule(name, provides, requires, requiresPkg); - } - - private static class TDModule implements Module { - - final String name; - final Class[] provides; - final Class[] requires; - final Class[] requiresPackages; - - private TDModule( - String name, Class[] provides, Class[] requires, Class[] requiresPackages) { - this.name = name; - this.provides = provides; - this.requires = requires; - this.requiresPackages = requiresPackages; - } - - @Override - public String toString() { - return name; - } - - @Override - public Class[] provides() { - return provides; - } - - @Override - public Class[] classes() { - return new Class[0]; - } - - @Override - public Class[] requires() { - return requires; - } - - @Override - public Class[] requiresPackages() { - return requiresPackages; - } - - @Override - public void build(Builder parent) {} - } - - Class[] of(Class... cls) { - return cls != null ? cls : new Class[0]; - } - - class MyFeature {} - - class FeatureA {} - - class Mod3 {} - - class Mod4 {} - - static class TDBeanScope implements BeanScope { - - final String containsType; - - TDBeanScope(Type containsType) { - this.containsType = containsType.getTypeName(); - } - - @Override - public boolean contains(String type) { - return containsType.equals(type); - } - - @Override - public T get(Class type) { - return null; - } - - @Override - public T get(Class type, String name) { - return null; - } - - @Override - public T get(Type type, String name) { - return null; - } - - @Override - public Optional getOptional(Class type) { - return Optional.empty(); - } - - @Override - public Optional getOptional(Type type, String name) { - return Optional.empty(); - } - - @Override - public List listByAnnotation(Class annotation) { - return null; - } - - @Override - public List list(Class type) { - return null; - } - - @Override - public List list(Type type) { - return null; - } - - @Override - public List listByPriority(Class type) { - return null; - } - - @Override - public List listByPriority(Class type, Class priority) { - return null; - } - - @Override - public Map map(Type type) { - return Collections.emptyMap(); - } - - @Override - public List all() { - return null; - } - - @Override - public boolean contains(Type type) { - return false; - } - - @Override - public void close() {} - } -}