diff --git a/components/api/api-core/src/test/java/org/eclipse/dirigible/components/api/core/CoreSuiteTest.java b/components/api/api-core/src/test/java/org/eclipse/dirigible/components/api/core/CoreSuiteTest.java index 2bb4a66d006..5e727a790ec 100644 --- a/components/api/api-core/src/test/java/org/eclipse/dirigible/components/api/core/CoreSuiteTest.java +++ b/components/api/api-core/src/test/java/org/eclipse/dirigible/components/api/core/CoreSuiteTest.java @@ -12,13 +12,14 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + import org.eclipse.dirigible.components.engine.javascript.service.JavascriptService; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.security.test.context.support.WithMockUser; @@ -33,14 +34,17 @@ @ComponentScan(basePackages = {"org.eclipse.dirigible.components.*"}) public class CoreSuiteTest { + @Autowired + protected WebApplicationContext wac; @Autowired private JavascriptService javascriptService; - @Autowired private MockMvc mockMvc; - @Autowired - protected WebApplicationContext wac; + + @SpringBootApplication + static class TestConfiguration { + } @Test public void executeConfigurationGetTest() throws Exception { @@ -89,8 +93,4 @@ public void executeDestinationsGetTest() throws Exception { .andDo(print()) .andExpect(status().is2xxSuccessful()); } - - @SpringBootApplication - static class TestConfiguration { - } } diff --git a/components/api/api-database/src/test/java/org/eclipse/dirigible/components/api/db/DatabaseSuiteTest.java b/components/api/api-database/src/test/java/org/eclipse/dirigible/components/api/db/DatabaseSuiteTest.java index f122e81744d..a0d6f9b385b 100644 --- a/components/api/api-database/src/test/java/org/eclipse/dirigible/components/api/db/DatabaseSuiteTest.java +++ b/components/api/api-database/src/test/java/org/eclipse/dirigible/components/api/db/DatabaseSuiteTest.java @@ -24,7 +24,7 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.security.test.context.support.WithMockUser; @@ -45,24 +45,28 @@ @TestInstance(Lifecycle.PER_CLASS) public class DatabaseSuiteTest { + /** The wac. */ + @Autowired + protected WebApplicationContext wac; /** The datasource repository. */ @Autowired private DataSourceRepository datasourceRepository; - @Autowired private DataSourcesManager datasourcesManager; - /** The javascript service. */ @Autowired private JavascriptService javascriptService; - /** The mock mvc. */ @Autowired private MockMvc mockMvc; - /** The wac. */ - @Autowired - protected WebApplicationContext wac; + + /** + * The Class TestConfiguration. + */ + @SpringBootApplication + static class TestConfiguration { + } /** * Setup. @@ -123,12 +127,4 @@ public void executeUpdateTest() throws Exception { public void executeSequenceTest() throws Exception { javascriptService.handleRequest("db-tests", "sequence-nextval.js", null, null, false); } - - - /** - * The Class TestConfiguration. - */ - @SpringBootApplication - static class TestConfiguration { - } } diff --git a/components/api/api-database/src/test/java/org/eclipse/dirigible/components/api/db/TestConfig.java b/components/api/api-database/src/test/java/org/eclipse/dirigible/components/api/db/TestConfig.java index 47fa3f90adc..3f65c1483d5 100644 --- a/components/api/api-database/src/test/java/org/eclipse/dirigible/components/api/db/TestConfig.java +++ b/components/api/api-database/src/test/java/org/eclipse/dirigible/components/api/db/TestConfig.java @@ -14,15 +14,15 @@ import org.eclipse.dirigible.components.base.tenant.TenantContext; import org.mockito.Mockito; import org.springframework.boot.test.context.TestConfiguration; -import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.context.annotation.Bean; +import org.springframework.test.context.bean.override.mockito.MockitoBean; import static org.mockito.Mockito.when; @TestConfiguration public class TestConfig { - @MockBean + @MockitoBean @DefaultTenant private Tenant defaultTenant; diff --git a/components/api/api-etcd/src/test/java/org/eclipse/dirigible/componenets/api/etcd/EtcdFacadeTest.java b/components/api/api-etcd/src/test/java/org/eclipse/dirigible/componenets/api/etcd/EtcdFacadeTest.java index af031b09268..17db5dc7f45 100644 --- a/components/api/api-etcd/src/test/java/org/eclipse/dirigible/componenets/api/etcd/EtcdFacadeTest.java +++ b/components/api/api-etcd/src/test/java/org/eclipse/dirigible/componenets/api/etcd/EtcdFacadeTest.java @@ -21,7 +21,7 @@ import org.junit.jupiter.api.TestInstance; import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.RegisterExtension; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.security.test.context.support.WithMockUser; diff --git a/components/api/api-extensions/src/test/java/org/eclipse/dirigible/components/api/extensions/ExtensionsSuiteTest.java b/components/api/api-extensions/src/test/java/org/eclipse/dirigible/components/api/extensions/ExtensionsSuiteTest.java index 09527fe39c6..5cd6b251e6e 100644 --- a/components/api/api-extensions/src/test/java/org/eclipse/dirigible/components/api/extensions/ExtensionsSuiteTest.java +++ b/components/api/api-extensions/src/test/java/org/eclipse/dirigible/components/api/extensions/ExtensionsSuiteTest.java @@ -24,7 +24,7 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.security.test.context.support.WithMockUser; @@ -39,20 +39,21 @@ @ComponentScan(basePackages = {"org.eclipse.dirigible.components.*"}) public class ExtensionsSuiteTest { + @Autowired + protected WebApplicationContext wac; @Autowired private ExtensionPointRepository extensionPointRepository; - @Autowired private ExtensionRepository extensionRepository; - @Autowired private JavascriptService javascriptService; - @Autowired private MockMvc mockMvc; - @Autowired - protected WebApplicationContext wac; + + @SpringBootApplication + static class TestConfiguration { + } @BeforeEach public void setup() throws Exception { @@ -72,6 +73,16 @@ public void cleanup() throws Exception { extensionRepository.deleteAll(); } + public static ExtensionPoint createExtensionPoint(String location, String name, String description) { + ExtensionPoint extensionPoint = new ExtensionPoint(location, name, description); + return extensionPoint; + } + + public static Extension createExtension(String location, String name, String description, String extensionPoint, String module) { + Extension extension = new Extension(location, name, description, extensionPoint, module, null); + return extension; + } + @Test public void executeExtensionsTest() throws Exception { javascriptService.handleRequest("extensions-tests", "extensions-get-extension-points.js", null, null, false); @@ -87,18 +98,4 @@ public void executeExtensionsMockTest() throws Exception { .andDo(print()) .andExpect(status().is2xxSuccessful()); } - - public static ExtensionPoint createExtensionPoint(String location, String name, String description) { - ExtensionPoint extensionPoint = new ExtensionPoint(location, name, description); - return extensionPoint; - } - - public static Extension createExtension(String location, String name, String description, String extensionPoint, String module) { - Extension extension = new Extension(location, name, description, extensionPoint, module, null); - return extension; - } - - @SpringBootApplication - static class TestConfiguration { - } } diff --git a/components/api/api-git/src/test/java/org/eclipse/dirigible/components/api/git/GitFacadeTest.java b/components/api/api-git/src/test/java/org/eclipse/dirigible/components/api/git/GitFacadeTest.java index f6098e41edb..7188a00a5cc 100644 --- a/components/api/api-git/src/test/java/org/eclipse/dirigible/components/api/git/GitFacadeTest.java +++ b/components/api/api-git/src/test/java/org/eclipse/dirigible/components/api/git/GitFacadeTest.java @@ -33,7 +33,7 @@ import org.junit.jupiter.api.TestInstance.Lifecycle; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.security.test.context.support.WithMockUser; @@ -53,23 +53,23 @@ @TestInstance(Lifecycle.PER_CLASS) public class GitFacadeTest { + /** The gson. */ + private final Gson gson = new Gson(); /** The username. */ private String username = "dirigible"; - /** The email. */ private String email = "dirigible@eclipse.com"; - /** The project name. */ private String projectName = "project1"; - /** The workspace name. */ private String workspaceName = "workspace"; - /** The repository. */ private String repository = "project1-repo"; - /** The gson. */ - private final Gson gson = new Gson(); + + @SpringBootApplication + static class TestConfiguration { + } /** * Test init repository and commit. @@ -126,9 +126,5 @@ private void assertProjectJsonExists(Project project) { assertEquals(1, parsedProjectJsonContent.size()); } - @SpringBootApplication - static class TestConfiguration { - } - } diff --git a/components/api/api-git/src/test/java/org/eclipse/dirigible/components/api/git/GitSuiteTest.java b/components/api/api-git/src/test/java/org/eclipse/dirigible/components/api/git/GitSuiteTest.java index ab785fd82e6..64651853194 100644 --- a/components/api/api-git/src/test/java/org/eclipse/dirigible/components/api/git/GitSuiteTest.java +++ b/components/api/api-git/src/test/java/org/eclipse/dirigible/components/api/git/GitSuiteTest.java @@ -16,7 +16,7 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.security.test.context.support.WithMockUser; @@ -32,21 +32,20 @@ @TestInstance(Lifecycle.PER_CLASS) public class GitSuiteTest { + @Autowired + protected WebApplicationContext wac; @Autowired private JavascriptService javascriptService; - @Autowired private MockMvc mockMvc; - @Autowired - protected WebApplicationContext wac; + + @SpringBootApplication + static class TestConfiguration { + } @Test public void executeGitTest() throws Exception { javascriptService.handleRequest("git-tests", "git-local.js", null, null, false); } - - @SpringBootApplication - static class TestConfiguration { - } } diff --git a/components/api/api-http/src/test/java/org/eclipse/dirigible/componenets/api/http/HttpSuiteTest.java b/components/api/api-http/src/test/java/org/eclipse/dirigible/componenets/api/http/HttpSuiteTest.java index 111b7ae5949..d1793a964e4 100644 --- a/components/api/api-http/src/test/java/org/eclipse/dirigible/componenets/api/http/HttpSuiteTest.java +++ b/components/api/api-http/src/test/java/org/eclipse/dirigible/componenets/api/http/HttpSuiteTest.java @@ -19,7 +19,7 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; @@ -50,18 +50,61 @@ @ComponentScan(basePackages = {"org.eclipse.dirigible.components.*"}) public class HttpSuiteTest { + @Autowired + protected WebApplicationContext context; @Autowired private JavascriptService javascriptService; - @Autowired private MockMvc mockMvc; - - @Autowired - protected WebApplicationContext context; - @Autowired private Filter springSecurityFilterChain; + + @Configuration + static class Config { + @Autowired + HttpResponseHeaderHandlerFilter httpResponseHeaderHandlerFilter; + + @Autowired + public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { + auth.inMemoryAuthentication() + .withUser("user") + .password("password") + .roles("ROLE"); + } + + @Bean + PasswordEncoder passwordEncoder() { + return NoOpPasswordEncoder.getInstance(); + } + + } + + + static class HttpResponseHeaderHandlerFilter extends OncePerRequestFilter { + + @Override + protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) + throws ServletException, IOException { + + response.setHeader("header1", "val1"); + response.setHeader("header2", "val2"); + + filterChain.doFilter(request, response); + } + } + + + @SpringBootApplication + static class TestConfiguration { + + @Bean + HttpResponseHeaderHandlerFilter getHttpResponseHeaderHandlerFilter() { + return new HttpResponseHeaderHandlerFilter(); + } + + } + @Test public void executeClientTest() throws Exception { javascriptService.handleRequest("http-tests", "client-get.js", null, null, false); @@ -155,49 +198,4 @@ public void executeSessionTest() throws Exception { .andDo(print()) .andExpect(status().is2xxSuccessful()); } - - @Configuration - static class Config { - @Autowired - public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { - auth.inMemoryAuthentication() - .withUser("user") - .password("password") - .roles("ROLE"); - } - - @Bean - PasswordEncoder passwordEncoder() { - return NoOpPasswordEncoder.getInstance(); - } - - @Autowired - HttpResponseHeaderHandlerFilter httpResponseHeaderHandlerFilter; - - } - - - static class HttpResponseHeaderHandlerFilter extends OncePerRequestFilter { - - @Override - protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) - throws ServletException, IOException { - - response.setHeader("header1", "val1"); - response.setHeader("header2", "val2"); - - filterChain.doFilter(request, response); - } - } - - - @SpringBootApplication - static class TestConfiguration { - - @Bean - HttpResponseHeaderHandlerFilter getHttpResponseHeaderHandlerFilter() { - return new HttpResponseHeaderHandlerFilter(); - } - - } } diff --git a/components/api/api-indexing/src/test/java/org/eclipse/dirigible/components/api/indexing/IndexingSuiteTest.java b/components/api/api-indexing/src/test/java/org/eclipse/dirigible/components/api/indexing/IndexingSuiteTest.java index cda128e66d8..fa4bc6f0ce0 100644 --- a/components/api/api-indexing/src/test/java/org/eclipse/dirigible/components/api/indexing/IndexingSuiteTest.java +++ b/components/api/api-indexing/src/test/java/org/eclipse/dirigible/components/api/indexing/IndexingSuiteTest.java @@ -14,7 +14,7 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.test.context.ContextConfiguration; @@ -30,11 +30,15 @@ @ComponentScan(basePackages = {"org.eclipse.dirigible.components.*"}) public class IndexingSuiteTest { + @Autowired + protected WebApplicationContext context; @Autowired private JavascriptService javascriptService; - @Autowired - protected WebApplicationContext context; + + @SpringBootApplication + static class TestConfiguration { + } @Test public void executeClientTest() throws Exception { @@ -42,8 +46,4 @@ public void executeClientTest() throws Exception { javascriptService.handleRequest("indexing-tests", "searcher-search.js", null, null, false); javascriptService.handleRequest("indexing-tests", "writer-add.js", null, null, false); } - - @SpringBootApplication - static class TestConfiguration { - } } diff --git a/components/api/api-indexing/src/test/java/org/eclipse/dirigible/components/api/indexing/service/IndexingServiceTest.java b/components/api/api-indexing/src/test/java/org/eclipse/dirigible/components/api/indexing/service/IndexingServiceTest.java index d771c31408a..e99a04e91ef 100644 --- a/components/api/api-indexing/src/test/java/org/eclipse/dirigible/components/api/indexing/service/IndexingServiceTest.java +++ b/components/api/api-indexing/src/test/java/org/eclipse/dirigible/components/api/indexing/service/IndexingServiceTest.java @@ -22,7 +22,7 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.test.context.ContextConfiguration; diff --git a/components/api/api-io/src/test/java/org/eclipse/dirigible/componenets/api/io/IOSuiteTest.java b/components/api/api-io/src/test/java/org/eclipse/dirigible/componenets/api/io/IOSuiteTest.java index f65ed1ad6c7..ef5e63b82b3 100644 --- a/components/api/api-io/src/test/java/org/eclipse/dirigible/componenets/api/io/IOSuiteTest.java +++ b/components/api/api-io/src/test/java/org/eclipse/dirigible/componenets/api/io/IOSuiteTest.java @@ -14,7 +14,7 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.security.test.context.support.WithMockUser; @@ -29,19 +29,16 @@ @ComponentScan(basePackages = {"org.eclipse.dirigible.components.*"}) public class IOSuiteTest { + @Autowired + protected WebApplicationContext wac; @Autowired private JavascriptService javascriptService; - @Autowired private MockMvc mockMvc; - @Autowired - protected WebApplicationContext wac; - @Test - public void executeFilesTest() throws Exception { - javascriptService.handleRequest("io-tests", "files-create-temp-file.js", null, null, false); - javascriptService.handleRequest("io-tests", "files-file-streams.js", null, null, false); + @SpringBootApplication + static class TestConfiguration { } // @Test @@ -49,13 +46,15 @@ public void executeFilesTest() throws Exception { // javascriptService.handleRequest("io-tests", "ftp-get-file.js", null, null, false); // } + @Test + public void executeFilesTest() throws Exception { + javascriptService.handleRequest("io-tests", "files-create-temp-file.js", null, null, false); + javascriptService.handleRequest("io-tests", "files-file-streams.js", null, null, false); + } + @Test public void executeStreamsTest() throws Exception { javascriptService.handleRequest("io-tests", "streams-copy.js", null, null, false); javascriptService.handleRequest("io-tests", "streams-text.js", null, null, false); } - - @SpringBootApplication - static class TestConfiguration { - } } diff --git a/components/api/api-mail/pom.xml b/components/api/api-mail/pom.xml index 1a5cb9e1fc2..9b2da56909c 100644 --- a/components/api/api-mail/pom.xml +++ b/components/api/api-mail/pom.xml @@ -1,54 +1,58 @@ - 4.0.0 - - - org.eclipse.dirigible - dirigible-components-parent - 13.0.0-SNAPSHOT - ../../pom.xml - - - Components - API - Mail - dirigible-components-api-mail - jar - - - - org.springframework.boot - spring-boot-starter-mail - - - - - org.eclipse.dirigible - dirigible-components-api-modules-javascript - - - - - org.eclipse.dirigible - dirigible-commons-helpers - - - - org.eclipse.dirigible - dirigible-commons-config - - - - - org.eclipse.dirigible - dirigible-components-api-test - - - - - - ../../../licensing-header.txt - ../../../ - + xmlns="http://maven.apache.org/POM/4.0.0" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 + + + org.eclipse.dirigible + dirigible-components-parent + 13.0.0-SNAPSHOT + ../../pom.xml + + + Components - API - Mail + dirigible-components-api-mail + jar + + + + org.eclipse.angus + angus-mail + + + org.springframework.boot + spring-boot-starter-mail + + + + + org.eclipse.dirigible + dirigible-components-api-modules-javascript + + + + + org.eclipse.dirigible + dirigible-commons-helpers + + + + org.eclipse.dirigible + dirigible-commons-config + + + + + org.eclipse.dirigible + dirigible-components-api-test + + + + + + ../../../licensing-header.txt + ../../../ + diff --git a/components/api/api-net/pom.xml b/components/api/api-net/pom.xml index 5e78ddd7cbd..ad04bcabd27 100644 --- a/components/api/api-net/pom.xml +++ b/components/api/api-net/pom.xml @@ -1,41 +1,46 @@ - - 4.0.0 - - - org.eclipse.dirigible - dirigible-components-parent - 13.0.0-SNAPSHOT - ../../pom.xml - - - Components - API - Net - dirigible-components-api-net - jar - - - - - org.eclipse.dirigible - dirigible-components-api-modules-javascript - - - - - org.eclipse.dirigible - dirigible-components-core-repository - - - - - org.eclipse.dirigible - dirigible-components-engine-javascript - - - - - - ../../../licensing-header.txt - ../../../ - - - \ No newline at end of file + + 4.0.0 + + + org.eclipse.dirigible + dirigible-components-parent + 13.0.0-SNAPSHOT + ../../pom.xml + + + Components - API - Net + dirigible-components-api-net + jar + + + + org.springframework + spring-messaging + + + + org.eclipse.dirigible + dirigible-components-api-modules-javascript + + + + + org.eclipse.dirigible + dirigible-components-core-repository + + + + + org.eclipse.dirigible + dirigible-components-engine-javascript + + + + + + ../../../licensing-header.txt + ../../../ + + + diff --git a/components/api/api-net/src/main/java/org/eclipse/dirigible/components/api/websockets/WebsocketClient.java b/components/api/api-net/src/main/java/org/eclipse/dirigible/components/api/websockets/WebsocketClient.java index 85f9396f5ca..41f31682e42 100644 --- a/components/api/api-net/src/main/java/org/eclipse/dirigible/components/api/websockets/WebsocketClient.java +++ b/components/api/api-net/src/main/java/org/eclipse/dirigible/components/api/websockets/WebsocketClient.java @@ -9,19 +9,7 @@ */ package org.eclipse.dirigible.components.api.websockets; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.concurrent.ExecutionException; - -import jakarta.websocket.ClientEndpoint; -import jakarta.websocket.OnClose; -import jakarta.websocket.OnError; -import jakarta.websocket.OnMessage; -import jakarta.websocket.OnOpen; -import jakarta.websocket.Session; - +import jakarta.websocket.*; import org.eclipse.dirigible.components.engine.javascript.service.JavascriptService; import org.eclipse.dirigible.repository.api.RepositoryPath; import org.slf4j.Logger; @@ -29,7 +17,6 @@ import org.springframework.messaging.converter.MappingJackson2MessageConverter; import org.springframework.messaging.simp.stomp.StompSession; import org.springframework.messaging.simp.stomp.StompSessionHandler; -import org.springframework.web.socket.client.WebSocketClient; import org.springframework.web.socket.client.standard.StandardWebSocketClient; import org.springframework.web.socket.messaging.WebSocketStompClient; import org.springframework.web.socket.sockjs.client.RestTemplateXhrTransport; @@ -37,6 +24,12 @@ import org.springframework.web.socket.sockjs.client.Transport; import org.springframework.web.socket.sockjs.client.WebSocketTransport; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ExecutionException; + /** * The Class WebsocketClient. */ @@ -44,20 +37,16 @@ public class WebsocketClient { /** The logger. */ - private static Logger logger = LoggerFactory.getLogger(WebsocketClient.class); - + private static final Logger logger = LoggerFactory.getLogger(WebsocketClient.class); + /** The javascript service. */ + private final JavascriptService javascriptService; /** The uri. */ - private String uri; - + private final String uri; /** The handler. */ - private String handler; - + private final String handler; /** The session. */ private StompSession session; - /** The javascript service. */ - private final JavascriptService javascriptService; - /** * Instantiates a new websocket client. * @@ -85,7 +74,7 @@ public StompSession connect() throws InterruptedException, ExecutionException { WebSocketStompClient stompClient = new WebSocketStompClient(new SockJsClient(transports)); stompClient.setMessageConverter(new MappingJackson2MessageConverter()); StompSessionHandler sessionHandler = new ClientStompSessionHandler(); - session = stompClient.connect(uri, sessionHandler) + session = stompClient.connectAsync(uri, sessionHandler) .get(); return session; } @@ -99,15 +88,6 @@ public String getUri() { return uri; } - /** - * Gets the javascript service. - * - * @return the javascript service - */ - public JavascriptService getJavascriptService() { - return javascriptService; - } - /** * Gets the handler. * @@ -143,6 +123,15 @@ public void onOpen(StompSession session) throws Exception { getJavascriptService().handleRequest(path.getSegments()[0], path.constructPathFrom(1), null, context, false); } + /** + * Gets the javascript service. + * + * @return the javascript service + */ + public JavascriptService getJavascriptService() { + return javascriptService; + } + /** * Process message. * diff --git a/components/api/api-platform/src/test/java/org/eclipse/dirigible/components/api/platform/PlatformSuiteTest.java b/components/api/api-platform/src/test/java/org/eclipse/dirigible/components/api/platform/PlatformSuiteTest.java index f39037c6190..7b5e49e391f 100644 --- a/components/api/api-platform/src/test/java/org/eclipse/dirigible/components/api/platform/PlatformSuiteTest.java +++ b/components/api/api-platform/src/test/java/org/eclipse/dirigible/components/api/platform/PlatformSuiteTest.java @@ -16,7 +16,7 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.security.test.context.support.WithMockUser; @@ -32,14 +32,17 @@ @TestInstance(Lifecycle.PER_CLASS) public class PlatformSuiteTest { + @Autowired + protected WebApplicationContext wac; @Autowired private JavascriptService javascriptService; - @Autowired private MockMvc mockMvc; - @Autowired - protected WebApplicationContext wac; + + @SpringBootApplication + static class TestConfiguration { + } @Test public void executePlatformTest() throws Exception { @@ -49,8 +52,4 @@ public void executePlatformTest() throws Exception { javascriptService.handleRequest("platform-tests", "workspace-create-workspace.js", null, null, false); javascriptService.handleRequest("platform-tests", "command-execute.js", null, null, false); } - - @SpringBootApplication - static class TestConfiguration { - } } diff --git a/components/api/api-platform/src/test/java/org/eclipse/dirigible/components/api/platform/TestConfig.java b/components/api/api-platform/src/test/java/org/eclipse/dirigible/components/api/platform/TestConfig.java index 023d217ccb1..68a58a7080c 100644 --- a/components/api/api-platform/src/test/java/org/eclipse/dirigible/components/api/platform/TestConfig.java +++ b/components/api/api-platform/src/test/java/org/eclipse/dirigible/components/api/platform/TestConfig.java @@ -13,15 +13,15 @@ import org.eclipse.dirigible.components.base.tenant.Tenant; import org.eclipse.dirigible.components.base.tenant.TenantContext; import org.springframework.boot.test.context.TestConfiguration; -import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.test.context.bean.override.mockito.MockitoBean; @TestConfiguration public class TestConfig { - @MockBean + @MockitoBean private TenantContext tenantContext; - @MockBean + @MockitoBean @DefaultTenant private Tenant defaultTenant; } diff --git a/components/api/api-rabbitmq/pom.xml b/components/api/api-rabbitmq/pom.xml index 937f2e74977..a8759b6c88f 100644 --- a/components/api/api-rabbitmq/pom.xml +++ b/components/api/api-rabbitmq/pom.xml @@ -1,5 +1,5 @@ - 4.0.0 @@ -64,12 +64,12 @@ org.testcontainers - junit-jupiter + testcontainers-junit-jupiter test org.testcontainers - rabbitmq + testcontainers-rabbitmq test diff --git a/components/api/api-redis/pom.xml b/components/api/api-redis/pom.xml index 9f860454cc1..b03e1e6bd14 100644 --- a/components/api/api-redis/pom.xml +++ b/components/api/api-redis/pom.xml @@ -42,7 +42,7 @@ org.testcontainers - junit-jupiter + testcontainers-junit-jupiter test diff --git a/components/api/api-test/src/test/java/org/eclipse/dirigible/components/api/test/APIAssertTest.java b/components/api/api-test/src/test/java/org/eclipse/dirigible/components/api/test/APIAssertTest.java index 785e38111a1..f38068a473b 100644 --- a/components/api/api-test/src/test/java/org/eclipse/dirigible/components/api/test/APIAssertTest.java +++ b/components/api/api-test/src/test/java/org/eclipse/dirigible/components/api/test/APIAssertTest.java @@ -14,7 +14,7 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.security.test.context.support.WithMockUser; diff --git a/components/api/api-test/src/test/java/org/eclipse/dirigible/components/api/test/ForbiddenTest.java b/components/api/api-test/src/test/java/org/eclipse/dirigible/components/api/test/ForbiddenTest.java index 7a891a076eb..46a75ea2ce6 100644 --- a/components/api/api-test/src/test/java/org/eclipse/dirigible/components/api/test/ForbiddenTest.java +++ b/components/api/api-test/src/test/java/org/eclipse/dirigible/components/api/test/ForbiddenTest.java @@ -16,7 +16,7 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.test.web.servlet.MockMvc; @@ -27,11 +27,15 @@ @ComponentScan(basePackages = {"org.eclipse.dirigible.components.*"}) public class ForbiddenTest { + @Autowired + protected WebApplicationContext wac; @Autowired private MockMvc mockMvc; - @Autowired - protected WebApplicationContext wac; + + @SpringBootApplication + static class TestConfiguration { + } @Test public void forbidden() throws Exception { @@ -39,8 +43,4 @@ public void forbidden() throws Exception { .andDo(print()) .andExpect(status().is4xxClientError()); } - - @SpringBootApplication - static class TestConfiguration { - } } diff --git a/components/api/api-utils/src/test/java/org/eclipse/dirigible/components/api/utils/UtilsSuiteTest.java b/components/api/api-utils/src/test/java/org/eclipse/dirigible/components/api/utils/UtilsSuiteTest.java index 24f1640856d..c0fec456869 100644 --- a/components/api/api-utils/src/test/java/org/eclipse/dirigible/components/api/utils/UtilsSuiteTest.java +++ b/components/api/api-utils/src/test/java/org/eclipse/dirigible/components/api/utils/UtilsSuiteTest.java @@ -14,7 +14,7 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.security.test.context.support.WithMockUser; @@ -29,14 +29,13 @@ @ComponentScan(basePackages = {"org.eclipse.dirigible.components.*"}) public class UtilsSuiteTest { + @Autowired + protected WebApplicationContext wac; @Autowired private JavascriptService javascriptService; - @Autowired private MockMvc mockMvc; - @Autowired - protected WebApplicationContext wac; @SpringBootApplication static class TestConfiguration { diff --git a/components/core/core-configurations/src/test/java/org/eclipse/dirigible/components/configurations/endpoint/ConfigurationsEndpointTest.java b/components/core/core-configurations/src/test/java/org/eclipse/dirigible/components/configurations/endpoint/ConfigurationsEndpointTest.java index f58d8f650dc..27eeb8a3d24 100644 --- a/components/core/core-configurations/src/test/java/org/eclipse/dirigible/components/configurations/endpoint/ConfigurationsEndpointTest.java +++ b/components/core/core-configurations/src/test/java/org/eclipse/dirigible/components/configurations/endpoint/ConfigurationsEndpointTest.java @@ -15,7 +15,7 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; @@ -31,13 +31,6 @@ public class ConfigurationsEndpointTest { @Autowired private ConfigurationsService configurationsService; - /** - * Find all. - */ - @Test - public void findAll() { - assertNotNull(configurationsService.findAll()); - } /** * The Class TestConfiguration. @@ -45,4 +38,12 @@ public void findAll() { @SpringBootApplication static class TestConfiguration { } + + /** + * Find all. + */ + @Test + public void findAll() { + assertNotNull(configurationsService.findAll()); + } } diff --git a/components/core/core-database/src/main/java/org/eclipse/dirigible/components/database/DataSourceSystemConfig.java b/components/core/core-database/src/main/java/org/eclipse/dirigible/components/database/DataSourceSystemConfig.java index 3052a581b91..7e413c53b52 100644 --- a/components/core/core-database/src/main/java/org/eclipse/dirigible/components/database/DataSourceSystemConfig.java +++ b/components/core/core-database/src/main/java/org/eclipse/dirigible/components/database/DataSourceSystemConfig.java @@ -9,13 +9,13 @@ */ package org.eclipse.dirigible.components.database; -import java.util.Properties; -import javax.sql.DataSource; +import com.zaxxer.hikari.HikariDataSource; +import jakarta.persistence.EntityManagerFactory; import org.eclipse.dirigible.commons.config.Configuration; import org.eclipse.dirigible.commons.config.DirigibleConfig; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties; +import org.springframework.boot.jdbc.autoconfigure.DataSourceProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Primary; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; @@ -25,8 +25,9 @@ import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.annotation.EnableTransactionManagement; -import com.zaxxer.hikari.HikariDataSource; -import jakarta.persistence.EntityManagerFactory; + +import javax.sql.DataSource; +import java.util.Properties; /** * The Class DataSourceSystemConfig. diff --git a/components/core/core-extensions/src/test/java/org/eclipse/dirigible/components/extensions/endpoint/ExtensionPointEndpointTest.java b/components/core/core-extensions/src/test/java/org/eclipse/dirigible/components/extensions/endpoint/ExtensionPointEndpointTest.java index 2fd1d9ef893..4e1c3d11b44 100644 --- a/components/core/core-extensions/src/test/java/org/eclipse/dirigible/components/extensions/endpoint/ExtensionPointEndpointTest.java +++ b/components/core/core-extensions/src/test/java/org/eclipse/dirigible/components/extensions/endpoint/ExtensionPointEndpointTest.java @@ -27,7 +27,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.domain.EntityScan; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.data.domain.Page; @@ -54,33 +54,35 @@ @Transactional public class ExtensionPointEndpointTest { + /** The wac. */ + @Autowired + protected WebApplicationContext wac; /** The entity manager. */ @Autowired private EntityManager entityManager; - /** The extension point service. */ @Autowired private ExtensionPointService extensionPointService; - /** The extension point repository. */ @Autowired private ExtensionPointRepository extensionPointRepository; - /** The test extension point. */ private ExtensionPoint testExtensionPoint; - /** The mock mvc. */ @Autowired private MockMvc mockMvc; - - /** The wac. */ - @Autowired - protected WebApplicationContext wac; - /** The spring security filter chain. */ @Autowired private FilterChainProxy springSecurityFilterChain; + + /** + * The Class TestConfiguration. + */ + @SpringBootApplication + static class TestConfiguration { + } + /** * Setup. * @@ -189,11 +191,4 @@ public void getAllExtensionPoints() throws Exception { .andDo(print()) .andExpect(status().is2xxSuccessful()); } - - /** - * The Class TestConfiguration. - */ - @SpringBootApplication - static class TestConfiguration { - } } diff --git a/components/core/core-initializers/src/test/java/org/eclipse/dirigible/components/initializers/TestConfig.java b/components/core/core-initializers/src/test/java/org/eclipse/dirigible/components/initializers/TestConfig.java index 2621fa8bd44..1206ee27855 100644 --- a/components/core/core-initializers/src/test/java/org/eclipse/dirigible/components/initializers/TestConfig.java +++ b/components/core/core-initializers/src/test/java/org/eclipse/dirigible/components/initializers/TestConfig.java @@ -13,15 +13,15 @@ import org.eclipse.dirigible.components.base.tenant.Tenant; import org.eclipse.dirigible.components.base.tenant.TenantContext; import org.springframework.boot.test.context.TestConfiguration; -import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.test.context.bean.override.mockito.MockitoBean; @TestConfiguration public class TestConfig { - @MockBean + @MockitoBean private TenantContext tenantContext; - @MockBean + @MockitoBean @DefaultTenant private Tenant defaultTenant; } diff --git a/components/core/core-registry/src/test/java/org/eclipse/dirigible/components/registry/endpoint/RegistryEndpointTest.java b/components/core/core-registry/src/test/java/org/eclipse/dirigible/components/registry/endpoint/RegistryEndpointTest.java index 7b694a4818d..64cc38e263c 100644 --- a/components/core/core-registry/src/test/java/org/eclipse/dirigible/components/registry/endpoint/RegistryEndpointTest.java +++ b/components/core/core-registry/src/test/java/org/eclipse/dirigible/components/registry/endpoint/RegistryEndpointTest.java @@ -21,7 +21,7 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.security.test.context.support.WithMockUser; @@ -40,26 +40,30 @@ @ComponentScan(basePackages = {"org.eclipse.dirigible.components.*"}) public class RegistryEndpointTest { + /** The wac. */ + @Autowired + protected WebApplicationContext wac; /** The repository. */ @Autowired private IRepository repository; - /** The registry service. */ @Autowired private RegistryService registryService; - /** The mock mvc. */ @Autowired private MockMvc mockMvc; - - /** The wac. */ - @Autowired - protected WebApplicationContext wac; - /** The spring security filter chain. */ @Autowired private FilterChainProxy springSecurityFilterChain; + + /** + * The Class TestConfiguration. + */ + @SpringBootApplication + static class TestConfiguration { + } + /** * Setup. * @@ -94,11 +98,4 @@ public void getResourceByPath() throws Exception { .andDo(print()) .andExpect(status().is2xxSuccessful()); } - - /** - * The Class TestConfiguration. - */ - @SpringBootApplication - static class TestConfiguration { - } } diff --git a/components/core/core-tracing/src/test/java/org/eclipse/dirigible/components/tracing/TaskStateEndpointTest.java b/components/core/core-tracing/src/test/java/org/eclipse/dirigible/components/tracing/TaskStateEndpointTest.java index 483abfc8b2a..f375e4790bc 100644 --- a/components/core/core-tracing/src/test/java/org/eclipse/dirigible/components/tracing/TaskStateEndpointTest.java +++ b/components/core/core-tracing/src/test/java/org/eclipse/dirigible/components/tracing/TaskStateEndpointTest.java @@ -27,7 +27,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.domain.EntityScan; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.data.domain.Page; @@ -54,33 +54,35 @@ @Transactional public class TaskStateEndpointTest { + /** The wac. */ + @Autowired + protected WebApplicationContext wac; /** The entity manager. */ @Autowired private EntityManager entityManager; - /** The tracing service. */ @Autowired private TaskStateService taskStateService; - /** The tracing repository. */ @Autowired private TaskStateRepository taskStateRepository; - /** The test task state. */ private TaskState testTaskState; - /** The mock mvc. */ @Autowired private MockMvc mockMvc; - - /** The wac. */ - @Autowired - protected WebApplicationContext wac; - /** The spring security filter chain. */ @Autowired private FilterChainProxy springSecurityFilterChain; + + /** + * The Class TestConfiguration. + */ + @SpringBootApplication + static class TestConfiguration { + } + /** * Setup. * @@ -192,11 +194,4 @@ public void getAllTaskStates() throws Exception { .andDo(print()) .andExpect(status().is2xxSuccessful()); } - - /** - * The Class TestConfiguration. - */ - @SpringBootApplication - static class TestConfiguration { - } } diff --git a/components/core/core-version/src/test/java/org/eclipse/dirigible/components/version/endpoint/VersionEndpointTest.java b/components/core/core-version/src/test/java/org/eclipse/dirigible/components/version/endpoint/VersionEndpointTest.java index cedbf7b1b71..5b5f4ac73e2 100644 --- a/components/core/core-version/src/test/java/org/eclipse/dirigible/components/version/endpoint/VersionEndpointTest.java +++ b/components/core/core-version/src/test/java/org/eclipse/dirigible/components/version/endpoint/VersionEndpointTest.java @@ -14,7 +14,7 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.security.test.context.support.WithMockUser; diff --git a/components/data/data-csvim/src/main/java/org/eclipse/dirigible/components/data/csvim/domain/Csvim.java b/components/data/data-csvim/src/main/java/org/eclipse/dirigible/components/data/csvim/domain/Csvim.java index aa14b4fc202..c33a340634f 100644 --- a/components/data/data-csvim/src/main/java/org/eclipse/dirigible/components/data/csvim/domain/Csvim.java +++ b/components/data/data-csvim/src/main/java/org/eclipse/dirigible/components/data/csvim/domain/Csvim.java @@ -9,28 +9,16 @@ */ package org.eclipse.dirigible.components.data.csvim.domain; +import com.google.gson.annotations.Expose; +import jakarta.annotation.Nullable; +import jakarta.persistence.*; +import org.eclipse.dirigible.components.base.artefact.Artefact; + import java.util.ArrayList; import java.util.List; import java.util.Objects; import java.util.Optional; -import org.eclipse.dirigible.components.base.artefact.Artefact; -import org.hibernate.annotations.LazyCollection; -import org.hibernate.annotations.LazyCollectionOption; - -import com.google.gson.annotations.Expose; - -import jakarta.annotation.Nullable; -import jakarta.persistence.CascadeType; -import jakarta.persistence.Column; -import jakarta.persistence.Entity; -import jakarta.persistence.FetchType; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.GenerationType; -import jakarta.persistence.Id; -import jakarta.persistence.OneToMany; -import jakarta.persistence.Table; - /** * The Csvim Entity. */ @@ -38,131 +26,63 @@ @Table(name = "DIRIGIBLE_CSVIM") public class Csvim extends Artefact { - /** - * The Constant ARTEFACT_TYPE. - */ public static final String ARTEFACT_TYPE = "csvim"; - /** - * The id. - */ @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "CSVIM_ID", nullable = false) private Long id; - /** - * The version. - */ @Column(name = "CSVIM_VERSION", columnDefinition = "VARCHAR") @Expose private String version; - /** - * The datasource. - */ @Column(name = "CSVIM_DATASOURCE", columnDefinition = "VARCHAR") @Expose private String datasource; - /** - * The csv file definitions. - */ - @OneToMany(mappedBy = "csvim", fetch = FetchType.LAZY, cascade = CascadeType.ALL) - @LazyCollection(LazyCollectionOption.FALSE) + @OneToMany(mappedBy = "csvim", fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true) @Nullable @Expose - private List files = new ArrayList(); - - /** - * Instantiates a new csvim. - * - * @param id the id - * @param version the version - * @param files the files - */ + private List files = new ArrayList<>(); + public Csvim(Long id, String version, List files) { this.id = id; this.version = version; this.files = files; } - /** - * Instantiates a new csvim. - */ - public Csvim() { + public Csvim() {} - } - - /** - * Gets the id. - * - * @return get the id of csvim - */ public Long getId() { return id; } - /** - * Sets the id. - * - * @param id the id of the csvim - */ public void setId(Long id) { this.id = id; } - /** - * Gets the version. - * - * @return get the version of csvim - */ public String getVersion() { return version; } - /** - * Sets the version. - * - * @param version the version of the csvim - */ public void setVersion(String version) { this.version = version; } - /** - * Gets the datasource. - * - * @return the datasource - */ public String getDatasource() { return datasource; } - /** - * Sets the datasource. - * - * @param datasource the new datasource - */ public void setDatasource(String datasource) { this.datasource = datasource; } - /** - * Gets the files. - * - * @return get list of csvFiles - */ @Nullable public List getFiles() { return files; } - /** - * Sets the files. - * - * @param csvFile set list of csvFiles - */ public void setFiles(@Nullable List csvFile) { this.files = csvFile; } @@ -172,7 +92,6 @@ public Optional getFileByKey(String key) { return files.stream() .filter(f -> Objects.equals(key, f.getKey())) .findFirst(); - } return Optional.empty(); } diff --git a/components/data/data-export/src/test/java/org/eclipse/dirigible/components/data/export/TestConfig.java b/components/data/data-export/src/test/java/org/eclipse/dirigible/components/data/export/TestConfig.java index 6434c327810..731154bed31 100644 --- a/components/data/data-export/src/test/java/org/eclipse/dirigible/components/data/export/TestConfig.java +++ b/components/data/data-export/src/test/java/org/eclipse/dirigible/components/data/export/TestConfig.java @@ -14,15 +14,15 @@ import org.eclipse.dirigible.components.base.tenant.TenantContext; import org.mockito.Mockito; import org.springframework.boot.test.context.TestConfiguration; -import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.context.annotation.Bean; +import org.springframework.test.context.bean.override.mockito.MockitoBean; import static org.mockito.Mockito.when; @TestConfiguration public class TestConfig { - @MockBean + @MockitoBean @DefaultTenant private Tenant defaultTenant; diff --git a/components/data/data-export/src/test/java/org/eclipse/dirigible/components/data/export/endpoint/DataAsyncExportEndpointTest.java b/components/data/data-export/src/test/java/org/eclipse/dirigible/components/data/export/endpoint/DataAsyncExportEndpointTest.java index 10c46a883b7..f3de97669af 100644 --- a/components/data/data-export/src/test/java/org/eclipse/dirigible/components/data/export/endpoint/DataAsyncExportEndpointTest.java +++ b/components/data/data-export/src/test/java/org/eclipse/dirigible/components/data/export/endpoint/DataAsyncExportEndpointTest.java @@ -34,7 +34,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.domain.EntityScan; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.security.test.context.support.WithMockUser; @@ -55,25 +55,29 @@ @Transactional public class DataAsyncExportEndpointTest { + /** The wac. */ + @Autowired + protected WebApplicationContext wac; /** The datasource repository. */ @Autowired private DataSourceRepository datasourceRepository; - /** The cms service. */ @Autowired private ExportService exportService; - /** The cms service. */ @Autowired private CmsService cmsService; - /** The mock mvc. */ @Autowired private MockMvc mockMvc; - /** The wac. */ - @Autowired - protected WebApplicationContext wac; + + /** + * The Class TestConfiguration. + */ + @SpringBootApplication + static class TestConfiguration { + } /** * Setup. @@ -113,12 +117,4 @@ public void exportDataTest() throws Exception { .getName()); // assertNotNull(document); fails on GitHub? } - - - /** - * The Class TestConfiguration. - */ - @SpringBootApplication - static class TestConfiguration { - } } diff --git a/components/data/data-export/src/test/java/org/eclipse/dirigible/components/data/export/endpoint/DataExportEndpointTest.java b/components/data/data-export/src/test/java/org/eclipse/dirigible/components/data/export/endpoint/DataExportEndpointTest.java index dbef6e4343d..82486347627 100644 --- a/components/data/data-export/src/test/java/org/eclipse/dirigible/components/data/export/endpoint/DataExportEndpointTest.java +++ b/components/data/data-export/src/test/java/org/eclipse/dirigible/components/data/export/endpoint/DataExportEndpointTest.java @@ -23,7 +23,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.domain.EntityScan; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.security.test.context.support.WithMockUser; @@ -51,21 +51,26 @@ @Transactional public class DataExportEndpointTest { + /** The wac. */ + @Autowired + protected WebApplicationContext wac; /** The datasource repository. */ @Autowired private DataSourceRepository datasourceRepository; - /** The workspace service. */ @Autowired private WorkspaceService workspaceService; - /** The mock mvc. */ @Autowired private MockMvc mockMvc; - /** The wac. */ - @Autowired - protected WebApplicationContext wac; + + /** + * The Class TestConfiguration. + */ + @SpringBootApplication + static class TestConfiguration { + } /** * Setup. @@ -123,11 +128,4 @@ public void exportSchemaAsModelTest() throws Exception { Project project = workspace.getProject("INFORMATION_SCHEMA"); assertNotNull(project); } - - /** - * The Class TestConfiguration. - */ - @SpringBootApplication - static class TestConfiguration { - } } diff --git a/components/data/data-export/src/test/java/org/eclipse/dirigible/components/data/export/service/DataExportServiceTest.java b/components/data/data-export/src/test/java/org/eclipse/dirigible/components/data/export/service/DataExportServiceTest.java index ef36432ff75..317151bd666 100644 --- a/components/data/data-export/src/test/java/org/eclipse/dirigible/components/data/export/service/DataExportServiceTest.java +++ b/components/data/data-export/src/test/java/org/eclipse/dirigible/components/data/export/service/DataExportServiceTest.java @@ -27,7 +27,7 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.security.web.FilterChainProxy; @@ -49,26 +49,30 @@ @Transactional public class DataExportServiceTest { + /** The wac. */ + @Autowired + protected WebApplicationContext wac; /** The datasource repository. */ @Autowired private DataSourceRepository datasourceRepository; - /** The data export service. */ @Autowired private DataExportService dataExportService; - /** The workspace service. */ @Autowired private WorkspaceService workspaceService; - - /** The wac. */ - @Autowired - protected WebApplicationContext wac; - /** The spring security filter chain. */ @Autowired private FilterChainProxy springSecurityFilterChain; + + /** + * The Class TestConfiguration. + */ + @SpringBootApplication + static class TestConfiguration { + } + /** * Setup. */ @@ -78,7 +82,6 @@ public void setup() { datasourceRepository.save(datasource); } - /** * Cleanup. */ @@ -133,11 +136,4 @@ public void exportSchemaAsModelTest() { assertNotNull(foundFile); } - - /** - * The Class TestConfiguration. - */ - @SpringBootApplication - static class TestConfiguration { - } } diff --git a/components/data/data-management/src/test/java/org/eclipse/dirigible/components/data/management/TestConfig.java b/components/data/data-management/src/test/java/org/eclipse/dirigible/components/data/management/TestConfig.java index 0e1a2f660b8..c41a8207081 100644 --- a/components/data/data-management/src/test/java/org/eclipse/dirigible/components/data/management/TestConfig.java +++ b/components/data/data-management/src/test/java/org/eclipse/dirigible/components/data/management/TestConfig.java @@ -14,15 +14,15 @@ import org.eclipse.dirigible.components.base.tenant.TenantContext; import org.mockito.Mockito; import org.springframework.boot.test.context.TestConfiguration; -import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.context.annotation.Bean; +import org.springframework.test.context.bean.override.mockito.MockitoBean; import static org.mockito.Mockito.when; @TestConfiguration public class TestConfig { - @MockBean + @MockitoBean @DefaultTenant private Tenant defaultTenant; diff --git a/components/data/data-management/src/test/java/org/eclipse/dirigible/components/data/management/endpoint/DatabaseMetadataEndpointTest.java b/components/data/data-management/src/test/java/org/eclipse/dirigible/components/data/management/endpoint/DatabaseMetadataEndpointTest.java index 8ca97b8b410..3f6fd1a6ac0 100644 --- a/components/data/data-management/src/test/java/org/eclipse/dirigible/components/data/management/endpoint/DatabaseMetadataEndpointTest.java +++ b/components/data/data-management/src/test/java/org/eclipse/dirigible/components/data/management/endpoint/DatabaseMetadataEndpointTest.java @@ -18,7 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.domain.EntityScan; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.security.test.context.support.WithMockUser; diff --git a/components/data/data-sources/src/main/java/org/eclipse/dirigible/components/data/sources/domain/DataSource.java b/components/data/data-sources/src/main/java/org/eclipse/dirigible/components/data/sources/domain/DataSource.java index e51d61e08bf..f62dae4e80b 100644 --- a/components/data/data-sources/src/main/java/org/eclipse/dirigible/components/data/sources/domain/DataSource.java +++ b/components/data/data-sources/src/main/java/org/eclipse/dirigible/components/data/sources/domain/DataSource.java @@ -13,8 +13,6 @@ import jakarta.persistence.*; import org.eclipse.dirigible.components.base.artefact.Artefact; import org.eclipse.dirigible.components.base.encryption.Encrypted; -import org.hibernate.annotations.LazyCollection; -import org.hibernate.annotations.LazyCollectionOption; import java.util.ArrayList; import java.util.List; @@ -62,10 +60,9 @@ public class DataSource extends Artefact { private String schema; /** The properties. */ - @OneToMany(mappedBy = "datasource", fetch = FetchType.LAZY, cascade = CascadeType.ALL) - @LazyCollection(LazyCollectionOption.FALSE) + @OneToMany(mappedBy = "datasource", fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true) @Expose - private List properties = new ArrayList(); + private List properties = new ArrayList<>(); /** * Instantiates a new data source. @@ -91,120 +88,62 @@ public DataSource(String location, String name, String description, String drive */ public DataSource() {} - /** - * Gets the id. - * - * @return the id - */ public Long getId() { return id; } - /** - * Sets the id. - * - * @param id the id to set - */ public void setId(Long id) { this.id = id; } - /** - * Gets the driver. - * - * @return the driver - */ public String getDriver() { return driver; } - /** - * Sets the driver. - * - * @param driver the driver to set - */ public void setDriver(String driver) { this.driver = driver; } - /** - * Gets the url. - * - * @return the url - */ public String getUrl() { return url; } - /** - * Sets the url. - * - * @param url the url to set - */ public void setUrl(String url) { this.url = url; } - /** - * Gets the username. - * - * @return the username - */ public String getUsername() { return username; } - /** - * Sets the username. - * - * @param username the username to set - */ public void setUsername(String username) { this.username = username; } - /** - * Gets the password. - * - * @return the password - */ public String getPassword() { return password; } - /** - * Sets the password. - * - * @param password the password to set - */ public void setPassword(String password) { this.password = password; } - /** - * Sets the properties. - * - * @param properties the properties to set - */ - public void setProperties(List properties) { - this.properties = properties; + public String getSchema() { + return schema; + } + + public void setSchema(String schema) { + this.schema = schema; } - /** - * Gets the properties. - * - * @return the properties - */ public List getProperties() { return properties; } - /** - * Get the property by name. - * - * @param name the name - * @return the property - */ + public void setProperties(List properties) { + this.properties = properties; + } + public DataSourceProperty getProperty(String name) { for (DataSourceProperty p : properties) { if (p.getName() @@ -215,46 +154,15 @@ public DataSourceProperty getProperty(String name) { return null; } - /** - * Adds the property. - * - * @param name the name - * @param value the value - * @return the data source property - */ public DataSourceProperty addProperty(String name, String value) { DataSourceProperty property = new DataSourceProperty(name, value, this); properties.add(property); return property; } - /** - * Gets the schema. - * - * @return the schema - */ - public String getSchema() { - return schema; - } - - /** - * Sets the schema. - * - * @param schema the new schema - */ - public void setSchema(String schema) { - this.schema = schema; - } - - /** - * To string. - * - * @return the string - */ @Override public String toString() { return "DataSource [id=" + id + ", driver=" + driver + ", url=" + url + ", username=" + username + ", schema=" + schema + ", properties=" + properties + "]"; } - } diff --git a/components/data/data-sources/src/test/java/org/eclipse/dirigible/components/data/sources/TestConfig.java b/components/data/data-sources/src/test/java/org/eclipse/dirigible/components/data/sources/TestConfig.java index 85f19c1eb7f..d0c7bccc609 100644 --- a/components/data/data-sources/src/test/java/org/eclipse/dirigible/components/data/sources/TestConfig.java +++ b/components/data/data-sources/src/test/java/org/eclipse/dirigible/components/data/sources/TestConfig.java @@ -11,11 +11,11 @@ import org.eclipse.dirigible.components.base.tenant.TenantContext; import org.springframework.boot.test.context.TestConfiguration; -import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.test.context.bean.override.mockito.MockitoBean; @TestConfiguration public class TestConfig { - @MockBean + @MockitoBean private TenantContext tenantContext; } diff --git a/components/data/data-sources/src/test/java/org/eclipse/dirigible/components/data/sources/endpoint/DataSourceEndpointTest.java b/components/data/data-sources/src/test/java/org/eclipse/dirigible/components/data/sources/endpoint/DataSourceEndpointTest.java index 6ad3e93adfd..c7494d78df6 100644 --- a/components/data/data-sources/src/test/java/org/eclipse/dirigible/components/data/sources/endpoint/DataSourceEndpointTest.java +++ b/components/data/data-sources/src/test/java/org/eclipse/dirigible/components/data/sources/endpoint/DataSourceEndpointTest.java @@ -29,7 +29,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.domain.EntityScan; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.data.domain.Page; @@ -54,33 +54,35 @@ @Transactional public class DataSourceEndpointTest { + /** The wac. */ + @Autowired + protected WebApplicationContext wac; /** The entity manager. */ @Autowired private EntityManager entityManager; - /** The datasource service. */ @Autowired private DataSourceService datasourceService; - /** The datasource repository. */ @Autowired private DataSourceRepository datasourceRepository; - /** The test data source. */ private DataSource testDataSource; - /** The mock mvc. */ @Autowired private MockMvc mockMvc; - - /** The wac. */ - @Autowired - protected WebApplicationContext wac; - /** The spring security filter chain. */ @Autowired private FilterChainProxy springSecurityFilterChain; + + /** + * The Class TestConfiguration. + */ + @SpringBootApplication + static class TestConfiguration { + } + /** * Setup. * @@ -193,11 +195,4 @@ public void getAllDataSources() throws Exception { .andDo(print()) .andExpect(status().is2xxSuccessful()); } - - /** - * The Class TestConfiguration. - */ - @SpringBootApplication - static class TestConfiguration { - } } diff --git a/components/data/data-store/src/test/java/org/eclipse/dirigible/components/data/store/DataStoreTest.java b/components/data/data-store/src/test/java/org/eclipse/dirigible/components/data/store/DataStoreTest.java index 981ad88ef60..891d8e3682a 100644 --- a/components/data/data-store/src/test/java/org/eclipse/dirigible/components/data/store/DataStoreTest.java +++ b/components/data/data-store/src/test/java/org/eclipse/dirigible/components/data/store/DataStoreTest.java @@ -9,16 +9,8 @@ */ package org.eclipse.dirigible.components.data.store; -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; - -import java.nio.charset.StandardCharsets; -import java.sql.SQLException; -import java.util.List; -import java.util.Map; -import java.util.Optional; - +import com.google.gson.JsonElement; +import com.google.gson.JsonSyntaxException; import org.apache.commons.io.IOUtils; import org.eclipse.dirigible.commons.api.helpers.GsonHelper; import org.eclipse.dirigible.commons.config.Configuration; @@ -45,15 +37,22 @@ import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.context.annotation.ComponentScan; import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.bean.override.mockito.MockitoBean; import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.test.context.support.AnnotationConfigContextLoader; import org.springframework.transaction.annotation.Transactional; -import com.google.gson.JsonElement; -import com.google.gson.JsonSyntaxException; +import java.nio.charset.StandardCharsets; +import java.sql.SQLException; +import java.util.List; +import java.util.Map; +import java.util.Optional; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; /** * The Class ObjectStoreTest. @@ -80,13 +79,21 @@ public class DataStoreTest { private DirigibleDataSource dataSource; - @MockBean + @MockitoBean private TenantContext tenantContext; - @MockBean + @MockitoBean @DefaultTenant private Tenant defaultTenant; + + /** + * The Class TestConfiguration. + */ + @SpringBootApplication + static class TestConfiguration { + } + /** * Setup. * @@ -116,11 +123,6 @@ public void setup() throws Exception { dataStore.recreate(); } - @AfterAll - public void cleanup() { - Configuration.set("DIRIGIBLE_DATABASE_DATASOURCE_NAME_DEFAULT", "DefaultDB"); - } - private void setupMocks() { CurrentTenantIdentifierResolverImpl tenantIdentifier = new CurrentTenantIdentifierResolverImpl(tenantContext); MultiTenantConnectionProviderImpl connectionProvider = @@ -128,6 +130,11 @@ private void setupMocks() { dataStore = new DataStore(this.dataSource, this.datasourcesManager, connectionProvider, tenantIdentifier); } + @AfterAll + public void cleanup() { + Configuration.set("DIRIGIBLE_DATABASE_DATASOURCE_NAME_DEFAULT", "DefaultDB"); + } + /** * Save object. */ @@ -155,7 +162,17 @@ public void save() { cleanupCustomers(); } + } + public void cleanupCustomers() { + List list; + list = dataStore.list("Customer"); + for (Object element : list) { + dataStore.delete("Customer", ((Long) ((Map) element).get("id"))); + } + list = dataStore.list("Customer"); + assertNotNull(list); + assertEquals(0, list.size()); } /** @@ -181,28 +198,6 @@ public void criteria() { } } - public void cleanupCustomers() { - List list; - list = dataStore.list("Customer"); - for (Object element : list) { - dataStore.delete("Customer", ((Long) ((Map) element).get("id"))); - } - list = dataStore.list("Customer"); - assertNotNull(list); - assertEquals(0, list.size()); - } - - public void cleanupCustomerAddresses() { - List list; - list = dataStore.list("CustomerAddress"); - for (Object element : list) { - dataStore.delete("CustomerAddress", ((Long) ((Map) element).get("id"))); - } - list = dataStore.list("CustomerAddress"); - assertNotNull(list); - assertEquals(0, list.size()); - } - /** * ManyToOne use in object. */ @@ -247,6 +242,17 @@ public void manyToOne() { } } + public void cleanupCustomerAddresses() { + List list; + list = dataStore.list("CustomerAddress"); + for (Object element : list) { + dataStore.delete("CustomerAddress", ((Long) ((Map) element).get("id"))); + } + list = dataStore.list("CustomerAddress"); + assertNotNull(list); + assertEquals(0, list.size()); + } + /** * OneToMany with a Bag in object. */ @@ -420,6 +426,14 @@ public void queryWithPrimitiveParameters() throws SQLException { } } + static Optional parseOptionalJson(String json) { + try { + return Optional.ofNullable(null == json ? null : GsonHelper.parseJson(json)); + } catch (JsonSyntaxException ex) { + throw new IllegalArgumentException("Invalid json: " + json, ex); + } + } + /** * Query object. * @@ -544,21 +558,4 @@ public void queryWithParametersArrayNumbers() throws SQLException { } } - static Optional parseOptionalJson(String json) { - try { - return Optional.ofNullable(null == json ? null : GsonHelper.parseJson(json)); - } catch (JsonSyntaxException ex) { - throw new IllegalArgumentException("Invalid json: " + json, ex); - } - } - - - - /** - * The Class TestConfiguration. - */ - @SpringBootApplication - static class TestConfiguration { - } - } diff --git a/components/data/data-store/src/test/java/org/eclipse/dirigible/components/data/store/DatabaseMetadataEndpointTest.java b/components/data/data-store/src/test/java/org/eclipse/dirigible/components/data/store/DatabaseMetadataEndpointTest.java index 6ea9436db62..cdb9a3651e2 100644 --- a/components/data/data-store/src/test/java/org/eclipse/dirigible/components/data/store/DatabaseMetadataEndpointTest.java +++ b/components/data/data-store/src/test/java/org/eclipse/dirigible/components/data/store/DatabaseMetadataEndpointTest.java @@ -11,7 +11,7 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.boot.autoconfigure.domain.EntityScan; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.security.test.context.support.WithMockUser; diff --git a/components/data/data-structures/src/main/java/org/eclipse/dirigible/components/data/structures/domain/Schema.java b/components/data/data-structures/src/main/java/org/eclipse/dirigible/components/data/structures/domain/Schema.java index 66f7491050c..4b9e20914e8 100644 --- a/components/data/data-structures/src/main/java/org/eclipse/dirigible/components/data/structures/domain/Schema.java +++ b/components/data/data-structures/src/main/java/org/eclipse/dirigible/components/data/structures/domain/Schema.java @@ -9,25 +9,14 @@ */ package org.eclipse.dirigible.components.data.structures.domain; +import com.google.gson.annotations.Expose; +import jakarta.persistence.*; +import org.eclipse.dirigible.components.base.artefact.Artefact; + import java.util.ArrayList; import java.util.List; import java.util.Set; -import jakarta.persistence.CascadeType; -import jakarta.persistence.Column; -import jakarta.persistence.Entity; -import jakarta.persistence.FetchType; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.GenerationType; -import jakarta.persistence.Id; -import jakarta.persistence.OneToMany; - -import org.eclipse.dirigible.components.base.artefact.Artefact; -import org.hibernate.annotations.LazyCollection; -import org.hibernate.annotations.LazyCollectionOption; - -import com.google.gson.annotations.Expose; - /** * The Class Schema. */ @@ -35,111 +24,41 @@ @jakarta.persistence.Table(name = "DIRIGIBLE_DATA_SCHEMAS") public class Schema extends Artefact { - /** The Constant ARTEFACT_TYPE. */ public static final String ARTEFACT_TYPE = "schema"; - /** The id. */ @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "SCHEMA_ID", nullable = false) private Long id; - /** The dataSource. */ @Column(name = "datasource", nullable = false) @Expose private String datasource; - /** The tables. */ - @OneToMany(mappedBy = "schemaReference", fetch = FetchType.LAZY, cascade = CascadeType.ALL) - @LazyCollection(LazyCollectionOption.FALSE) + @OneToMany(mappedBy = "schemaReference", fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true) @Expose - private List tables = new ArrayList
(); + private List
tables = new ArrayList<>(); - /** The views. */ - @OneToMany(mappedBy = "schemaReference", fetch = FetchType.LAZY, cascade = CascadeType.ALL) - @LazyCollection(LazyCollectionOption.FALSE) + @OneToMany(mappedBy = "schemaReference", fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true) @Expose - private List views = new ArrayList(); - - /** - * Instantiates a new schema. - * - * @param location the location - * @param name the name - * @param description the description - * @param dependencies the dependencies - */ + private List views = new ArrayList<>(); + public Schema(String location, String name, String description, Set dependencies) { super(location, name, ARTEFACT_TYPE, description, dependencies); } - /** - * Instantiates a new schema. - */ public Schema() { super(); } - /** - * Gets the id. - * - * @return the id - */ public Long getId() { return id; } - /** - * Sets the id. - * - * @param id the id to set - */ public void setId(Long id) { this.id = id; } - /** - * Gets the tables. - * - * @return the tables - */ - public List
getTables() { - return tables; - } - - /** - * Sets the tables. - * - * @param tables the tables to set - */ - public void setTables(List
tables) { - this.tables = tables; - } - - /** - * Gets the views. - * - * @return the views - */ - public List getViews() { - return views; - } - - /** - * Sets the views. - * - * @param views the views to set - */ - public void setViews(List views) { - this.views = views; - } - - /** - * Find table. - * - * @param name the name - * @return the table - */ public Table findTable(String name) { for (Table t : getTables()) { if (t.getName() @@ -150,12 +69,14 @@ public Table findTable(String name) { return null; } - /** - * Find view. - * - * @param name the name - * @return the view - */ + public List
getTables() { + return tables; + } + + public void setTables(List
tables) { + this.tables = tables; + } + public View findView(String name) { for (View v : getViews()) { if (v.getName() @@ -166,34 +87,26 @@ public View findView(String name) { return null; } - /** - * Gets the datasource. - * - * @return the datasource - */ + public List getViews() { + return views; + } + + public void setViews(List views) { + this.views = views; + } + public String getDatasource() { return datasource; } - /** - * Sets the data source. - * - * @param dataSource the new data source - */ public void setDataSource(String dataSource) { this.datasource = dataSource; } - /** - * To string. - * - * @return the string - */ @Override public String toString() { return "Schema [id=" + id + ", tables=" + tables + ", views=" + views + ", datasource=" + datasource + ", location=" + location + ", name=" + name + ", type=" + type + ", description=" + description + ", key=" + key + ", dependencies=" + dependencies + ", createdBy=" + createdBy + ", createdAt=" + createdAt + ", updatedBy=" + updatedBy + ", updatedAt=" + updatedAt + "]"; } - } diff --git a/components/data/data-structures/src/main/java/org/eclipse/dirigible/components/data/structures/domain/Table.java b/components/data/data-structures/src/main/java/org/eclipse/dirigible/components/data/structures/domain/Table.java index 2b54b373b55..d3fc04cdc7b 100644 --- a/components/data/data-structures/src/main/java/org/eclipse/dirigible/components/data/structures/domain/Table.java +++ b/components/data/data-structures/src/main/java/org/eclipse/dirigible/components/data/structures/domain/Table.java @@ -9,31 +9,17 @@ */ package org.eclipse.dirigible.components.data.structures.domain; -import java.util.ArrayList; -import java.util.List; -import java.util.Set; - +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.google.gson.annotations.Expose; import jakarta.annotation.Nullable; -import jakarta.persistence.CascadeType; -import jakarta.persistence.Column; -import jakarta.persistence.Entity; -import jakarta.persistence.FetchType; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.GenerationType; -import jakarta.persistence.Id; -import jakarta.persistence.JoinColumn; -import jakarta.persistence.ManyToOne; -import jakarta.persistence.OneToMany; -import jakarta.persistence.OneToOne; - +import jakarta.persistence.*; import org.eclipse.dirigible.components.base.artefact.Artefact; -import org.hibernate.annotations.LazyCollection; -import org.hibernate.annotations.LazyCollectionOption; import org.hibernate.annotations.OnDelete; import org.hibernate.annotations.OnDeleteAction; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.google.gson.annotations.Expose; +import java.util.ArrayList; +import java.util.List; +import java.util.Set; /** * The Class Table. @@ -42,61 +28,43 @@ @jakarta.persistence.Table(name = "DIRIGIBLE_DATA_TABLES") public class Table extends Artefact { - /** The Constant ARTEFACT_TYPE. */ public static final String ARTEFACT_TYPE = "table"; - - /** The id. */ - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name = "TABLE_ID", nullable = false) - private Long id; - - /** The kind. */ @Column(name = "TABLE_KIND", columnDefinition = "VARCHAR", nullable = true, length = 255) @Expose protected String kind; - - /** The schema name. */ @Column(name = "TABLE_SCHEMA", columnDefinition = "VARCHAR", nullable = true, length = 255) @Expose protected String schema; - /** The columns. */ - @OneToMany(mappedBy = "table", fetch = FetchType.LAZY, cascade = CascadeType.ALL) - @LazyCollection(LazyCollectionOption.FALSE) + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "TABLE_ID", nullable = false) + private Long id; + + @OneToMany(mappedBy = "table", fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true) @Expose - private List columns = new ArrayList(); + private List columns = new ArrayList<>(); - /** The indexes. */ - @OneToMany(mappedBy = "table", fetch = FetchType.LAZY, cascade = CascadeType.ALL) - @LazyCollection(LazyCollectionOption.FALSE) + @OneToMany(mappedBy = "table", fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true) @Nullable @Expose - private List indexes = new ArrayList(); + private List indexes = new ArrayList<>(); - /** The constraints. */ @OneToOne(mappedBy = "table", fetch = FetchType.LAZY, cascade = CascadeType.ALL, optional = true, orphanRemoval = true) @Nullable @Expose private TableConstraints constraints; - /** The schema reference. */ @ManyToOne(fetch = FetchType.EAGER, optional = true) @JoinColumn(name = "SCHEMA_ID", nullable = true) @OnDelete(action = OnDeleteAction.CASCADE) @JsonIgnore private Schema schemaReference; - /** - * Instantiates a new table. - * - * @param location the location - * @param name the name - * @param description the description - * @param dependencies the dependencies - * @param kind the kind - * @param schema the schema name - */ + public Table(String tableName) { + this(tableName, tableName, null, null, "TABLE", ""); + } + public Table(String location, String name, String description, Set dependencies, String kind, String schema) { super(location, name, ARTEFACT_TYPE, description, dependencies); this.constraints = new TableConstraints(this); @@ -104,101 +72,43 @@ public Table(String location, String name, String description, Set depen this.schema = schema; } - /** - * Instantiates a new table. - * - * @param tableName the table name - */ - public Table(String tableName) { - this(tableName, tableName, null, null, "TABLE", ""); - } - - /** - * Instantiates a new table. - */ public Table() { super(); this.constraints = new TableConstraints(); } - /** - * Gets the id. - * - * @return the id - */ public Long getId() { return id; } - /** - * Sets the id. - * - * @param id the id to set - */ public void setId(Long id) { this.id = id; } - /** - * Gets the kind. - * - * @return the kind - */ public String getKind() { return kind; } - /** - * Sets the kind. - * - * @param kind the kind to set - */ public void setKind(String kind) { this.kind = kind; } - /** - * Gets the schema name. - * - * @return the schema name - */ public String getSchema() { return schema; } - /** - * Sets the schema name. - * - * @param schema the schema name to set - */ public void setSchema(String schema) { this.schema = schema; } - /** - * Gets the columns. - * - * @return the columns - */ public List getColumns() { return columns; } - /** - * Sets the columns. - * - * @param columns the columns to set - */ public void setColumns(List columns) { this.columns = columns; } - /** - * Get the column by name. - * - * @param name the name - * @return the column - */ public TableColumn getColumn(String name) { for (TableColumn c : columns) { if (c.getName() @@ -209,34 +119,17 @@ public TableColumn getColumn(String name) { return null; } - /** - * Gets the indexes. - * - * @return the indexes - */ public List getIndexes() { return indexes; } - /** - * Sets the indexes. - * - * @param indexes the indexes to set - */ public void setIndexes(List indexes) { this.indexes = indexes; } - /** - * Get the index by name. - * - * @param name the name - * @return the index - */ public TableIndex getIndex(String name) { - final List indexesList = indexes; - if (indexesList != null) { - for (TableIndex i : indexesList) { + if (indexes != null) { + for (TableIndex i : indexes) { if (i.getName() .equals(name)) { return i; @@ -246,47 +139,22 @@ public TableIndex getIndex(String name) { return null; } - /** - * Gets the constraints. - * - * @return the constraints - */ public TableConstraints getConstraints() { return constraints; } - /** - * Sets the constraints. - * - * @param constraints the constraints to set - */ public void setConstraints(TableConstraints constraints) { this.constraints = constraints; } - /** - * Gets the schema reference. - * - * @return the schema reference - */ public Schema getSchemaReference() { return schemaReference; } - /** - * Sets the schema reference. - * - * @param schemaReference the new schema reference - */ public void setSchemaReference(Schema schemaReference) { this.schemaReference = schemaReference; } - /** - * To string. - * - * @return the string - */ @Override public String toString() { return "Table [id=" + id + ", schemaName=" + schema + ", columns=" + columns + ", indexes=" + indexes + ", constraints=" @@ -295,20 +163,6 @@ public String toString() { + updatedBy + ", updatedAt=" + updatedAt + "]"; } - /** - * Adds the column. - * - * @param name the name - * @param type the type - * @param length the length - * @param nullable the nullable - * @param primaryKey the primary key - * @param defaultValue the default value - * @param precision the precision - * @param scale the scale - * @param unique the unique - * @return the table column - */ public TableColumn addColumn(String name, String type, String length, boolean nullable, boolean primaryKey, String defaultValue, String precision, String scale, boolean unique) { TableColumn tableColumn = new TableColumn(name, type, length, nullable, primaryKey, defaultValue, precision, scale, unique, this); @@ -316,22 +170,9 @@ public TableColumn addColumn(String name, String type, String length, boolean nu return tableColumn; } - /** - * Adds the index. - * - * @param name the name - * @param type the type - * @param unique the unique - * @param order the order - * @param columns the columns - * @return the table index - */ public TableIndex addIndex(String name, String type, boolean unique, String order, String[] columns) { TableIndex tableIndex = new TableIndex(name, type, unique, order, columns, this); indexes.add(tableIndex); return tableIndex; } - - - } diff --git a/components/data/data-structures/src/main/java/org/eclipse/dirigible/components/data/structures/domain/TableConstraints.java b/components/data/data-structures/src/main/java/org/eclipse/dirigible/components/data/structures/domain/TableConstraints.java index b71a96e9df2..240191e257d 100644 --- a/components/data/data-structures/src/main/java/org/eclipse/dirigible/components/data/structures/domain/TableConstraints.java +++ b/components/data/data-structures/src/main/java/org/eclipse/dirigible/components/data/structures/domain/TableConstraints.java @@ -13,8 +13,6 @@ import com.google.gson.annotations.Expose; import jakarta.annotation.Nullable; import jakarta.persistence.*; -import org.hibernate.annotations.LazyCollection; -import org.hibernate.annotations.LazyCollectionOption; import org.hibernate.annotations.OnDelete; import org.hibernate.annotations.OnDeleteAction; @@ -28,127 +26,75 @@ @jakarta.persistence.Table(name = "DIRIGIBLE_DATA_TABLE_CONSTRAINTS") public class TableConstraints { - /** The id. */ @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "CONSTRAINTS_ID", nullable = false) private Long id; - /** The primary key. */ + /** Primary key (already LAZY – unchanged) */ @OneToOne(mappedBy = "constraints", fetch = FetchType.LAZY, cascade = CascadeType.ALL, optional = true) @Nullable @Expose private TableConstraintPrimaryKey primaryKey; - /** The foreign keys. */ - @OneToMany(mappedBy = "constraints", fetch = FetchType.LAZY, cascade = CascadeType.ALL) - @LazyCollection(LazyCollectionOption.FALSE) + @OneToMany(mappedBy = "constraints", fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true) @Nullable @Expose - private List foreignKeys = new ArrayList(); + private List foreignKeys = new ArrayList<>(); - /** The unique indices. */ - @OneToMany(mappedBy = "constraints", fetch = FetchType.LAZY, cascade = CascadeType.ALL) - @LazyCollection(LazyCollectionOption.FALSE) + @OneToMany(mappedBy = "constraints", fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true) @Nullable @Expose - private List uniqueIndexes = new ArrayList(); + private List uniqueIndexes = new ArrayList<>(); - /** The checks. */ - @OneToMany(mappedBy = "constraints", fetch = FetchType.LAZY, cascade = CascadeType.ALL) - @LazyCollection(LazyCollectionOption.FALSE) + @OneToMany(mappedBy = "constraints", fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true) @Nullable @Expose - private List checks = new ArrayList(); + private List checks = new ArrayList<>(); - /** The table. */ + /** The table */ @OneToOne(fetch = FetchType.LAZY, optional = true) @JoinColumn(name = "TABLE_ID", nullable = true) @OnDelete(action = OnDeleteAction.CASCADE) @JsonIgnore private Table table; - /** - * Instantiates a new table constraints. - * - * @param table the table - */ public TableConstraints(Table table) { this(); this.table = table; } - /** - * Instantiates a new table constraints. - */ public TableConstraints() { super(); } - /** - * Gets the id. - * - * @return the id - */ public Long getId() { return id; } - /** - * Sets the id. - * - * @param id the id to set - */ public void setId(Long id) { this.id = id; } - /** - * Gets the primary key. - * - * @return the primaryKey - */ public TableConstraintPrimaryKey getPrimaryKey() { return primaryKey; } - /** - * Sets the primary key. - * - * @param primaryKey the primaryKey to set - */ public void setPrimaryKey(TableConstraintPrimaryKey primaryKey) { this.primaryKey = primaryKey; } - /** - * Gets the foreign keys. - * - * @return the foreignKeys - */ public List getForeignKeys() { return foreignKeys; } - /** - * Sets the foreign keys. - * - * @param foreignKeys the foreignKeys to set - */ public void setForeignKeys(List foreignKeys) { this.foreignKeys = foreignKeys; } - /** - * Get the foreignKey by name. - * - * @param name the name - * @return the foreignKey - */ public TableConstraintForeignKey getForeignKey(String name) { - final List foreignKeysList = foreignKeys; - if (foreignKeysList != null) { - for (TableConstraintForeignKey fk : foreignKeysList) { + if (foreignKeys != null) { + for (TableConstraintForeignKey fk : foreignKeys) { if (fk.getName() .equals(name)) { return fk; @@ -158,34 +104,17 @@ public TableConstraintForeignKey getForeignKey(String name) { return null; } - /** - * Gets the unique indexes. - * - * @return the uniqueIndexes - */ public List getUniqueIndexes() { return uniqueIndexes; } - /** - * Sets the unique indexes. - * - * @param uniqueIndexes the uniqueIndexes to set - */ public void setUniqueIndexes(List uniqueIndexes) { this.uniqueIndexes = uniqueIndexes; } - /** - * Get the uniqueIndex by name. - * - * @param name the name - * @return the uniqueIndex - */ public TableConstraintUnique getUniqueIndex(String name) { - final List uniqueIndexesList = uniqueIndexes; - if (uniqueIndexesList != null) { - for (TableConstraintUnique ui : uniqueIndexesList) { + if (uniqueIndexes != null) { + for (TableConstraintUnique ui : uniqueIndexes) { if (ui.getName() .equals(name)) { return ui; @@ -195,34 +124,17 @@ public TableConstraintUnique getUniqueIndex(String name) { return null; } - /** - * Gets the checks. - * - * @return the checks - */ public List getChecks() { return checks; } - /** - * Sets the checks. - * - * @param checks the checks to set - */ public void setChecks(List checks) { this.checks = checks; } - /** - * Get the checks by name. - * - * @param name the name - * @return the checks - */ public TableConstraintCheck getCheck(String name) { - final List checksList = checks; - if (checksList != null) { - for (TableConstraintCheck ck : checksList) { + if (checks != null) { + for (TableConstraintCheck ck : checks) { if (ck.getName() .equals(name)) { return ck; @@ -232,29 +144,14 @@ public TableConstraintCheck getCheck(String name) { return null; } - /** - * Gets the table. - * - * @return the table - */ public Table getTable() { return table; } - /** - * Sets the table. - * - * @param table the table to set - */ public void setTable(Table table) { this.table = table; } - /** - * To string. - * - * @return the string - */ @Override public String toString() { return "TableConstraints{" + "id=" + id + ", primaryKey=" + primaryKey + ", foreignKeys=" + foreignKeys + ", uniqueIndexes=" diff --git a/components/data/data-structures/src/test/java/org/eclipse/dirigible/components/data/structures/TestConfig.java b/components/data/data-structures/src/test/java/org/eclipse/dirigible/components/data/structures/TestConfig.java index 88a917b04f2..3fbd7c73309 100644 --- a/components/data/data-structures/src/test/java/org/eclipse/dirigible/components/data/structures/TestConfig.java +++ b/components/data/data-structures/src/test/java/org/eclipse/dirigible/components/data/structures/TestConfig.java @@ -13,15 +13,15 @@ import org.eclipse.dirigible.components.base.tenant.Tenant; import org.eclipse.dirigible.components.base.tenant.TenantContext; import org.springframework.boot.test.context.TestConfiguration; -import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.test.context.bean.override.mockito.MockitoBean; @TestConfiguration public class TestConfig { - @MockBean + @MockitoBean private TenantContext tenantContext; - @MockBean + @MockitoBean @DefaultTenant private Tenant defaultTenant; } diff --git a/components/engine/engine-camel/src/generated/java/org/eclipse/dirigible/components/engine/camel/components/DirigibleJavaScriptEndpointUriFactory.java b/components/engine/engine-camel/src/generated/java/org/eclipse/dirigible/components/engine/camel/components/DirigibleJavaScriptEndpointUriFactory.java index 7df1f983f84..17ebbdeff7b 100644 --- a/components/engine/engine-camel/src/generated/java/org/eclipse/dirigible/components/engine/camel/components/DirigibleJavaScriptEndpointUriFactory.java +++ b/components/engine/engine-camel/src/generated/java/org/eclipse/dirigible/components/engine/camel/components/DirigibleJavaScriptEndpointUriFactory.java @@ -66,4 +66,3 @@ public boolean isLenientProperties() { return false; } } - diff --git a/components/engine/engine-di/src/test/java/org/eclipse/dirigible/components/engine/javascript/endpoint/JavascriptEndpointDITest.java b/components/engine/engine-di/src/test/java/org/eclipse/dirigible/components/engine/javascript/endpoint/JavascriptEndpointDITest.java index 23929a417bb..f056f158a4a 100644 --- a/components/engine/engine-di/src/test/java/org/eclipse/dirigible/components/engine/javascript/endpoint/JavascriptEndpointDITest.java +++ b/components/engine/engine-di/src/test/java/org/eclipse/dirigible/components/engine/javascript/endpoint/JavascriptEndpointDITest.java @@ -27,7 +27,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.security.test.context.support.WithMockUser; @@ -51,18 +51,16 @@ @AutoConfigureMockMvc public class JavascriptEndpointDITest { - /** The javascript service. */ + /** The wac. */ @Autowired - private JavascriptService javascriptService; + protected WebApplicationContext wac; /** The mock mvc. */ // @Autowired // private MockMvc mockMvc; - - /** The wac. */ + /** The javascript service. */ @Autowired - protected WebApplicationContext wac; - + private JavascriptService javascriptService; /** The spring security filter chain. */ @Autowired private FilterChainProxy springSecurityFilterChain; @@ -74,6 +72,14 @@ public class JavascriptEndpointDITest { @Autowired private DataSourcesManager datasourcesManager; + + /** + * The Class TestConfiguration. + */ + @SpringBootApplication + static class TestConfiguration { + } + /** * Setup. * @@ -89,19 +95,6 @@ public void setup() throws Exception { "org.eclipse.dirigible.components.base.http.access.UserResponseVerifier.getResponse().getOutputStream().println(\"Hello World!\");".getBytes()); } - /** - * Cleanup. - * - * @throws Exception the exception - */ - @AfterEach - public void cleanup() throws Exception { - - // delete test javascript service - repository.removeResource("/registry/public/test/hello-world.js"); - repository.removeResource("/registry/public/test1/test2/hello-world.js"); - } - // @Test // public void handleRequest() { // assertNotNull(javascriptService.handleRequest("test", "hello-world.js", null, null, false)); @@ -213,9 +206,15 @@ public void cleanup() throws Exception { // } /** - * The Class TestConfiguration. + * Cleanup. + * + * @throws Exception the exception */ - @SpringBootApplication - static class TestConfiguration { + @AfterEach + public void cleanup() throws Exception { + + // delete test javascript service + repository.removeResource("/registry/public/test/hello-world.js"); + repository.removeResource("/registry/public/test1/test2/hello-world.js"); } } diff --git a/components/engine/engine-di/src/test/java/org/eclipse/dirigible/components/engine/javascript/endpoint/TestConfig.java b/components/engine/engine-di/src/test/java/org/eclipse/dirigible/components/engine/javascript/endpoint/TestConfig.java index 295c0108471..ead9c0bf5ef 100644 --- a/components/engine/engine-di/src/test/java/org/eclipse/dirigible/components/engine/javascript/endpoint/TestConfig.java +++ b/components/engine/engine-di/src/test/java/org/eclipse/dirigible/components/engine/javascript/endpoint/TestConfig.java @@ -13,15 +13,15 @@ import org.eclipse.dirigible.components.base.tenant.Tenant; import org.eclipse.dirigible.components.base.tenant.TenantContext; import org.springframework.boot.test.context.TestConfiguration; -import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.test.context.bean.override.mockito.MockitoBean; @TestConfiguration public class TestConfig { - @MockBean + @MockitoBean private TenantContext tenantContext; - @MockBean + @MockitoBean @DefaultTenant private Tenant defaultTenant; } diff --git a/components/engine/engine-javascript/src/test/java/org/eclipse/dirigible/components/engine/javascript/endpoint/JavascriptEndpointTest.java b/components/engine/engine-javascript/src/test/java/org/eclipse/dirigible/components/engine/javascript/endpoint/JavascriptEndpointTest.java index 0338cbaeca2..47ed1db6a69 100644 --- a/components/engine/engine-javascript/src/test/java/org/eclipse/dirigible/components/engine/javascript/endpoint/JavascriptEndpointTest.java +++ b/components/engine/engine-javascript/src/test/java/org/eclipse/dirigible/components/engine/javascript/endpoint/JavascriptEndpointTest.java @@ -9,12 +9,6 @@ */ package org.eclipse.dirigible.components.engine.javascript.endpoint; -import static org.hamcrest.Matchers.containsString; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; -import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - import org.eclipse.dirigible.components.engine.javascript.service.JavascriptService; import org.eclipse.dirigible.repository.api.IRepository; import org.junit.jupiter.api.AfterEach; @@ -23,8 +17,8 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc; import org.springframework.context.annotation.ComponentScan; import org.springframework.security.test.context.support.WithMockUser; import org.springframework.security.web.FilterChainProxy; @@ -32,6 +26,12 @@ import org.springframework.test.web.servlet.MockMvc; import org.springframework.web.context.WebApplicationContext; +import static org.hamcrest.Matchers.containsString; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + /** * The Class JavascriptEndpointTest. */ @@ -42,18 +42,15 @@ @ComponentScan(basePackages = {"org.eclipse.dirigible.components.*"}) public class JavascriptEndpointTest { + /** The wac. */ + @Autowired + protected WebApplicationContext wac; /** The javascript service. */ @Autowired private JavascriptService javascriptService; - /** The mock mvc. */ @Autowired private MockMvc mockMvc; - - /** The wac. */ - @Autowired - protected WebApplicationContext wac; - /** The spring security filter chain. */ @Autowired private FilterChainProxy springSecurityFilterChain; @@ -62,6 +59,14 @@ public class JavascriptEndpointTest { @Autowired private IRepository repository; + + /** + * The Class TestConfiguration. + */ + @SpringBootApplication + static class TestConfiguration { + } + /** * Setup. * @@ -77,6 +82,11 @@ public void setup() throws Exception { "org.eclipse.dirigible.components.base.http.access.UserResponseVerifier.getResponse().getOutputStream().println(\"Hello World!\");".getBytes()); } + // @Test + // public void handleRequest() { + // assertNotNull(javascriptService.handleRequest("test", "hello-world.js", null, null, false)); + // } + /** * Cleanup. * @@ -90,11 +100,6 @@ public void cleanup() throws Exception { repository.removeResource("/registry/public/test1/test2/hello-world.js"); } - // @Test - // public void handleRequest() { - // assertNotNull(javascriptService.handleRequest("test", "hello-world.js", null, null, false)); - // } - /** * Gets the status. * @@ -199,11 +204,4 @@ public void getResultDeepPath() throws Exception { .andExpect(content().string(containsString("Hello World!"))); } - - /** - * The Class TestConfiguration. - */ - @SpringBootApplication - static class TestConfiguration { - } } diff --git a/components/engine/engine-jobs/src/main/java/org/eclipse/dirigible/components/jobs/domain/Job.java b/components/engine/engine-jobs/src/main/java/org/eclipse/dirigible/components/jobs/domain/Job.java index 5784942c054..4d500819171 100644 --- a/components/engine/engine-jobs/src/main/java/org/eclipse/dirigible/components/jobs/domain/Job.java +++ b/components/engine/engine-jobs/src/main/java/org/eclipse/dirigible/components/jobs/domain/Job.java @@ -12,9 +12,6 @@ import com.google.gson.annotations.Expose; import jakarta.persistence.*; import org.eclipse.dirigible.components.base.artefact.Artefact; -import org.hibernate.annotations.LazyCollection; -import org.hibernate.annotations.LazyCollectionOption; -import org.springframework.data.annotation.Transient; import java.sql.Timestamp; import java.util.ArrayList; @@ -28,109 +25,59 @@ @Table(name = "DIRIGIBLE_JOBS") public class Job extends Artefact { - /** The Constant ARTEFACT_TYPE. */ public static final String ARTEFACT_TYPE = "job"; - /** The id. */ @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "JOB_ID", nullable = false) private Long id; - /** - * The group. - */ - @Column(name = "JOB_GROUP", columnDefinition = "VARCHAR", nullable = false, length = 255) + @Column(name = "JOB_GROUP", nullable = false, length = 255) @Expose private String group; - /** - * The clazz. - */ - @Column(name = "JOB_CLASS", columnDefinition = "VARCHAR", nullable = false, length = 255) + @Column(name = "JOB_CLASS", nullable = false, length = 255) @Expose private String clazz = ""; - /** - * The expression. - */ - @Column(name = "JOB_EXPRESSION", columnDefinition = "VARCHAR", nullable = false, length = 255) + @Column(name = "JOB_EXPRESSION", nullable = false, length = 255) @Expose private String expression; - /** - * The handler. - */ - @Column(name = "JOB_HANDLER", columnDefinition = "VARCHAR", nullable = true, length = 255) + @Column(name = "JOB_HANDLER", length = 255) @Expose private String handler; - /** - * The engine. - */ - @Column(name = "JOB_ENGINE", columnDefinition = "VARCHAR", nullable = true, length = 100) + @Column(name = "JOB_ENGINE", length = 100) @Expose private String engine; - /** - * The singleton. - */ - @Column(name = "JOB_SINGLETON", columnDefinition = "BOOLEAN", nullable = false) + @Column(name = "JOB_SINGLETON", nullable = false) @Expose private Boolean singleton = false; - /** - * The enabled. - */ - @Column(name = "JOB_ENABLED", columnDefinition = "BOOLEAN", nullable = false) + @Column(name = "JOB_ENABLED", nullable = false) @Expose private Boolean enabled = true; /** - * The parameters. + * NOT persisted. Populated externally. */ - @OneToMany(mappedBy = "job", fetch = FetchType.LAZY, cascade = CascadeType.ALL) - @LazyCollection(LazyCollectionOption.FALSE) - @Transient + @jakarta.persistence.Transient private List parameters = new ArrayList<>(); - /** The status. */ - @Column(name = "JOB_STATUS", nullable = true) + @Column(name = "JOB_STATUS") @Enumerated(EnumType.STRING) private JobStatus status = JobStatus.UNKNOWN; - /** - * The message. - */ - @Column(name = "JOB_MESSAGE", columnDefinition = "VARCHAR", nullable = true, length = 2000) + @Column(name = "JOB_MESSAGE", length = 2000) @Expose private String message; - /** - * The executed at. - */ - @Column(name = "JOB_EXECUTED_AT", columnDefinition = "TIMESTAMP", nullable = true) + @Column(name = "JOB_EXECUTED_AT") @Expose private Timestamp executedAt; - /** - * Instantiates a new job. - * - * @param location the location - * @param name the name - * @param description the description - * @param dependencies the dependencies - * @param group the group - * @param clazz the clazz - * @param expression the expression - * @param handler the handler - * @param engine the engine - * @param singleton the singleton - * @param enabled the enabled - * @param status the status - * @param message the message - * @param executedAt the executed at - */ public Job(String location, String name, String description, Set dependencies, String group, String clazz, String expression, String handler, String engine, Boolean singleton, Boolean enabled, JobStatus status, String message, Timestamp executedAt) { super(location, name, ARTEFACT_TYPE, description, dependencies); @@ -146,21 +93,6 @@ public Job(String location, String name, String description, Set depende this.executedAt = executedAt; } - /** - * Instantiates a new job. - * - * @param name the name - * @param group the group - * @param clazz the clazz - * @param handler the handler - * @param engine the engine - * @param description the description - * @param expression the expression - * @param singleton the singleton - * @param parameters the parameters - * @param location the location - * @param dependencies the dependencies - */ public Job(String name, String group, String clazz, String handler, String engine, String description, String expression, Boolean singleton, List parameters, String location, Set dependencies) { super(location, name, ARTEFACT_TYPE, description, dependencies); @@ -173,200 +105,91 @@ public Job(String name, String group, String clazz, String handler, String engin this.parameters = parameters; } - /** - * Instantiates a new job. - */ public Job() { super(); this.type = ARTEFACT_TYPE; } - /** - * Gets the id. - * - * @return the id - */ public Long getId() { return id; } - /** - * Sets the id. - * - * @param id the new id - */ public void setId(Long id) { this.id = id; } - /** - * Gets the group. - * - * @return the group - */ public String getGroup() { return group; } - /** - * Sets the group. - * - * @param group the new group - */ public void setGroup(String group) { this.group = group; } - /** - * Gets the clazz. - * - * @return the clazz - */ public String getClazz() { return clazz; } - /** - * Sets the clazz. - * - * @param clazz the new clazz - */ public void setClazz(String clazz) { this.clazz = clazz; } - /** - * Gets the expression. - * - * @return the expression - */ public String getExpression() { return expression; } - /** - * Sets the expression. - * - * @param expression the new expression - */ public void setExpression(String expression) { this.expression = expression; } - /** - * Gets the handler. - * - * @return the handler - */ public String getHandler() { return handler; } - /** - * Sets the handler. - * - * @param handler the new handler - */ public void setHandler(String handler) { this.handler = handler; } - /** - * Gets the engine. - * - * @return the engine - */ public String getEngine() { return engine; } - /** - * Sets the engine. - * - * @param engine the new engine - */ public void setEngine(String engine) { this.engine = engine; } - /** - * Checks if is singleton. - * - * @return true, if is singleton - */ public Boolean isSingleton() { return singleton; } - /** - * Sets the singleton. - * - * @param singleton the new singleton - */ public void setSingleton(Boolean singleton) { this.singleton = singleton; } - /** - * Checks if is enabled. - * - * @return true, if is enabled - */ public Boolean isEnabled() { return enabled; } - /** - * Sets the enabled. - * - * @param enabled the new enabled - */ public void setEnabled(Boolean enabled) { this.enabled = enabled; } - /** - * Gets the status. - * - * @return the status - */ public JobStatus getStatus() { return status; } - /** - * Sets the status. - * - * @param status the new status - */ public void setStatus(JobStatus status) { this.status = status; } - /** - * Gets the parameters list. - * - * @return the parameters list - */ public List getParameters() { return parameters; } - /** - * Sets the parameters list. - * - * @param parameters the new parameters list - */ public void setParameters(List parameters) { this.parameters = parameters; } - /** - * Get the parameter by name. - * - * @param name the name - * @return the parameter - */ public JobParameter getParameter(String name) { for (JobParameter p : parameters) { if (p.getName() @@ -377,53 +200,26 @@ public JobParameter getParameter(String name) { return null; } - /** - * Gets the message. - * - * @return the message - */ public String getMessage() { return message; } - /** - * Sets the message. - * - * @param message the new message - */ public void setMessage(String message) { this.message = message; } - /** - * Gets the executed at. - * - * @return the executed at - */ public Timestamp getExecutedAt() { return executedAt; } - /** - * Sets the executed at. - * - * @param executedAt the new executed at - */ public void setExecutedAt(Timestamp executedAt) { this.executedAt = executedAt; } - /** - * To string. - * - * @return the string - */ @Override public String toString() { - return "Job {" + " id=" + id + ", group=" + group + ", clazz=" + clazz + ", expression=" + expression + ", handler=" + handler + return "Job {" + "id=" + id + ", group=" + group + ", clazz=" + clazz + ", expression=" + expression + ", handler=" + handler + ", engine=" + engine + ", singleton=" + singleton + ", enabled=" + enabled + ", parameters=" + parameters + ", status=" - + status + ", message=" + message + ", executedAt=" + executedAt + ", location=" + location + ", name=" + name + ", type=" - + type + ", description=" + description + ", key=" + key + ", dependencies=" + dependencies + ", createdBy=" + createdBy - + ", createdAt=" + createdAt + ", updatedBy=" + updatedBy + ", updatedAt=" + updatedAt + '}'; + + status + ", message=" + message + ", executedAt=" + executedAt + '}'; } } diff --git a/components/engine/engine-jobs/src/test/java/org/eclipse/dirigible/components/jobs/TestConfig.java b/components/engine/engine-jobs/src/test/java/org/eclipse/dirigible/components/jobs/TestConfig.java index 5f75dbab4eb..a8feaa35c48 100644 --- a/components/engine/engine-jobs/src/test/java/org/eclipse/dirigible/components/jobs/TestConfig.java +++ b/components/engine/engine-jobs/src/test/java/org/eclipse/dirigible/components/jobs/TestConfig.java @@ -13,15 +13,15 @@ import org.eclipse.dirigible.components.base.tenant.Tenant; import org.eclipse.dirigible.components.base.tenant.TenantContext; import org.springframework.boot.test.context.TestConfiguration; -import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.test.context.bean.override.mockito.MockitoBean; @TestConfiguration public class TestConfig { - @MockBean + @MockitoBean private TenantContext tenantContext; - @MockBean + @MockitoBean @DefaultTenant private Tenant defaultTenant; } diff --git a/components/engine/engine-jobs/src/test/java/org/eclipse/dirigible/components/jobs/endpoint/JobEndpointTest.java b/components/engine/engine-jobs/src/test/java/org/eclipse/dirigible/components/jobs/endpoint/JobEndpointTest.java index 65cf0844f89..dd804663b48 100644 --- a/components/engine/engine-jobs/src/test/java/org/eclipse/dirigible/components/jobs/endpoint/JobEndpointTest.java +++ b/components/engine/engine-jobs/src/test/java/org/eclipse/dirigible/components/jobs/endpoint/JobEndpointTest.java @@ -34,7 +34,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.domain.EntityScan; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.data.domain.Page; @@ -58,33 +58,35 @@ @Transactional public class JobEndpointTest { + /** The wac. */ + @Autowired + protected WebApplicationContext wac; /** The entity manager. */ @Autowired private EntityManager entityManager; - /** The job service. */ @Autowired private JobService jobService; - /** The job repository. */ @Autowired private JobRepository jobRepository; - /** The test job. */ private Job testJob; - /** The mockMvc. */ @Autowired private MockMvc mockMvc; - - /** The wac. */ - @Autowired - protected WebApplicationContext wac; - /** The spring security filter chain. */ @Autowired private FilterChainProxy springSecurityFilterChain; + + /** + * The Class TestConfiguration. + */ + @SpringBootApplication + static class TestConfiguration { + } + /** * Setup. * @@ -111,6 +113,29 @@ public void setup() throws Exception { } + /** + * Creates the job. + * + * @param jobService the job repository + * @param name the job name + * @param group the job group + * @param clazz the job clazz + * @param handler the job handler + * @param engine the job engine + * @param description the job description + * @param expression the job expression + * @param singleton the singleton + * @param parameters the job parameters + * @param location the job location + * @param dependencies the dependencies + */ + public static void createJob(JobService jobService, String name, String group, String clazz, String handler, String engine, + String description, String expression, boolean singleton, List parameters, String location, + Set dependencies) { + Job job = new Job(name, group, clazz, handler, engine, description, expression, singleton, parameters, location, dependencies); + jobService.save(job); + } + /** * Cleanup. */ @@ -172,34 +197,4 @@ public void disableJob() throws Exception { // .andExpect(status().is2xxSuccessful()); } - - /** - * Creates the job. - * - * @param jobService the job repository - * @param name the job name - * @param group the job group - * @param clazz the job clazz - * @param handler the job handler - * @param engine the job engine - * @param description the job description - * @param expression the job expression - * @param singleton the singleton - * @param parameters the job parameters - * @param location the job location - * @param dependencies the dependencies - */ - public static void createJob(JobService jobService, String name, String group, String clazz, String handler, String engine, - String description, String expression, boolean singleton, List parameters, String location, - Set dependencies) { - Job job = new Job(name, group, clazz, handler, engine, description, expression, singleton, parameters, location, dependencies); - jobService.save(job); - } - - /** - * The Class TestConfiguration. - */ - @SpringBootApplication - static class TestConfiguration { - } } diff --git a/components/engine/engine-listeners/src/test/java/org/eclipse/dirigible/components/listeners/endpoint/ListenerEndpointTest.java b/components/engine/engine-listeners/src/test/java/org/eclipse/dirigible/components/listeners/endpoint/ListenerEndpointTest.java index a01b6a64dfd..6d4e4b290aa 100644 --- a/components/engine/engine-listeners/src/test/java/org/eclipse/dirigible/components/listeners/endpoint/ListenerEndpointTest.java +++ b/components/engine/engine-listeners/src/test/java/org/eclipse/dirigible/components/listeners/endpoint/ListenerEndpointTest.java @@ -22,13 +22,13 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc; import org.springframework.context.annotation.ComponentScan; import org.springframework.security.test.context.support.WithMockUser; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext.ClassMode; +import org.springframework.test.context.bean.override.mockito.MockitoBean; import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.test.web.servlet.MockMvc; import org.springframework.transaction.annotation.Transactional; @@ -64,11 +64,11 @@ public class ListenerEndpointTest { private MockMvc mockMvc; /** The tenant context. */ - @MockBean + @MockitoBean private TenantContext tenantContext; /** The tenant. */ - @MockBean + @MockitoBean @DefaultTenant private Tenant tenant; diff --git a/components/engine/engine-listeners/src/test/java/org/eclipse/dirigible/components/listeners/repository/ListenerRepositoryTest.java b/components/engine/engine-listeners/src/test/java/org/eclipse/dirigible/components/listeners/repository/ListenerRepositoryTest.java index 741dfda49ea..830deb142cc 100644 --- a/components/engine/engine-listeners/src/test/java/org/eclipse/dirigible/components/listeners/repository/ListenerRepositoryTest.java +++ b/components/engine/engine-listeners/src/test/java/org/eclipse/dirigible/components/listeners/repository/ListenerRepositoryTest.java @@ -23,10 +23,10 @@ import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.context.annotation.ComponentScan; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext.ClassMode; +import org.springframework.test.context.bean.override.mockito.MockitoBean; import org.springframework.transaction.annotation.Transactional; import java.util.List; @@ -55,11 +55,11 @@ public class ListenerRepositoryTest { private EntityManager entityManager; /** The tenant context. */ - @MockBean + @MockitoBean private TenantContext tenantContext; /** The tenant. */ - @MockBean + @MockitoBean @DefaultTenant private Tenant tenant; diff --git a/components/engine/engine-listeners/src/test/java/org/eclipse/dirigible/components/listeners/synchronizer/ListenerSynchronizerTest.java b/components/engine/engine-listeners/src/test/java/org/eclipse/dirigible/components/listeners/synchronizer/ListenerSynchronizerTest.java index d35b95b76c8..767fe33132c 100644 --- a/components/engine/engine-listeners/src/test/java/org/eclipse/dirigible/components/listeners/synchronizer/ListenerSynchronizerTest.java +++ b/components/engine/engine-listeners/src/test/java/org/eclipse/dirigible/components/listeners/synchronizer/ListenerSynchronizerTest.java @@ -22,10 +22,10 @@ import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.context.annotation.ComponentScan; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext.ClassMode; +import org.springframework.test.context.bean.override.mockito.MockitoBean; import java.nio.file.Path; import java.text.ParseException; @@ -52,11 +52,11 @@ public class ListenerSynchronizerTest { private ListenerRepository listenerRepository; /** The tenant context. */ - @MockBean + @MockitoBean private TenantContext tenantContext; /** The tenant. */ - @MockBean + @MockitoBean @DefaultTenant private Tenant tenant; diff --git a/components/engine/engine-odata/src/test/java/org/eclipse/dirigible/components/odata/TestConfig.java b/components/engine/engine-odata/src/test/java/org/eclipse/dirigible/components/odata/TestConfig.java index 1d5f379ada9..6ac95b0a971 100644 --- a/components/engine/engine-odata/src/test/java/org/eclipse/dirigible/components/odata/TestConfig.java +++ b/components/engine/engine-odata/src/test/java/org/eclipse/dirigible/components/odata/TestConfig.java @@ -13,15 +13,15 @@ import org.eclipse.dirigible.components.base.tenant.Tenant; import org.eclipse.dirigible.components.base.tenant.TenantContext; import org.springframework.boot.test.context.TestConfiguration; -import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.test.context.bean.override.mockito.MockitoBean; @TestConfiguration public class TestConfig { - @MockBean + @MockitoBean private TenantContext tenantContext; - @MockBean + @MockitoBean @DefaultTenant private Tenant defaultTenant; } diff --git a/components/engine/engine-openapi/src/test/java/org/eclipse/dirigible/components/openapi/endpoint/OpenAPIEndpointTest.java b/components/engine/engine-openapi/src/test/java/org/eclipse/dirigible/components/openapi/endpoint/OpenAPIEndpointTest.java index 1feceb30774..bb5c0dcc10c 100644 --- a/components/engine/engine-openapi/src/test/java/org/eclipse/dirigible/components/openapi/endpoint/OpenAPIEndpointTest.java +++ b/components/engine/engine-openapi/src/test/java/org/eclipse/dirigible/components/openapi/endpoint/OpenAPIEndpointTest.java @@ -9,13 +9,6 @@ */ package org.eclipse.dirigible.components.openapi.endpoint; -import static org.eclipse.dirigible.components.openapi.repository.OpenAPIRepositoryTest.createOpenAPI; -import static org.hamcrest.CoreMatchers.containsString; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; -import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - import org.eclipse.dirigible.components.base.tenant.DefaultTenant; import org.eclipse.dirigible.components.base.tenant.Tenant; import org.eclipse.dirigible.components.base.tenant.TenantContext; @@ -31,17 +24,24 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.domain.EntityScan; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc; import org.springframework.context.annotation.ComponentScan; import org.springframework.security.test.context.support.WithMockUser; import org.springframework.security.web.FilterChainProxy; +import org.springframework.test.context.bean.override.mockito.MockitoBean; import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.test.web.servlet.MockMvc; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.context.WebApplicationContext; +import static org.eclipse.dirigible.components.openapi.repository.OpenAPIRepositoryTest.createOpenAPI; +import static org.hamcrest.CoreMatchers.containsString; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + /** * The Class OpenAPIEndpointTest. */ @@ -54,18 +54,15 @@ @Transactional class OpenAPIEndpointTest { + /** The wac. */ + @Autowired + protected WebApplicationContext wac; /** The open API repository. */ @Autowired private OpenAPIRepository openAPIRepository; - /** The mock mvc. */ @Autowired private MockMvc mockMvc; - - /** The wac. */ - @Autowired - protected WebApplicationContext wac; - /** The spring security filter chain. */ @Autowired private FilterChainProxy springSecurityFilterChain; @@ -74,13 +71,21 @@ class OpenAPIEndpointTest { @Autowired private IRepository repository; - @MockBean + @MockitoBean private TenantContext tenantContext; - @MockBean + @MockitoBean @DefaultTenant private Tenant defaultTenant; + + /** + * The Class TestConfiguration. + */ + @SpringBootApplication + static class TestConfiguration { + } + /** * Setup. */ @@ -124,11 +129,4 @@ public void testGetVersion() throws Exception { .andExpect(content().string(containsString( "{\"openapi\":\"3.0.1\",\"info\":{\"title\":\"Applications Services Open API\",\"description\":\"Services Open API provided by the applications\",\"contact\":{\"name\":\"Eclipse Dirigible\",\"url\":\"https://www.dirigible.io\",\"email\":\"dirigible-dev@eclipse.org\"},\"license\":{\"name\":\"Eclipse Public License - v 2.0\",\"url\":\"https://www.eclipse.org/legal/epl-v20.html\"},\"version\":\"0.0.1\"},\"servers\":[],\"security\":[],\"tags\":[],\"paths\":{},\"components\":{\"schemas\":{},\"responses\":{},\"parameters\":{},\"examples\":{},\"requestBodies\":{},\"headers\":{},\"securitySchemes\":{},\"links\":{},\"callbacks\":{}}}"))); } - - /** - * The Class TestConfiguration. - */ - @SpringBootApplication - static class TestConfiguration { - } } diff --git a/components/engine/engine-openapi/src/test/java/org/eclipse/dirigible/components/openapi/repository/OpenAPIRepositoryTest.java b/components/engine/engine-openapi/src/test/java/org/eclipse/dirigible/components/openapi/repository/OpenAPIRepositoryTest.java index 9658ad7e159..55626cdbf45 100644 --- a/components/engine/engine-openapi/src/test/java/org/eclipse/dirigible/components/openapi/repository/OpenAPIRepositoryTest.java +++ b/components/engine/engine-openapi/src/test/java/org/eclipse/dirigible/components/openapi/repository/OpenAPIRepositoryTest.java @@ -9,6 +9,7 @@ */ package org.eclipse.dirigible.components.openapi.repository; +import jakarta.persistence.EntityManager; import org.eclipse.dirigible.components.base.tenant.DefaultTenant; import org.eclipse.dirigible.components.base.tenant.Tenant; import org.eclipse.dirigible.components.base.tenant.TenantContext; @@ -21,14 +22,14 @@ import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.context.annotation.ComponentScan; +import org.springframework.test.context.bean.override.mockito.MockitoBean; import org.springframework.transaction.annotation.Transactional; -import jakarta.persistence.EntityManager; import java.util.Optional; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; /** * The Class OpenAPIRepositoryTest. @@ -40,21 +41,27 @@ @Transactional public class OpenAPIRepositoryTest { - /** The open API repository. */ - @Autowired - private OpenAPIRepository openAPIRepository; - /** The entity manager. */ @Autowired EntityManager entityManager; - - @MockBean + /** The open API repository. */ + @Autowired + private OpenAPIRepository openAPIRepository; + @MockitoBean private TenantContext tenantContext; - @MockBean + @MockitoBean @DefaultTenant private Tenant defaultTenant; + + /** + * The Class TestConfiguration. + */ + @SpringBootApplication + static class TestConfiguration { + } + /** * Setup. */ @@ -79,6 +86,19 @@ public void cleanup() { openAPIRepository.deleteAll(); } + /** + * Creates the openapi. + * + * @param location the location + * @param name the name + * @param description the description + * @return the openapi + */ + public static OpenAPI createOpenAPI(String location, String name, String description) { + OpenAPI openAPI = new OpenAPI(location, name, description); + return openAPI; + } + /** * Gets the one. * @@ -112,24 +132,4 @@ public void getReferenceUsingEntityManager() { assertNotNull(openAPI); assertNotNull(openAPI.getLocation()); } - - /** - * Creates the openapi. - * - * @param location the location - * @param name the name - * @param description the description - * @return the openapi - */ - public static OpenAPI createOpenAPI(String location, String name, String description) { - OpenAPI openAPI = new OpenAPI(location, name, description); - return openAPI; - } - - /** - * The Class TestConfiguration. - */ - @SpringBootApplication - static class TestConfiguration { - } } diff --git a/components/engine/engine-openapi/src/test/java/org/eclipse/dirigible/components/openapi/service/OpenAPIServiceTest.java b/components/engine/engine-openapi/src/test/java/org/eclipse/dirigible/components/openapi/service/OpenAPIServiceTest.java index 92e61c73460..1b73d12b862 100644 --- a/components/engine/engine-openapi/src/test/java/org/eclipse/dirigible/components/openapi/service/OpenAPIServiceTest.java +++ b/components/engine/engine-openapi/src/test/java/org/eclipse/dirigible/components/openapi/service/OpenAPIServiceTest.java @@ -9,12 +9,6 @@ */ package org.eclipse.dirigible.components.openapi.service; -import static org.eclipse.dirigible.components.openapi.repository.OpenAPIRepositoryTest.createOpenAPI; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertThrows; -import java.util.List; - import org.eclipse.dirigible.components.base.tenant.DefaultTenant; import org.eclipse.dirigible.components.base.tenant.Tenant; import org.eclipse.dirigible.components.base.tenant.TenantContext; @@ -27,12 +21,17 @@ import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.context.annotation.ComponentScan; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; +import org.springframework.test.context.bean.override.mockito.MockitoBean; import org.springframework.transaction.annotation.Transactional; +import java.util.List; + +import static org.eclipse.dirigible.components.openapi.repository.OpenAPIRepositoryTest.createOpenAPI; +import static org.junit.jupiter.api.Assertions.*; + /** * The Class OpenAPIServiceTest. */ @@ -51,10 +50,10 @@ class OpenAPIServiceTest { @Autowired private OpenAPIService openAPIService; - @MockBean + @MockitoBean private TenantContext tenantContext; - @MockBean + @MockitoBean @DefaultTenant private Tenant defaultTenant; diff --git a/components/engine/engine-openapi/src/test/java/org/eclipse/dirigible/components/openapi/synchronizer/OpenAPISynchronizerTest.java b/components/engine/engine-openapi/src/test/java/org/eclipse/dirigible/components/openapi/synchronizer/OpenAPISynchronizerTest.java index 9ec6e4d6b28..54c3937120a 100644 --- a/components/engine/engine-openapi/src/test/java/org/eclipse/dirigible/components/openapi/synchronizer/OpenAPISynchronizerTest.java +++ b/components/engine/engine-openapi/src/test/java/org/eclipse/dirigible/components/openapi/synchronizer/OpenAPISynchronizerTest.java @@ -9,17 +9,7 @@ */ package org.eclipse.dirigible.components.openapi.synchronizer; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertTrue; - -import java.io.IOException; -import java.nio.file.Path; -import java.text.ParseException; -import java.util.List; - import jakarta.persistence.EntityManager; - import org.eclipse.dirigible.components.base.tenant.DefaultTenant; import org.eclipse.dirigible.components.base.tenant.Tenant; import org.eclipse.dirigible.components.base.tenant.TenantContext; @@ -34,10 +24,17 @@ import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.context.annotation.ComponentScan; +import org.springframework.test.context.bean.override.mockito.MockitoBean; import org.springframework.transaction.annotation.Transactional; +import java.io.IOException; +import java.nio.file.Path; +import java.text.ParseException; +import java.util.List; + +import static org.junit.jupiter.api.Assertions.*; + /** * The Class OpenAPISynchronizerTest. */ @@ -48,31 +45,36 @@ @Transactional class OpenAPISynchronizerTest { + /** + * The entity manager. + */ + @Autowired + EntityManager entityManager; /** * The openapi repository. */ @Autowired private OpenAPIRepository openAPIRepository; - /** * The openapi synchronizer. */ @Autowired private OpenAPISynchronizer openAPISynchronizer; - - /** - * The entity manager. - */ - @Autowired - EntityManager entityManager; - - @MockBean + @MockitoBean private TenantContext tenantContext; - @MockBean + @MockitoBean @DefaultTenant private Tenant defaultTenant; + + /** + * The Class TestConfiguration. + */ + @SpringBootApplication + static class TestConfiguration { + } + /** * Setup. */ @@ -134,11 +136,4 @@ public void testLoad() throws IOException, ParseException { .getLocation()); } - /** - * The Class TestConfiguration. - */ - @SpringBootApplication - static class TestConfiguration { - } - } diff --git a/components/engine/engine-proxy/pom.xml b/components/engine/engine-proxy/pom.xml index 8fc83901bd6..2ae4ec204b4 100644 --- a/components/engine/engine-proxy/pom.xml +++ b/components/engine/engine-proxy/pom.xml @@ -17,7 +17,7 @@ org.springframework.cloud spring-cloud-starter-gateway-server-webmvc - 4.3.3 + 5.0.0 org.eclipse.dirigible diff --git a/components/engine/engine-security/src/test/java/org/eclipse/dirigible/components/security/endpoint/AccessEndpointTest.java b/components/engine/engine-security/src/test/java/org/eclipse/dirigible/components/security/endpoint/AccessEndpointTest.java index 04bf7e07bad..cc80fcfc52d 100644 --- a/components/engine/engine-security/src/test/java/org/eclipse/dirigible/components/security/endpoint/AccessEndpointTest.java +++ b/components/engine/engine-security/src/test/java/org/eclipse/dirigible/components/security/endpoint/AccessEndpointTest.java @@ -18,7 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.domain.EntityScan; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.http.MediaType; @@ -47,22 +47,27 @@ @Transactional class AccessEndpointTest { + /** The wac. */ + @Autowired + protected WebApplicationContext wac; /** The access repository. */ @Autowired private AccessRepository accessRepository; - /** The mock mvc. */ @Autowired private MockMvc mockMvc; - - /** The wac. */ - @Autowired - protected WebApplicationContext wac; - /** The spring security filter chain. */ @Autowired private FilterChainProxy springSecurityFilterChain; + + /** + * The Class TestConfiguration. + */ + @SpringBootApplication + static class TestConfiguration { + } + /** * Setup. */ @@ -98,11 +103,4 @@ public void testGetSecurityAccesses() throws Exception { .andDo(print()) .andExpect(status().isOk()); } - - /** - * The Class TestConfiguration. - */ - @SpringBootApplication - static class TestConfiguration { - } } diff --git a/components/engine/engine-security/src/test/java/org/eclipse/dirigible/components/security/endpoint/RoleEndpointTest.java b/components/engine/engine-security/src/test/java/org/eclipse/dirigible/components/security/endpoint/RoleEndpointTest.java index ae9c56e04e4..e50e7f184c3 100644 --- a/components/engine/engine-security/src/test/java/org/eclipse/dirigible/components/security/endpoint/RoleEndpointTest.java +++ b/components/engine/engine-security/src/test/java/org/eclipse/dirigible/components/security/endpoint/RoleEndpointTest.java @@ -18,7 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.domain.EntityScan; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.security.test.context.support.WithMockUser; @@ -46,22 +46,27 @@ @Transactional class RoleEndpointTest { + /** The wac. */ + @Autowired + protected WebApplicationContext wac; /** The role repository. */ @Autowired private RoleRepository roleRepository; - /** The mock mvc. */ @Autowired private MockMvc mockMvc; - - /** The wac. */ - @Autowired - protected WebApplicationContext wac; - /** The spring security filter chain. */ @Autowired private FilterChainProxy springSecurityFilterChain; + + /** + * The Class TestConfiguration. + */ + @SpringBootApplication + static class TestConfiguration { + } + /** * Setup. */ @@ -98,11 +103,4 @@ public void testGetSecurityRoles() throws Exception { .andDo(print()) .andExpect(status().isOk()); } - - /** - * The Class TestConfiguration. - */ - @SpringBootApplication - static class TestConfiguration { - } } diff --git a/components/engine/engine-web/src/test/java/org/eclipse/dirigible/components/engine/web/TestConfig.java b/components/engine/engine-web/src/test/java/org/eclipse/dirigible/components/engine/web/TestConfig.java index dfe242912b6..d35b131ed15 100644 --- a/components/engine/engine-web/src/test/java/org/eclipse/dirigible/components/engine/web/TestConfig.java +++ b/components/engine/engine-web/src/test/java/org/eclipse/dirigible/components/engine/web/TestConfig.java @@ -13,15 +13,15 @@ import org.eclipse.dirigible.components.base.tenant.Tenant; import org.eclipse.dirigible.components.base.tenant.TenantContext; import org.springframework.boot.test.context.TestConfiguration; -import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.test.context.bean.override.mockito.MockitoBean; @TestConfiguration public class TestConfig { - @MockBean + @MockitoBean private TenantContext tenantContext; - @MockBean + @MockitoBean @DefaultTenant private Tenant defaultTenant; } diff --git a/components/engine/engine-web/src/test/java/org/eclipse/dirigible/components/engine/web/endpoint/WebEndpointTest.java b/components/engine/engine-web/src/test/java/org/eclipse/dirigible/components/engine/web/endpoint/WebEndpointTest.java index 390f81c074f..cd5dac5016a 100644 --- a/components/engine/engine-web/src/test/java/org/eclipse/dirigible/components/engine/web/endpoint/WebEndpointTest.java +++ b/components/engine/engine-web/src/test/java/org/eclipse/dirigible/components/engine/web/endpoint/WebEndpointTest.java @@ -19,12 +19,12 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.domain.EntityScan; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc; import org.springframework.context.annotation.ComponentScan; import org.springframework.security.test.context.support.WithMockUser; import org.springframework.security.web.FilterChainProxy; +import org.springframework.test.context.bean.override.mockito.MockitoBean; import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.test.web.servlet.MockMvc; import org.springframework.transaction.annotation.Transactional; @@ -52,37 +52,38 @@ @Transactional public class WebEndpointTest { - /** The mock mvc. */ - @Autowired - private MockMvc mockMvc; - + /** The project json. */ + private static final String projectJson = "{\n" + " \"guid\":\"demo\",\n" + " \"repository\":{\n" + " \"type\":\"git\",\n" + + " \"branch\":\"master\",\n" + " \"url\":\"https://github.com/dirigiblelabs/demo.git\"\n" + " }}"; /** The wac. */ @Autowired protected WebApplicationContext wac; - + /** The definition repository. */ + @MockitoBean + DefinitionRepository definitionRepository; + /** The mock mvc. */ + @Autowired + private MockMvc mockMvc; /** The spring security filter chain. */ @Autowired private FilterChainProxy springSecurityFilterChain; - /** The synchronization processor. */ @Autowired private SynchronizationProcessor synchronizationProcessor; - /** The classpath expander. */ @Autowired private ClasspathExpander classpathExpander; - /** The synchronization watcher. */ @Autowired private SynchronizationWatcher synchronizationWatcher; - /** The definition repository. */ - @MockBean - DefinitionRepository definitionRepository; - /** The project json. */ - private static final String projectJson = "{\n" + " \"guid\":\"demo\",\n" + " \"repository\":{\n" + " \"type\":\"git\",\n" - + " \"branch\":\"master\",\n" + " \"url\":\"https://github.com/dirigiblelabs/demo.git\"\n" + " }}"; + /** + * The Class TestConfiguration. + */ + @SpringBootApplication + static class TestConfiguration { + } /** * Load the artefact. @@ -127,11 +128,4 @@ public void process() throws Exception { synchronizationProcessor.processSynchronizers(); } } - - /** - * The Class TestConfiguration. - */ - @SpringBootApplication - static class TestConfiguration { - } } diff --git a/components/engine/engine-websockets/src/test/java/org/eclipse/dirigible/components/websockets/TestConfig.java b/components/engine/engine-websockets/src/test/java/org/eclipse/dirigible/components/websockets/TestConfig.java index 49a31cc51f4..9009d2e6da3 100644 --- a/components/engine/engine-websockets/src/test/java/org/eclipse/dirigible/components/websockets/TestConfig.java +++ b/components/engine/engine-websockets/src/test/java/org/eclipse/dirigible/components/websockets/TestConfig.java @@ -13,15 +13,15 @@ import org.eclipse.dirigible.components.base.tenant.Tenant; import org.eclipse.dirigible.components.base.tenant.TenantContext; import org.springframework.boot.test.context.TestConfiguration; -import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.test.context.bean.override.mockito.MockitoBean; @TestConfiguration public class TestConfig { - @MockBean + @MockitoBean private TenantContext tenantContext; - @MockBean + @MockitoBean @DefaultTenant private Tenant defaultTenant; } diff --git a/components/engine/engine-websockets/src/test/java/org/eclipse/dirigible/components/websockets/endpoint/WebsocketEndpointTest.java b/components/engine/engine-websockets/src/test/java/org/eclipse/dirigible/components/websockets/endpoint/WebsocketEndpointTest.java index b2ef052034d..027baa6884d 100644 --- a/components/engine/engine-websockets/src/test/java/org/eclipse/dirigible/components/websockets/endpoint/WebsocketEndpointTest.java +++ b/components/engine/engine-websockets/src/test/java/org/eclipse/dirigible/components/websockets/endpoint/WebsocketEndpointTest.java @@ -22,7 +22,7 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.security.test.context.support.WithMockUser; @@ -43,26 +43,30 @@ @Transactional public class WebsocketEndpointTest { + /** The wac. */ + @Autowired + protected WebApplicationContext wac; /** The websocket service. */ @Autowired private WebsocketService websocketService; - /** The websocket repository. */ @Autowired private WebsocketRepository websocketRepository; - /** The mock mvc. */ @Autowired private MockMvc mockMvc; - - /** The wac. */ - @Autowired - protected WebApplicationContext wac; - /** The spring security filter chain. */ @Autowired private FilterChainProxy springSecurityFilterChain; + + /** + * The Class TestConfiguration. + */ + @SpringBootApplication + static class TestConfiguration { + } + /** * Setup. */ @@ -96,11 +100,4 @@ public void findAllExtensionPoints() throws Exception { .andExpect(status().is2xxSuccessful()); // .andExpect(jsonPath("$.content[0].location").value("/a/b/c/w1.websocket")); } - - /** - * The Class TestConfiguration. - */ - @SpringBootApplication - static class TestConfiguration { - } } diff --git a/components/engine/engine-wiki/src/test/java/org/eclipse/dirigible/components/engine/wiki/endpoint/TestConfig.java b/components/engine/engine-wiki/src/test/java/org/eclipse/dirigible/components/engine/wiki/endpoint/TestConfig.java index f38e0a39a95..516d954691d 100644 --- a/components/engine/engine-wiki/src/test/java/org/eclipse/dirigible/components/engine/wiki/endpoint/TestConfig.java +++ b/components/engine/engine-wiki/src/test/java/org/eclipse/dirigible/components/engine/wiki/endpoint/TestConfig.java @@ -13,15 +13,15 @@ import org.eclipse.dirigible.components.base.tenant.Tenant; import org.eclipse.dirigible.components.base.tenant.TenantContext; import org.springframework.boot.test.context.TestConfiguration; -import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.test.context.bean.override.mockito.MockitoBean; @TestConfiguration public class TestConfig { - @MockBean + @MockitoBean private TenantContext tenantContext; - @MockBean + @MockitoBean @DefaultTenant private Tenant defaultTenant; } diff --git a/components/engine/engine-wiki/src/test/java/org/eclipse/dirigible/components/engine/wiki/endpoint/WikiEndpointTest.java b/components/engine/engine-wiki/src/test/java/org/eclipse/dirigible/components/engine/wiki/endpoint/WikiEndpointTest.java index 62b7a880382..3987b4fa848 100644 --- a/components/engine/engine-wiki/src/test/java/org/eclipse/dirigible/components/engine/wiki/endpoint/WikiEndpointTest.java +++ b/components/engine/engine-wiki/src/test/java/org/eclipse/dirigible/components/engine/wiki/endpoint/WikiEndpointTest.java @@ -26,7 +26,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.domain.EntityScan; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.security.test.context.support.WithMockUser; @@ -48,14 +48,12 @@ @Transactional public class WikiEndpointTest { - /** The mock mvc. */ - @Autowired - private MockMvc mockMvc; - /** The wac. */ @Autowired protected WebApplicationContext wac; - + /** The mock mvc. */ + @Autowired + private MockMvc mockMvc; /** The spring security filter chain. */ @Autowired private FilterChainProxy springSecurityFilterChain; @@ -64,6 +62,14 @@ public class WikiEndpointTest { @Autowired private SynchronizationProcessor synchronizationProcessor; + + /** + * The Class TestConfiguration. + */ + @SpringBootApplication + static class TestConfiguration { + } + /** * Load the artefact. * @@ -88,11 +94,4 @@ public void process() throws Exception { synchronizationProcessor.processSynchronizers(); } } - - /** - * The Class TestConfiguration. - */ - @SpringBootApplication - static class TestConfiguration { - } } diff --git a/components/ide/ide-git/src/test/java/org/eclipse/dirigible/components/ide/git/command/CloneComandTest.java b/components/ide/ide-git/src/test/java/org/eclipse/dirigible/components/ide/git/command/CloneComandTest.java index 6935d0819bf..a0b52fcf8bc 100644 --- a/components/ide/ide-git/src/test/java/org/eclipse/dirigible/components/ide/git/command/CloneComandTest.java +++ b/components/ide/ide-git/src/test/java/org/eclipse/dirigible/components/ide/git/command/CloneComandTest.java @@ -28,7 +28,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.domain.EntityScan; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.security.test.context.support.WithMockUser; @@ -53,6 +53,14 @@ public class CloneComandTest { @Autowired private WorkspaceService workspaceService; + + /** + * The Class TestConfiguration. + */ + @SpringBootApplication + static class TestConfiguration { + } + /** * Creates the workspace test. * @@ -143,11 +151,4 @@ public void createWorkspaceNoProjectTest() throws GitConnectorException { } } - /** - * The Class TestConfiguration. - */ - @SpringBootApplication - static class TestConfiguration { - } - } diff --git a/components/ide/ide-git/src/test/java/org/eclipse/dirigible/components/ide/git/command/GitConnectorTest.java b/components/ide/ide-git/src/test/java/org/eclipse/dirigible/components/ide/git/command/GitConnectorTest.java index 1b32f38ad61..ada44e53927 100644 --- a/components/ide/ide-git/src/test/java/org/eclipse/dirigible/components/ide/git/command/GitConnectorTest.java +++ b/components/ide/ide-git/src/test/java/org/eclipse/dirigible/components/ide/git/command/GitConnectorTest.java @@ -30,7 +30,7 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.domain.EntityScan; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.security.test.context.support.WithMockUser; @@ -50,6 +50,14 @@ public class GitConnectorTest { /** The Constant DIRIGIBLE_TEST_GIT_ENABLED. */ public static final String DIRIGIBLE_TEST_GIT_ENABLED = "DIRIGIBLE_TEST_GIT_ENABLED"; + + /** + * The Class TestConfiguration. + */ + @SpringBootApplication + static class TestConfiguration { + } + /** * Clone repository. * @@ -83,11 +91,4 @@ public void cloneRepository() throws IOException, InvalidRemoteException, Transp } } - /** - * The Class TestConfiguration. - */ - @SpringBootApplication - static class TestConfiguration { - } - } diff --git a/components/ide/ide-git/src/test/java/org/eclipse/dirigible/components/ide/git/command/InitCommandTest.java b/components/ide/ide-git/src/test/java/org/eclipse/dirigible/components/ide/git/command/InitCommandTest.java index 5baaf9f38cf..f3a0ef20e0d 100644 --- a/components/ide/ide-git/src/test/java/org/eclipse/dirigible/components/ide/git/command/InitCommandTest.java +++ b/components/ide/ide-git/src/test/java/org/eclipse/dirigible/components/ide/git/command/InitCommandTest.java @@ -20,7 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.domain.EntityScan; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.security.test.context.support.WithMockUser; @@ -41,6 +41,14 @@ public class InitCommandTest { @Autowired private InitCommand initCommand; + + /** + * The Class TestConfiguration. + */ + @SpringBootApplication + static class TestConfiguration { + } + /** * Inits the repository test. * @@ -61,11 +69,4 @@ public void initRepositoryTest() throws GitConnectorException, IOException { } } - /** - * The Class TestConfiguration. - */ - @SpringBootApplication - static class TestConfiguration { - } - } diff --git a/components/ide/ide-git/src/test/java/org/eclipse/dirigible/components/ide/git/command/PullComandTest.java b/components/ide/ide-git/src/test/java/org/eclipse/dirigible/components/ide/git/command/PullComandTest.java index 086838a2268..2d4260ce0fe 100644 --- a/components/ide/ide-git/src/test/java/org/eclipse/dirigible/components/ide/git/command/PullComandTest.java +++ b/components/ide/ide-git/src/test/java/org/eclipse/dirigible/components/ide/git/command/PullComandTest.java @@ -26,7 +26,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.domain.EntityScan; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.security.test.context.support.WithMockUser; @@ -55,6 +55,14 @@ public class PullComandTest { @Autowired private WorkspaceService workspaceService; + + /** + * The Class TestConfiguration. + */ + @SpringBootApplication + static class TestConfiguration { + } + /** * Creates the workspace test. * @@ -82,11 +90,4 @@ public void createWorkspaceTest() throws GitConnectorException { } } - /** - * The Class TestConfiguration. - */ - @SpringBootApplication - static class TestConfiguration { - } - } diff --git a/components/ide/ide-git/src/test/java/org/eclipse/dirigible/components/ide/git/command/PushComandTest.java b/components/ide/ide-git/src/test/java/org/eclipse/dirigible/components/ide/git/command/PushComandTest.java index c3358d72760..69b5a83d9bf 100644 --- a/components/ide/ide-git/src/test/java/org/eclipse/dirigible/components/ide/git/command/PushComandTest.java +++ b/components/ide/ide-git/src/test/java/org/eclipse/dirigible/components/ide/git/command/PushComandTest.java @@ -26,7 +26,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.domain.EntityScan; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.security.test.context.support.WithMockUser; @@ -64,6 +64,14 @@ public class PushComandTest { @Autowired private WorkspaceService workspaceService; + + /** + * The Class TestConfiguration. + */ + @SpringBootApplication + static class TestConfiguration { + } + /** * Creates the workspace test. * @@ -100,11 +108,4 @@ public void createWorkspaceTest() throws GitConnectorException { } } - /** - * The Class TestConfiguration. - */ - @SpringBootApplication - static class TestConfiguration { - } - } diff --git a/components/ide/ide-git/src/test/java/org/eclipse/dirigible/components/ide/git/command/ResetComandTest.java b/components/ide/ide-git/src/test/java/org/eclipse/dirigible/components/ide/git/command/ResetComandTest.java index ecb5e89da7d..515789aea3b 100644 --- a/components/ide/ide-git/src/test/java/org/eclipse/dirigible/components/ide/git/command/ResetComandTest.java +++ b/components/ide/ide-git/src/test/java/org/eclipse/dirigible/components/ide/git/command/ResetComandTest.java @@ -25,7 +25,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.domain.EntityScan; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.security.test.context.support.WithMockUser; @@ -54,6 +54,14 @@ public class ResetComandTest { @Autowired private WorkspaceService workspaceService; + + /** + * The Class TestConfiguration. + */ + @SpringBootApplication + static class TestConfiguration { + } + /** * Creates the workspace test. * @@ -78,11 +86,4 @@ public void createWorkspaceTest() throws GitConnectorException { } } - /** - * The Class TestConfiguration. - */ - @SpringBootApplication - static class TestConfiguration { - } - } diff --git a/components/ide/ide-git/src/test/java/org/eclipse/dirigible/components/ide/git/command/ShareComandTest.java b/components/ide/ide-git/src/test/java/org/eclipse/dirigible/components/ide/git/command/ShareComandTest.java index 3bcc5c4b31e..03eed8f2771 100644 --- a/components/ide/ide-git/src/test/java/org/eclipse/dirigible/components/ide/git/command/ShareComandTest.java +++ b/components/ide/ide-git/src/test/java/org/eclipse/dirigible/components/ide/git/command/ShareComandTest.java @@ -23,7 +23,7 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.domain.EntityScan; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.security.test.context.support.WithMockUser; @@ -49,6 +49,14 @@ public class ShareComandTest { /** The workspaces service. */ private WorkspaceService workspaceService; + + /** + * The Class TestConfiguration. + */ + @SpringBootApplication + static class TestConfiguration { + } + /** * Creates the workspace test. * @@ -85,11 +93,4 @@ public void createWorkspaceTest() throws GitConnectorException { } } - /** - * The Class TestConfiguration. - */ - @SpringBootApplication - static class TestConfiguration { - } - } diff --git a/components/ide/ide-git/src/test/java/org/eclipse/dirigible/components/ide/git/command/UpdateDepenedenciesComandTest.java b/components/ide/ide-git/src/test/java/org/eclipse/dirigible/components/ide/git/command/UpdateDepenedenciesComandTest.java index 412acc60bfc..450b431643e 100644 --- a/components/ide/ide-git/src/test/java/org/eclipse/dirigible/components/ide/git/command/UpdateDepenedenciesComandTest.java +++ b/components/ide/ide-git/src/test/java/org/eclipse/dirigible/components/ide/git/command/UpdateDepenedenciesComandTest.java @@ -23,7 +23,7 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.domain.EntityScan; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.security.test.context.support.WithMockUser; @@ -49,6 +49,14 @@ public class UpdateDepenedenciesComandTest { /** The workspaces service. */ private WorkspaceService workspaceService; + + /** + * The Class TestConfiguration. + */ + @SpringBootApplication + static class TestConfiguration { + } + /** * Creates the workspace test. * @@ -81,11 +89,4 @@ public void createWorkspaceTest() throws GitConnectorException { } } - /** - * The Class TestConfiguration. - */ - @SpringBootApplication - static class TestConfiguration { - } - } diff --git a/components/ide/ide-problems/src/test/java/org/eclipse/dirigible/components/ide/problems/endpoint/ProblemsEndpointTest.java b/components/ide/ide-problems/src/test/java/org/eclipse/dirigible/components/ide/problems/endpoint/ProblemsEndpointTest.java index 4d2a6882a23..9c7214be0f5 100644 --- a/components/ide/ide-problems/src/test/java/org/eclipse/dirigible/components/ide/problems/endpoint/ProblemsEndpointTest.java +++ b/components/ide/ide-problems/src/test/java/org/eclipse/dirigible/components/ide/problems/endpoint/ProblemsEndpointTest.java @@ -13,6 +13,7 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + import org.eclipse.dirigible.components.ide.problems.domain.Problem; import org.eclipse.dirigible.components.ide.problems.service.ProblemService; import org.junit.jupiter.api.AfterEach; @@ -22,7 +23,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.domain.EntityScan; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.data.domain.PageRequest; @@ -52,6 +53,14 @@ class ProblemsEndpointTest { @Autowired private MockMvc mockMvc; + + /** + * The Class TestConfiguration. + */ + @SpringBootApplication + static class TestConfiguration { + } + /** * Setup. * @@ -79,6 +88,26 @@ void cleanup() throws Exception { } + /** + * Creates the problem. + * + * @param location the location + * @param type the type + * @param line the line + * @param column the column + * @param cause the cause + * @param expected the expected + * @param category the category + * @param module the module + * @param source the source + * @param program the program + * @return the problem + */ + public static Problem createProblem(String location, String type, String line, String column, String cause, String expected, + String category, String module, String source, String program) { + return new Problem(location, type, line, column, cause, expected, category, module, source, program); + } + /** * Find all problems. */ @@ -115,31 +144,4 @@ void getProblemsByCondition() throws Exception { .andDo(print()) .andExpect(status().is2xxSuccessful()); } - - /** - * Creates the problem. - * - * @param location the location - * @param type the type - * @param line the line - * @param column the column - * @param cause the cause - * @param expected the expected - * @param category the category - * @param module the module - * @param source the source - * @param program the program - * @return the problem - */ - public static Problem createProblem(String location, String type, String line, String column, String cause, String expected, - String category, String module, String source, String program) { - return new Problem(location, type, line, column, cause, expected, category, module, source, program); - } - - /** - * The Class TestConfiguration. - */ - @SpringBootApplication - static class TestConfiguration { - } } diff --git a/components/ide/ide-workspace/src/test/java/org/eclipse/dirigible/components/ide/workspace/endpoint/WorkspaceEndpointTest.java b/components/ide/ide-workspace/src/test/java/org/eclipse/dirigible/components/ide/workspace/endpoint/WorkspaceEndpointTest.java index f1a564228f9..24c17ed7097 100644 --- a/components/ide/ide-workspace/src/test/java/org/eclipse/dirigible/components/ide/workspace/endpoint/WorkspaceEndpointTest.java +++ b/components/ide/ide-workspace/src/test/java/org/eclipse/dirigible/components/ide/workspace/endpoint/WorkspaceEndpointTest.java @@ -33,7 +33,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.domain.EntityScan; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; @@ -55,22 +55,38 @@ @EntityScan("org.eclipse.dirigible.components") public class WorkspaceEndpointTest { + /** The wac. */ + @Autowired + protected WebApplicationContext wac; /** The workspace service. */ @Autowired private WorkspaceService workspaceService; - /** The mock mvc. */ @Autowired private MockMvc mockMvc; - - /** The wac. */ - @Autowired - protected WebApplicationContext wac; - /** The spring security filter chain. */ @Autowired private FilterChainProxy springSecurityFilterChain; + + /** + * The Class TestConfiguration. + */ + @SpringBootApplication + static class TestConfiguration { + + /** + * Creates the project status provider. + * + * @return the project status provider + */ + @Bean + public ProjectStatusProvider createProjectStatusProvider() { + return new DummyProjectStatusProvider(); + } + + } + /** * Setup. * @@ -150,22 +166,4 @@ public void move() throws Exception { .andDo(print()) .andExpect(status().is2xxSuccessful()); } - - /** - * The Class TestConfiguration. - */ - @SpringBootApplication - static class TestConfiguration { - - /** - * Creates the project status provider. - * - * @return the project status provider - */ - @Bean - public ProjectStatusProvider createProjectStatusProvider() { - return new DummyProjectStatusProvider(); - } - - } } diff --git a/components/ide/ide-workspace/src/test/java/org/eclipse/dirigible/components/ide/workspace/endpoint/WorkspaceFindEndpointTest.java b/components/ide/ide-workspace/src/test/java/org/eclipse/dirigible/components/ide/workspace/endpoint/WorkspaceFindEndpointTest.java index b47a2fd64bd..e9db292c184 100644 --- a/components/ide/ide-workspace/src/test/java/org/eclipse/dirigible/components/ide/workspace/endpoint/WorkspaceFindEndpointTest.java +++ b/components/ide/ide-workspace/src/test/java/org/eclipse/dirigible/components/ide/workspace/endpoint/WorkspaceFindEndpointTest.java @@ -23,7 +23,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.domain.EntityScan; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.http.MediaType; @@ -44,18 +44,24 @@ @EntityScan("org.eclipse.dirigible.components") public class WorkspaceFindEndpointTest { - /** The mock mvc. */ - @Autowired - private MockMvc mockMvc; - /** The wac. */ @Autowired protected WebApplicationContext wac; - + /** The mock mvc. */ + @Autowired + private MockMvc mockMvc; /** The spring security filter chain. */ @Autowired private FilterChainProxy springSecurityFilterChain; + + /** + * The Class TestConfiguration. + */ + @SpringBootApplication + static class TestConfiguration { + } + /** * Setup. * @@ -100,11 +106,4 @@ public void findInWorkspace() throws Exception { .andDo(print()) .andExpect(status().is2xxSuccessful()); } - - /** - * The Class TestConfiguration. - */ - @SpringBootApplication - static class TestConfiguration { - } } diff --git a/components/ide/ide-workspace/src/test/java/org/eclipse/dirigible/components/ide/workspace/endpoint/WorkspaceSearchEndpointTest.java b/components/ide/ide-workspace/src/test/java/org/eclipse/dirigible/components/ide/workspace/endpoint/WorkspaceSearchEndpointTest.java index f234023ff61..d9e12ba064c 100644 --- a/components/ide/ide-workspace/src/test/java/org/eclipse/dirigible/components/ide/workspace/endpoint/WorkspaceSearchEndpointTest.java +++ b/components/ide/ide-workspace/src/test/java/org/eclipse/dirigible/components/ide/workspace/endpoint/WorkspaceSearchEndpointTest.java @@ -23,7 +23,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.domain.EntityScan; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.http.MediaType; @@ -44,18 +44,24 @@ @EntityScan("org.eclipse.dirigible.components") public class WorkspaceSearchEndpointTest { - /** The mock mvc. */ - @Autowired - private MockMvc mockMvc; - /** The wac. */ @Autowired protected WebApplicationContext wac; - + /** The mock mvc. */ + @Autowired + private MockMvc mockMvc; /** The spring security filter chain. */ @Autowired private FilterChainProxy springSecurityFilterChain; + + /** + * The Class TestConfiguration. + */ + @SpringBootApplication + static class TestConfiguration { + } + /** * Setup. * @@ -87,11 +93,4 @@ public void findInWorkspace() throws Exception { .andDo(print()) .andExpect(status().is2xxSuccessful()); } - - /** - * The Class TestConfiguration. - */ - @SpringBootApplication - static class TestConfiguration { - } } diff --git a/components/ide/ide-workspace/src/test/java/org/eclipse/dirigible/components/ide/workspace/endpoint/WorkspacesEndpointTest.java b/components/ide/ide-workspace/src/test/java/org/eclipse/dirigible/components/ide/workspace/endpoint/WorkspacesEndpointTest.java index 128306634f8..49dbbf1b5a0 100644 --- a/components/ide/ide-workspace/src/test/java/org/eclipse/dirigible/components/ide/workspace/endpoint/WorkspacesEndpointTest.java +++ b/components/ide/ide-workspace/src/test/java/org/eclipse/dirigible/components/ide/workspace/endpoint/WorkspacesEndpointTest.java @@ -19,6 +19,7 @@ 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.eclipse.dirigible.components.ide.workspace.domain.File; import org.eclipse.dirigible.components.ide.workspace.domain.Project; import org.eclipse.dirigible.components.ide.workspace.domain.Workspace; @@ -30,7 +31,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.domain.EntityScan; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.http.MediaType; @@ -51,22 +52,27 @@ @EntityScan("org.eclipse.dirigible.components") public class WorkspacesEndpointTest { + /** The wac. */ + @Autowired + protected WebApplicationContext wac; /** The workspace service. */ @Autowired private WorkspaceService workspaceService; - /** The mock mvc. */ @Autowired private MockMvc mockMvc; - - /** The wac. */ - @Autowired - protected WebApplicationContext wac; - /** The spring security filter chain. */ @Autowired private FilterChainProxy springSecurityFilterChain; + + /** + * The Class TestConfiguration. + */ + @SpringBootApplication + static class TestConfiguration { + } + /** * Setup. * @@ -199,11 +205,4 @@ public void createGetDeleteFile() throws Exception { .andExpect(status().is2xxSuccessful()); } - /** - * The Class TestConfiguration. - */ - @SpringBootApplication - static class TestConfiguration { - } - } diff --git a/components/ide/ide-workspace/src/test/java/org/eclipse/dirigible/components/ide/workspace/service/ActionsServiceTest.java b/components/ide/ide-workspace/src/test/java/org/eclipse/dirigible/components/ide/workspace/service/ActionsServiceTest.java index 5548745d37d..7f19b127c4c 100644 --- a/components/ide/ide-workspace/src/test/java/org/eclipse/dirigible/components/ide/workspace/service/ActionsServiceTest.java +++ b/components/ide/ide-workspace/src/test/java/org/eclipse/dirigible/components/ide/workspace/service/ActionsServiceTest.java @@ -22,7 +22,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.domain.EntityScan; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.security.test.context.support.WithMockUser; @@ -39,15 +39,6 @@ @EntityScan("org.eclipse.dirigible.components") public class ActionsServiceTest { - - /** The actions service. */ - @Autowired - private ActionsService actionsService; - - /** The workspaces core service. */ - @Autowired - private WorkspaceService workspaceService; - /** The project json content. */ private static final String PROJECT_JSON_CONTENT = """ { @@ -68,8 +59,21 @@ public class ActionsServiceTest { }] } """; + /** The actions service. */ + @Autowired + private ActionsService actionsService; + /** The workspaces core service. */ + @Autowired + private WorkspaceService workspaceService; + /** + * The Class TestConfiguration. + */ + @SpringBootApplication + static class TestConfiguration { + } + /** * Publish with action test. */ @@ -99,7 +103,6 @@ public void publishWithActionTest() { workspaceService.deleteWorkspace("TestWorkspace1"); } - /** * Publish without action test. */ @@ -127,11 +130,4 @@ public void publishWithoutActionTest() { } } - /** - * The Class TestConfiguration. - */ - @SpringBootApplication - static class TestConfiguration { - } - } diff --git a/components/ide/ide-workspace/src/test/java/org/eclipse/dirigible/components/ide/workspace/service/ProjectTest.java b/components/ide/ide-workspace/src/test/java/org/eclipse/dirigible/components/ide/workspace/service/ProjectTest.java index 2a4c5b245fe..89c9a20cb3f 100644 --- a/components/ide/ide-workspace/src/test/java/org/eclipse/dirigible/components/ide/workspace/service/ProjectTest.java +++ b/components/ide/ide-workspace/src/test/java/org/eclipse/dirigible/components/ide/workspace/service/ProjectTest.java @@ -22,7 +22,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.domain.EntityScan; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.security.test.context.support.WithMockUser; @@ -43,6 +43,14 @@ public class ProjectTest { @Autowired private WorkspaceService workspaceService; + + /** + * The Class TestConfiguration. + */ + @SpringBootApplication + static class TestConfiguration { + } + /** * Creates the folder test. */ @@ -160,11 +168,4 @@ public void deleteFolderTest() { workspaceService.deleteWorkspace("TestWorkspace1"); } - /** - * The Class TestConfiguration. - */ - @SpringBootApplication - static class TestConfiguration { - } - } diff --git a/components/ide/ide-workspace/src/test/java/org/eclipse/dirigible/components/ide/workspace/service/WorkspaceTest.java b/components/ide/ide-workspace/src/test/java/org/eclipse/dirigible/components/ide/workspace/service/WorkspaceTest.java index 72692c1d414..5eab6c9b8ba 100644 --- a/components/ide/ide-workspace/src/test/java/org/eclipse/dirigible/components/ide/workspace/service/WorkspaceTest.java +++ b/components/ide/ide-workspace/src/test/java/org/eclipse/dirigible/components/ide/workspace/service/WorkspaceTest.java @@ -25,7 +25,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.domain.EntityScan; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.security.test.context.support.WithMockUser; @@ -46,6 +46,14 @@ public class WorkspaceTest { @Autowired private WorkspaceService workspaceService; + + /** + * The Class TestConfiguration. + */ + @SpringBootApplication + static class TestConfiguration { + } + /** * Creates the project test. */ @@ -462,11 +470,4 @@ public void deleteFileTest() { workspaceService.deleteWorkspace("TestWorkspace1"); } - /** - * The Class TestConfiguration. - */ - @SpringBootApplication - static class TestConfiguration { - } - } diff --git a/components/ide/ide-workspace/src/test/java/org/eclipse/dirigible/components/ide/workspace/service/WorkspacesServiceTest.java b/components/ide/ide-workspace/src/test/java/org/eclipse/dirigible/components/ide/workspace/service/WorkspacesServiceTest.java index e7470ef66fc..fa6a97b6510 100644 --- a/components/ide/ide-workspace/src/test/java/org/eclipse/dirigible/components/ide/workspace/service/WorkspacesServiceTest.java +++ b/components/ide/ide-workspace/src/test/java/org/eclipse/dirigible/components/ide/workspace/service/WorkspacesServiceTest.java @@ -20,7 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.domain.EntityScan; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.security.test.context.support.WithMockUser; @@ -41,6 +41,14 @@ public class WorkspacesServiceTest { @Autowired private WorkspaceService workspaceService; + + /** + * The Class TestConfiguration. + */ + @SpringBootApplication + static class TestConfiguration { + } + /** * Creates the workspace test. */ @@ -121,11 +129,4 @@ public void deleteWorkspaceTest() { assertEquals(false, workspace2.exists()); } - /** - * The Class TestConfiguration. - */ - @SpringBootApplication - static class TestConfiguration { - } - } diff --git a/modules/odata/odata-core-test/src/main/java/org/eclipse/dirigible/engine/odata2/sql/OData2RequestBuilder.java b/modules/odata/odata-core-test/src/main/java/org/eclipse/dirigible/engine/odata2/sql/OData2RequestBuilder.java index a9417a2cc71..b7883560e5f 100644 --- a/modules/odata/odata-core-test/src/main/java/org/eclipse/dirigible/engine/odata2/sql/OData2RequestBuilder.java +++ b/modules/odata/odata-core-test/src/main/java/org/eclipse/dirigible/engine/odata2/sql/OData2RequestBuilder.java @@ -9,24 +9,11 @@ */ package org.eclipse.dirigible.engine.odata2.sql; -import static org.apache.olingo.odata2.api.commons.ODataHttpMethod.GET; -import static org.apache.olingo.odata2.api.commons.ODataHttpMethod.POST; -import static org.apache.olingo.odata2.api.commons.ODataHttpMethod.PUT; -import static org.easymock.EasyMock.capture; -import static org.easymock.EasyMock.expect; -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.net.URI; -import java.net.URISyntaxException; -import java.nio.charset.StandardCharsets; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Locale; -import java.util.Map.Entry; +import jakarta.servlet.ServletContext; +import jakarta.servlet.ServletInputStream; +import jakarta.servlet.ServletRequest; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.ws.rs.core.*; import org.apache.cxf.helpers.IOUtils; import org.apache.cxf.jaxrs.impl.MetadataMap; import org.apache.cxf.jaxrs.impl.PathSegmentImpl; @@ -46,22 +33,22 @@ import org.apache.olingo.odata2.core.processor.ODataSingleProcessorService; import org.apache.olingo.odata2.core.rest.ODataSubLocator; import org.apache.olingo.odata2.core.rest.SubLocatorParameter; -import org.easymock.Capture; -import org.easymock.CaptureType; -import org.easymock.EasyMock; -import org.easymock.EasyMockSupport; -import org.easymock.IAnswer; +import org.easymock.*; import org.eclipse.dirigible.engine.odata2.sql.processor.DefaultSQLProcessor; -import jakarta.servlet.ServletContext; -import jakarta.servlet.ServletInputStream; -import jakarta.servlet.ServletRequest; -import jakarta.servlet.http.HttpServletRequest; -import jakarta.ws.rs.core.HttpHeaders; -import jakarta.ws.rs.core.MultivaluedMap; -import jakarta.ws.rs.core.PathSegment; -import jakarta.ws.rs.core.Response; -import jakarta.ws.rs.core.UriInfo; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.net.URI; +import java.net.URISyntaxException; +import java.nio.ByteBuffer; +import java.nio.charset.StandardCharsets; +import java.util.*; +import java.util.Map.Entry; + +import static org.apache.olingo.odata2.api.commons.ODataHttpMethod.*; +import static org.easymock.EasyMock.capture; +import static org.easymock.EasyMock.expect; /** * Base class for OData API tests, which can be used to simulate calls to the OData API without @@ -74,7 +61,6 @@ * {@link OData2RequestBuilder#enrichServletContextMock(ServletContext)} and * {@link OData2RequestBuilder#enrichServletRequestMock(ServletRequest)} methods to provide the * handles to you mock data. - * */ public class OData2RequestBuilder { @@ -162,28 +148,6 @@ public Response executeRequest() throws IOException, ODataException { return executeRequest(GET); } - /** - * Service factory. - * - * @param serviceFactory serviceFactory - * @return OData2RequestBuilder - */ - public OData2RequestBuilder serviceFactory(ODataServiceFactory serviceFactory) { - this.serviceFactory = serviceFactory; - return this; - } - - /** - * Creates the request. - * - * @param sf ODataServiceFactory - * @return OData2RequestBuilder - */ - public static OData2RequestBuilder createRequest(ODataServiceFactory sf) { - final OData2RequestBuilder request = new OData2RequestBuilder(); - return request.serviceFactory(sf); - } - /** * This methods executes an OData Request based on applied parameters and mocked REST layer. * @@ -213,7 +177,7 @@ public Response executeRequest(final ODataHttpMethod method) throws IOException, headersMap.add("cache-control", "no-cache"); headersMap.add("connection", "keep-alive"); headersMap.add("Content-Type", "application/json"); - headersMap.add("host", HOST + "" + PORT); + headersMap.add("host", HOST + PORT); headersMap.add("user-agent", "Mozilla/5.0"); expect(httpHeaders.getRequestHeaders()).andReturn(headersMap); final Capture nameCapture = Capture.newInstance(CaptureType.LAST); @@ -293,42 +257,6 @@ public Response executeRequest(final ODataHttpMethod method) throws IOException, return response; } - - - /** - * Execute batch request. - * - * @param batch the batch - * @return the o data response - * @throws IOException Signals that an I/O exception has occurred. - * @throws URISyntaxException the URI syntax exception - * @throws ODataException the o data exception - */ - public ODataResponse executeBatchRequest(List batch) throws IOException, URISyntaxException, ODataException { - InputStream body = EntityProvider.writeBatchRequest(batch, "batch_1"); - String batchRequestBody = IOUtils.toString(body); - - PathInfoImpl pathInfo = new PathInfoImpl(); - pathInfo.setServiceRoot(new URI("https://localhost:8080/odata/v2")); - pathInfo.setODataPathSegment(Collections.singletonList(new ODataPathSegmentImpl("$batch", null))); - ODataRequest batchRequest = ODataRequest.method(POST) - .contentType("application/json") - .pathInfo(pathInfo) - .acceptableLanguages(Collections.singletonList(Locale.ENGLISH)) - .build(); - - ODataContext testContext = new ODataContextImpl(batchRequest, serviceFactory); - - ODataSingleProcessorService service = (ODataSingleProcessorService) serviceFactory.createService(testContext); - DefaultSQLProcessor proc = (DefaultSQLProcessor) service.getProcessor(); - proc.setContext(testContext); - BatchHandlerImpl handler = new BatchHandlerImpl(serviceFactory, service); - - return proc.executeBatch(handler, "multipart/mixed; boundary=batch_1", - new ByteArrayInputStream(batchRequestBody.getBytes(StandardCharsets.UTF_8))); - } - - /** * Gets the servlet input stream. * @@ -341,36 +269,26 @@ protected void getServletInputStream(final ODataHttpMethod method, final EasyMoc final HttpServletRequest servletRequest) throws IOException { @SuppressWarnings("resource") final ServletInputStream contentInputStream = easyMockSupport.createMock(ServletInputStream.class); // NOSONAR mock doesn't have to - // be closed + // be closed if (method.equals(POST) || method.equals(PUT)) { expect(contentInputStream.available()).andReturn(0) .anyTimes(); if (contentSize > 0) { - expect(contentInputStream.read(EasyMock.anyObject())).andReturn(contentSize) - .times(1) - .andReturn(-1) - .times(1) - .andReturn(0) - .anyTimes(); + expect(contentInputStream.read(EasyMock.anyObject(ByteBuffer.class))).andReturn(contentSize) + .times(1) + .andReturn(-1) + .times(1) + .andReturn(0) + .anyTimes(); } else { - expect(contentInputStream.read(EasyMock.anyObject())).andReturn(contentSize) - .times(1); + expect(contentInputStream.read(EasyMock.anyObject(ByteBuffer.class))).andReturn(contentSize) + .times(1); } } expect(servletRequest.getInputStream()).andReturn(contentInputStream) .atLeastOnce(); } - /** - * Content. - * - * @param content the content - * @return OData2RequestBuilder - */ - public OData2RequestBuilder content(@SuppressWarnings("unused") final String content) { // NOSONAR to be overridden by subclasses - return this; - } - /** * Callback to add entries to the servletContext needed for the respective test context. EasyMock is * used for the tests, so you can add data by using {@link EasyMock#expect(Object)} in the passed @@ -388,7 +306,6 @@ protected void enrichServletContextMock(final ServletContext servletContext) { * {@link ServletContext} reference, for instance. * * @param servletRequest the EasyMock instance of the {@link ServletRequest}. - * */ protected void enrichServletRequestMock(final ServletRequest servletRequest) { // default implementation is empty @@ -440,4 +357,69 @@ private String absoluteServiceRoot() { return PROTOCOL + "://" + HOST + ":" + PORT + RELATIVE_SERVICE_ROOT; } + /** + * Creates the request. + * + * @param sf ODataServiceFactory + * @return OData2RequestBuilder + */ + public static OData2RequestBuilder createRequest(ODataServiceFactory sf) { + final OData2RequestBuilder request = new OData2RequestBuilder(); + return request.serviceFactory(sf); + } + + /** + * Service factory. + * + * @param serviceFactory serviceFactory + * @return OData2RequestBuilder + */ + public OData2RequestBuilder serviceFactory(ODataServiceFactory serviceFactory) { + this.serviceFactory = serviceFactory; + return this; + } + + /** + * Execute batch request. + * + * @param batch the batch + * @return the o data response + * @throws IOException Signals that an I/O exception has occurred. + * @throws URISyntaxException the URI syntax exception + * @throws ODataException the o data exception + */ + public ODataResponse executeBatchRequest(List batch) throws IOException, URISyntaxException, ODataException { + InputStream body = EntityProvider.writeBatchRequest(batch, "batch_1"); + String batchRequestBody = IOUtils.toString(body); + + PathInfoImpl pathInfo = new PathInfoImpl(); + pathInfo.setServiceRoot(new URI("https://localhost:8080/odata/v2")); + pathInfo.setODataPathSegment(Collections.singletonList(new ODataPathSegmentImpl("$batch", null))); + ODataRequest batchRequest = ODataRequest.method(POST) + .contentType("application/json") + .pathInfo(pathInfo) + .acceptableLanguages(Collections.singletonList(Locale.ENGLISH)) + .build(); + + ODataContext testContext = new ODataContextImpl(batchRequest, serviceFactory); + + ODataSingleProcessorService service = (ODataSingleProcessorService) serviceFactory.createService(testContext); + DefaultSQLProcessor proc = (DefaultSQLProcessor) service.getProcessor(); + proc.setContext(testContext); + BatchHandlerImpl handler = new BatchHandlerImpl(serviceFactory, service); + + return proc.executeBatch(handler, "multipart/mixed; boundary=batch_1", + new ByteArrayInputStream(batchRequestBody.getBytes(StandardCharsets.UTF_8))); + } + + /** + * Content. + * + * @param content the content + * @return OData2RequestBuilder + */ + public OData2RequestBuilder content(@SuppressWarnings("unused") final String content) { // NOSONAR to be overridden by subclasses + return this; + } + } diff --git a/pom.xml b/pom.xml index d14067fa1ae..c6a9a9eb325 100644 --- a/pom.xml +++ b/pom.xml @@ -128,9 +128,9 @@ 5.0.0 - 3.5.9 + 4.0.1 3.5.6 - 2.8.13 + 3.0.0 0.52 @@ -171,7 +171,7 @@ 6.1.0 - 4.15.0 + 4.16.0 2.4 @@ -901,6 +901,11 @@ mockito-core test + + org.springframework.boot + spring-boot-starter-webmvc-test + test + @@ -931,6 +936,12 @@ 4.39.0 test + + io.rest-assured + rest-assured + 5.5.6 + test + commons-collections commons-collections diff --git a/tests/tests-framework/src/main/java/org/eclipse/dirigible/tests/base/IntegrationTest.java b/tests/tests-framework/src/main/java/org/eclipse/dirigible/tests/base/IntegrationTest.java index 4d24ebcc43a..f021505e8e8 100644 --- a/tests/tests-framework/src/main/java/org/eclipse/dirigible/tests/base/IntegrationTest.java +++ b/tests/tests-framework/src/main/java/org/eclipse/dirigible/tests/base/IntegrationTest.java @@ -16,7 +16,7 @@ import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.test.annotation.DirtiesContext; diff --git a/tests/tests-integrations/src/main/java/org/eclipse/dirigible/integration/tests/api/javascript/DirigibleJavaScriptIT.java b/tests/tests-integrations/src/main/java/org/eclipse/dirigible/integration/tests/api/javascript/DirigibleJavaScriptIT.java index 8073583a9e6..4c52a72ebf9 100644 --- a/tests/tests-integrations/src/main/java/org/eclipse/dirigible/integration/tests/api/javascript/DirigibleJavaScriptIT.java +++ b/tests/tests-integrations/src/main/java/org/eclipse/dirigible/integration/tests/api/javascript/DirigibleJavaScriptIT.java @@ -15,7 +15,7 @@ import org.junit.jupiter.api.DynamicContainer; import org.junit.jupiter.api.TestFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.test.context.bean.override.mockito.MockitoBean; import java.util.List; @@ -24,7 +24,7 @@ public class DirigibleJavaScriptIT extends IntegrationTest { @Autowired private DirigibleJavaScriptTestsFactory jsTestFactory; - @MockBean + @MockitoBean private ProjectStatusProvider projectStatusProvider; @TestFactory