diff --git a/modules/services/searching/pom.xml b/modules/services/searching/pom.xml index 6b52e72d..cdd427f5 100644 --- a/modules/services/searching/pom.xml +++ b/modules/services/searching/pom.xml @@ -135,6 +135,13 @@ org.springframework.boot spring-boot-starter-test + + + com.h2database + h2 + test + + diff --git a/modules/services/searching/src/main/java/org/fao/geonet/searching/controller/XsltSearchController.java b/modules/services/searching/src/main/java/org/fao/geonet/searching/controller/XsltSearchController.java index 1c74326c..fe74b236 100644 --- a/modules/services/searching/src/main/java/org/fao/geonet/searching/controller/XsltSearchController.java +++ b/modules/services/searching/src/main/java/org/fao/geonet/searching/controller/XsltSearchController.java @@ -28,6 +28,8 @@ description = "Proxy for ElasticSearch catalog search operations") @Controller public class XsltSearchController { + + public @Autowired ElasticSearchProxy proxy; diff --git a/modules/services/searching/src/test/java/org/fao/geonet/searching/MainSearchTest.java b/modules/services/searching/src/test/java/org/fao/geonet/searching/MainSearchTest.java new file mode 100644 index 00000000..d322f873 --- /dev/null +++ b/modules/services/searching/src/test/java/org/fao/geonet/searching/MainSearchTest.java @@ -0,0 +1,43 @@ +/** + * (c) 2020 Open Source Geospatial Foundation - all rights reserved This code is licensed under the + * GPL 2.0 license, available at the root application directory. + */ + +package org.fao.geonet.searching; + +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; +import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +import org.fao.geonet.common.search.ElasticSearchProxy; +import org.fao.geonet.searching.controller.XsltSearchController; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mockito; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.web.servlet.MockMvc; + +@RunWith(SpringRunner.class) +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +@AutoConfigureMockMvc +@AutoConfigureTestDatabase +public class MainSearchTest { + + @Autowired + private MockMvc mockMvc; + + @Autowired + private XsltSearchController xsltSearchController; + + @Test + public void nominal() throws Exception { + xsltSearchController.proxy = Mockito.mock(ElasticSearchProxy.class); + this.mockMvc.perform(post("/portal/api/search/records/xslt")).andDo(print()).andExpect(status().isOk()); + } + + +}