Class TestResourcesController
java.lang.Object
io.micronaut.testresources.server.TestResourcesController
- All Implemented Interfaces:
io.micronaut.core.order.Ordered
,TestResourcesResolver
@Controller("/")
@ExecuteOn("blocking")
public class TestResourcesController
extends Object
implements TestResourcesResolver
The main test resources controller, which will answer requests performed by the
test resources client to resolve properties or close test resources.
-
Field Summary
Fields inherited from interface io.micronaut.core.order.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
Fields inherited from interface io.micronaut.testresources.core.TestResourcesResolver
TEST_RESOURCES_PROPERTY
-
Constructor Summary
ConstructorDescriptionTestResourcesController
(List<PropertyResolutionListener> propertyResolutionListeners, io.micronaut.runtime.server.EmbeddedServer embeddedServer, io.micronaut.context.ApplicationContext applicationContext, ResolverLoader loader) -
Method Summary
Modifier and TypeMethodDescriptionboolean
closeAll()
Closes all test resources.boolean
closeScope
(@Nullable String id) Closes a test resource scope.getRequiredProperties
(String expression) Lists all properties required to resolve a particular expression.Lists all properties required by all resolvers.Lists all resolvable properties.getResolvableProperties
(Map<String, Collection<String>> propertyEntries, Map<String, Object> testResourcesConfig) Lists all resolvable properties for a particular configuration.Lists all test containers started by the server.listContainersByScope
(@Nullable String scope) Lists all test containers started by the server for a particular scope.Resolves a property.void
Requests a test resources service shutdown.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.micronaut.core.order.Ordered
getOrder
Methods inherited from interface io.micronaut.testresources.core.TestResourcesResolver
getDisplayName, getId
-
Constructor Details
-
TestResourcesController
public TestResourcesController(List<PropertyResolutionListener> propertyResolutionListeners, io.micronaut.runtime.server.EmbeddedServer embeddedServer, io.micronaut.context.ApplicationContext applicationContext, ResolverLoader loader)
-
-
Method Details
-
getResolvableProperties
Lists all resolvable properties. PrefergetResolvableProperties(Map, Map)
to list all properties which can be resolved for a particular configuration.- Returns:
- the list of resolvable properties which do not depend on the application configuration
-
getResolvableProperties
@Post("/list") public List<String> getResolvableProperties(Map<String, Collection<String>> propertyEntries, Map<String, Object> testResourcesConfig) Lists all resolvable properties for a particular configuration.- Specified by:
getResolvableProperties
in interfaceTestResourcesResolver
- Parameters:
propertyEntries
- the property entriestestResourcesConfig
- the test resources configuration- Returns:
- the list of properties
-
getRequiredProperties
@Get("/requirements/expr/{expression}") public List<String> getRequiredProperties(String expression) Lists all properties required to resolve a particular expression.- Specified by:
getRequiredProperties
in interfaceTestResourcesResolver
- Parameters:
expression
- the expression which needs to be resolved.- Returns:
- the list of required properties
-
getRequiredPropertyEntries
Lists all properties required by all resolvers.- Specified by:
getRequiredPropertyEntries
in interfaceTestResourcesResolver
- Returns:
- the list of required properties
-
resolve
@Post("/resolve") public Optional<String> resolve(String name, Map<String, Object> properties, Map<String, Object> testResourcesConfig) Resolves a property.- Specified by:
resolve
in interfaceTestResourcesResolver
- Parameters:
name
- the property to resolveproperties
- the resolved required propertiestestResourcesConfig
- the test resources configuration- Returns:
- the resolved property, if any
-
closeAll
@Get("/close/all") public boolean closeAll()Closes all test resources.- Returns:
- true if the operation was successful
-
closeScope
Closes a test resource scope.- Parameters:
id
- the scope id- Returns:
- true if the operation was successful
-
listContainers
Lists all test containers started by the server.- Returns:
- the list of test containers
-
listContainersByScope
@Get("/testcontainers/{scope}") public List<TestContainer> listContainersByScope(@Nullable @Nullable String scope) Lists all test containers started by the server for a particular scope.- Parameters:
scope
- the scope id- Returns:
- the list of test containers
-
stopService
@Post("/stop") public void stopService()Requests a test resources service shutdown.
-