### Question:
RecordStructureFormatter { public String format(final RecordStructure structure) throws MavenReportException { if (structure == null) { throw new IllegalArgumentException("Record structure cannot be null."); } final StringBuilder definitionBuilder = new StringBuilder(); for (int i = 0, size = structure.getRootLevelMemberCount(); i < size; i++) { final RecordStructureMember member = structure.getRootLevelMember(i); if (member instanceof RecordStructureField) { definitionBuilder.append(fieldFormatter.format((RecordStructureField) member)); } else if (member instanceof AbstractParentRecordStructureMember) { definitionBuilder.append(listFormatter.format((AbstractParentRecordStructureMember) member)); } else { definitionBuilder.append(includeFormatter.format((RecordInclude) member)); } } return definitionBuilder.toString(); } RecordStructureFormatter(final VelocityEngine engine);  RecordStructureFormatter(final FieldFormatter fieldFormatter, final ParentalMemberFormatter listFormatter,
            final IncludeFormatter includeFormatter); String format(final RecordStructure structure);  }### Answer:
@Test public void testFormat() throws Exception { final RecordStructureField field = mock(RecordStructureField.class); final String formattedField = "i am a formatted field"; when(fieldFormatter.format(field)).thenReturn(formattedField); final RecordStructureList list = mock(RecordStructureList.class); final String formattedList = "i am a formatted list"; when(listFormatter.format(list)).thenReturn(formattedList); final RecordInclude include = mock(RecordInclude.class); final String formattedInclude = "a formatted include"; when(includeFormatter.format(include)).thenReturn(formattedInclude); final RecordStructure structure = mock(RecordStructure.class); when(structure.getRootLevelMemberCount()).thenReturn(Integer.valueOf(3)); when(structure.getRootLevelMember(0)).thenReturn(field); when(structure.getRootLevelMember(1)).thenReturn(list); when(structure.getRootLevelMember(2)).thenReturn(include); assertThat(formatter.format(structure)).isEqualTo(formattedField + formattedList + formattedInclude); }
@Test public void testFormatNullStructure() throws Exception { IllegalArgumentException e = assertThrows(IllegalArgumentException.class, () -> { formatter.format(null); }); assertThat(e.getMessage()).isEqualTo("Record structure cannot be null."); }