我正在使用Framework for Integrated Test。我知道如何基本上使用ColumnFixture
,RowFixture
和ActionFixture
。现在我的问题是,如果我有像Customer
这样的嵌套对象,对象正在保存带有某些字段的Address
对象,我该如何解析这类对象。
前:
package com.sample;
import java.sql.Date;
public class Customer {
private String name;
private int no;
private Date dob;
private Address address;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getNo() {
return no;
}
public void setNo(int no) {
this.no = no;
}
public Date getDob() {
return dob;
}
public void setDob(Date dob) {
this.dob = dob;
}
public Address getAddress() {
return address;
}
public void setAddress(Address address) {
this.address = address;
}
@Override
public String toString() {
return "Customer [name=" + name + ", no=" + no + ", dob=" + dob
+ ", address=" + address + "]";
}
}
package com.sample;
public class Address {
private int dno;
private String street;
private String city;
public int getDno() {
return dno;
}
public void setDno(int dno) {
this.dno = dno;
}
public String getStreet() {
return street;
}
public void setStreet(String street) {
this.street = street;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
@Override
public String toString() {
return "Address [dno=" + dno + ", street=" + street + ", city=" + city
+ "]";
}
}
现在,在我的夹具中,我想检查(使用ActionFixture
)getCustomer()
方法返回客户对象。现在在parse(String s, Type)
其中's'是来自输入文件的客户对象的字符串格式,如何将其转换为Customer
对象。
我的做法是否正确?