From 8658df95a92319b4dbab87d518dde4e5bb30f6e3 Mon Sep 17 00:00:00 2001 From: Trisha Anand Date: Mon, 30 Sep 2019 18:17:35 +0000 Subject: [PATCH] All action executions now return object of type ActionExecutionResult. RestApiPlugin returns the same object which contains statusCode, headers and body. --- app/server/appsmith-interfaces/pom.xml | 6 ++ .../external/models/ActionConfiguration.java | 4 +- .../models/ActionExecutionResult.java | 18 ++++ .../appsmith/external/models/Property.java | 2 + .../models/ResourceConfiguration.java | 2 + .../external/plugins/PluginExecutor.java | 5 +- .../com/external/plugins/PostgresPlugin.java | 13 ++- .../com/external/plugins/RestApiPlugin.java | 94 +++++++++++-------- app/server/appsmith-server/pom.xml | 5 + .../server/configurations/CommonConfig.java | 6 ++ .../server/controllers/ActionController.java | 5 +- .../server/services/ActionService.java | 5 +- .../server/services/ActionServiceImpl.java | 85 +++++++++++++++-- .../services/OrganizationServiceImpl.java | 1 - .../services/ApplicationServiceTest.java | 3 - .../server/services/LayoutServiceTest.java | 2 - .../services/OrganizationServiceTest.java | 2 - .../server/services/PageServiceTest.java | 2 - .../server/services/UserServiceTest.java | 4 - 19 files changed, 190 insertions(+), 74 deletions(-) create mode 100644 app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/ActionExecutionResult.java diff --git a/app/server/appsmith-interfaces/pom.xml b/app/server/appsmith-interfaces/pom.xml index c955fad13a..b6bb5eb1ba 100644 --- a/app/server/appsmith-interfaces/pom.xml +++ b/app/server/appsmith-interfaces/pom.xml @@ -64,6 +64,12 @@ 1.18.8 provided + + com.fasterxml.jackson.core + jackson-databind + 2.9.8 + compile + diff --git a/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/ActionConfiguration.java b/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/ActionConfiguration.java index 935f5c11d6..fa4dc9ae2b 100644 --- a/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/ActionConfiguration.java +++ b/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/ActionConfiguration.java @@ -1,5 +1,6 @@ package com.appsmith.external.models; +import com.fasterxml.jackson.databind.JsonNode; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; @@ -9,6 +10,7 @@ import org.springframework.data.mongodb.core.mapping.Document; import org.springframework.http.HttpMethod; import java.util.List; +import java.util.Map; @Getter @Setter @@ -29,7 +31,7 @@ public class ActionConfiguration { String path; List headers; List queryParameters; - JSONObject body; + Map body; HttpMethod httpMethod; // DB action fields diff --git a/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/ActionExecutionResult.java b/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/ActionExecutionResult.java new file mode 100644 index 0000000000..4ecb3b9fec --- /dev/null +++ b/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/ActionExecutionResult.java @@ -0,0 +1,18 @@ +package com.appsmith.external.models; + +import com.fasterxml.jackson.databind.JsonNode; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@ToString +@NoArgsConstructor +public class ActionExecutionResult { + + String statusCode; + JsonNode headers; + JsonNode body; +} diff --git a/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/Property.java b/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/Property.java index 9fa290ec1a..296584a207 100644 --- a/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/Property.java +++ b/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/Property.java @@ -2,9 +2,11 @@ package com.appsmith.external.models; import lombok.Getter; import lombok.Setter; +import lombok.ToString; @Getter @Setter +@ToString public class Property { String key; diff --git a/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/ResourceConfiguration.java b/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/ResourceConfiguration.java index 0596bd2186..123e13207d 100644 --- a/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/ResourceConfiguration.java +++ b/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/ResourceConfiguration.java @@ -21,4 +21,6 @@ public class ResourceConfiguration { List properties; + //For REST API + List headers; } diff --git a/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/plugins/PluginExecutor.java b/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/plugins/PluginExecutor.java index df7314e645..47edea3625 100644 --- a/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/plugins/PluginExecutor.java +++ b/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/plugins/PluginExecutor.java @@ -1,14 +1,15 @@ package com.appsmith.external.plugins; import com.appsmith.external.models.ActionConfiguration; +import com.appsmith.external.models.ActionExecutionResult; import com.appsmith.external.models.Param; import com.appsmith.external.models.ResourceConfiguration; import org.pf4j.ExtensionPoint; -import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; import java.util.List; public interface PluginExecutor extends ExtensionPoint { - Flux execute(ResourceConfiguration resourceConfiguration, ActionConfiguration action, List params); + Mono execute(ResourceConfiguration resourceConfiguration, ActionConfiguration action, List params); } diff --git a/app/server/appsmith-plugins/postgresPlugin/src/main/java/com/external/plugins/PostgresPlugin.java b/app/server/appsmith-plugins/postgresPlugin/src/main/java/com/external/plugins/PostgresPlugin.java index b10602dee2..aaff78ea7d 100644 --- a/app/server/appsmith-plugins/postgresPlugin/src/main/java/com/external/plugins/PostgresPlugin.java +++ b/app/server/appsmith-plugins/postgresPlugin/src/main/java/com/external/plugins/PostgresPlugin.java @@ -1,6 +1,7 @@ package com.external.plugins; import com.appsmith.external.models.ActionConfiguration; +import com.appsmith.external.models.ActionExecutionResult; import com.appsmith.external.models.Param; import com.appsmith.external.models.ResourceConfiguration; import com.appsmith.external.plugins.BasePlugin; @@ -10,7 +11,7 @@ import org.pf4j.Extension; import org.pf4j.PluginException; import org.pf4j.PluginWrapper; import org.springframework.util.Assert; -import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; import java.sql.Connection; import java.sql.DriverManager; @@ -73,9 +74,9 @@ public class PostgresPlugin extends BasePlugin { public static class PostgresPluginExecutor implements PluginExecutor { @Override - public Flux execute(ResourceConfiguration resourceConfiguration, - ActionConfiguration actionConfiguration, - List params) { + public Mono execute(ResourceConfiguration resourceConfiguration, + ActionConfiguration actionConfiguration, + List params) { log.debug("In the PostgresPlugin execute with resourceConfiguration: {}, ActionConfig: {}", resourceConfiguration, actionConfiguration); @@ -98,9 +99,11 @@ public class PostgresPlugin extends BasePlugin { } catch (SQLException e) { log.error("", e); } + //Return list because list is the actual result. ActionExecutionResult is just a stop gap measure list.forEach(System.out::println); - return Flux.fromIterable(list); + ActionExecutionResult result = new ActionExecutionResult(); + return Mono.just(result); } } diff --git a/app/server/appsmith-plugins/restApiPlugin/src/main/java/com/external/plugins/RestApiPlugin.java b/app/server/appsmith-plugins/restApiPlugin/src/main/java/com/external/plugins/RestApiPlugin.java index c0c5c060b2..cad504529d 100644 --- a/app/server/appsmith-plugins/restApiPlugin/src/main/java/com/external/plugins/RestApiPlugin.java +++ b/app/server/appsmith-plugins/restApiPlugin/src/main/java/com/external/plugins/RestApiPlugin.java @@ -1,31 +1,37 @@ package com.external.plugins; import com.appsmith.external.models.ActionConfiguration; +import com.appsmith.external.models.ActionExecutionResult; import com.appsmith.external.models.Param; +import com.appsmith.external.models.Property; import com.appsmith.external.models.ResourceConfiguration; import com.appsmith.external.plugins.BasePlugin; import com.appsmith.external.plugins.PluginExecutor; +import com.fasterxml.jackson.databind.ObjectMapper; import lombok.extern.slf4j.Slf4j; import org.json.JSONObject; import org.pf4j.Extension; import org.pf4j.PluginWrapper; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; -import org.springframework.http.MediaType; +import org.springframework.http.HttpStatus; import org.springframework.web.reactive.function.BodyInserters; -import org.springframework.web.reactive.function.client.ClientResponse; import org.springframework.web.reactive.function.client.WebClient; -import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; +import java.io.IOException; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.stream.Collectors; public class RestApiPlugin extends BasePlugin { + private static ObjectMapper objectMapper; + public RestApiPlugin(PluginWrapper wrapper) { super(wrapper); + this.objectMapper = new ObjectMapper(); } @Slf4j @@ -33,14 +39,14 @@ public class RestApiPlugin extends BasePlugin { public static class RestApiPluginExecutor implements PluginExecutor { @Override - public Flux execute(ResourceConfiguration resourceConfiguration, - ActionConfiguration actionConfiguration, - List params) { - JSONObject requestBody = actionConfiguration.getBody(); + public Mono execute(ResourceConfiguration resourceConfiguration, + ActionConfiguration actionConfiguration, + List params) { + Map requestBody = actionConfiguration.getBody(); if (requestBody == null) { - requestBody = new JSONObject(); + requestBody = (Map) new HashMap(); } - //TODO: Substitue variables from params in all parts (actionConfig, resourceConfig etc) via JsonPath: https://github.com/json-path/JsonPath + Map propertyMap = params.stream() .collect(Collectors.toMap(Param::getKey, param -> param)); @@ -48,39 +54,51 @@ public class RestApiPlugin extends BasePlugin { String url = resourceConfiguration.getUrl() + path; HttpMethod httpMethod = actionConfiguration.getHttpMethod(); if (httpMethod == null) { - return Flux.error(new Exception("HttpMethod must not be null")); + return Mono.error(new Exception("HttpMethod must not be null")); } - log.debug("Going to make a RestApi call to url: {}, httpMethod: {}", url, httpMethod); + WebClient.Builder webClientBuilder = WebClient.builder().baseUrl(url); - WebClient webClient = WebClient.builder() - .baseUrl(url) - // TODO: Ideally this should come from action / resource config - .defaultHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) - .build(); - - WebClient.RequestHeadersSpec request = webClient.method(httpMethod) - .body(BodyInserters.fromObject(requestBody)); - - Mono responseMono = request.exchange(); - return responseMono.flatMapMany(response -> { - log.debug("Got response: {}", response); - // TODO: Refactor for better switch case - List contentTypes = response.headers().header(HttpHeaders.CONTENT_TYPE); - Class clazz = String.class; - if (contentTypes != null && contentTypes.size() > 0) { - String contentType = contentTypes.get(0); - boolean isJson = MediaType.APPLICATION_JSON_UTF8_VALUE.toLowerCase() - .equals(contentType.toLowerCase() - .replaceAll("\\s", "")) - || MediaType.APPLICATION_JSON_VALUE.equals(contentType.toLowerCase()); - - if (isJson) { - clazz = JSONObject.class; - } + if (resourceConfiguration.getHeaders() != null) { + List headers = resourceConfiguration.getHeaders(); + for (Property header : headers) { + webClientBuilder.defaultHeader(header.getKey(), header.getValue()); } - return response.bodyToFlux(clazz); - }); + } + + if (actionConfiguration.getHeaders() != null) { + List headers = actionConfiguration.getHeaders(); + for (Property header : headers) { + webClientBuilder.defaultHeader(header.getKey(), header.getValue()); + } + } + + return webClientBuilder + .build() + .method(httpMethod) + .body(BodyInserters.fromObject(requestBody)) + .exchange() + .flatMap(clientResponse -> clientResponse.toEntity(String.class)) + .map(stringResponseEntity -> { + /**TODO + * Handle XML response. Currently we only handle JSON responses. + */ + HttpHeaders headers = stringResponseEntity.getHeaders(); + String body = stringResponseEntity.getBody(); + HttpStatus statusCode = stringResponseEntity.getStatusCode(); + + ActionExecutionResult result = new ActionExecutionResult(); + result.setStatusCode(statusCode.toString()); + try { + result.setBody(objectMapper.readTree(body)); + String headerInJsonString = objectMapper.writeValueAsString(headers); + result.setHeaders(objectMapper.readTree(headerInJsonString)); + } catch (IOException e) { + e.printStackTrace(); + } + + return result; + }); } } } diff --git a/app/server/appsmith-server/pom.xml b/app/server/appsmith-server/pom.xml index fce897e7d3..c2e3e22740 100644 --- a/app/server/appsmith-server/pom.xml +++ b/app/server/appsmith-server/pom.xml @@ -101,6 +101,11 @@ de.flapdoodle.embed.mongo test + + org.codehaus.jackson + jackson-mapper-asl + 1.9.13 + com.segment.analytics.java analytics diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/configurations/CommonConfig.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/configurations/CommonConfig.java index beb9220219..4fc88bffcd 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/configurations/CommonConfig.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/configurations/CommonConfig.java @@ -1,5 +1,6 @@ package com.appsmith.server.configurations; +import com.fasterxml.jackson.databind.ObjectMapper; import lombok.Getter; import lombok.Setter; import org.springframework.beans.factory.annotation.Value; @@ -31,4 +32,9 @@ public class CommonConfig { public Validator validator() { return Validation.buildDefaultValidatorFactory().getValidator(); } + + @Bean + public ObjectMapper objectMapper() { + return new ObjectMapper(); + } } diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/controllers/ActionController.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/controllers/ActionController.java index ff77825112..24100c8bee 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/controllers/ActionController.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/controllers/ActionController.java @@ -1,5 +1,6 @@ package com.appsmith.server.controllers; +import com.appsmith.external.models.ActionExecutionResult; import com.appsmith.server.constants.Url; import com.appsmith.server.domains.Action; import com.appsmith.server.dtos.ExecuteActionDTO; @@ -8,7 +9,7 @@ import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; @RestController @RequestMapping(Url.ACTION_URL) @@ -19,7 +20,7 @@ public class ActionController extends BaseController executeAction(@RequestBody ExecuteActionDTO executeActionDTO) { + public Mono executeAction(@RequestBody ExecuteActionDTO executeActionDTO) { return service.executeAction(executeActionDTO); } } diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ActionService.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ActionService.java index 6e1081bec1..a0ada72122 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ActionService.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ActionService.java @@ -1,10 +1,11 @@ package com.appsmith.server.services; +import com.appsmith.external.models.ActionExecutionResult; import com.appsmith.server.domains.Action; import com.appsmith.server.dtos.ExecuteActionDTO; -import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; public interface ActionService extends CrudService { - Flux executeAction(ExecuteActionDTO executeActionDTO); + Mono executeAction(ExecuteActionDTO executeActionDTO); } diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ActionServiceImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ActionServiceImpl.java index 5078eb7a7b..17b11f9279 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ActionServiceImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ActionServiceImpl.java @@ -1,5 +1,9 @@ package com.appsmith.server.services; +import com.appsmith.external.models.ActionConfiguration; +import com.appsmith.external.models.ActionExecutionResult; +import com.appsmith.external.models.Param; +import com.appsmith.external.models.ResourceConfiguration; import com.appsmith.external.plugins.PluginExecutor; import com.appsmith.server.domains.Action; import com.appsmith.server.domains.Page; @@ -11,6 +15,10 @@ import com.appsmith.server.dtos.ExecuteActionDTO; import com.appsmith.server.exceptions.AppsmithError; import com.appsmith.server.exceptions.AppsmithException; import com.appsmith.server.repositories.ActionRepository; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.github.mustachejava.DefaultMustacheFactory; +import com.github.mustachejava.Mustache; +import com.github.mustachejava.MustacheFactory; import com.segment.analytics.Analytics; import lombok.extern.slf4j.Slf4j; import org.pf4j.PluginManager; @@ -18,14 +26,18 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.mongodb.core.ReactiveMongoTemplate; import org.springframework.data.mongodb.core.convert.MongoConverter; import org.springframework.stereotype.Service; -import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import reactor.core.scheduler.Scheduler; import javax.validation.Validator; import javax.validation.constraints.NotNull; +import java.io.StringReader; +import java.io.StringWriter; +import java.io.Writer; import java.util.ArrayList; import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; @Slf4j @Service @@ -36,6 +48,7 @@ public class ActionServiceImpl extends BaseService executeAction(ExecuteActionDTO executeActionDTO) { + public Mono executeAction(ExecuteActionDTO executeActionDTO) { String actionId = executeActionDTO.getActionId(); log.debug("Going to execute action with id: {}", actionId); @@ -133,12 +148,62 @@ public class ActionServiceImpl extends BaseService resourceMono.zipWith(pluginExecutorMono, (resource, pluginExecutor) -> - { - log.debug("*** About to invoke the plugin**"); - // TODO: The CommandParams is being passed as null here. Move it to interfaces.CommandParams - N/A - return pluginExecutor.execute(resource.getResourceConfiguration(), action.getActionConfiguration(), executeActionDTO.getParams()); - })) - .flatMapIterable(Flux::toIterable); + return actionMono + .flatMap(action -> resourceMono.zipWith(pluginExecutorMono, (resource, pluginExecutor) -> { + log.debug("Variable substitutions before invoking the plugin"); + + //Do variable substitution before invoking the plugin + Map replaceParamsMap = executeActionDTO + .getParams() + .stream() + .collect(Collectors.toMap(Param::getKey, Param::getValue, + // Incase there's a conflict, we pick the older value + (oldValue, newValue) -> oldValue) + ); + ResourceConfiguration resourceConfiguration = (ResourceConfiguration) variableSubstitution(resource.getResourceConfiguration(), replaceParamsMap); + ActionConfiguration actionConfiguration = (ActionConfiguration) variableSubstitution(action.getActionConfiguration(), replaceParamsMap); + + log.debug("About to invoke the plugin"); + long start = System.currentTimeMillis(); + Mono actionExecutionResultMono = pluginExecutor.execute(resourceConfiguration, actionConfiguration, executeActionDTO.getParams()); + long end = System.currentTimeMillis(); + log.debug("Time taken by plugin executor is : {} ms",(end-start)); + return actionExecutionResultMono; + })) + .flatMap(obj -> obj); + } + + + /** + * This function replaces the variables in the Object with the actual params + */ + public Object variableSubstitution(Object configuration, + Map replaceParamsMap) { + + try { + // Convert the object to String as a preparation to send it to mustacheReplacement + String objectInJsonString = objectMapper.writeValueAsString(configuration); + objectInJsonString = mustacheReplacement(objectInJsonString, configuration.getClass().getSimpleName(), replaceParamsMap); + return objectMapper.readValue(objectInJsonString, configuration.getClass()); + } catch (Exception e) { + e.printStackTrace(); + } + return configuration; + } + + /** + * + * @param template : This is the string which contains {{key}} which would be replaced with value + * @param name : This is the class name of the object from which template string was created + * @param keyValueMap : This is the map of keys with values. + * @return It finally returns the string in which all the keys in template have been replaced with values. + */ + private String mustacheReplacement(String template, String name, Map keyValueMap) { + MustacheFactory mf = new DefaultMustacheFactory(); + Mustache mustache = mf.compile(new StringReader(template), name); + Writer writer = new StringWriter(); + mustache.execute(writer, keyValueMap); + + return writer.toString(); } } diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/OrganizationServiceImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/OrganizationServiceImpl.java index 76107e776f..9a5bf9a4ce 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/OrganizationServiceImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/OrganizationServiceImpl.java @@ -4,7 +4,6 @@ import com.appsmith.server.constants.FieldName; import com.appsmith.server.domains.Organization; import com.appsmith.server.domains.OrganizationSetting; import com.appsmith.server.domains.Setting; -import com.appsmith.server.domains.User; import com.appsmith.server.exceptions.AppsmithError; import com.appsmith.server.exceptions.AppsmithException; import com.appsmith.server.repositories.OrganizationRepository; 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 0423b3c61c..d994c3538f 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,16 +8,13 @@ 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 c0e8e6b7d4..82d3239363 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,7 +15,6 @@ 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; @@ -23,7 +22,6 @@ 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 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 734b3b8f7c..99cd5c36f3 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 @@ -10,13 +10,11 @@ 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/PageServiceTest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/PageServiceTest.java index 2e841d9ead..c364f76545 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,13 +13,11 @@ 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 9eab95b078..b52d296dc4 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 @@ -2,7 +2,6 @@ package com.appsmith.server.services; import com.appsmith.server.domains.Organization; import com.appsmith.server.domains.User; -import com.appsmith.server.domains.UserState; import com.appsmith.server.exceptions.AppsmithError; import com.appsmith.server.exceptions.AppsmithException; import org.junit.Before; @@ -10,14 +9,11 @@ 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