@Test
    public void testUpdate() {

        Book bookD = bookRepository.findByTitle("Book D").get(0);
        System.out.println(bookD);

        Long id = bookD.getId();

        bookD.setTitle("Book E");
        bookD.setPrice(new BigDecimal("199.99"));
        bookD.setPublishDate(LocalDate.of(2024, 1, 31));

        given()
                .contentType(ContentType.JSON)
                .body(bookD)
                .when()
                    .put("/books")
                .then()
                    .statusCode(200)
                    .contentType(ContentType.JSON);

        // get the updated book
        Book updatedBook = bookRepository.findById(id).orElseThrow();
        System.out.println(updatedBook);

        assertEquals(id, updatedBook.getId());
        assertEquals("Book E", updatedBook.getTitle());
        assertEquals(new BigDecimal("199.99"), updatedBook.getPrice());
        assertEquals(LocalDate.of(2024, 1, 31), updatedBook.getPublishDate());
        
    }
Book b4 = new Book("Book D",
BigDecimal.valueOf(39.99),
LocalDate.of(2023, 5, 5));
spring-data-jpa-postgresql/src/test/java/com/mkyong/BookControllerTest.java