@Test public void testAggregate() { final StructureField recordField = new StructureField("recordField", 1, DataType.I2); final StructureRecord structureRecord = new StructureRecord("structureRecord", 1); structureRecord.addChildMember(recordField); final StructureCharacterField nestedListCharField = new StructureCharacterField("nestedListCharField", 1, 23); final AbstractParentStructure nestedList = new StructureList("nestedList", 1); nestedList.addChildMember(nestedListCharField); final StructureField rootLevelListField = new StructureField("rootLevelListField", 1, DataType.F8); final FixedLengthStructureList rootLevelList = new FixedLengthStructureList("rootLevelList", 1, 2); rootLevelList.addChildMember(rootLevelListField); rootLevelList.addChildMember(nestedList); final StructureField rootLevelField = new StructureField("rootLevelField", 1, DataType.I2); final Structure structure = new Structure("structure", Arrays.asList(rootLevelField, rootLevelList, structureRecord)); final Field rootLevelFieldDoc = new Field(rootLevelField.getName(), "This is the description of the root level field", false, Arrays.asList(new EnumeratedValue("0", "The value is false"), new EnumeratedValue("1", "The value is true")), Collections.<CodeSet> emptyList()); final Field rootLevelListDoc = new Field(rootLevelList.getName(), "This is the root-level list.", false, Collections.<EnumeratedValue> emptyList(), Collections.<CodeSet> emptyList()); final Field rootLevelListFieldDoc = new Field(rootLevelListField.getName(), "This is a field within the root-level list", true, Collections.<EnumeratedValue> emptyList(), Collections.singletonList(new CodeSet(1234, "This is a code set"))); final Field nestedListDoc = new Field(nestedList.getName(), "This is a nested list", false, Collections.<EnumeratedValue> emptyList(), Collections.<CodeSet> emptyList()); final Field nestedListCharFieldDoc = new Field(nestedListCharField.getName(), "This is a character field within a nested list.", true, Collections.<EnumeratedValue> emptyList(), Collections.<CodeSet> emptyList()); final Field recordRecordDoc = new Field(structureRecord.getName(), "This is a record", false, Collections.<EnumeratedValue> emptyList(), Collections.<CodeSet> emptyList()); final Field recordFieldDoc = new Field(recordField.getName(), "This is a field inside a record.", true, Collections.<EnumeratedValue> emptyList(), Collections.<CodeSet> emptyList()); final RecordStructureDocumentation recordDocumentation = new RecordStructureDocumentation( "This is the description of the record structure", InterfaceStructureType.REPLY, Arrays.asList(rootLevelFieldDoc, rootLevelListDoc, rootLevelListFieldDoc, nestedListDoc, nestedListCharFieldDoc, recordRecordDoc, recordFieldDoc)); final Map<String, RecordStructureDocumentation> documentation = new TreeMap<String, RecordStructureDocumentation>( CaseInsensitiveComparator.getInstance()); documentation.put(structure.getName(), recordDocumentation); final List<RecordStructure> records = aggregator.aggregate(Collections.singletonList(structure), documentation); assertThat(records).hasSize(1); final RecordStructure record = records.get(0); assertThat(record.getName()).isEqualTo("structure"); assertThat(record.getStructureType()).isEqualTo(recordDocumentation.getStructureType()); assertThat(record.getDescription()).isEqualTo(recordDocumentation.getDescription()); assertThat(record.getRootLevelMemberCount()).isEqualTo(3); final RecordStructureField recordRootField = record.getRootLevelMember(0); assertThat(recordRootField.getName()).isEqualTo(rootLevelField.getName()); assertThat(recordRootField.getDataType()).isEqualTo(rootLevelField.getDataType()); assertThat(recordRootField.getDescription()).isEqualTo(rootLevelFieldDoc.getDescription()); assertThat(recordRootField.getValues()).isEqualTo(rootLevelFieldDoc.getValues()); assertThat(recordRootField.getCodeSets()).isEqualTo(rootLevelFieldDoc.getCodeSets()); assertThat(recordRootField.isOptional()).isEqualTo(rootLevelFieldDoc.isOptional()); final FixedLengthRecordStructureList recordRootList = record.getRootLevelMember(1); assertThat(recordRootList.getName()).isEqualTo(rootLevelList.getName()); assertThat(recordRootList.getDescription()).isEqualTo(rootLevelListDoc.getDescription()); assertThat(recordRootList.getListSize()).isEqualTo(2); assertThat(recordRootList.getChildMemberCount()).isEqualTo(2); final RecordRecord recordRootRecord = record.getRootLevelMember(2); assertThat(recordRootRecord.getName()).isEqualTo(structureRecord.getName()); assertThat(recordRootRecord.getDescription()).isEqualTo(recordRecordDoc.getDescription()); assertThat(recordRootRecord.getChildMemberCount()).isEqualTo(1); final RecordStructureField recordRootListField = recordRootList.getChildMember(0); assertThat(recordRootListField.getName()).isEqualTo(rootLevelListField.getName()); assertThat(recordRootListField.getDataType()).isEqualTo(rootLevelListField.getDataType()); assertThat(recordRootListField.getDescription()).isEqualTo(rootLevelListFieldDoc.getDescription()); assertThat(recordRootListField.getCodeSets()).isEqualTo(rootLevelListFieldDoc.getCodeSets()); assertThat(recordRootListField.getValues()).isEqualTo(rootLevelListFieldDoc.getValues()); assertThat(recordRootListField.isOptional()).isEqualTo(rootLevelListFieldDoc.isOptional()); final AbstractParentRecordStructureMember recordNestedList = recordRootList.getChildMember(1); assertThat(recordNestedList.getName()).isEqualTo(nestedList.getName()); assertThat(recordNestedList.getDescription()).isEqualTo(nestedListDoc.getDescription()); assertThat(recordNestedList.getChildMemberCount()).isEqualTo(1); final RecordStructureCharacterField recordNestedField = recordNestedList.getChildMember(0); assertThat(recordNestedField.getName()).isEqualTo(nestedListCharField.getName()); assertThat(recordNestedField.getDescription()).isEqualTo(nestedListCharFieldDoc.getDescription()); assertThat(recordNestedField.getDataType()).isEqualTo(nestedListCharField.getDataType()); assertThat(recordNestedField.getDataLength()).isEqualTo(nestedListCharField.getDataLength()); assertThat(recordNestedField.isOptional()).isEqualTo(nestedListCharFieldDoc.isOptional()); assertThat(recordNestedField.getCodeSets()).isEqualTo(nestedListCharFieldDoc.getCodeSets()); assertThat(recordNestedField.getValues()).isEqualTo(nestedListCharFieldDoc.getValues()); final RecordStructureField recordRecordField = recordRootRecord.getChildMember(0); assertThat(recordRecordField.getName()).isEqualTo(recordField.getName()); assertThat(recordRecordField.getDescription()).isEqualTo(recordFieldDoc.getDescription()); assertThat(recordRecordField.getCodeSets()).isEmpty(); assertThat(recordRecordField.getValues()).isEmpty(); }
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);  }