diff --git a/.run/PlatformApplication.run.xml b/.run/PlatformApplication.run.xml
index 288a7e33..7210756e 100644
--- a/.run/PlatformApplication.run.xml
+++ b/.run/PlatformApplication.run.xml
@@ -6,7 +6,7 @@
-
+
diff --git a/build.gradle.kts b/build.gradle.kts
index 9ff558a4..3f780167 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -1,3 +1,5 @@
+import java.time.Duration
+
plugins {
java
pmd
@@ -26,6 +28,8 @@ repositories {
mavenCentral()
}
+val testContainer = "1.19.0"
+
dependencies {
compileOnly("org.projectlombok:lombok")
@@ -38,6 +42,11 @@ dependencies {
testImplementation("org.springframework.boot:spring-boot-starter-test")
testImplementation("org.skyscreamer:jsonassert:1.5.3")
+
+ testImplementation("com.surrealdb:surrealdb-driver:0.1.0")
+ testImplementation("org.testcontainers:testcontainers:${testContainer}")
+ testImplementation("org.testcontainers:junit-jupiter:$testContainer")
+
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
testCompileOnly("org.projectlombok:lombok")
testAnnotationProcessor("org.projectlombok:lombok")
@@ -45,6 +54,8 @@ dependencies {
tasks.withType {
useJUnitPlatform()
+ jvmArgs = listOf("-Xmx2048m")
+ timeout.set(Duration.ofMinutes(2))
}
tasks {
diff --git a/src/main/java/com/wcc/platform/configuration/DatabaseConfig.java b/src/main/java/com/wcc/platform/configuration/DatabaseConfig.java
index 39222dff..e8848457 100644
--- a/src/main/java/com/wcc/platform/configuration/DatabaseConfig.java
+++ b/src/main/java/com/wcc/platform/configuration/DatabaseConfig.java
@@ -16,8 +16,13 @@ public class DatabaseConfig {
public SyncSurrealDriver getDriver(final SurrealDbConfig config) {
final var conn =
new SurrealWebSocketConnection(config.getHost(), config.getPort(), config.isTls());
+
conn.connect(config.getConnections());
+
final var driver = new SyncSurrealDriver(conn);
+
+ driver.signIn(config.getUsername(), config.getPassword());
+
driver.use(config.getNamespace(), config.getDatabase());
return driver;
diff --git a/src/main/java/com/wcc/platform/repository/surrealdb/SurrealDbPageRepository.java b/src/main/java/com/wcc/platform/repository/surrealdb/SurrealDbPageRepository.java
index b589066a..86c1b391 100644
--- a/src/main/java/com/wcc/platform/repository/surrealdb/SurrealDbPageRepository.java
+++ b/src/main/java/com/wcc/platform/repository/surrealdb/SurrealDbPageRepository.java
@@ -12,7 +12,8 @@
@Repository
public class SurrealDbPageRepository implements PageRepository {
- static final String TABLE = "page";
+ /* default */ static final String TABLE = "page";
+
private final SyncSurrealDriver driver;
@Autowired
diff --git a/src/main/java/com/wcc/platform/repository/surrealdb/SurrealDbResourceRepository.java b/src/main/java/com/wcc/platform/repository/surrealdb/SurrealDbResourceRepository.java
index e092a900..4a7da398 100644
--- a/src/main/java/com/wcc/platform/repository/surrealdb/SurrealDbResourceRepository.java
+++ b/src/main/java/com/wcc/platform/repository/surrealdb/SurrealDbResourceRepository.java
@@ -13,7 +13,7 @@
@Repository
public class SurrealDbResourceRepository implements ResourceContentRepository {
- static final String TABLE = "resource_content";
+ /* default */ static final String TABLE = "resource_content";
private final SyncSurrealDriver driver;
@Autowired
diff --git a/src/main/java/com/wcc/platform/service/CmsService.java b/src/main/java/com/wcc/platform/service/CmsService.java
index 324aac96..05e75a57 100644
--- a/src/main/java/com/wcc/platform/service/CmsService.java
+++ b/src/main/java/com/wcc/platform/service/CmsService.java
@@ -10,25 +10,18 @@
import com.wcc.platform.domain.cms.pages.LandingPage;
import com.wcc.platform.domain.cms.pages.TeamPage;
import com.wcc.platform.domain.exceptions.PlatformInternalException;
-import com.wcc.platform.repository.PageRepository;
import com.wcc.platform.utils.FileUtil;
-import java.util.Optional;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
/** CMS service responsible for simple pages. */
@Service
public class CmsService {
private final ObjectMapper objectMapper;
- private final PageRepository repository;
@Autowired
- public CmsService(
- final ObjectMapper objectMapper,
- @Qualifier("getPageRepository") final PageRepository repository) {
+ public CmsService(final ObjectMapper objectMapper) {
this.objectMapper = objectMapper;
- this.repository = repository;
}
/**
@@ -65,8 +58,6 @@ public FooterPage getFooter() {
* @return Landing page of the community.
*/
public LandingPage getLandingPage() {
- Optional