DatasetMetadataMerger { DatasetMetadata merge( final List<DatasetMetadata> metadata ) { if ( metadata == null || metadata.isEmpty() ) return null; DatasetMetadata mergedMetadata = null; for ( DatasetMetadata datasetMetadata : metadata ) { if ( mergedMetadata == null ) mergedMetadata = datasetMetadata; else mergedMetadata = merge( mergedMetadata, datasetMetadata ); } return mergedMetadata; }    }
@Test public void testMerge() { DatasetMetadataMerger datasetMetadataMerger = new DatasetMetadataMerger(); DatasetMetadata providerMetadata = createDatasetMetadata( URL_1 ); DatasetMetadata layerMetadata = createDatasetMetadata( URL_2, URL_3 ); DatasetMetadata mergedMetadata = datasetMetadataMerger.merge( providerMetadata, layerMetadata ); List<MetadataUrl> metadataUrls = mergedMetadata.getMetadataUrls(); assertThat( metadataUrls.size(), is( 3 ) ); }
@Test public void testMergeThree() { DatasetMetadataMerger datasetMetadataMerger = new DatasetMetadataMerger(); DatasetMetadata metadata1 = createDatasetMetadata( URL_1 ); DatasetMetadata metadata2 = createDatasetMetadata( URL_2, URL_3 ); DatasetMetadata metadata3 = createDatasetMetadata( URL_4 ); DatasetMetadata mergedMetadata = datasetMetadataMerger.merge( asList( metadata1, metadata2, metadata3 ) ); List<MetadataUrl> metadataUrls = mergedMetadata.getMetadataUrls(); assertThat( metadataUrls.size(), is( 4 ) ); }