spring-test-elasticsearch

TestContainers wrapper around the Elasticsearch for Spring Boot applications

License

License

Categories

Categories

Search Business Logic Libraries Elasticsearch
GroupId

GroupId

com.jupiter-tools
ArtifactId

ArtifactId

spring-test-elasticsearch
Last Version

Last Version

0.1
Release Date

Release Date

Type

Type

jar
Description

Description

spring-test-elasticsearch
TestContainers wrapper around the Elasticsearch for Spring Boot applications
Project URL

Project URL

https://github.com/jupiter-tools/spring-test-elasticsearch
Source Code Management

Source Code Management

https://github.com/jupiter-tools/spring-test-elasticsearch

Download spring-test-elasticsearch

How to add to project

<!-- https://jarcasting.com/artifacts/com.jupiter-tools/spring-test-elasticsearch/ -->
<dependency>
    <groupId>com.jupiter-tools</groupId>
    <artifactId>spring-test-elasticsearch</artifactId>
    <version>0.1</version>
</dependency>
// https://jarcasting.com/artifacts/com.jupiter-tools/spring-test-elasticsearch/
implementation 'com.jupiter-tools:spring-test-elasticsearch:0.1'
// https://jarcasting.com/artifacts/com.jupiter-tools/spring-test-elasticsearch/
implementation ("com.jupiter-tools:spring-test-elasticsearch:0.1")
'com.jupiter-tools:spring-test-elasticsearch:jar:0.1'
<dependency org="com.jupiter-tools" name="spring-test-elasticsearch" rev="0.1">
  <artifact name="spring-test-elasticsearch" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.jupiter-tools', module='spring-test-elasticsearch', version='0.1')
)
libraryDependencies += "com.jupiter-tools" % "spring-test-elasticsearch" % "0.1"
[com.jupiter-tools/spring-test-elasticsearch "0.1"]

Dependencies

compile (4)

Group / Artifact Type Version
org.springframework.boot : spring-boot-starter jar
org.springframework.boot : spring-boot-starter-test jar
org.testcontainers : elasticsearch jar 1.12.3
org.springframework.boot : spring-boot-starter-data-elasticsearch jar

Project Modules

There are no modules declared in this project.

Spring Test Elasticsearch

Tools to write integration tests of Spring Framework with the Elasticsearch.

How to write integration tests on Spring Boot with Elasticsearch in docker

Add this library in dependencies:

<dependency>
    <groupId>com.jupiter-tools</groupId>
    <artifactId>spring-test-elasticsearch</artifactId>
    <version>0.1</version>
</dependency>

Now, you can start the Elasticsearch cluster in a docker container(TestContainers) by the using of @ElasticsearchTestContainer annotation in tests:

@ElasticsearchTestContainer
@SpringBootTest
class SpTestElasticTestAppApplicationTests {

    @Autowired
    private ElasticsearchTemplate elasticsearchTemplate;

    @BeforeAll
    static void setUp() {
        // populate a data set in index
    }

    @Test
    void findTest() {
       var query = GetQuery.getById("100123");
       Foo foo = elasticsearchTemplate.queryForObject(query, Foo.class);
       assertThat(foo).isNotNull();
    }
}
com.jupiter-tools

Versions

Version
0.1