Skip to content

Latest commit

 

History

History
36 lines (21 loc) · 1.63 KB

File metadata and controls

36 lines (21 loc) · 1.63 KB
layout page
title 401.13 Reading Notes
permalink /401-R13/

Related Resources & Integration Testing

One-to-One Relationships

  • Using the annotation @OneToOne within each class (before an instance of the related class), two classes may be related.

    • Additional annotations (like @RestResource) may be included to further define the relationship.
  • Respective repository interfaces must be made for each.

  • CRUD requests may be made with respect to the related resource.

  • Tested by POST-ing two objects, then PUT-ing the association. (GET the resulting resources)

One-to-Many Relationships

  • Using the two respective annotations @OneToMany and @ManyToOne before an instance of the related class, multiple resources may be related to a single resource.

  • CRUD requests may be made with respect to the related resource to both associate an instance (PUT) and to GET the associated resources.

  • Tested by POST-ing more than two objects, the PUT-ing the same relationship to the first with each other (respectively)

Many-to-Many

  • Using the annotation @ManyToMany, individual instances of one resource may be associated with multiple others (including webbed relationships)

Integration Testing In Spring

  • Integration testing is used to verify that resources have the expected relationships and interactions. (Some documentation here)

  • The annotations @ExtendWith() , @ContextConfiguration(), and @WebAppConfiguration set up the testing context for the given classes to simulate relationships and associated behaviors