Fail with an error if can't find page when creating an action
This commit is contained in:
parent
69dd082cf6
commit
1d5fa960db
|
|
@ -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<ActionRepository, Action, Str
|
|||
|
||||
return pageService
|
||||
.findById(action.getPageId(), READ_PAGES)
|
||||
.switchIfEmpty(Mono.error(
|
||||
new AppsmithException(AppsmithError.NO_RESOURCE_FOUND, "page", action.getPageId())))
|
||||
.zipWith(userMono)
|
||||
.flatMap(tuple -> {
|
||||
Page page = tuple.getT1();
|
||||
|
|
|
|||
|
|
@ -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<Action> 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() {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user