concept terminal window in category cloud

appears as: Terminal window
Cloud Native Spring in Action

This is an excerpt from Manning's book Cloud Native Spring in Action.

A basic test setup is included when starting a Spring project from Spring Initializr. In the build.gradle file, you automatically get the dependencies needed for testing a Spring application. On top of that, a test class is automatically generated. Let’s have a look at how the GreetingServiceApplicationTests class might look after initializing the project.

Listing 3.8. The Book class with validation constraints defined for each field.
package com.polarbookshop.catalogservice.domain;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.PastOrPresent;
import javax.validation.constraints.Pattern;
import java.time.Year;

public class Book {
    @NotBlank(message = "The book ISBN must be defined.")
    @Pattern(regexp = "^(97([89]))?\\d{9}(\\d|X)$", message = "The ISBN format must follow the standards ISBN-10 or ISBN-13.") #1
    private String isbn;
    @NotBlank(message = "The book title must be defined.") #2
    private String title;
    @NotBlank(message = "The book author must be defined.")
    private String author;
    @PastOrPresent(message = "The book cannot have been published in the future.") #3
    private Year publishingYear;

    // Rest of the class
}