diff --git a/app/server/.gitlab-ci.yml b/app/server/.gitlab-ci.yml
index 351d4cce9c..509000a67a 100644
--- a/app/server/.gitlab-ci.yml
+++ b/app/server/.gitlab-ci.yml
@@ -6,7 +6,6 @@
image: docker:latest
services:
- docker:dind
- - mongo:latest
cache:
paths:
@@ -28,7 +27,8 @@ stages:
maven-build:
image: maven:3-jdk-11-slim
stage: build
- script: "mvn package -DskipTests -B"
+ script:
+ - mvn package -B -Dspring.profiles.active=local
artifacts:
paths:
- appsmith-server/target/*.jar
@@ -45,7 +45,6 @@ docker-package:
only:
- master
-
heroku-deploy:
stage: deploy
image: tmaier/dpl:latest
diff --git a/app/server/appsmith-interfaces/pom.xml b/app/server/appsmith-interfaces/pom.xml
index 534a55dd1b..c955fad13a 100644
--- a/app/server/appsmith-interfaces/pom.xml
+++ b/app/server/appsmith-interfaces/pom.xml
@@ -11,7 +11,7 @@
4.0.0
com.appsmith
interfaces
- ${project.version}
+ 1.0-SNAPSHOT
interfaces
diff --git a/app/server/appsmith-plugins/pom.xml b/app/server/appsmith-plugins/pom.xml
index 6920e23634..66e0a7f36c 100644
--- a/app/server/appsmith-plugins/pom.xml
+++ b/app/server/appsmith-plugins/pom.xml
@@ -11,7 +11,7 @@
4.0.0
com.appsmith
appsmith-plugins
- ${project.version}
+ 1.0-SNAPSHOT
pom
diff --git a/app/server/appsmith-server/pom.xml b/app/server/appsmith-server/pom.xml
index 91d71693af..bb5c35fbaa 100644
--- a/app/server/appsmith-server/pom.xml
+++ b/app/server/appsmith-server/pom.xml
@@ -10,7 +10,7 @@
com.appsmith
server
- ${project.version}
+ 1.0-SNAPSHOT
jar
server
@@ -96,6 +96,11 @@
compiler
0.9.6
+
+ de.flapdoodle.embed
+ de.flapdoodle.embed.mongo
+ test
+
diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/ServerApplicationTests.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/ServerApplicationTests.java
index f44cff85be..0407b5581f 100644
--- a/app/server/appsmith-server/src/test/java/com/appsmith/server/ServerApplicationTests.java
+++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/ServerApplicationTests.java
@@ -1,16 +1,29 @@
package com.appsmith.server;
+import com.appsmith.server.services.ApplicationServiceTest;
+import com.appsmith.server.services.LayoutServiceTest;
+import com.appsmith.server.services.OrganizationServiceTest;
+import com.appsmith.server.services.PageServiceTest;
+import com.appsmith.server.services.UserServiceTest;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.context.junit4.SpringRunner;
-@RunWith(SpringRunner.class)
+@RunWith(Suite.class)
@SpringBootTest
+@Suite.SuiteClasses({
+ OrganizationServiceTest.class,
+ ApplicationServiceTest.class,
+ LayoutServiceTest.class,
+ UserServiceTest.class,
+ PageServiceTest.class,
+})
public class ServerApplicationTests {
@Test
public void contextLoads() {
+ assert(true);
}
}
diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/configurations/SeedMongoData.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/configurations/SeedMongoData.java
new file mode 100644
index 0000000000..4cded216a2
--- /dev/null
+++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/configurations/SeedMongoData.java
@@ -0,0 +1,93 @@
+package com.appsmith.server.configurations;
+
+import com.appsmith.server.domains.Application;
+import com.appsmith.server.domains.Organization;
+import com.appsmith.server.domains.Page;
+import com.appsmith.server.domains.User;
+import com.appsmith.server.domains.UserState;
+import com.appsmith.server.repositories.ApplicationRepository;
+import com.appsmith.server.repositories.OrganizationRepository;
+import com.appsmith.server.repositories.PageRepository;
+import com.appsmith.server.repositories.UserRepository;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.boot.ApplicationRunner;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import reactor.core.publisher.Flux;
+import reactor.core.publisher.Mono;
+
+@Slf4j
+@Configuration
+public class SeedMongoData {
+
+ @Bean
+ ApplicationRunner init(UserRepository userRepository,
+ OrganizationRepository organizationRepository,
+ ApplicationRepository applicationRepository,
+ PageRepository pageRepository) {
+ log.info("Seeding the data");
+ Object[][] userData = {
+ {"user test", "usertest@usertest.com", UserState.ACTIVATED},
+ {"api_user", "api_user", UserState.ACTIVATED},
+ };
+ Object[][] orgData = {
+ {"Spring Test Organization", "appsmith-spring-test.com", "appsmith.com"}
+ };
+ Object[][] appData = {
+ {"LayoutServiceTest TestApplications"}
+ };
+ Object[][] pageData = {
+ {"validPageName"}
+ };
+ return args -> {
+ organizationRepository.deleteAll()
+ .thenMany(
+ // Seed the organization data into the DB
+ Flux.just(orgData)
+ .map(array -> {
+ Organization organization = new Organization();
+ organization.setName((String) array[0]);
+ organization.setDomain((String) array[1]);
+ organization.setWebsite((String) array[2]);
+ return organization;
+ }).flatMap(organizationRepository::save)
+ )
+ // Query the seed data to get the organizationId (required for application creation)
+ .then(organizationRepository.findByName((String) orgData[0][0]))
+ .map(org -> org.getId())
+ // Seed the user data into the DB
+ .flatMapMany(orgId -> Flux.just(userData)
+ .map(array -> {
+ User user = new User();
+ user.setName((String) array[0]);
+ user.setEmail((String) array[1]);
+ user.setState((UserState) array[2]);
+ user.setOrganizationId(orgId);
+ return user;
+ })
+ .flatMap(userRepository::save)
+ .then(Mono.just(orgId))
+ ).flatMap(orgId ->
+ // Seed the application data into the DB
+ Flux.just(appData).map(array -> {
+ Application app = new Application();
+ app.setName((String) array[0]);
+ app.setOrganizationId(orgId);
+ return app;
+ }).flatMap(applicationRepository::save)
+ // Query the seed data to get the applicationId (required for page creation)
+ ).then(applicationRepository.findByName((String) appData[0][0]))
+ .map(application -> application.getId())
+ .flatMapMany(appId -> Flux.just(pageData)
+ // Seed the page data into the DB
+ .map(array -> {
+ Page page = new Page();
+ page.setName((String) array[0]);
+ page.setApplicationId(appId);
+ return page;
+ })
+ .flatMap(pageRepository::save)
+ ).subscribe(obj -> log.info("Last Saved Object: " + obj));
+ };
+ }
+}
diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ApplicationServiceTest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ApplicationServiceTest.java
index d994c3538f..0423b3c61c 100644
--- a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ApplicationServiceTest.java
+++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ApplicationServiceTest.java
@@ -8,13 +8,16 @@ import lombok.extern.slf4j.Slf4j;
import org.junit.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.boot.test.context.SpringBootTest;
import org.springframework.security.test.context.support.WithMockUser;
+import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit4.SpringRunner;
import reactor.core.publisher.Mono;
import reactor.test.StepVerifier;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.springframework.test.annotation.DirtiesContext.ClassMode.BEFORE_CLASS;
@RunWith(SpringRunner.class)
@SpringBootTest
diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/LayoutServiceTest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/LayoutServiceTest.java
index 7855bbd0a0..c0e8e6b7d4 100644
--- a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/LayoutServiceTest.java
+++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/LayoutServiceTest.java
@@ -15,6 +15,7 @@ import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.security.test.context.support.WithMockUser;
+import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit4.SpringRunner;
import reactor.core.publisher.Mono;
import reactor.test.StepVerifier;
@@ -22,6 +23,7 @@ import reactor.test.StepVerifier;
import java.util.concurrent.atomic.AtomicReference;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.springframework.test.annotation.DirtiesContext.ClassMode.BEFORE_CLASS;
@RunWith(SpringRunner.class)
@SpringBootTest
@@ -41,15 +43,8 @@ public class LayoutServiceTest {
Mono applicationMono;
@Before
- @WithMockUser(username = "api_user")
public void setup() {
-
- Application testApplication = new Application();
- testApplication.setName("LayoutServiceTest TestApplications");
- applicationMono =
- applicationService.findByName(testApplication.getName())
- .switchIfEmpty(applicationService.create(testApplication));
-
+ applicationMono = applicationService.findByName("LayoutServiceTest TestApplications");
}
@Test
@@ -157,15 +152,9 @@ public class LayoutServiceTest {
testLayout.setDsl(obj);
Page testPage = new Page();
- testPage.setName("LayoutServiceTest updateLayoutValidPage");
+ testPage.setName("validPageName");
Page page = pageService
.findByName(testPage.getName())
- .switchIfEmpty(applicationMono
- .map(application -> {
- testPage.setApplicationId(application.getId());
- return testPage;
- })
- .flatMap(pageService::save))
.block();
Layout startLayout = layoutService.createLayout(page.getId(), testLayout).block();
diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/OrganizationServiceTest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/OrganizationServiceTest.java
index 1813c3a124..7a57eeecb4 100644
--- a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/OrganizationServiceTest.java
+++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/OrganizationServiceTest.java
@@ -9,11 +9,13 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit4.SpringRunner;
import reactor.core.publisher.Mono;
import reactor.test.StepVerifier;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.springframework.test.annotation.DirtiesContext.ClassMode.BEFORE_CLASS;
@RunWith(SpringRunner.class)
@SpringBootTest
diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/PageServiceTest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/PageServiceTest.java
index c364f76545..2e841d9ead 100644
--- a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/PageServiceTest.java
+++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/PageServiceTest.java
@@ -13,11 +13,13 @@ import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.security.test.context.support.WithMockUser;
+import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit4.SpringRunner;
import reactor.core.publisher.Mono;
import reactor.test.StepVerifier;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.springframework.test.annotation.DirtiesContext.ClassMode.BEFORE_CLASS;
@RunWith(SpringRunner.class)
@SpringBootTest
diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/UserServiceTest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/UserServiceTest.java
index 2dcf356bad..9eab95b078 100644
--- a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/UserServiceTest.java
+++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/UserServiceTest.java
@@ -10,11 +10,14 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit4.SpringRunner;
import reactor.core.publisher.Mono;
import reactor.test.StepVerifier;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.springframework.test.annotation.DirtiesContext.ClassMode.BEFORE_CLASS;
+import static org.springframework.test.annotation.DirtiesContext.ClassMode.BEFORE_EACH_TEST_METHOD;
@RunWith(SpringRunner.class)
@SpringBootTest
@@ -31,22 +34,9 @@ public class UserServiceTest {
@Before
public void setup() {
- //User init
- User user = new User();
- user.setName("user test");
- user.setEmail("usertest@usertest.com");
- user.setState(UserState.ACTIVATED);
- //Store the user in case its not present in the database.
- userMono = userService.findByEmail("usertest@usertest.com").switchIfEmpty(Mono.defer(() -> userService.save(user)));
- //Organization init
- Organization organization = new Organization();
- organization.setName("Spring Test Organization");
- organization.setDomain("appsmith-spring-test.com");
- organization.setWebsite("appsmith.com");
-
- //Store the organization in case its not present in the database.
- organizationMono = organizationService.getByName("Spring Test Organization").switchIfEmpty(Mono.defer(() -> organizationService.save(organization)));
+ userMono = userService.findByEmail("usertest@usertest.com");
+ organizationMono = organizationService.getByName("Spring Test Organization");
}
//Test the update organization flow.
diff --git a/app/server/appsmith-server/src/test/resources/application-test.properties b/app/server/appsmith-server/src/test/resources/application-test.properties
new file mode 100644
index 0000000000..4b20d38b38
--- /dev/null
+++ b/app/server/appsmith-server/src/test/resources/application-test.properties
@@ -0,0 +1,20 @@
+# Jackson Properties
+spring.jackson.default-property-inclusion=non_null
+
+#Mongo properties
+spring.data.mongodb.database=mobtools
+spring.data.mongodb.host=localhost
+spring.data.mongodb.port=27017
+#spring.data.mongodb.username=
+#spring.data.mongodb.password=
+
+logging.level.root=INFO
+logging.level.com.appsmith=debug
+logging.pattern.console=%X - %m%n
+
+#Spring security
+spring.security.oauth2.client.registration.google.client-id=869021686091-9b84bbf7ea683t1aaefqnmefcnmk6fq6.apps.googleusercontent.com
+spring.security.oauth2.client.registration.google.client-secret=9dvITt4OayEY1HfeY8bHX74p
+
+# Accounts from specific domains are allowed to login
+oauth2.allowed-domains=appsmith.com
\ No newline at end of file
diff --git a/app/server/docker-compose.yml b/app/server/docker-compose.yml
index 2fad306519..b8be720fb9 100644
--- a/app/server/docker-compose.yml
+++ b/app/server/docker-compose.yml
@@ -17,6 +17,15 @@ services:
networks:
- appsmith
+ mongo_seed:
+ image: appsmith-mongo
+ links:
+ - mongo
+ volumes:
+ - ./mongo-seed:/mongo-seed
+ networks:
+ - appsmith
+
networks:
appsmith:
driver: bridge
\ No newline at end of file