Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this journal assignment, you will reflect on the contact service you submitted in Module Three and the task service you submitted in this module.

In this journal assignment, you will reflect on the contact service you submitted in Module Three and the task service you submitted in this module. Specifically, you will describe your unit testing approach and describe your experience with writing the JUnit tests. This will help to prepare you for the Project Two submission, due in Module Seven, in which you will submit a summary and reflections report.
Address the following questions:
To what extent was your testing approach aligned to the software requirements? Support your claims with specific evidence.
Defend the overall quality of your JUnit tests for the contact service and task service. In other words, how do you know that your JUnit tests were effective on the basis of coverage percentage?
How did you ensure that your code was technically sound? Cite specific lines of code from your tests to illustrate.
How did you ensure that your code was efficient? Cite specific lines of code from your tests to illustrate.
Contact.java
public class Contact{
private String contactId;
private String firstName;
private String lastName;
private String phoneNumber;
private String address;
public Contact(String contactId, String firstName, String lastName, String phoneNumber, String address){
this.contactId = contactId;
this.firstName = firstName;
this.lastName = lastName;
this.phoneNumber = phoneNumber;
this.address = address;
}
// Getters and setters
public String getContactId(){
return contactId;
}
public String getFirstName(){
return firstName;
}
public void setFirstName(String firstName){
this.firstName = firstName;
}
public String getLastName(){
return lastName;
}
public void setLastName(String lastName){
this.lastName = lastName;
}
public String getPhoneNumber(){
return phoneNumber;
}
public void setPhoneNumber(String phoneNumber){
this.phoneNumber = phoneNumber;
}
public String getAddress(){
return address;
}
public void setAddress(String address){
this.address = address;
}
}
ContactTest.Java
public class Contact{
private String contactId;
private String firstName;
private String lastName;
private String phoneNumber;
private String address;
public Contact(String contactId, String firstName, String lastName, String phoneNumber, String address){
this.contactId = contactId;
this.firstName = firstName;
this.lastName = lastName;
this.phoneNumber = phoneNumber;
this.address = address;
}
// Getters and setters
public String getContactId(){
return contactId;
}
public String getFirstName(){
return firstName;
}
public void setFirstName(String firstName){
this.firstName = firstName;
}
public String getLastName(){
return lastName;
}
public void setLastName(String lastName){
this.lastName = lastName;
}
public String getPhoneNumber(){
return phoneNumber;
}
public void setPhoneNumber(String phoneNumber){
this.phoneNumber = phoneNumber;
}
public String getAddress(){
return address;
}
public void setAddress(String address){
this.address = address;
}
}
ContactService.java
import java.util.HashMap;
import java.util.Map;
public class ContactService {
private Map contacts;
public ContactService(){
this.contacts = new HashMap<>();
}
public void addContact(Contact contact){
contacts.put(contact.getContactId(), contact);
}
public void deleteContact(String contactId){
contacts.remove(contactId);
}
public void updateContact(String contactId, String firstName, String lastName, String phoneNumber, String address){
if (contacts.containsKey(contactId)){
Contact contact = contacts.get(contactId);
contact.setFirstName(firstName);
contact.setLastName(lastName);
contact.setPhoneNumber(phoneNumber);
contact.setAddress(address);
}
}
public Contact getContactById(String contactId){
return contacts.get(contactId);
}
}
Cimport org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
public class ContactServiceTest {
@Test
public void testAddContact(){
ContactService contactService = new ContactService();
Contact contact = new Contact("12345", "John", "Doe", "1234567890","123 Main St");
contactService.addContact(contact);
assertEquals(contact, contactService.getContactById("12345"));
}
@Test
public void testDeleteContact(){
ContactService contactService = new ContactService();
Contact contact = new Contact("12345","

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases Illuminated

Authors: Catherine Ricardo

2nd Edition

1449606008, 978-1449606008

More Books

Students also viewed these Databases questions

Question

Identify HRM systems, practices, and policies.

Answered: 1 week ago