Tidy up test - TestInfoOneToOne, oneToOne cascade update

This commit is contained in:
rbygrave committed 2014-10-29 23:45:24 +13:00
1 parent 306cc4adf4
commit 0f3b1eb812
2 files changed
+8 -9

No files matched your search

@@ -16,7 +16,7 @@ public class TestInfoOneToOne extends BaseTestCase {
InfoCustomer customer = new InfoCustomer(); InfoCustomer customer = new InfoCustomer();
customer.setName("first info cust"); customer.setName("first info cust");
customer.setInfos(company); customer.setCompany(company);
customer.save(); customer.save();
@@ -34,13 +34,13 @@ public class TestInfoOneToOne extends BaseTestCase {
customer.update(); customer.update();
// update the customer and company // update the customer and company
customer.getInfos().setName("2nd mod company"); customer.getCompany().setName("2nd mod company");
customer.setName("2nd mod customer"); customer.setName("2nd mod customer");
customer.update(); customer.update();
// fetch and then update both // fetch and then update both
InfoCustomer fetchedCustomer = InfoCustomer.find.byId(customer.getId()); InfoCustomer fetchedCustomer = InfoCustomer.find.byId(customer.getId());
fetchedCustomer.getInfos().setName("3rd mod company"); fetchedCustomer.getCompany().setName("3rd mod company");
fetchedCustomer.setName("3rd mod customer"); fetchedCustomer.setName("3rd mod customer");
fetchedCustomer.update(); fetchedCustomer.update();
@@ -18,8 +18,7 @@ public class InfoCustomer extends Model {
String name; String name;
@OneToOne(cascade = CascadeType.ALL) @OneToOne(cascade = CascadeType.ALL)
//@JoinColumn(name = "id_info_company") InfoCompany company;
InfoCompany infos = new InfoCompany();
public Long getId() { public Long getId() {
return id; return id;
@@ -45,11 +44,11 @@ public class InfoCustomer extends Model {
this.name = name; this.name = name;
} }
public InfoCompany getInfos() { public InfoCompany getCompany() {
return infos; return company;
} }
public void setInfos(InfoCompany infos) { public void setCompany(InfoCompany company) {
this.infos = infos; this.company = company;
} }
} }