dimanche 6 septembre 2015

JPA Entity must be unit tested and how?

I have a Spring MVC application (Spring Boot v. 1.2.5) that uses JPA to interact with a popular Sql Database.
Thus, I have several entities mapping all the tables in the db. Clearly, these classes are having only getters/setters and annotations for the relations between entities.

E.g.:

@Entity
@Table
public class Article {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @JsonView(View.Private.class)
    private Long id;

    @Column(nullable = false)
    @JsonView(View.Public.class)
    private String name;

    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    @JoinColumn(name = "categoryId", nullable = false, updatable = false)
    @JsonIgnore
    private Category category;

   //Constructors Getters and Setters
   ...
}

My question is: should I unit test these classes? What should I test? How

Aucun commentaire:

Enregistrer un commentaire