@Test public void testAggregateMismatchedDocumentation() { final StructureField fieldA = new StructureField("fieldA", 1, DataType.I2); final StructureField fieldB = new StructureField("fieldB", 1, DataType.I4); final StructureField fieldC = new StructureField("fieldC", 1, DataType.DQ8); final StructureField fieldD = new StructureField("fieldD", 1, DataType.VC); final Structure structure = new Structure("mismatched-doc", Arrays.asList(fieldA, fieldB, fieldC, fieldD)); final Field fieldADoc = new Field("fieldA", "this is field a", false, Collections.singletonList(new EnumeratedValue("a value", "a description")), Collections.<CodeSet> emptyList()); final Field fieldBDoc = new Field("fieldD", "this is field b", false, Collections.<EnumeratedValue> emptyList(), Collections.<CodeSet> emptyList()); final Field fieldCDoc = new Field("fieldC", "this is field c", false, Collections.<EnumeratedValue> emptyList(), Collections.<CodeSet> emptyList()); final Field fieldDDoc = new Field("fieldB", "this is field d", true, Collections.<EnumeratedValue> emptyList(), Collections.singletonList(new CodeSet(4758, "a code set"))); final RecordStructureDocumentation documentation = new RecordStructureDocumentation( "this is a description of the record structure", null, Arrays.asList(fieldADoc, fieldBDoc, fieldCDoc, fieldDDoc)); final List<RecordStructure> aggregates = aggregator.aggregate(Collections.singletonList(structure), Collections.singletonMap(structure.getName(), documentation)); assertThat(aggregates).hasSize(1); final RecordStructure aggregate = aggregates.get(0); assertThat(aggregate.getName()).isEqualTo(structure.getName()); assertThat(aggregate.getDescription()).isEqualTo(documentation.getDescription()); assertThat(aggregate.getStructureType()).isEqualTo(documentation.getStructureType()); assertThat(aggregate.getRootLevelMemberCount()).isEqualTo(4); final RecordStructureField recordFieldA = aggregate.getRootLevelMember(0); assertThat(recordFieldA.getName()).isEqualTo(fieldA.getName()); assertThat(recordFieldA.getDataType()).isEqualTo(fieldA.getDataType()); assertThat(recordFieldA.getDescription()).isEqualTo(fieldADoc.getDescription()); assertThat(recordFieldA.getCodeSets()).isEqualTo(fieldADoc.getCodeSets()); assertThat(recordFieldA.getValues()).isEqualTo(fieldADoc.getValues()); assertThat(recordFieldA.isOptional()).isEqualTo(fieldADoc.isOptional()); final RecordStructureField recordFieldB = aggregate.getRootLevelMember(1); assertThat(recordFieldB.getName()).isEqualTo(fieldB.getName()); assertThat(recordFieldB.getDataType()).isEqualTo(fieldB.getDataType()); assertThat(recordFieldB.getDescription()).isEmpty(); assertThat(recordFieldB.getCodeSets()).isEmpty(); assertThat(recordFieldB.getValues()).isEmpty(); assertThat(recordFieldB.isOptional()).isFalse(); final RecordStructureField recordFieldC = aggregate.getRootLevelMember(2); assertThat(recordFieldC.getName()).isEqualTo(fieldC.getName()); assertThat(recordFieldC.getDataType()).isEqualTo(fieldC.getDataType()); assertThat(recordFieldC.getDescription()).isEqualTo(fieldCDoc.getDescription()); assertThat(recordFieldC.getCodeSets()).isEqualTo(fieldCDoc.getCodeSets()); assertThat(recordFieldC.getValues()).isEqualTo(fieldCDoc.getValues()); assertThat(recordFieldC.isOptional()).isEqualTo(fieldCDoc.isOptional()); final RecordStructureField recordFieldD = aggregate.getRootLevelMember(3); assertThat(recordFieldD.getName()).isEqualTo(fieldD.getName()); assertThat(recordFieldD.getDataType()).isEqualTo(fieldD.getDataType()); assertThat(recordFieldD.getDescription()).isEmpty(); assertThat(recordFieldD.getCodeSets()).isEmpty(); assertThat(recordFieldD.getValues()).isEmpty(); assertThat(recordFieldD.isOptional()).isFalse(); }
public List<RecordStructure> aggregate(final List<Structure> structures, final Map<String, RecordStructureDocumentation> recordStructureDocumentation) { if (structures == null) { throw new IllegalArgumentException("Structures cannot be null."); } if (recordStructureDocumentation == null) { throw new IllegalArgumentException("Record structure documentation cannot be null."); } final List<RecordStructure> records = new ArrayList<RecordStructure>(structures.size()); for (final Structure structure : structures) { final String structureName = structure.getName(); if (recordStructureDocumentation.containsKey(structureName)) { final RecordStructureDocumentation documentation = recordStructureDocumentation.get(structureName); records.add(new RecordStructure(structureName, toRecordMembers(structure, documentation.getFields()), documentation.getDescription(), documentation.getStructureType())); } else { records.add(new RecordStructure(structureName, toRecordMembers(structure, Collections.<Field> emptyList()))); } } return records; }
RecordStructureAggregator { public List<RecordStructure> aggregate(final List<Structure> structures, final Map<String, RecordStructureDocumentation> recordStructureDocumentation) { if (structures == null) { throw new IllegalArgumentException("Structures cannot be null."); } if (recordStructureDocumentation == null) { throw new IllegalArgumentException("Record structure documentation cannot be null."); } final List<RecordStructure> records = new ArrayList<RecordStructure>(structures.size()); for (final Structure structure : structures) { final String structureName = structure.getName(); if (recordStructureDocumentation.containsKey(structureName)) { final RecordStructureDocumentation documentation = recordStructureDocumentation.get(structureName); records.add(new RecordStructure(structureName, toRecordMembers(structure, documentation.getFields()), documentation.getDescription(), documentation.getStructureType())); } else { records.add(new RecordStructure(structureName, toRecordMembers(structure, Collections.<Field> emptyList()))); } } return records; } }
RecordStructureAggregator { public List<RecordStructure> aggregate(final List<Structure> structures, final Map<String, RecordStructureDocumentation> recordStructureDocumentation) { if (structures == null) { throw new IllegalArgumentException("Structures cannot be null."); } if (recordStructureDocumentation == null) { throw new IllegalArgumentException("Record structure documentation cannot be null."); } final List<RecordStructure> records = new ArrayList<RecordStructure>(structures.size()); for (final Structure structure : structures) { final String structureName = structure.getName(); if (recordStructureDocumentation.containsKey(structureName)) { final RecordStructureDocumentation documentation = recordStructureDocumentation.get(structureName); records.add(new RecordStructure(structureName, toRecordMembers(structure, documentation.getFields()), documentation.getDescription(), documentation.getStructureType())); } else { records.add(new RecordStructure(structureName, toRecordMembers(structure, Collections.<Field> emptyList()))); } } return records; }  }
RecordStructureAggregator { public List<RecordStructure> aggregate(final List<Structure> structures, final Map<String, RecordStructureDocumentation> recordStructureDocumentation) { if (structures == null) { throw new IllegalArgumentException("Structures cannot be null."); } if (recordStructureDocumentation == null) { throw new IllegalArgumentException("Record structure documentation cannot be null."); } final List<RecordStructure> records = new ArrayList<RecordStructure>(structures.size()); for (final Structure structure : structures) { final String structureName = structure.getName(); if (recordStructureDocumentation.containsKey(structureName)) { final RecordStructureDocumentation documentation = recordStructureDocumentation.get(structureName); records.add(new RecordStructure(structureName, toRecordMembers(structure, documentation.getFields()), documentation.getDescription(), documentation.getStructureType())); } else { records.add(new RecordStructure(structureName, toRecordMembers(structure, Collections.<Field> emptyList()))); } } return records; }  List<RecordStructure> aggregate(final List<Structure> structures,
            final Map<String, RecordStructureDocumentation> recordStructureDocumentation); }
RecordStructureAggregator { public List<RecordStructure> aggregate(final List<Structure> structures, final Map<String, RecordStructureDocumentation> recordStructureDocumentation) { if (structures == null) { throw new IllegalArgumentException("Structures cannot be null."); } if (recordStructureDocumentation == null) { throw new IllegalArgumentException("Record structure documentation cannot be null."); } final List<RecordStructure> records = new ArrayList<RecordStructure>(structures.size()); for (final Structure structure : structures) { final String structureName = structure.getName(); if (recordStructureDocumentation.containsKey(structureName)) { final RecordStructureDocumentation documentation = recordStructureDocumentation.get(structureName); records.add(new RecordStructure(structureName, toRecordMembers(structure, documentation.getFields()), documentation.getDescription(), documentation.getStructureType())); } else { records.add(new RecordStructure(structureName, toRecordMembers(structure, Collections.<Field> emptyList()))); } } return records; }  List<RecordStructure> aggregate(final List<Structure> structures,
            final Map<String, RecordStructureDocumentation> recordStructureDocumentation);  }