この例 ( https://github.com/21decemb/spring-boot-dbunit-example )に従って、データベース サービスの単体テストを作成しようとしました。データセットとテスト例を作成しました。テストを実行した後、受け取ったもの: org.dbunit.dataset.NoSuchTableException: orders
データセット.xml:
<?xml version="1.0" encoding="UTF-8"?>
<dataset>
<!-- CUSTOMER DATA -->
<customers id="1" name="Customer" active="1"/>
<!-- POSITION DATA -->
<positions id="1" name="POSITION1"/>
<positions id="2" name="POSITION2"/>
<positions id="3" name="POSITION3"/>
<!-- ORDER DATA -->
<orders id="1" name="order1" color="RED" express="0" date="2016-12-11 19:47:39" last_update="2016-12-11 19:47:39" parent_id="1" active="1"/>
<!--<orders id="2" name="order2" color="WHITE" customer_id="1" position_id="1" express="0" date="2016-12-11 19:47:39" last_update="2016-12-11 19:47:39" active="0"/>-->
</dataset>
2 番目の注文行は、2 つの可能性をテストしていたためコメントされています。これが結合によるものであることはわかっています。「位置」と「顧客」(結合のない単純なエンティティ) のみをテストすると、正しく動作します。
私の「注文」エンティティ:
@Entity
@Table(name = "orders", schema = Config.dbSchema)
public class Order implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private long id;
private String name;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name="POSITION_ID")
private Position position;
private short express;
private Date date;
@Column(name="LAST_UPDATE")
private Date lastUpdate;
@Column(name="parent_id")
private Long parentId;
private short active;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name="CUSTOMER_ID")
private Customer customer;
@OneToMany(mappedBy = "order", fetch = FetchType.LAZY)
private List<Component> components;
//getters and setters
}
誰でもそれを修正する方法について何か考えがありますか?
前もって感謝します。