> 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/exercicio-testes-de-api-com-restassured/problema-5-consultar-pedido-por-id/findbyid-retorna-pedido-existente-quando-logado-como-admin.md).

# findById retorna pedido existente quando logado como admin

```java
@Test
public void findByIdShouldReturnOrderWhenLoggedAsAdmin() {

    existingId = 1L;

    given()
            .header("Content-type", "application/json")
            .header("Authorization", "Bearer " + adminToken)
            .accept(ContentType.JSON)
            .when()
            .get("/orders/{id}", existingId)
            .then()
            .statusCode(200)
            .assertThat().body("id", equalTo(1))
            .assertThat().body("moment", equalTo("2022-07-25T13:00:00Z"))
            .assertThat().body("status", equalTo("PAID"))
            .assertThat().body("items.name", hasItems("The Lord of the Rings", "Macbook Pro"));
}
```
