Question: import java.io . PrintWriter; import java.util.ArrayList; / * * * * @author AV * / public class TestCustomerData { / * * * All tests
import java.ioPrintWriter;
import java.util.ArrayList;
@author AV
public class TestCustomerData
All tests for PesronData class
@return total score for AggregationClass part of assignment
public static boolean testsPrintWriter out
out.printlnr
CustomerData Class TEST SETS r
;
boolean t testSetCustomerDataClassout;
boolean t testSetCustomerDataClassout;
return t && t;
Set of unit tests for noargument constructor, constructor, accessors
@param outputStream stream to direct output into
@return number of points earned for this unit. is returned if even one of
the tests failed
public static boolean testSetCustomerDataClassPrintWriter outputStream
int count ;
int expectedCount ;
CustomerData p new CustomerData;
Test #
if pgetFirstNameequals && pgetLastNameequals && pgetPhoneequals
&& pgetAddressequals && pgetMailingList false && pgetCustomerNumber
&& pgetTransactionssize
outputStream.printfssr
"Test Set : Test for noargument constructor, and accessor methods",
"PASSED";
count;
else
outputStream.printfssr
"Test Set : Test for noargument constructor, and accessor methods",
"FAILED";
Test # constructor tests
ArrayList list new ArrayList;
list.addL;
list.addL;
list.addL;
CustomerData p new CustomerDataTom "Sumerson", Ave NE Sometown,
false, list;
if ptoStringequalsFirst name: Tom; Last name: Sumerson; Address: Ave NE Sometown, ; Phone: ; Customer number: ; Mailing list: false; Transactions:
outputStream.printfssr
"Test Set : Test for constructor with parameters", "PASSED";
count;
else
outputStream.printfssr
"Test Set : Test for constructor with parameters", "FAILED";
Test # Deep copy of the ArrayList field
list.addL; p must be unchanged by this
if ptoStringequalsFirst name: Tom; Last name: Sumerson; Address: Ave NE Sometown, ; Phone: ; Customer number: ; Mailing list: false; Transactions:
outputStream.printfssr
"Test Set : Test for deep copy of the ArrayList field", "PASSED";
count;
else
outputStream.printfssr
"Test Set : Test for deep copy of the ArrayList field", "FAILED";
Test # getters test
ifpgetFirstNameequalsTom
&& pgetLastNameequalsSumerson
&& pgetPhoneequals
&& pgetAddressequals Ave NE Sometown,
&& pgetCustomerNumber
&& pgetMailingList false
&& pgetTransactionstoStringequals
outputStream.printfssr
"Test Set : Test for accessors", "PASSED";
count;
else
outputStream.printfssr
"Test Set : Test for accessors", "FAILED";
Test # getTransactions deep copy test
ArrayList list pgetTransactions;
listaddL;
ifptoStringequalsFirst name: Tom; Last name: Sumerson; Address: Ave NE Sometown, ; Phone: ; Customer number: ; Mailing list: false; Transactions:
outputStream.printfssr
"Test Set : Test for getTransactions deep copy", "PASSED";
count;
else
outputStream.printfssr
"Test Set : Test for getTransactions deep copy", "FAILED";
ArrayList list new ArrayList;
listaddL;
listaddL;
listaddL;
p new CustomerDataTom "Sumerson", Ave NE Sometown, false, list;
Test # Mutators
psetCustomerNumber;
psetMailingListtrue;
ArrayList list new ArrayList;
listaddL;
listaddL;
listaddL;
psetTransactionslist;
if ptoStringequalsFirst name: Tom; Last name: Sumerson; Address: Ave NE Sometown, ; Phone: ; Customer number: ; Mailing list: true; Transactions:
outputStream.printfssr
"Test Set : Test for all mutator methods", "PASSED";
count;
else
outputStream.printfssr
"Test Set : Test for all mutator methods", "FAILED";
Test # Deep copy of the ArrayList field when changed by mutator
listaddL;
if ptoStringequalsFirst name: Tom; Last name: Sumerson; Address: Ave NE Someto
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
