Class HazelcastTestResourceProvider

java.lang.Object
io.micronaut.testresources.testcontainers.AbstractTestContainersProvider<org.testcontainers.containers.GenericContainer<?>>
io.micronaut.testresources.hazelcast.HazelcastTestResourceProvider
All Implemented Interfaces:
io.micronaut.core.order.Ordered, TestResourcesResolver, ToggableTestResourcesResolver

public class HazelcastTestResourceProvider extends AbstractTestContainersProvider<org.testcontainers.containers.GenericContainer<?>>
Provides a TestContainers-based resource provider for Hazelcast, allowing integration tests to use Hazelcast instances within isolated environments. This class extends the AbstractTestContainersProvider, leveraging the capabilities of TestContainers to create and manage Hazelcast Docker containers. It resolves Hazelcast-related properties required by the application's integration tests.
  • Field Details

  • Constructor Details

    • HazelcastTestResourceProvider

      public HazelcastTestResourceProvider()
  • Method Details

    • getResolvableProperties

      public List<String> getResolvableProperties(Map<String, Collection<String>> propertyEntries, Map<String,Object> testResourcesConfig)
      Description copied from interface: TestResourcesResolver
      Returns 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 calling TestResourcesResolver.getRequiredPropertyEntries() and values are those property entries resolved.
      Parameters:
      propertyEntries - the property entries
      testResourcesConfig - the test resources configuration
      Returns:
      the list of properties
    • getDisplayName

      public String getDisplayName()
      Description copied from interface: TestResourcesResolver
      Returns a display name for a test resources resolver, used for debugging purposes.
      Returns:
      the display name
    • getSimpleName

      protected String getSimpleName()
      Description copied from class: AbstractTestContainersProvider
      Returns the name of the resource resolver, for example "kafka" or "mysql".
      Specified by:
      getSimpleName in class AbstractTestContainersProvider<org.testcontainers.containers.GenericContainer<?>>
      Returns:
      the name of the resolver
    • getDefaultImageName

      protected String getDefaultImageName()
      Description copied from class: AbstractTestContainersProvider
      Returns the default image name.
      Specified by:
      getDefaultImageName in class AbstractTestContainersProvider<org.testcontainers.containers.GenericContainer<?>>
      Returns:
      the default image name.
    • createContainer

      protected org.testcontainers.containers.GenericContainer<?> createContainer(org.testcontainers.utility.DockerImageName imageName, Map<String,Object> requestedProperties, Map<String,Object> testResourcesConfig)
      Description copied from class: AbstractTestContainersProvider
      Creates the test container.
      Specified by:
      createContainer in class AbstractTestContainersProvider<org.testcontainers.containers.GenericContainer<?>>
      Parameters:
      imageName - the docker image name
      requestedProperties - the resolved properties
      testResourcesConfig - the test resources configuration
      Returns:
      a container
    • resolveProperty

      protected Optional<String> resolveProperty(String propertyName, org.testcontainers.containers.GenericContainer<?> container)
      Specified by:
      resolveProperty in class AbstractTestContainersProvider<org.testcontainers.containers.GenericContainer<?>>
    • shouldAnswer

      protected boolean shouldAnswer(String propertyName, Map<String,Object> requestedProperties, Map<String,Object> testResourcesConfig)
      Description copied from class: AbstractTestContainersProvider
      Determines 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:
      shouldAnswer in class AbstractTestContainersProvider<org.testcontainers.containers.GenericContainer<?>>
      Parameters:
      propertyName - the property to resolve
      requestedProperties - the resolved properties
      testResourcesConfig - the test resources configuration
      Returns:
      if this resolver should answer