Class MailpitTestResourceProvider
java.lang.Object
io.micronaut.testresources.testcontainers.AbstractTestContainersProvider<MailpitTestResourceProvider.MailpitContainer>
io.micronaut.testresources.mailpit.MailpitTestResourceProvider
- All Implemented Interfaces:
io.micronaut.core.order.Ordered, TestResourcesResolver, ToggableTestResourcesResolver
public class MailpitTestResourceProvider
extends AbstractTestContainersProvider<MailpitTestResourceProvider.MailpitContainer>
A test resource provider which will spawn a Mailpit test container.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA Mailpit container with configured SMTP and UI container ports.Nested classes/interfaces inherited from class AbstractTestContainersProvider
AbstractTestContainersProvider.ContainerCommand -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringFields inherited from interface io.micronaut.core.order.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCEFields inherited from interface TestResourcesResolver
TEST_RESOURCES_PROPERTY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateContainer(org.testcontainers.utility.DockerImageName imageName, Map<String, Object> requestedProperties, Map<String, Object> testResourcesConfig) Creates the test container.protected StringReturns the default image name.Returns a display name for a test resources resolver, used for debugging purposes.getRequiredProperties(String expression) Returns the list of properties which should be read before resolving an expression: this can be used if the resolver itself needs some configuration properties.getResolvableProperties(Map<String, Collection<String>> propertyEntries, Map<String, Object> testResourcesConfig) Returns the list of properties that this resolver is able to support.protected StringReturns the name of the resource resolver, for example "kafka" or "mysql".resolveProperty(String propertyName, MailpitTestResourceProvider.MailpitContainer container) resolveWithoutContainer(String propertyName, Map<String, Object> properties, Map<String, Object> testResourcesConfig) Lets a resolver provide a value for the requested property without triggering the creation of a test container.protected booleanshouldAnswer(String propertyName, Map<String, Object> requestedProperties, Map<String, Object> testResourcesConfig) Determines if this resolver can resolve the requested property.Methods inherited from class AbstractTestContainersProvider
configureContainer, executeInContainer, getContainerOwnerKey, getContainerQuery, getDefaultStartupTimeout, getName, getOrder, prepareContainer, resolve, resolveProperty, stringOrNullMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface TestResourcesResolver
getId, getRequiredPropertyEntriesMethods inherited from interface ToggableTestResourcesResolver
isEnabled
-
Field Details
-
JAVAMAIL_SMTP_HOST
- See Also:
-
JAVAMAIL_SMTP_PORT
- See Also:
-
JAVAMAIL_SMTP_AUTH
- See Also:
-
JAVAMAIL_SMTP_STARTTLS
- See Also:
-
MAILPIT_UI_URL
- See Also:
-
MAILPIT_API_URL
- See Also:
-
DEFAULT_IMAGE
- See Also:
-
DISPLAY_NAME
- See Also:
-
SIMPLE_NAME
- See Also:
-
-
Constructor Details
-
MailpitTestResourceProvider
public MailpitTestResourceProvider()
-
-
Method Details
-
getResolvableProperties
public List<String> getResolvableProperties(Map<String, Collection<String>> propertyEntries, Map<String, Object> testResourcesConfig) Description copied from interface:TestResourcesResolverReturns the list of properties that this resolver is able to support. The property entries map is a map which keys are the property entries retrieved from callingTestResourcesResolver.getRequiredPropertyEntries()and values are those property entries resolved.- Parameters:
propertyEntries- the property entriestestResourcesConfig- the test resources configuration- Returns:
- the list of properties
-
getRequiredProperties
Description copied from interface:TestResourcesResolverReturns the list of properties which should be read before resolving an expression: this can be used if the resolver itself needs some configuration properties.- Parameters:
expression- the expression which needs to be resolved.- Returns:
- the list of configuration properties this resolver requires
-
getDisplayName
Description copied from interface:TestResourcesResolverReturns a display name for a test resources resolver, used for debugging purposes.- Returns:
- the display name
-
createContainer
protected MailpitTestResourceProvider.MailpitContainer createContainer(org.testcontainers.utility.DockerImageName imageName, Map<String, Object> requestedProperties, Map<String, Object> testResourcesConfig) Description copied from class:AbstractTestContainersProviderCreates the test container.- Specified by:
createContainerin classAbstractTestContainersProvider<MailpitTestResourceProvider.MailpitContainer>- Parameters:
imageName- the docker image namerequestedProperties- the resolved propertiestestResourcesConfig- the test resources configuration- Returns:
- a container
-
resolveProperty
protected Optional<String> resolveProperty(String propertyName, MailpitTestResourceProvider.MailpitContainer container) - Specified by:
resolvePropertyin classAbstractTestContainersProvider<MailpitTestResourceProvider.MailpitContainer>
-
getSimpleName
Description copied from class:AbstractTestContainersProviderReturns the name of the resource resolver, for example "kafka" or "mysql".- Specified by:
getSimpleNamein classAbstractTestContainersProvider<MailpitTestResourceProvider.MailpitContainer>- Returns:
- the name of the resolver
-
shouldAnswer
protected boolean shouldAnswer(String propertyName, Map<String, Object> requestedProperties, Map<String, Object> testResourcesConfig) Description copied from class:AbstractTestContainersProviderDetermines if this resolver can resolve the requested property. It is used in order to make sure that a "Postgres" resolver wouldn't provide a value if the requested container type is for MySQL, for example.- Overrides:
shouldAnswerin classAbstractTestContainersProvider<MailpitTestResourceProvider.MailpitContainer>- Parameters:
propertyName- the property to resolverequestedProperties- the resolved propertiestestResourcesConfig- the test resources configuration- Returns:
- if this resolver should answer
-
resolveWithoutContainer
protected Optional<String> resolveWithoutContainer(String propertyName, Map<String, Object> properties, Map<String, Object> testResourcesConfig) Description copied from class:AbstractTestContainersProviderLets a resolver provide a value for the requested property without triggering the creation of a test container. This can be used in case a resolver wants to check existing containers first.- Overrides:
resolveWithoutContainerin classAbstractTestContainersProvider<MailpitTestResourceProvider.MailpitContainer>- Parameters:
propertyName- the name of the property to resolveproperties- the properties used to resolvetestResourcesConfig- the test resources configuration- Returns:
- a resolved property
-
getDefaultImageName
Description copied from class:AbstractTestContainersProviderReturns the default image name.- Specified by:
getDefaultImageNamein classAbstractTestContainersProvider<MailpitTestResourceProvider.MailpitContainer>- Returns:
- the default image name.
-