Author: brett Date: Fri Aug 26 02:29:05 2005 New Revision: 240197 URL: http://svn.apache.org/viewcvs?rev=240197&view=rev Log: PR: MNG-693 added tests for reporting inheritence to mirror plugin inheritence, cleanup and utilise executions element
Modified: maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/ModelUtils.java maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssembler.java maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssemblerTest.java Modified: maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/ModelUtils.java URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/ModelUtils.java?rev=240197&r1=240196&r2=240197&view=diff ============================================================================== --- maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/ModelUtils.java (original) +++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/ModelUtils.java Fri Aug 26 02:29:05 2005 @@ -21,6 +21,9 @@ import org.apache.maven.model.Plugin; import org.apache.maven.model.PluginContainer; import org.apache.maven.model.PluginExecution; +import org.apache.maven.model.ReportPlugin; +import org.apache.maven.model.ReportSet; +import org.apache.maven.model.Reporting; import org.apache.maven.model.Repository; import org.apache.maven.project.inheritance.DefaultModelInheritanceAssembler; import org.apache.maven.project.inheritance.ModelInheritanceAssembler; @@ -69,7 +72,7 @@ { assembledPlugin = childPlugin; - ModelUtils.mergePluginDefinitions( childPlugin, parentPlugin, handleAsInheritance ); + mergePluginDefinitions( childPlugin, parentPlugin, handleAsInheritance ); } if ( handleAsInheritance && parentInherited == null ) @@ -97,6 +100,68 @@ } } + public static void mergeReportPluginLists( Reporting child, Reporting parent, boolean handleAsInheritance ) + { + if ( child == null || parent == null ) + { + // nothing to do. + return; + } + + List parentPlugins = parent.getPlugins(); + + if ( parentPlugins != null && !parentPlugins.isEmpty() ) + { + Map assembledPlugins = new TreeMap(); + + Map childPlugins = child.getReportPluginsAsMap(); + + for ( Iterator it = parentPlugins.iterator(); it.hasNext(); ) + { + ReportPlugin parentPlugin = (ReportPlugin) it.next(); + + String parentInherited = parentPlugin.getInherited(); + + if ( !handleAsInheritance || parentInherited == null || + Boolean.valueOf( parentInherited ).booleanValue() ) + { + + ReportPlugin assembledPlugin = parentPlugin; + + ReportPlugin childPlugin = (ReportPlugin) childPlugins.get( parentPlugin.getKey() ); + + if ( childPlugin != null ) + { + assembledPlugin = childPlugin; + + mergeReportPluginDefinitions( childPlugin, parentPlugin, handleAsInheritance ); + } + + if ( handleAsInheritance && parentInherited == null ) + { + assembledPlugin.unsetInheritanceApplied(); + } + + assembledPlugins.put( assembledPlugin.getKey(), assembledPlugin ); + } + } + + for ( Iterator it = childPlugins.values().iterator(); it.hasNext(); ) + { + ReportPlugin childPlugin = (ReportPlugin) it.next(); + + if ( !assembledPlugins.containsKey( childPlugin.getKey() ) ) + { + assembledPlugins.put( childPlugin.getKey(), childPlugin ); + } + } + + child.setPlugins( new ArrayList( assembledPlugins.values() ) ); + + child.flushReportPluginMap(); + } + } + public static void mergePluginDefinitions( Plugin child, Plugin parent, boolean handleAsInheritance ) { if ( child == null || parent == null ) @@ -116,7 +181,7 @@ } // merge the lists of goals that are not attached to an <execution/> - ModelUtils.mergeGoalContainerDefinitions( child, parent ); + mergeGoalContainerDefinitions( child, parent ); // from here to the end of the method is dealing with merging of the <executions/> section. String parentInherited = parent.getInherited(); @@ -143,7 +208,7 @@ if ( childExecution != null ) { - ModelUtils.mergePluginExecutionDefinitions( childExecution, parentExecution ); + mergePluginExecutionDefinitions( childExecution, parentExecution ); assembled = childExecution; } @@ -175,6 +240,77 @@ } + public static void mergeReportPluginDefinitions( ReportPlugin child, ReportPlugin parent, + boolean handleAsInheritance ) + { + if ( child == null || parent == null ) + { + // nothing to do. + return; + } + + if ( child.getVersion() == null && parent.getVersion() != null ) + { + child.setVersion( parent.getVersion() ); + } + + // from here to the end of the method is dealing with merging of the <executions/> section. + String parentInherited = parent.getInherited(); + + boolean parentIsInherited = parentInherited == null || Boolean.valueOf( parentInherited ).booleanValue(); + + List parentReportSets = parent.getReportSets(); + + if ( parentReportSets != null && !parentReportSets.isEmpty() ) + { + Map assembledReportSets = new TreeMap(); + + Map childReportSets = child.getReportSetsAsMap(); + + for ( Iterator it = parentReportSets.iterator(); it.hasNext(); ) + { + ReportSet parentReportSet = (ReportSet) it.next(); + + if ( !handleAsInheritance || parentIsInherited ) + { + ReportSet assembledReportSet = parentReportSet; + + ReportSet childReportSet = (ReportSet) childReportSets.get( parentReportSet.getId() ); + + if ( childReportSet != null ) + { + mergeReportSetDefinitions( childReportSet, parentReportSet ); + + assembledReportSet = childReportSet; + } + else if ( handleAsInheritance && parentInherited == null ) + { + parentReportSet.unsetInheritanceApplied(); + } + + assembledReportSets.put( assembledReportSet.getId(), assembledReportSet ); + } + } + + for ( Iterator it = childReportSets.entrySet().iterator(); it.hasNext(); ) + { + Map.Entry entry = (Map.Entry) it.next(); + + String id = (String) entry.getKey(); + + if ( !assembledReportSets.containsKey( id ) ) + { + assembledReportSets.put( id, entry.getValue() ); + } + } + + child.setReportSets( new ArrayList( assembledReportSets.values() ) ); + + child.flushReportSetMap(); + } + + } + /** * @param child * @param parent @@ -249,30 +385,30 @@ { child.setPhase( parent.getPhase() ); } - + List parentGoals = parent.getGoals(); List childGoals = child.getGoals(); - + List goals = new ArrayList(); - + if ( childGoals != null && !childGoals.isEmpty() ) { goals.addAll( childGoals ); } - + if ( parentGoals != null ) { for ( Iterator goalIterator = parentGoals.iterator(); goalIterator.hasNext(); ) { String goal = (String) goalIterator.next(); - + if ( !goals.contains( goal ) ) { goals.add( goal ); } } } - + child.setGoals( goals ); Xpp3Dom childConfiguration = (Xpp3Dom) child.getConfiguration(); @@ -283,6 +419,41 @@ child.setConfiguration( childConfiguration ); } + private static void mergeReportSetDefinitions( ReportSet child, ReportSet parent ) + { + List parentReports = parent.getReports(); + List childReports = child.getReports(); + + List reports = new ArrayList(); + + if ( childReports != null && !childReports.isEmpty() ) + { + reports.addAll( childReports ); + } + + if ( parentReports != null ) + { + for ( Iterator i = parentReports.iterator(); i.hasNext(); ) + { + String report = (String) i.next(); + + if ( !reports.contains( report ) ) + { + reports.add( report ); + } + } + } + + child.setReports( reports ); + + Xpp3Dom childConfiguration = (Xpp3Dom) child.getConfiguration(); + Xpp3Dom parentConfiguration = (Xpp3Dom) parent.getConfiguration(); + + childConfiguration = Xpp3Dom.mergeXpp3Dom( childConfiguration, parentConfiguration ); + + child.setConfiguration( childConfiguration ); + } + static Model cloneModel( Model model ) { // TODO: would be nice for the modello:java code to generate this as a copy constructor @@ -297,24 +468,24 @@ public static List mergeRepositoryLists( List dominant, List recessive ) { List repositories = new ArrayList(); - + for ( Iterator it = dominant.iterator(); it.hasNext(); ) { Repository repository = (Repository) it.next(); - + repositories.add( repository ); } - + for ( Iterator it = recessive.iterator(); it.hasNext(); ) { Repository repository = (Repository) it.next(); - + if ( !repositories.contains( repository ) ) { repositories.add( repository ); } } - + return repositories; } } Modified: maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssembler.java URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssembler.java?rev=240197&r1=240196&r2=240197&view=diff ============================================================================== --- maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssembler.java (original) +++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssembler.java Fri Aug 26 02:29:05 2005 @@ -23,15 +23,12 @@ import org.apache.maven.model.Extension; import org.apache.maven.model.Model; import org.apache.maven.model.PluginManagement; -import org.apache.maven.model.ReportPlugin; -import org.apache.maven.model.ReportSet; import org.apache.maven.model.Reporting; import org.apache.maven.model.Repository; import org.apache.maven.model.Scm; import org.apache.maven.model.Site; import org.apache.maven.project.ModelUtils; import org.codehaus.plexus.util.StringUtils; -import org.codehaus.plexus.util.xml.Xpp3Dom; import java.util.ArrayList; import java.util.HashMap; @@ -152,17 +149,18 @@ } // Build - assembleBuildInheritance( child, parent.getBuild() ); - + assembleBuildInheritance( child, parent ); + assembleDependencyInheritance( child, parent ); child.setRepositories( ModelUtils.mergeRepositoryLists( child.getRepositories(), parent.getRepositories() ) ); - child.setPluginRepositories( ModelUtils.mergeRepositoryLists( child.getPluginRepositories(), parent.getPluginRepositories() ) ); - + child.setPluginRepositories( + ModelUtils.mergeRepositoryLists( child.getPluginRepositories(), parent.getPluginRepositories() ) ); + assembleReportingInheritance( child, parent ); - + assembleDependencyManagementInheritance( child, parent ); - + assembleDistributionManagementInheritance( child, parent ); } @@ -170,7 +168,7 @@ { DistributionManagement cDistMgmt = child.getDistributionManagement(); DistributionManagement pDistMgmt = parent.getDistributionManagement(); - + if ( cDistMgmt == null ) { child.setDistributionManagement( pDistMgmt ); @@ -181,27 +179,27 @@ { cDistMgmt.setRepository( pDistMgmt.getRepository() ); } - + if ( cDistMgmt.getSnapshotRepository() == null ) { cDistMgmt.setSnapshotRepository( pDistMgmt.getSnapshotRepository() ); } - + if ( StringUtils.isEmpty( cDistMgmt.getDownloadUrl() ) ) { cDistMgmt.setDownloadUrl( pDistMgmt.getDownloadUrl() ); } - + if ( cDistMgmt.getRelocation() == null ) { cDistMgmt.setRelocation( pDistMgmt.getRelocation() ); } - + if ( cDistMgmt.getSite() == null ) { cDistMgmt.setSite( pDistMgmt.getSite() ); } - + // NOTE: We SHOULD NOT be inheriting status, since this is an assessment of the POM quality. } } @@ -247,161 +245,29 @@ Reporting childReporting = child.getReporting(); Reporting parentReporting = parent.getReporting(); - if ( childReporting != null && parentReporting != null ) + if ( parentReporting != null ) { - if ( StringUtils.isEmpty( childReporting.getOutputDirectory() ) ) + if ( childReporting == null ) { - childReporting.setOutputDirectory( parentReporting.getOutputDirectory() ); - } - - Map mergedReportPlugins = new HashMap(); - - Map childReportersByKey = childReporting.getReportPluginsAsMap(); - - List parentReportPlugins = parentReporting.getPlugins(); - - if ( parentReportPlugins != null ) - { - for ( Iterator it = parentReportPlugins.iterator(); it.hasNext(); ) - { - ReportPlugin parentReportPlugin = (ReportPlugin) it.next(); - - String inherited = parentReportPlugin.getInherited(); - - if ( StringUtils.isEmpty( inherited ) || Boolean.valueOf( inherited ).booleanValue() ) - { - ReportPlugin childReportPlugin = (ReportPlugin) childReportersByKey.get( - parentReportPlugin.getKey() ); - - ReportPlugin mergedReportPlugin = parentReportPlugin; - - if ( childReportPlugin != null ) - { - mergedReportPlugin = childReportPlugin; - - mergeReportPlugins( childReportPlugin, parentReportPlugin ); - } - else if ( StringUtils.isEmpty( inherited ) ) - { - mergedReportPlugin.unsetInheritanceApplied(); - } - - mergedReportPlugins.put( mergedReportPlugin.getKey(), mergedReportPlugin ); - } - } + childReporting = new Reporting(); + child.setReporting( childReporting ); } - for ( Iterator it = childReportersByKey.entrySet().iterator(); it.hasNext(); ) + if ( StringUtils.isEmpty( childReporting.getOutputDirectory() ) ) { - Map.Entry entry = (Map.Entry) it.next(); - - String key = (String) entry.getKey(); - - if ( !mergedReportPlugins.containsKey( key ) ) - { - mergedReportPlugins.put( key, entry.getValue() ); - } + childReporting.setOutputDirectory( parentReporting.getOutputDirectory() ); } - childReporting.setPlugins( new ArrayList( mergedReportPlugins.values() ) ); - - childReporting.flushReportPluginMap(); + ModelUtils.mergeReportPluginLists( childReporting, parentReporting, true ); } } - private void mergeReportPlugins( ReportPlugin childReportPlugin, ReportPlugin parentReportPlugin ) - { - if ( StringUtils.isEmpty( childReportPlugin.getVersion() ) ) - { - childReportPlugin.setVersion( parentReportPlugin.getVersion() ); - } - - Xpp3Dom childConfig = (Xpp3Dom) childReportPlugin.getConfiguration(); - Xpp3Dom parentConfig = (Xpp3Dom) parentReportPlugin.getConfiguration(); - - childReportPlugin.setConfiguration( Xpp3Dom.mergeXpp3Dom( childConfig, parentConfig ) ); - - Map mergedReportSets = new HashMap(); - - Map childReportSetsById = childReportPlugin.getReportSetsAsMap(); - - for ( Iterator it = parentReportPlugin.getReportSets().iterator(); it.hasNext(); ) - { - ReportSet parentReportSet = (ReportSet) it.next(); - - String inherited = parentReportSet.getInherited(); - - if ( StringUtils.isEmpty( inherited ) || Boolean.valueOf( inherited ).booleanValue() ) - { - ReportSet childReportSet = (ReportSet) childReportSetsById.get( parentReportSet.getId() ); - - ReportSet merged = parentReportSet; - - if ( childReportSet != null ) - { - merged = childReportSet; - - Xpp3Dom parentRSConfig = (Xpp3Dom) parentReportSet.getConfiguration(); - Xpp3Dom mergedRSConfig = (Xpp3Dom) merged.getConfiguration(); - - merged.setConfiguration( Xpp3Dom.mergeXpp3Dom( mergedRSConfig, parentRSConfig ) ); - - List mergedReports = merged.getReports(); - - if ( mergedReports == null ) - { - mergedReports = new ArrayList(); - - merged.setReports( mergedReports ); - } - - List parentRSReports = parentReportSet.getReports(); - - if ( parentRSReports != null ) - { - for ( Iterator reportIterator = parentRSReports.iterator(); reportIterator.hasNext(); ) - { - String report = (String) reportIterator.next(); - - if ( !mergedReports.contains( report ) ) - { - mergedReports.add( report ); - } - } - } - } - else if ( StringUtils.isEmpty( inherited ) ) - { - merged.unsetInheritanceApplied(); - } - - mergedReportSets.put( merged.getId(), merged ); - } - } - - for ( Iterator rsIterator = childReportSetsById.entrySet().iterator(); rsIterator.hasNext(); ) - { - Map.Entry entry = (Map.Entry) rsIterator.next(); - - String key = (String) entry.getKey(); - - if ( !mergedReportSets.containsKey( key ) ) - { - mergedReportSets.put( key, entry.getValue() ); - } - } - - childReportPlugin.setReportSets( new ArrayList( mergedReportSets.values() ) ); - - childReportPlugin.flushReportSetMap(); - } - private void assembleDependencyInheritance( Model child, Model parent ) { Map depsMap = new HashMap(); - + List deps = parent.getDependencies(); - + if ( deps != null ) { for ( Iterator it = deps.iterator(); it.hasNext(); ) @@ -410,9 +276,9 @@ depsMap.put( dependency.getManagementKey(), dependency ); } } - + deps = child.getDependencies(); - + if ( deps != null ) { for ( Iterator it = deps.iterator(); it.hasNext(); ) @@ -421,13 +287,14 @@ depsMap.put( dependency.getManagementKey(), dependency ); } } - + child.setDependencies( new ArrayList( depsMap.values() ) ); } - private void assembleBuildInheritance( Model child, Build parentBuild ) + private void assembleBuildInheritance( Model child, Model parent ) { Build childBuild = child.getBuild(); + Build parentBuild = parent.getBuild(); if ( parentBuild != null ) { Modified: maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssemblerTest.java URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssemblerTest.java?rev=240197&r1=240196&r2=240197&view=diff ============================================================================== --- maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssemblerTest.java (original) +++ maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssemblerTest.java Fri Aug 26 02:29:05 2005 @@ -18,10 +18,13 @@ import junit.framework.TestCase; import org.apache.maven.model.Build; -import org.apache.maven.model.Goal; import org.apache.maven.model.Model; import org.apache.maven.model.Parent; import org.apache.maven.model.Plugin; +import org.apache.maven.model.PluginExecution; +import org.apache.maven.model.ReportPlugin; +import org.apache.maven.model.ReportSet; +import org.apache.maven.model.Reporting; import org.apache.maven.model.Repository; import org.apache.maven.model.Resource; import org.apache.maven.model.Scm; @@ -382,28 +385,167 @@ assertEquals( "Plugin keys don't match", reference.getKey(), test.getKey() ); assertEquals( "Plugin configurations don't match", reference.getConfiguration(), test.getConfiguration() ); - List referenceGoals = reference.getGoals(); - Map testGoalsMap = test.getGoalsAsMap(); + List referenceExecutions = reference.getExecutions(); + Map testExecutionsMap = test.getExecutionsAsMap(); - if ( referenceGoals != null && !referenceGoals.isEmpty() ) + if ( referenceExecutions != null && !referenceExecutions.isEmpty() ) { - assertTrue( "Missing goals specification", ( testGoalsMap != null && !testGoalsMap.isEmpty() ) ); + assertTrue( "Missing goals specification", ( testExecutionsMap != null && !testExecutionsMap.isEmpty() ) ); - for ( Iterator it = referenceGoals.iterator(); it.hasNext(); ) + for ( Iterator it = referenceExecutions.iterator(); it.hasNext(); ) { - Goal referenceGoal = (Goal) it.next(); - Goal testGoal = (Goal) testGoalsMap.get( referenceGoal.getId() ); + PluginExecution referenceExecution = (PluginExecution) it.next(); + PluginExecution testExecution = (PluginExecution) testExecutionsMap.get( referenceExecution.getId() ); - assertNotNull( "Goal from reference not found in test", testGoal ); + assertNotNull( "Goal from reference not found in test", testExecution ); - assertEquals( "Goal IDs don't match", referenceGoal.getId(), testGoal.getId() ); - assertEquals( "Goal configurations don't match", referenceGoal.getConfiguration(), - testGoal.getConfiguration() ); + assertEquals( "Goal IDs don't match", referenceExecution.getId(), testExecution.getId() ); + assertEquals( "Goal configurations don't match", referenceExecution.getConfiguration(), + testExecution.getConfiguration() ); + assertEquals( "Goal lists don't match", referenceExecution.getGoals(), testExecution.getGoals() ); } } else { - assertTrue( "Unexpected goals specification", ( testGoalsMap == null || testGoalsMap.isEmpty() ) ); + assertTrue( "Unexpected goals specification", + ( testExecutionsMap == null || testExecutionsMap.isEmpty() ) ); + } + } + + public void testReportInheritanceWhereParentReportWithoutInheritFlagAndChildHasNoReports() + { + Model parent = makeBaseModel( "parent" ); + + Model child = makeBaseModel( "child" ); + + ReportPlugin parentReport = new ReportPlugin(); + parentReport.setArtifactId( "maven-testInheritance-report-plugin" ); + parentReport.setGroupId( "org.apache.maven.plugins" ); + parentReport.setVersion( "1.0" ); + + List parentPlugins = Collections.singletonList( parentReport ); + + Reporting parentBuild = new Reporting(); + parentBuild.setPlugins( parentPlugins ); + + parent.setReporting( parentBuild ); + + assembler.assembleModelInheritance( child, parent ); + + assertReports( parentPlugins, child ); + } + + public void testReportInheritanceWhereParentReportWithTrueInheritFlagAndChildHasNoReports() + { + Model parent = makeBaseModel( "parent" ); + + Model child = makeBaseModel( "child" ); + + ReportPlugin parentPlugin = new ReportPlugin(); + parentPlugin.setArtifactId( "maven-testInheritance2-report-plugin" ); + parentPlugin.setGroupId( "org.apache.maven.plugins" ); + parentPlugin.setVersion( "1.0" ); + parentPlugin.setInherited( "true" ); + + List parentPlugins = Collections.singletonList( parentPlugin ); + + Reporting parentBuild = new Reporting(); + parentBuild.setPlugins( parentPlugins ); + + parent.setReporting( parentBuild ); + + assembler.assembleModelInheritance( child, parent ); + + assertReports( parentPlugins, child ); + } + + public void testReportInheritanceWhereParentReportWithFalseInheritFlagAndChildHasNoReports() + { + Model parent = makeBaseModel( "parent" ); + + Model child = makeBaseModel( "child" ); + + ReportPlugin parentPlugin = new ReportPlugin(); + parentPlugin.setArtifactId( "maven-testInheritance3-report-plugin" ); + parentPlugin.setGroupId( "org.apache.maven.plugins" ); + parentPlugin.setVersion( "1.0" ); + parentPlugin.setInherited( "false" ); + + List parentPlugins = Collections.singletonList( parentPlugin ); + + Reporting parentBuild = new Reporting(); + parentBuild.setPlugins( parentPlugins ); + + parent.setReporting( parentBuild ); + + assembler.assembleModelInheritance( child, parent ); + + assertReports( new ArrayList(), child ); + } + + private void assertReports( List expectedPlugins, Model child ) + { + Reporting childBuild = child.getReporting(); + + if ( expectedPlugins != null && !expectedPlugins.isEmpty() ) + { + assertNotNull( childBuild ); + + Map childPluginsMap = childBuild.getReportPluginsAsMap(); + + if ( childPluginsMap != null ) + { + assertEquals( expectedPlugins.size(), childPluginsMap.size() ); + + for ( Iterator it = expectedPlugins.iterator(); it.hasNext(); ) + { + ReportPlugin expectedPlugin = (ReportPlugin) it.next(); + + ReportPlugin childPlugin = (ReportPlugin) childPluginsMap.get( expectedPlugin.getKey() ); + + assertReportsEqual( expectedPlugin, childPlugin ); + } + } + else + { + fail( "child plugins collection is null, but expectations map is not." ); + } + } + else + { + assertTrue( childBuild == null || childBuild.getPlugins() == null || childBuild.getPlugins().isEmpty() ); + } + } + + private void assertReportsEqual( ReportPlugin reference, ReportPlugin test ) + { + assertEquals( "Plugin keys don't match", reference.getKey(), test.getKey() ); + assertEquals( "Plugin configurations don't match", reference.getConfiguration(), test.getConfiguration() ); + + List referenceReportSets = reference.getReportSets(); + Map testReportSetsMap = test.getReportSetsAsMap(); + + if ( referenceReportSets != null && !referenceReportSets.isEmpty() ) + { + assertTrue( "Missing goals specification", ( testReportSetsMap != null && !testReportSetsMap.isEmpty() ) ); + + for ( Iterator it = referenceReportSets.iterator(); it.hasNext(); ) + { + ReportSet referenceReportSet = (ReportSet) it.next(); + ReportSet testReportSet = (ReportSet) testReportSetsMap.get( referenceReportSet.getId() ); + + assertNotNull( "Goal from reference not found in test", testReportSet ); + + assertEquals( "Goal IDs don't match", referenceReportSet.getId(), testReportSet.getId() ); + assertEquals( "Goal configurations don't match", referenceReportSet.getConfiguration(), + testReportSet.getConfiguration() ); + assertEquals( "Reports don't match", referenceReportSet.getReports(), testReportSet.getReports() ); + } + } + else + { + assertTrue( "Unexpected goals specification", + ( testReportSetsMap == null || testReportSetsMap.isEmpty() ) ); } } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]