本文整理汇总了Java中io.bootique.BQModuleProvider类的典型用法代码示例。如果您正苦于以下问题:Java BQModuleProvider类的具体用法?Java BQModuleProvider怎么用?Java BQModuleProvider使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BQModuleProvider类属于io.bootique包,在下文中一共展示了BQModuleProvider类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testMetadata
import io.bootique.BQModuleProvider; //导入依赖的package包/类
protected void testMetadata() {
testWithFactory(testFactory -> {
// must auto-load modules to ensure all tested module dependencies are present...
BQRuntime runtime = testFactory.app().autoLoadModules().createRuntime();
BQModuleProvider provider = matchingProvider();
String providerName = provider.name();
// loading metadata ensures that all annotations are properly applied...
Optional<ModuleMetadata> moduleMetadata = runtime
.getInstance(ModulesMetadata.class)
.getModules()
.stream()
.filter(mmd -> providerName.equals(mmd.getProviderName()))
.findFirst();
assertTrue("No module metadata available for provider: '" + providerName + "'", moduleMetadata.isPresent());
moduleMetadata.get().getConfigs();
});
}
示例2: build
import io.bootique.BQModuleProvider; //导入依赖的package包/类
public BQModuleProvider build() {
return new BQModuleProvider() {
@Override
public Module module() {
return commands;
}
@Override
public Collection<Class<? extends Module>> overrides() {
return Collections.singleton(BQCoreModule.class);
}
@Override
public String name() {
return "Commands.Builder";
}
};
}
示例3: testCustomNamedModule
import io.bootique.BQModuleProvider; //导入依赖的package包/类
@Test
public void testCustomNamedModule() {
BQRuntime runtime = runtimeFactory.app().module(new BQModuleProvider() {
@Override
public Module module() {
return b -> {
};
}
@Override
public BQModule.Builder moduleBuilder() {
return BQModuleProvider.super
.moduleBuilder()
.name("mymodule");
}
}).createRuntime();
ModulesMetadata md = runtime.getInstance(ModulesMetadata.class);
assertEquals("Expected BQCoreModule + 2 test modules + custom module", 4, md.getModules().size());
Optional<ModuleMetadata> myMd = md.getModules()
.stream()
.filter(m -> "mymodule".equals(m.getName()))
.findFirst();
assertTrue(myMd.isPresent());
}
示例4: createPropertiesProvider
import io.bootique.BQModuleProvider; //导入依赖的package包/类
protected BQModuleProvider createPropertiesProvider() {
return new BQModuleProvider() {
@Override
public Module module() {
return binder -> BQCoreModule.extend(binder).setProperties(properties);
}
@Override
public BQModule.Builder moduleBuilder() {
return BQModuleProvider.super
.moduleBuilder()
.name("BQInternalTestFactory:Builder:properties");
}
@Override
public String name() {
return "BQInternalTestFactory:Builder:properties:provider";
}
};
}
示例5: createVariablesProvider
import io.bootique.BQModuleProvider; //导入依赖的package包/类
protected BQModuleProvider createVariablesProvider() {
return new BQModuleProvider() {
@Override
public Module module() {
return binder -> {
BQCoreModule.extend(binder).setVars(variables).declareVars(declaredVars);
};
}
@Override
public BQModule.Builder moduleBuilder() {
return BQModuleProvider.super
.moduleBuilder()
.name("BQInternalTestFactory:Builder:variables");
}
@Override
public String name() {
return "BQInternalTestFactory:Builder:variables:provider";
}
};
}
示例6: testAlsoRun_DecorateWithPrivate
import io.bootique.BQModuleProvider; //导入依赖的package包/类
@Test
public void testAlsoRun_DecorateWithPrivate() {
// use private "-s" command in decorator
BQModuleProvider commandsOverride = Commands.builder().add(MainCommand.class).noModuleCommands().build();
CommandDecorator decorator = CommandDecorator.alsoRun("s");
BQRuntime runtime = createRuntime(commandsOverride, decorator);
CommandOutcome outcome = runtime.run();
waitForAllToFinish();
assertTrue(outcome.isSuccess());
assertTrue(getCommand(runtime, MainCommand.class).isExecuted());
assertTrue(getCommand(runtime, SuccessfulCommand.class).isExecuted());
}
示例7: testModuleCommands
import io.bootique.BQModuleProvider; //导入依赖的package包/类
@Test
public void testModuleCommands() {
BQModuleProvider provider = Commands.builder().build();
BQRuntime runtime = testFactory.app(args).module(provider).createRuntime();
CommandManager commandManager = runtime.getInstance(CommandManager.class);
Map<String, ManagedCommand> commands = commandManager.getAllCommands();
assertCommandKeys(commands, "help", "help-config");
assertFalse(commands.get("help").isHidden());
assertFalse(commands.get("help").isDefault());
assertTrue(commands.get("help").isHelp());
assertFalse(commands.get("help-config").isHidden());
assertFalse(commands.get("help-config").isDefault());
}
示例8: testNoModuleCommands
import io.bootique.BQModuleProvider; //导入依赖的package包/类
@Test
public void testNoModuleCommands() {
BQModuleProvider provider = Commands.builder().noModuleCommands().build();
BQRuntime runtime = testFactory.app(args).module(provider).createRuntime();
CommandManager commandManager = runtime.getInstance(CommandManager.class);
Map<String, ManagedCommand> commands = commandManager.getAllCommands();
assertCommandKeys(commands, "help", "help-config");
assertTrue(commands.get("help").isHidden());
assertFalse(commands.get("help").isDefault());
assertTrue(commands.get("help").isHelp());
assertTrue(commands.get("help-config").isHidden());
assertFalse(commands.get("help-config").isDefault());
}
示例9: testModule_ExtraCommandAsType
import io.bootique.BQModuleProvider; //导入依赖的package包/类
@Test
public void testModule_ExtraCommandAsType() {
BQModuleProvider provider = Commands.builder(C1.class).build();
BQRuntime runtime = testFactory.app(args).module(provider).createRuntime();
CommandManager commandManager = runtime.getInstance(CommandManager.class);
Map<String, ManagedCommand> commands = commandManager.getAllCommands();
assertCommandKeys(commands, "c1", "help", "help-config");
assertFalse(commands.get("help").isHidden());
assertFalse(commands.get("help").isDefault());
assertTrue(commands.get("help").isHelp());
assertFalse(commands.get("help-config").isHidden());
assertFalse(commands.get("help-config").isDefault());
assertTrue(commands.containsKey("c1"));
assertFalse(commands.get("c1").isDefault());
}
示例10: moduleBuilder
import io.bootique.BQModuleProvider; //导入依赖的package包/类
@Override
public BQModule.Builder moduleBuilder() {
return BQModuleProvider.super
.moduleBuilder()
.description("Provides configuration for JCache subsystem. Module itself does NOT include a JCache provider."
+ " The users will need to add a provider of their choice to the application classpath.");
}
示例11: createPropertiesProvider
import io.bootique.BQModuleProvider; //导入依赖的package包/类
protected BQModuleProvider createPropertiesProvider() {
return new BQModuleProvider() {
@Override
public Module module() {
return binder -> BQCoreModule.extend(binder).setProperties(properties);
}
@Override
public String name() {
return "BQTestRuntimeBuilder:properties";
}
};
}
示例12: testMatchingProvider
import io.bootique.BQModuleProvider; //导入依赖的package包/类
@Test
public void testMatchingProvider() {
BQModuleProvider p = new BQModuleProviderChecker(P1.class).matchingProvider();
Assert.assertNotNull(p);
Assert.assertTrue(p instanceof P1);
}
示例13: testBeforeRun_DecorateWithPrivate
import io.bootique.BQModuleProvider; //导入依赖的package包/类
@Test
public void testBeforeRun_DecorateWithPrivate() {
// use private "-s" command in decorator
BQModuleProvider commandsOverride = Commands.builder().add(MainCommand.class).noModuleCommands().build();
CommandDecorator decorator = CommandDecorator.beforeRun("s");
BQRuntime runtime = createRuntime(commandsOverride, decorator);
CommandOutcome outcome = runtime.run();
assertTrue(outcome.isSuccess());
assertTrue(getCommand(runtime, MainCommand.class).isExecuted());
assertTrue(getCommand(runtime, SuccessfulCommand.class).isExecuted());
}
示例14: createRuntime
import io.bootique.BQModuleProvider; //导入依赖的package包/类
private BQRuntime createRuntime(BQModuleProvider commandsOverride, CommandDecorator decorator) {
return testFactory
.app("--a")
.module(b -> BQCoreModule.extend(b)
.addCommand(MainCommand.class)
.addCommand(SuccessfulCommand.class)
.decorateCommand(MainCommand.class, decorator))
.module(commandsOverride)
.createRuntime();
}
示例15: testModule_ExtraCommandAsInstance
import io.bootique.BQModuleProvider; //导入依赖的package包/类
@Test
public void testModule_ExtraCommandAsInstance() {
BQModuleProvider provider = Commands.builder().add(new C1()).build();
BQRuntime runtime = testFactory.app(args).module(provider).createRuntime();
CommandManager commandManager = runtime.getInstance(CommandManager.class);
Map<String, ManagedCommand> commands = commandManager.getAllCommands();
assertCommandKeys(commands, "c1", "help", "help-config");
}