I have method:
public ReportBuilder addDiffs(List<String> diffs) {
if (this.diffs == null) {
this.diffs = new ArrayList<>();
}
this.diffs.addAll(diffs);
return this;
}
And I want to make unit-test. As I khow it should be like:
@Test
public void ReportBuilderTest() {
ReportBuilder builder = new ReportBuilder();
List<String> list = new ArrayList<>();
list.add("some string");
builder.addDiffs(list);
assertEquals(builder.getDiffs(), list));
}
It is example, but my class is inner service and i can't create getter for it. And diffs are private. How to make proper unit-test for this method? Maybe there is a problem with architecture?