我是编程初学者,所以如果我问一个小问题,请原谅我。
我的问题是,如何使我的测试方法能够检查与 CalendarModel 相关的 UserModel 的 OneToMany 连接。我想检查该列表是否包含正确的实体,因此 UserModel 的所有 4 个字段都经过测试。
我的用户模型:
import com.fasterxml.jackson.annotation.JsonIgnore;
import java.util.List;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
@Entity
public class UserModel {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private long id;
@OneToMany(mappedBy = "id")
@JsonIgnore
private List<CalendarModel> calendarModels;
private String username;
private String password;
public UserModel(long id, String username, String password) {
this.id = id;
this.username = username;
this.password = password;
}
public UserModel() {
}
public long getId() {
return id; …Run Code Online (Sandbox Code Playgroud)