From 1d5fa960dbc99c1faa77caa6ff5b5e285a3180b6 Mon Sep 17 00:00:00 2001 From: Shrikant Kandula Date: Thu, 18 Jun 2020 15:05:55 +0530 Subject: [PATCH] Fail with an error if can't find page when creating an action --- .../server/services/ActionServiceImpl.java | 3 ++- .../server/services/ActionServiceTest.java | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) 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 58796d1764..82dc906b85 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 @@ -48,7 +48,6 @@ import org.springframework.util.StringUtils; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import reactor.core.scheduler.Scheduler; -import retrofit.http.HEAD; import javax.lang.model.SourceVersion; import javax.validation.Validator; @@ -143,6 +142,8 @@ public class ActionServiceImpl extends BaseService { Page page = tuple.getT1(); diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ActionServiceTest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ActionServiceTest.java index 0bfc6a3695..4751f2a6a4 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ActionServiceTest.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ActionServiceTest.java @@ -243,6 +243,25 @@ public class ActionServiceTest { .verify(); } + @Test + @WithUserDetails(value = "api_user") + public void invalidCreateActionInvalidPageId() { + Action action = new Action(); + action.setName("randomActionName3"); + action.setPageId("invalid page id here"); + ActionConfiguration actionConfiguration = new ActionConfiguration(); + actionConfiguration.setHttpMethod(HttpMethod.GET); + action.setActionConfiguration(actionConfiguration); + Mono actionMono = Mono.just(action) + .flatMap(actionService::create); + StepVerifier + .create(actionMono) + .expectErrorMatches(throwable -> throwable instanceof AppsmithException && + throwable.getMessage().equals( + AppsmithError.NO_RESOURCE_FOUND.getMessage("page", "invalid page id here"))) + .verify(); + } + @Test @WithUserDetails(value = "api_user") public void testVariableSubstitution() {