Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started