diff --git a/pom.xml b/pom.xml
index 2e5f9e3..d3437a6 100644
--- a/pom.xml
+++ b/pom.xml
@@ -20,36 +20,57 @@
The DB API of the OpenSmartCLIDE project.
- 11
+
+ 8
-
- org.springframework.boot
- spring-boot-starter-data-mongodb
-
-
org.springframework.boot
spring-boot-starter-web
-
+
+
- org.projectlombok
- lombok
- true
+ org.springframework.boot
+ spring-boot-starter-data-mongodb
+
org.springframework.boot
spring-boot-starter-test
test
+
+
+ junit
+ junit
+ 4.11
+ test
+
+
+
+
+ de.flapdoodle.embed
+ de.flapdoodle.embed.mongo
+ test
+
+
+
+
+ org.projectlombok
+ lombok
+ 1.18.24
+ provided
+
+
org.springframework.boot
spring-boot-starter-validation
+
diff --git a/src/main/java/org/eclipse/opensmartclide/dbapi/controller/ServiceController.java b/src/main/java/org/eclipse/opensmartclide/dbapi/controller/ServiceController.java
index eefa660..1e124cf 100644
--- a/src/main/java/org/eclipse/opensmartclide/dbapi/controller/ServiceController.java
+++ b/src/main/java/org/eclipse/opensmartclide/dbapi/controller/ServiceController.java
@@ -32,24 +32,24 @@ public class ServiceController {
private MongoTemplate template;
@GetMapping("/services")
- public List getAllServices(@RequestParam(value = "licence",required = false) String licence,
- @RequestParam(value = "framework",required = false) String framework,
- @RequestParam(value = "min_stars",required = false) String min_stars,
- @RequestParam(value = "max_stars",required = false) String max_stars,
- @RequestParam(value = "min_forks",required = false) String min_forks,
- @RequestParam(value = "max_forks",required = false) String max_forks,
- @RequestParam(value = "min_watchers",required = false) String min_watchers,
- @RequestParam(value = "max_watchers",required = false) String max_watchers,
- @RequestParam(value = "url",required = false) String url,
- @RequestParam(value = "deployable",required = false) String deployable,
- @RequestParam(value = "created_before",required = false) String created_before,
- @RequestParam(value = "created_after",required = false) String created_after,
- @RequestParam(value = "updated_before",required = false) String updated_before,
- @RequestParam(value = "updated_after",required = false) String updated_after,
- @RequestParam(value = "user_id",required = false) String userId,
- @RequestParam(value = "registry_id",required = false) String registryId,
- @RequestParam(value = "workspace_id",required = false) String workspaceId,
- @RequestParam(value = "search",required = false) String search) throws ParseException {
+ public List getAllServices(@RequestParam(value = "licence", required = false) String licence,
+ @RequestParam(value = "framework", required = false) String framework,
+ @RequestParam(value = "min_stars", required = false) String min_stars,
+ @RequestParam(value = "max_stars", required = false) String max_stars,
+ @RequestParam(value = "min_forks", required = false) String min_forks,
+ @RequestParam(value = "max_forks", required = false) String max_forks,
+ @RequestParam(value = "min_watchers", required = false) String min_watchers,
+ @RequestParam(value = "max_watchers", required = false) String max_watchers,
+ @RequestParam(value = "url", required = false) String url,
+ @RequestParam(value = "deployable", required = false) String deployable,
+ @RequestParam(value = "created_before", required = false) String created_before,
+ @RequestParam(value = "created_after", required = false) String created_after,
+ @RequestParam(value = "updated_before", required = false) String updated_before,
+ @RequestParam(value = "updated_after", required = false) String updated_after,
+ @RequestParam(value = "user_id", required = false) String userId,
+ @RequestParam(value = "registry_id", required = false) String registryId,
+ @RequestParam(value = "workspace_id", required = false) String workspaceId,
+ @RequestParam(value = "search", required = false) String search) throws ParseException {
if (search != null) {
TextIndexDefinition textIndexDefinition = new TextIndexDefinition.TextIndexDefinitionBuilder()
.onField("name")
diff --git a/src/main/java/org/eclipse/opensmartclide/dbapi/model/Service.java b/src/main/java/org/eclipse/opensmartclide/dbapi/model/Service.java
index c9ea461..c54d303 100644
--- a/src/main/java/org/eclipse/opensmartclide/dbapi/model/Service.java
+++ b/src/main/java/org/eclipse/opensmartclide/dbapi/model/Service.java
@@ -2,6 +2,9 @@
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
+import lombok.Getter;
+import lombok.Setter;
+
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.index.TextIndexed;
diff --git a/src/main/java/org/eclipse/opensmartclide/dbapi/repository/ServiceRepository.java b/src/main/java/org/eclipse/opensmartclide/dbapi/repository/ServiceRepository.java
index af5d29e..9b25b0c 100644
--- a/src/main/java/org/eclipse/opensmartclide/dbapi/repository/ServiceRepository.java
+++ b/src/main/java/org/eclipse/opensmartclide/dbapi/repository/ServiceRepository.java
@@ -3,8 +3,5 @@
import org.eclipse.opensmartclide.dbapi.model.Service;
import org.springframework.data.mongodb.repository.MongoRepository;
-import java.util.Date;
-import java.util.List;
-
public interface ServiceRepository extends MongoRepository {
}
diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties
index 1342a4b..649a971 100644
--- a/src/main/resources/application.properties
+++ b/src/main/resources/application.properties
@@ -1,6 +1,6 @@
#spring.data.mongodb.host=$MONGODB_HOST
#spring.data.mongodb.port=$MONGODB_PORT
spring.data.mongodb.database=smartclide
+spring.mongodb.embedded.version=3.6.5
#spring.data.mongodb.username=$MONGODB_USERNAME
-#spring.data.mongodb.password=$MONGODB_PASSWORD
-
+#spring.data.mongodb.password=$MONGODB_PASSWORD
\ No newline at end of file
diff --git a/src/test/java/org/eclipse/opensmartclide/dbapi/repository/CiManagerRepositoryTest.java b/src/test/java/org/eclipse/opensmartclide/dbapi/repository/CiManagerRepositoryTest.java
new file mode 100644
index 0000000..1997eb7
--- /dev/null
+++ b/src/test/java/org/eclipse/opensmartclide/dbapi/repository/CiManagerRepositoryTest.java
@@ -0,0 +1,75 @@
+package org.eclipse.opensmartclide.dbapi.repository;
+
+import static org.junit.Assert.assertEquals;
+import java.util.Optional;
+import org.eclipse.opensmartclide.dbapi.model.CiManager;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.autoconfigure.data.mongo.DataMongoTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@DataMongoTest
+class CiManagerRepositoryTest {
+
+ @Autowired
+ private CiManagerRepository ciManagerRepository;
+
+ @BeforeEach
+ public void setUp() throws Exception {
+ CiManager ciManager = new CiManager();
+ ciManager.setId(Long.toString(1L));
+ ciManager.setUser_id("testCiManagerUserId");
+ ciManager.setType("testCiManagerType");
+ ciManager.setUrl("testCiManagerUrl");
+ ciManager.setUsername("testCiManagerUsername");
+ ciManager.setToken("testCiManagerToken");
+
+ ciManagerRepository.save(ciManager);
+ }
+
+ @Test
+ public void assertCiManagerIdPersisted() {
+ Optional ciManager = ciManagerRepository.findById(Long.toString(1L));
+ String ciManagerId = ciManager.get().getId();
+ assertEquals(Long.toString(1L), ciManagerId);
+ }
+
+ @Test
+ public void assertCiManagerUserIdPersisted() {
+ Optional ciManager = ciManagerRepository.findById(Long.toString(1L));
+ String ciManagerUserId = ciManager.get().getUser_id();
+ assertEquals("testCiManagerUserId", ciManagerUserId);
+ }
+
+ @Test
+ public void assertCiManagerTypePersisted() {
+ Optional ciManager = ciManagerRepository.findById(Long.toString(1L));
+ String ciManagerType = ciManager.get().getType();
+ assertEquals("testCiManagerType", ciManagerType);
+ }
+
+ @Test
+ public void assertCiManagerUrlPersisted() {
+ Optional ciManager = ciManagerRepository.findById(Long.toString(1L));
+ String ciManagerUrl = ciManager.get().getUrl();
+ assertEquals("testCiManagerUrl", ciManagerUrl);
+ }
+
+ @Test
+ public void assertCiManagerUsernamePersisted() {
+ Optional ciManager = ciManagerRepository.findById(Long.toString(1L));
+ String ciManagerUsername = ciManager.get().getUsername();
+ assertEquals("testCiManagerUsername", ciManagerUsername);
+ }
+
+ @Test
+ public void assertCiManagerTokenPersisted() {
+ Optional ciManager = ciManagerRepository.findById(Long.toString(1L));
+ String ciManagerToken = ciManager.get().getToken();
+ assertEquals("testCiManagerToken", ciManagerToken);
+ }
+
+}
diff --git a/src/test/java/org/eclipse/opensmartclide/dbapi/repository/DeploymentPlatformRepositoryTest.java b/src/test/java/org/eclipse/opensmartclide/dbapi/repository/DeploymentPlatformRepositoryTest.java
new file mode 100644
index 0000000..c46d0c8
--- /dev/null
+++ b/src/test/java/org/eclipse/opensmartclide/dbapi/repository/DeploymentPlatformRepositoryTest.java
@@ -0,0 +1,67 @@
+package org.eclipse.opensmartclide.dbapi.repository;
+
+import static org.junit.Assert.assertEquals;
+import java.util.Optional;
+import org.eclipse.opensmartclide.dbapi.model.DeploymentPlatform;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.autoconfigure.data.mongo.DataMongoTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@DataMongoTest
+class DeploymentPlatformRepositoryTest {
+
+ @Autowired
+ private DeploymentPlatformRepository deploymentPlatformRepository;
+
+ @BeforeEach
+ public void setUp() throws Exception {
+ DeploymentPlatform deploymentPlatform = new DeploymentPlatform();
+ deploymentPlatform.setId(Long.toString(1L));
+ deploymentPlatform.setUser_id("testDeploymentPlatformUserId");
+ deploymentPlatform.setUrl("testDeploymentPlatformUrl");
+ deploymentPlatform.setUsername("testDeploymentPlatformUsername");
+ deploymentPlatform.setToken("testDeploymentPlatformToken");
+
+ deploymentPlatformRepository.save(deploymentPlatform);
+ }
+
+ @Test
+ public void assertDeploymentPlatformIdPersisted() {
+ Optional deploymentPlatform = deploymentPlatformRepository.findById(Long.toString(1L));
+ String deploymentPlatformId = deploymentPlatform.get().getId();
+ assertEquals(Long.toString(1L), deploymentPlatformId);
+ }
+
+ @Test
+ public void assertDeploymentPlatformUserIdPersisted() {
+ Optional deploymentPlatform = deploymentPlatformRepository.findById(Long.toString(1L));
+ String deploymentPlatformUserId = deploymentPlatform.get().getUser_id();
+ assertEquals("testDeploymentPlatformUserId", deploymentPlatformUserId);
+ }
+
+ @Test
+ public void assertDeploymentPlatformUrlPersisted() {
+ Optional deploymentPlatform = deploymentPlatformRepository.findById(Long.toString(1L));
+ String deploymentPlatformUrl = deploymentPlatform.get().getUrl();
+ assertEquals("testDeploymentPlatformUrl", deploymentPlatformUrl);
+ }
+
+ @Test
+ public void assertDeploymentPlatformUsernamePersisted() {
+ Optional deploymentPlatform = deploymentPlatformRepository.findById(Long.toString(1L));
+ String deploymentPlatformUsername = deploymentPlatform.get().getUsername();
+ assertEquals("testDeploymentPlatformUsername", deploymentPlatformUsername);
+ }
+
+ @Test
+ public void assertDeploymentPlatformTokenPersisted() {
+ Optional deploymentPlatform = deploymentPlatformRepository.findById(Long.toString(1L));
+ String deploymentPlatformToken = deploymentPlatform.get().getToken();
+ assertEquals("testDeploymentPlatformToken", deploymentPlatformToken);
+ }
+
+}
diff --git a/src/test/java/org/eclipse/opensmartclide/dbapi/repository/DeploymentRepositoryTest.java b/src/test/java/org/eclipse/opensmartclide/dbapi/repository/DeploymentRepositoryTest.java
new file mode 100644
index 0000000..3a7330e
--- /dev/null
+++ b/src/test/java/org/eclipse/opensmartclide/dbapi/repository/DeploymentRepositoryTest.java
@@ -0,0 +1,176 @@
+package org.eclipse.opensmartclide.dbapi.repository;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Optional;
+import org.eclipse.opensmartclide.dbapi.model.Deployment;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.autoconfigure.data.mongo.DataMongoTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@DataMongoTest
+class DeploymentRepositoryTest {
+
+ @Autowired
+ private DeploymentRepository deploymentRepository;
+
+ private Date currentDate;
+
+ @BeforeEach
+ public void setUp() throws Exception {
+ Deployment deployment = new Deployment();
+ deployment.setId(Long.toString(1L));
+ deployment.setUser_id("testDeploymentUserId");
+ deployment.setUser("testDeploymentUser");
+ deployment.setGit_credentials_id("testDeploymentGitCredentialsId");
+ deployment.setName("testDeploymentName");
+ deployment.setProject("testDeploymentProject");
+ deployment.setService_url("testDeploymentServiceUrl");
+ deployment.setK8s_url("testDeploymentK8sUrl");
+ deployment.setPort(8080);
+ deployment.setReplicas(2);
+ deployment.setWorkflow_id("testDeploymentWorkflowId");
+ deployment.setService_id("testDeploymentServiceId");
+ deployment.setVersion("testDeploymentVersion");
+ deployment.setState("testDeploymentState");
+
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd/mm/yyyy");
+
+ Date createdDate = simpleDateFormat.parse("01/10/2022");
+ currentDate = new Date();
+ Date updatedDate = simpleDateFormat.parse(simpleDateFormat.format(currentDate));
+ Date stoppedDate = simpleDateFormat.parse("03/10/2022");
+ deployment.setCreated(createdDate);
+ deployment.setUpdated(updatedDate);
+ deployment.setStopped(stoppedDate);
+
+ deploymentRepository.save(deployment);
+ }
+
+ @Test
+ public void assertDeploymentIdPersisted() {
+ Optional deployment = deploymentRepository.findById(Long.toString(1L));
+ String deploymentId = deployment.get().getId();
+ assertEquals(Long.toString(1L), deploymentId);
+ }
+
+ @Test
+ public void assertDeploymentUserIdPersisted() {
+ Optional deployment = deploymentRepository.findById(Long.toString(1L));
+ String deploymentUserId = deployment.get().getUser_id();
+ assertEquals("testDeploymentUserId", deploymentUserId);
+ }
+
+ @Test
+ public void assertDeploymentUserPersisted() {
+ Optional deployment = deploymentRepository.findById(Long.toString(1L));
+ String deploymentUser = deployment.get().getUser();
+ assertEquals("testDeploymentUser", deploymentUser);
+ }
+
+ @Test
+ public void assertDeploymentGitCredentialsIdPersisted() {
+ Optional deployment = deploymentRepository.findById(Long.toString(1L));
+ String deploymentGitCredentialsId = deployment.get().getGit_credentials_id();
+ assertEquals("testDeploymentGitCredentialsId", deploymentGitCredentialsId);
+ }
+
+ @Test
+ public void assertDeploymentNamePersisted() {
+ Optional deployment = deploymentRepository.findById(Long.toString(1L));
+ String deploymentName = deployment.get().getName();
+ assertEquals("testDeploymentName", deploymentName);
+ }
+
+ @Test
+ public void assertDeploymentProjectPersisted() {
+ Optional deployment = deploymentRepository.findById(Long.toString(1L));
+ String deploymentProject = deployment.get().getProject();
+ assertEquals("testDeploymentProject", deploymentProject);
+ }
+
+ @Test
+ public void assertDeploymentServiceUrlPersisted() {
+ Optional deployment = deploymentRepository.findById(Long.toString(1L));
+ String deploymentUrl = deployment.get().getService_url();
+ assertEquals("testDeploymentServiceUrl", deploymentUrl);
+ }
+
+ @Test
+ public void assertDeploymentK8sUrlPersisted() {
+ Optional deployment = deploymentRepository.findById(Long.toString(1L));
+ String deploymentK8sUrl = deployment.get().getK8s_url();
+ assertEquals("testDeploymentK8sUrl", deploymentK8sUrl);
+ }
+
+ @Test
+ public void assertDeploymentPortPersisted() {
+ Optional deployment = deploymentRepository.findById(Long.toString(1L));
+ Integer deploymentPort = deployment.get().getPort();
+ assertEquals(Integer.valueOf(8080), deploymentPort);
+ }
+
+ @Test
+ public void assertDeploymentReplicasPersisted() {
+ Optional deployment = deploymentRepository.findById(Long.toString(1L));
+ Integer deploymentReplicas = deployment.get().getReplicas();
+ assertEquals(Integer.valueOf(2), deploymentReplicas);
+ }
+
+ @Test
+ public void assertDeploymentWorkflowIdPersisted() {
+ Optional deployment = deploymentRepository.findById(Long.toString(1L));
+ String deploymentWorkflowId = deployment.get().getWorkflow_id();
+ assertEquals("testDeploymentWorkflowId", deploymentWorkflowId);
+ }
+
+ @Test
+ public void assertDeploymentServiceIdPersisted() {
+ Optional deployment = deploymentRepository.findById(Long.toString(1L));
+ String deploymentServiceId = deployment.get().getService_id();
+ assertEquals("testDeploymentServiceId", deploymentServiceId);
+ }
+
+ @Test
+ public void assertDeploymentVersionPersisted() {
+ Optional deployment = deploymentRepository.findById(Long.toString(1L));
+ String deploymentVersion = deployment.get().getVersion();
+ assertEquals("testDeploymentVersion", deploymentVersion);
+ }
+
+ @Test
+ public void assertDeploymentStatePersisted() {
+ Optional deployment = deploymentRepository.findById(Long.toString(1L));
+ String deploymentState = deployment.get().getState();
+ assertEquals("testDeploymentState", deploymentState);
+ }
+
+ @Test
+ public void assertDeploymentCreatedDatePersisted() throws ParseException {
+ Optional deployment = deploymentRepository.findById(Long.toString(1L));
+ Date deploymentCreatedDate = deployment.get().getCreated();
+ assertTrue(deploymentCreatedDate.equals(new SimpleDateFormat("dd/mm/yyyy").parse("01/10/2022")));
+ }
+
+ @Test
+ public void assertDeploymentUpdatedDatePersisted() throws ParseException {
+ Optional deployment = deploymentRepository.findById(Long.toString(1L));
+ Date deploymentUpdatedDate = deployment.get().getUpdated();
+ assertTrue(deploymentUpdatedDate.toString().equals(currentDate.toString()));
+ }
+
+ @Test
+ public void assertDeploymentStoppedDatePersisted() throws ParseException {
+ Optional deployment = deploymentRepository.findById(Long.toString(1L));
+ Date deploymentStoppedDate = deployment.get().getStopped();
+ assertTrue(deploymentStoppedDate.equals(new SimpleDateFormat("dd/mm/yyyy").parse("03/10/2022")));
+ }
+}
diff --git a/src/test/java/org/eclipse/opensmartclide/dbapi/repository/GitCredentialsRepositoryTest.java b/src/test/java/org/eclipse/opensmartclide/dbapi/repository/GitCredentialsRepositoryTest.java
new file mode 100644
index 0000000..b725c78
--- /dev/null
+++ b/src/test/java/org/eclipse/opensmartclide/dbapi/repository/GitCredentialsRepositoryTest.java
@@ -0,0 +1,75 @@
+package org.eclipse.opensmartclide.dbapi.repository;
+
+import static org.junit.Assert.assertEquals;
+import java.util.Optional;
+import org.eclipse.opensmartclide.dbapi.model.GitCredentials;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.autoconfigure.data.mongo.DataMongoTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@DataMongoTest
+class GitCredentialsRepositoryTest {
+
+ @Autowired
+ private GitCredentialsRepository gitCredentialsRepository;
+
+ @BeforeEach
+ public void setUp() {
+ GitCredentials gitCredentials = new GitCredentials();
+ gitCredentials.setId(Long.toString(1L));
+ gitCredentials.setUser_id("testGitCredentialsUserId");
+ gitCredentials.setType("testGitCredentialsType");
+ gitCredentials.setUrl("testGitCredentialsUrl");
+ gitCredentials.setUsername("testGitCredentialsUsername");
+ gitCredentials.setToken("testGitCredentialsToken");
+
+ gitCredentialsRepository.save(gitCredentials);
+ }
+
+ @Test
+ public void assertGitCredentialsIdPersisted() {
+ Optional gitCredentials = gitCredentialsRepository.findById(Long.toString(1L));
+ String gitCredentialsId = gitCredentials.get().getId();
+ assertEquals(Long.toString(1L), gitCredentialsId);
+ }
+
+ @Test
+ public void assertGitCredentialsUserIdPersisted() {
+ Optional gitCredentials = gitCredentialsRepository.findById(Long.toString(1L));
+ String gitCredentialsUserId = gitCredentials.get().getUser_id();
+ assertEquals("testGitCredentialsUserId", gitCredentialsUserId);
+ }
+
+ @Test
+ public void assertGitCredentialsTypePersisted() {
+ Optional gitCredentials = gitCredentialsRepository.findById(Long.toString(1L));
+ String gitCredentialsType = gitCredentials.get().getType();
+ assertEquals("testGitCredentialsType", gitCredentialsType);
+ }
+
+ @Test
+ public void assertGitCredentialsUrlPersisted() {
+ Optional gitCredentials = gitCredentialsRepository.findById(Long.toString(1L));
+ String gitCredentialsUrl = gitCredentials.get().getUrl();
+ assertEquals("testGitCredentialsUrl", gitCredentialsUrl);
+ }
+
+ @Test
+ public void assertGitCredentialsUsernamePersisted() {
+ Optional gitCredentials = gitCredentialsRepository.findById(Long.toString(1L));
+ String gitCredentialsUsername = gitCredentials.get().getUsername();
+ assertEquals("testGitCredentialsUsername", gitCredentialsUsername);
+ }
+
+ @Test
+ public void assertGitCredentialsTokenPersisted() {
+ Optional gitCredentials = gitCredentialsRepository.findById(Long.toString(1L));
+ String gitCredentialsToken = gitCredentials.get().getToken();
+ assertEquals("testGitCredentialsToken", gitCredentialsToken);
+ }
+
+}
diff --git a/src/test/java/org/eclipse/opensmartclide/dbapi/repository/ServiceRegistryRepositoryTest.java b/src/test/java/org/eclipse/opensmartclide/dbapi/repository/ServiceRegistryRepositoryTest.java
new file mode 100644
index 0000000..5d3c532
--- /dev/null
+++ b/src/test/java/org/eclipse/opensmartclide/dbapi/repository/ServiceRegistryRepositoryTest.java
@@ -0,0 +1,74 @@
+package org.eclipse.opensmartclide.dbapi.repository;
+
+import static org.junit.Assert.assertEquals;
+import java.util.Optional;
+import org.eclipse.opensmartclide.dbapi.model.ServiceRegistry;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.autoconfigure.data.mongo.DataMongoTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@DataMongoTest
+class ServiceRegistryRepositoryTest {
+
+ @Autowired
+ private ServiceRegistryRepository serviceRegistryRepository;
+
+ @BeforeEach
+ public void setUp() {
+ ServiceRegistry serviceRegistry = new ServiceRegistry();
+ serviceRegistry.setId(Long.toString(1L));
+ serviceRegistry.setUser_id("testServiceRegistryUserId");
+ serviceRegistry.setType("testServiceRegistryType");
+ serviceRegistry.setUrl("testServiceRegistryUrl");
+ serviceRegistry.setUsername("testServiceRegistryUsername");
+ serviceRegistry.setToken("testServiceRegistryToken");
+
+ serviceRegistryRepository.save(serviceRegistry);
+ }
+
+ @Test
+ public void assertServiceRegistryIdPersisted() {
+ Optional serviceRegistry = serviceRegistryRepository.findById(Long.toString(1L));
+ String serviceRegistryId = serviceRegistry.get().getId();
+ assertEquals(Long.toString(1L), serviceRegistryId);
+ }
+
+ @Test
+ public void assertServiceRegistryUserIdPersisted() {
+ Optional serviceRegistry = serviceRegistryRepository.findById(Long.toString(1L));
+ String serviceRegistryUserId = serviceRegistry.get().getUser_id();
+ assertEquals("testServiceRegistryUserId", serviceRegistryUserId);
+ }
+
+ @Test
+ public void assertServiceRegistryTypePersisted() {
+ Optional serviceRegistry = serviceRegistryRepository.findById(Long.toString(1L));
+ String serviceRegistryType = serviceRegistry.get().getType();
+ assertEquals("testServiceRegistryType", serviceRegistryType);
+ }
+
+ @Test
+ public void assertServiceRegistryUrlPersisted() {
+ Optional serviceRegistry = serviceRegistryRepository.findById(Long.toString(1L));
+ String serviceRegistryUrl = serviceRegistry.get().getUrl();
+ assertEquals("testServiceRegistryUrl", serviceRegistryUrl);
+ }
+
+ @Test
+ public void assertServiceRegistryUsernamePersisted() {
+ Optional serviceRegistry = serviceRegistryRepository.findById(Long.toString(1L));
+ String serviceRegistryUsername = serviceRegistry.get().getUsername();
+ assertEquals("testServiceRegistryUsername", serviceRegistryUsername);
+ }
+
+ @Test
+ public void assertServiceRegistryTokenPersisted() {
+ Optional serviceRegistry = serviceRegistryRepository.findById(Long.toString(1L));
+ String serviceRegistryToken = serviceRegistry.get().getToken();
+ assertEquals("testServiceRegistryToken", serviceRegistryToken);
+ }
+}
diff --git a/src/test/java/org/eclipse/opensmartclide/dbapi/repository/ServiceRepositoryTest.java b/src/test/java/org/eclipse/opensmartclide/dbapi/repository/ServiceRepositoryTest.java
new file mode 100644
index 0000000..344ff76
--- /dev/null
+++ b/src/test/java/org/eclipse/opensmartclide/dbapi/repository/ServiceRepositoryTest.java
@@ -0,0 +1,138 @@
+package org.eclipse.opensmartclide.dbapi.repository;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
+import org.eclipse.opensmartclide.dbapi.model.Service;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.autoconfigure.data.mongo.DataMongoTest;
+import org.springframework.test.context.junit4.SpringRunner;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Optional;
+
+@RunWith(SpringRunner.class)
+@DataMongoTest
+class ServiceRepositoryTest {
+
+ @Autowired
+ private ServiceRepository serviceRepository;
+
+ @BeforeEach
+ public void setUp() throws Exception {
+ Service service = new Service();
+ service.setId(Long.toString(1L));
+ service.setName("testServiceName");
+ service.setUser_id("testUserId");
+ service.setRegistry_id("testRegistryId");
+ service.setWorkspace_id("testWorkSpaceId");
+ service.setGit_credentials_id("testGitCredentialsId");
+ service.setUrl("testServiceUrl");
+ service.setDescription("testServiceDescription");
+ service.setIsPublic(true);
+ service.setLicence("testServiceLicense");
+ service.setFramework("testServiceFramework");
+
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd/mm/yyyy");
+ Date createdDate = simpleDateFormat.parse("10/01/2022");
+ Date updatedDate = simpleDateFormat.parse("20/03/2022");
+ service.setCreated(createdDate);
+ service.setUpdated(updatedDate);
+
+ serviceRepository.save(service);
+ }
+
+ @Test
+ public void assertServiceIdPersisted() {
+ Optional service = serviceRepository.findById(Long.toString(1L));
+ String serviceId = service.get().getId();
+ assertEquals(Long.toString(1L), serviceId);
+ }
+
+ @Test
+ public void assertServiceNamePersisted() {
+ Optional service = serviceRepository.findById(Long.toString(1L));
+ String serviceName = service.get().getName();
+ assertEquals("testServiceName", serviceName);
+ }
+
+ @Test
+ public void assertServiceUserIdPersisted() {
+ Optional service = serviceRepository.findById(Long.toString(1L));
+ String serviceUserId = service.get().getUser_id();
+ assertEquals("testUserId", serviceUserId);
+ }
+
+ @Test
+ public void assertServiceRegistryIdPersisted() {
+ Optional service = serviceRepository.findById(Long.toString(1L));
+ String serviceRegistryId = service.get().getRegistry_id();
+ assertEquals("testRegistryId", serviceRegistryId);
+ }
+
+ @Test
+ public void assertServiceWorkspaceIdPersisted() {
+ Optional service = serviceRepository.findById(Long.toString(1L));
+ String serviceWorkspaceId = service.get().getWorkspace_id();
+ assertEquals("testWorkSpaceId", serviceWorkspaceId);
+ }
+
+ @Test
+ public void assertServiceGitCredentialsIdPersisted() {
+ Optional service = serviceRepository.findById(Long.toString(1L));
+ String serviceGitCredentialsId = service.get().getGit_credentials_id();
+ assertEquals("testGitCredentialsId", serviceGitCredentialsId);
+ }
+
+ @Test
+ public void assertServiceUrlPersisted() {
+ Optional service = serviceRepository.findById(Long.toString(1L));
+ String serviceUrl = service.get().getUrl();
+ assertEquals("testServiceUrl", serviceUrl);
+ }
+
+ @Test
+ public void assertServiceDescriptionPersisted() {
+ Optional service = serviceRepository.findById(Long.toString(1L));
+ String serviceDescription = service.get().getDescription();
+ assertEquals("testServiceDescription", serviceDescription);
+ }
+
+ @Test
+ public void assertServiceIsPublic() {
+ Optional service = serviceRepository.findById(Long.toString(1L));
+ boolean serviceIsPublic = service.get().getIsPublic();
+ assertTrue(serviceIsPublic == true);
+ }
+
+ @Test
+ public void assertServiceLicensePersisted() {
+ Optional service = serviceRepository.findById(Long.toString(1L));
+ String serviceLicense = service.get().getLicence();
+ assertEquals("testServiceLicense", serviceLicense);
+ }
+
+ @Test
+ public void assertServiceFrameworkPersisted() {
+ Optional service = serviceRepository.findById(Long.toString(1L));
+ String serviceFramework = service.get().getFramework();
+ assertEquals("testServiceFramework", serviceFramework);
+ }
+
+ @Test
+ public void assertServiceCreatedDatePersisted() throws ParseException {
+ Optional service = serviceRepository.findById(Long.toString(1L));
+ Date serviceCreatedDate = service.get().getCreated();
+ assertTrue(serviceCreatedDate.equals(new SimpleDateFormat("dd/mm/yyyy").parse("10/01/2022")));
+ }
+
+ @Test
+ public void assertServiceUpdatedDatePersisted() throws ParseException {
+ Optional service = serviceRepository.findById(Long.toString(1L));
+ Date serviceUpdatedDate = service.get().getUpdated();
+ assertTrue(serviceUpdatedDate.equals(new SimpleDateFormat("dd/mm/yyyy").parse("20/03/2022")));
+ }
+}
diff --git a/src/test/java/org/eclipse/opensmartclide/dbapi/repository/TeamRepositoryTest.java b/src/test/java/org/eclipse/opensmartclide/dbapi/repository/TeamRepositoryTest.java
new file mode 100644
index 0000000..4418275
--- /dev/null
+++ b/src/test/java/org/eclipse/opensmartclide/dbapi/repository/TeamRepositoryTest.java
@@ -0,0 +1,42 @@
+package org.eclipse.opensmartclide.dbapi.repository;
+
+import static org.junit.Assert.assertEquals;
+import java.util.Optional;
+import org.eclipse.opensmartclide.dbapi.model.Team;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.autoconfigure.data.mongo.DataMongoTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@DataMongoTest
+class TeamRepositoryTest {
+
+ @Autowired
+ private TeamRepository teamRepository;
+
+ @BeforeEach
+ public void setUp() {
+ Team team = new Team();
+ team.setId(Long.toString(1L));
+ team.setName("testTeamName");
+
+ teamRepository.save(team);
+ }
+
+ @Test
+ public void assertTeamIdPersisted() {
+ Optional team = teamRepository.findById(Long.toString(1L));
+ String teamId = team.get().getId();
+ assertEquals(Long.toString(1L), teamId);
+ }
+
+ @Test
+ public void assertTeamNamePersisted() {
+ Optional team = teamRepository.findById(Long.toString(1L));
+ String teamName = team.get().getName();
+ assertEquals("testTeamName", teamName);
+ }
+}
diff --git a/src/test/java/org/eclipse/opensmartclide/dbapi/repository/UserRepositoryTest.java b/src/test/java/org/eclipse/opensmartclide/dbapi/repository/UserRepositoryTest.java
new file mode 100644
index 0000000..946f64a
--- /dev/null
+++ b/src/test/java/org/eclipse/opensmartclide/dbapi/repository/UserRepositoryTest.java
@@ -0,0 +1,51 @@
+package org.eclipse.opensmartclide.dbapi.repository;
+
+import static org.junit.Assert.assertEquals;
+import java.util.Optional;
+import org.eclipse.opensmartclide.dbapi.model.User;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.autoconfigure.data.mongo.DataMongoTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@DataMongoTest
+class UserRepositoryTest {
+
+ @Autowired
+ private UserRepository userRepository;
+
+ @BeforeEach
+ public void setUp() {
+ User user = new User();
+ user.setId(Long.toString(1L));
+ user.setEmail("testUser@email.com");
+ user.setTeam_id("testUserTeamId");
+
+ userRepository.save(user);
+ }
+
+ @Test
+ public void assertUserIdPersisted() {
+ Optional user = userRepository.findById(Long.toString(1L));
+ String userId = user.get().getId();
+ assertEquals(Long.toString(1L), userId);
+ }
+
+ @Test
+ public void assertUserEmailPersisted() {
+ Optional user = userRepository.findById(Long.toString(1L));
+ String userEmail = user.get().getEmail();
+ assertEquals("testUser@email.com", userEmail);
+ }
+
+ @Test
+ public void assertUserTeamIdPersisted() {
+ Optional user = userRepository.findById(Long.toString(1L));
+ String userTeamId = user.get().getTeam_id();
+ assertEquals("testUserTeamId", userTeamId);
+ }
+
+}
diff --git a/src/test/java/org/eclipse/opensmartclide/dbapi/repository/WorkflowRepositoryTest.java b/src/test/java/org/eclipse/opensmartclide/dbapi/repository/WorkflowRepositoryTest.java
new file mode 100644
index 0000000..100c812
--- /dev/null
+++ b/src/test/java/org/eclipse/opensmartclide/dbapi/repository/WorkflowRepositoryTest.java
@@ -0,0 +1,100 @@
+package org.eclipse.opensmartclide.dbapi.repository;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Optional;
+import org.eclipse.opensmartclide.dbapi.model.Workflow;
+import org.eclipse.opensmartclide.dbapi.repository.WorkflowRepository;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.autoconfigure.data.mongo.DataMongoTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@DataMongoTest
+class WorkflowRepositoryTest {
+
+ @Autowired
+ private WorkflowRepository workflowRepository;
+
+ @BeforeEach
+ public void setUp() throws Exception {
+ Workflow workflow = new Workflow();
+ workflow.setId(Long.toString(1L));
+ workflow.setUser_id("testWorkflowUserId");
+ workflow.setGit_credentials_id("testWorkflowGitCredentialsId");
+ workflow.setName("testWorkflowName");
+ workflow.setUrl("testWorkflowUrl");
+ workflow.setDescription("testWorkflowDescription");
+ workflow.setIs_public(true);
+
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd/mm/yyyy");
+ Date createdDate = simpleDateFormat.parse("15/09/2022");
+ Date updatedDate = simpleDateFormat.parse("11/07/2022");
+ workflow.setCreated(createdDate);
+ workflow.setUpdated(updatedDate);
+
+ workflowRepository.save(workflow);
+ }
+
+ @Test
+ public void assertWorkflowIdPersisted() {
+ Optional workflow = workflowRepository.findById(Long.toString(1L));
+ String workflowId = workflow.get().getId();
+ assertEquals(Long.toString(1L), workflowId);
+ }
+
+ @Test
+ public void assertWorkflowUserIdPersisted() {
+ Optional workflow = workflowRepository.findById(Long.toString(1L));
+ String workflowUserId = workflow.get().getUser_id();
+ assertEquals("testWorkflowUserId", workflowUserId);
+ }
+
+ @Test
+ public void assertWorkflowGitCredentialsIdPersisted() {
+ Optional workflow = workflowRepository.findById(Long.toString(1L));
+ String workflowGitCredentialsId = workflow.get().getGit_credentials_id();
+ assertEquals("testWorkflowGitCredentialsId", workflowGitCredentialsId);
+ }
+
+ @Test
+ public void assertWorkflowNamePersisted() {
+ Optional workflow = workflowRepository.findById(Long.toString(1L));
+ String workflowName = workflow.get().getName();
+ assertEquals("testWorkflowName", workflowName);
+ }
+
+ @Test
+ public void assertWorkflowUrlPersisted() {
+ Optional workflow = workflowRepository.findById(Long.toString(1L));
+ String workflowUrl = workflow.get().getUrl();
+ assertEquals("testWorkflowUrl", workflowUrl);
+ }
+
+ @Test
+ public void assertWorkflowDescriptionPersisted() {
+ Optional workflow = workflowRepository.findById(Long.toString(1L));
+ String workflowDescription = workflow.get().getDescription();
+ assertEquals("testWorkflowDescription", workflowDescription);
+ }
+
+ @Test
+ public void assertWorkflowCreatedDatePersisted() throws ParseException {
+ Optional workflow = workflowRepository.findById(Long.toString(1L));
+ Date workflowCreatedDate = workflow.get().getCreated();
+ assertTrue(workflowCreatedDate.equals(new SimpleDateFormat("dd/mm/yyyy").parse("15/09/2022")));
+ }
+
+ @Test
+ public void assertWorkflowUpdatedDatePersisted() throws ParseException {
+ Optional workflow = workflowRepository.findById(Long.toString(1L));
+ Date workflowUpdatedDate = workflow.get().getUpdated();
+ assertTrue(workflowUpdatedDate.equals(new SimpleDateFormat("dd/mm/yyyy").parse("11/07/2022")));
+ }
+}