@Test
    public void testCreate() {

        // Create a new Book E
        Book newBook = new Book("Book E", new BigDecimal("9.99"), LocalDate.parse("2023-09-14"));
        HttpHeaders headers = new HttpHeaders();
        headers.add("Content-Type", "application/json");
        HttpEntity<Book> request = new HttpEntity<>(newBook, headers);

        // test POST save
        ResponseEntity<Book> responseEntity =
                restTemplate.postForEntity(BASEURI + "/books", request, Book.class);

        assertEquals(HttpStatus.CREATED, responseEntity.getStatusCode());

        // find Book E
        List<Book> list = bookRepository.findByTitle("Book E");

        // Test Book E details
        Book book = list.get(0);
        assertEquals("Book E", book.getTitle());
        assertEquals(BigDecimal.valueOf(9.99), book.getPrice());
        assertEquals(LocalDate.of(2023, 9, 14), book.getPublishDate());

    }
Testing with TestRestTemplate and @Testcontainers (image mysql:8.0-debian)
spring-data-jpa-mysql/src/test/java/com/mkyong/BookControllerTest.java