This repository has been archived by the owner on Nov 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rebased onto chris-hellen-master and created update tests
- Loading branch information
1 parent
d0af7d7
commit d4471b1
Showing
2 changed files
with
59 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
src/test/java/org/folio/sample/integration/api/books/UpdateBookTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package org.folio.sample.integration.api.books; | ||
|
||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.Matchers.equalTo; | ||
import static org.hamcrest.Matchers.is; | ||
|
||
import io.restassured.response.Response; | ||
import java.time.LocalDate; | ||
import java.util.UUID; | ||
|
||
import org.folio.sample.domain.dto.BookDTO; | ||
import org.folio.sample.domain.dto.BookForCreationDTO; | ||
import org.folio.sample.integration.AbstractBaseApiTest; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.http.HttpStatus; | ||
|
||
class UpdateBookTest extends AbstractBaseApiTest{ | ||
@Test | ||
void testNotFound(){ | ||
ra() | ||
.pathParam("id", UUID.fromString("00000000-0000-0000-0000-000000000000")) | ||
.get(getRequestUrl("books/{id}")) | ||
.then() | ||
.statusCode(is(HttpStatus.NOT_FOUND.value())); | ||
} | ||
|
||
@Test | ||
void testUpdate(){ | ||
Response postResponse = ra() | ||
.body( | ||
BookForCreationDTO | ||
.builder() | ||
.name("book 1") | ||
.publishedDate(LocalDate.of(2024, 1, 1)) | ||
.build() | ||
) | ||
.post(getRequestUrl("books")); | ||
postResponse.then().statusCode(is(HttpStatus.CREATED.value())); | ||
|
||
UUID createdId = postResponse.as(BookDTO.class).getId(); | ||
|
||
Response putResponse = ra() | ||
.body( | ||
BookForCreationDTO | ||
.builder() | ||
.name("updated book") | ||
.publishedDate(LocalDate.of(2020, 1, 1)) | ||
.build() | ||
) | ||
.pathParam("id", createdId) | ||
.put(getRequestUrl("books/{id}")); | ||
putResponse.then().statusCode(is(HttpStatus.OK.value())); | ||
|
||
BookDTO book = putResponse.getBody().as(BookDTO.class); | ||
assertThat(book.getName(), is(equalTo("updated book"))); | ||
assertThat(book.getPublishedDate(), is(equalTo(LocalDate.of(2020, 1, 1)))); | ||
} | ||
} |