> For the complete documentation index, see [llms.txt](https://olavo-moreira.gitbook.io/studies/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://olavo-moreira.gitbook.io/studies/testes-api-mockmvc-e-restassured/exercicios-testes-de-api-com-mockmvc/problema-4-consultar-pedido-por-id/404-para-pedido-inexistente-quando-logado-como-cliente.md).

# 404 para pedido inexistente quando logado como cliente

```java
   @Test
    public void findByIdShouldReturnNotFoundWhenOrderDontExistAndLoggedAsClient() throws Exception {
        ResultActions result =

                mockMvc.perform(get("/orders/{id}", nonExistingId)
                        .header("Authorization", "Bearer " + clientToken)
                        .accept(MediaType.APPLICATION_JSON));
        result.andExpect(status().isNotFound());
    }
```
