Skip to content

Commit

Permalink
ISSUE-28: Make tests compatible with static frontend.
Browse files Browse the repository at this point in the history
  • Loading branch information
pavlo-bystrytskyi committed Oct 17, 2024
1 parent 86cc201 commit f58955d
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
import lombok.AllArgsConstructor;
import lombok.NonNull;
import org.jetbrains.annotations.NotNull;
import org.springframework.http.HttpMethod;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.resource.NoResourceFoundException;

import java.util.List;

Expand All @@ -32,11 +34,31 @@ public List<ActorResponse> getByName(@PathVariable @NonNull String prefix) {
return actorService.getActorsByPrefix(prefix).stream().map(ActorResponse::from).toList();
}

/**
* Prevents the frontend fallback response from being returned if the request path is invalid.
*
* @throws NoResourceFoundException
*/
@GetMapping("/autocompletion/")
public void getByNameInvalid() throws NoResourceFoundException {
throw new NoResourceFoundException(HttpMethod.GET, "/api/actor/autocompletion/");
}

@GetMapping("/movie/{movieId}")
public List<ActorResponse> getByMovieId(@PathVariable @NonNull Long movieId) {
return actorService.getActorsByMovieId(movieId).stream().map(ActorResponse::from).toList();
}

/**
* Prevents the frontend fallback response from being returned if the request path is invalid.
*
* @throws NoResourceFoundException
*/
@GetMapping("/movie/")
public void getByMovieIdInvalid() throws NoResourceFoundException {
throw new NoResourceFoundException(HttpMethod.GET, "/api/actor/movie/");
}

@PutMapping
public void update() {
// TODO
Expand Down

0 comments on commit f58955d

Please sign in to comment.