DocumentationConfig { public FunctionDocumentation document(FunctionDocumentation functionDocumentation, Function function) { addItemDocumentation(functionDocumentation, getFieldIds(function.getWorkAreaOne())); if(function.isTwoWorkAreas()) { addItemDocumentation(functionDocumentation, getFieldIds(function.getWorkAreaTwo())); } return functionDocumentation; } DocumentationConfig(DataDictionary dataDictionary); FunctionDocumentation document(FunctionDocumentation functionDocumentation, Function function);  }
@Test public void testDocumentTwoWorkAreaFunction() { Mockito.when(this.functionMock.getWorkAreaOne()).thenReturn(workAreaOne); Mockito.when(this.functionMock.isTwoWorkAreas()).thenReturn(true); Mockito.when(this.functionMock.getWorkAreaTwo()).thenReturn(workAreaTwo); FunctionDocumentation result = this.documentationConfig.document(functionDocumentation, functionMock); assertSame(functionDocumentation, result); assertEquals(4, result.getFields().size()); assertFalse(result.getFields().contains(new MissingDocumentation(this.groupedField.getId()))); assertTrue(result.getFields().remove(iDocOne)); assertTrue(result.getFields().remove(iDocTwo)); assertTrue(result.getFields().remove(iDocFour)); assertEquals(1, result.getFields().size()); assertTrue(result.getFields().first() instanceof MissingDocumentation); }
@Test public void testDocumentOneWorkAreaFunction() { Mockito.when(this.functionMock.getWorkAreaOne()).thenReturn(workAreaOne); Mockito.when(this.functionMock.isTwoWorkAreas()).thenReturn(false); FunctionDocumentation result = this.documentationConfig.document(functionDocumentation, functionMock); assertSame(functionDocumentation, result); assertEquals(2, result.getFields().size()); assertTrue(result.getFields().contains(iDocOne)); assertTrue(result.getFields().contains(iDocTwo)); Mockito.verify(this.functionMock, Mockito.never()).getWorkAreaTwo(); }