-
Notifications
You must be signed in to change notification settings - Fork 2.5k
/
HibernateSearchElasticsearchDevServicesEnabledImplicitlyTest.java
76 lines (62 loc) · 2.89 KB
/
HibernateSearchElasticsearchDevServicesEnabledImplicitlyTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package io.quarkus.it.hibernate.search.orm.elasticsearch.devservices;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.is;
import java.util.List;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledOnOs;
import org.junit.jupiter.api.condition.OS;
import io.quarkus.test.common.DevServicesContext;
import io.quarkus.test.junit.QuarkusTest;
import io.quarkus.test.junit.QuarkusTestProfile;
import io.quarkus.test.junit.TestProfile;
import io.restassured.RestAssured;
@QuarkusTest
@DisabledOnOs(OS.WINDOWS)
@TestProfile(HibernateSearchElasticsearchDevServicesEnabledImplicitlyTest.Profile.class)
public class HibernateSearchElasticsearchDevServicesEnabledImplicitlyTest {
public static class Profile implements QuarkusTestProfile {
@Override
public String getConfigProfile() {
// Don't use %test properties;
// that way, we can control whether quarkus.hibernate-search-orm.elasticsearch.hosts is set or not.
// In this test, we do NOT set quarkus.hibernate-search-orm.elasticsearch.hosts.
return "someotherprofile";
}
@Override
public List<TestResourceEntry> testResources() {
// Enables injection of DevServicesContext
return List.of(new TestResourceEntry(DevServicesContextSpy.class));
}
}
DevServicesContext context;
@Test
public void testDevServicesProperties() {
assertThat(context.devServicesProperties())
.containsKey("quarkus.hibernate-search-orm.elasticsearch.hosts");
assertThat(context.devServicesProperties().get("quarkus.hibernate-search-orm.elasticsearch.hosts"))
.isNotEmpty()
.isNotEqualTo("localhost:9200");
}
@Test
public void testHibernateSearch() {
RestAssured.when().get("/test/dev-services/hosts").then()
.statusCode(200)
.body(is(context.devServicesProperties().get("quarkus.hibernate-search-orm.elasticsearch.hosts")));
RestAssured.when().get("/test/dev-services/schema-management-strategy").then()
.statusCode(200)
// If the value is drop-and-create, this would indicate we're using the %test profile:
// that would be a bug in this test (see the Profile class above).
.body(is("drop-and-create-and-drop"));
RestAssured.when().get("/test/dev-services/count").then()
.statusCode(200)
.body(is("0"));
RestAssured.when().put("/test/dev-services/init-data").then()
.statusCode(204);
RestAssured.when().put("/test/hibernate-search/refresh").then()
.statusCode(200)
.body(is("OK"));
RestAssured.when().get("/test/dev-services/count").then()
.statusCode(200)
.body(is("1"));
}
}