Parsing nested objects in FIT

151 Views Asked by At

I am using Framework for Integrated Test. I know how to use ColumnFixture, RowFixture and ActionFixture basically. Now my problem is, if I have nested objects like Customer object is holding Address object with some fields, how can I parse such kind of objects.

ex:

        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
                        + "]";
            }
        }

Now, in my my fixture, I want to check (using ActionFixture) getCustomer() method that returns customer object. Now in the parse(String s, Type) where 's' is string format of customer object coming from input file, how can I convert it into Customer object.

Is my approach proper?

0

There are 0 best solutions below