Your question is Java Encapsulation and OOP. Take a moment with it on the right.
Talk me through your thinking if you like. When you're confident, submit your answer and I'll grade it like a real screen (7/10 or better passes).
Accion Labs uses this class internally on a QA automation project to track failures for one test suite run. It's meant to be a textbook example of encapsulation for a junior engineer to study.
import java.util.ArrayList;
import java.util.List;
public class TestExecutionReport {
public String suiteName;
public List<String> failedCases = new ArrayList<>();
public static List<TestExecutionReport> ALL_REPORTS = new ArrayList<>();
public TestExecutionReport(String suiteName) {
this.suiteName = suiteName;
ALL_REPORTS.add(this);
}
public void recordFailure(String caseId) {
failedCases.add(caseId);
}
public List<String> getFailedCases() {
return failedCases;
}
public int getFailureCount() {
return failedCases.size();
}
public void setSuiteName(String name) {
suiteName = name;
}
}
Explain whether this class actually achieves encapsulation, and walk through each specific OOP concept it's supposed to demonstrate, pointing out exactly what's wrong with each one. Answer in writing.