Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

Commit

Permalink
Rebased onto chris-hellen-master and created update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-hellen committed Apr 10, 2024
1 parent d0af7d7 commit d4471b1
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import org.junit.jupiter.api.Test;
import org.springframework.http.HttpStatus;

public class GetLeapYearBookTest extends AbstractBaseApiTest {
class GetLeapYearBookTest extends AbstractBaseApiTest {
@Test
void testEmptyGet(){
Response response = ra()
Expand Down
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))));
}
}

0 comments on commit d4471b1

Please sign in to comment.