@Test( expected = EnforcerRuleException.class ) public void shouldFailWithAParentWhichIsNotPartOfTheReactory() throws EnforcerRuleException, ExpressionEvaluationException { MavenProject mp1 = createProjectParent(); MavenProject wrongParentVerison = mock( MavenProject.class ); when( wrongParentVerison.getGroupId() ).thenReturn( "org.apache" ); when( wrongParentVerison.getArtifactId() ).thenReturn( "m1" ); when( wrongParentVerison.getVersion() ).thenReturn( "1.0-SNAPSHOT" ); when( wrongParentVerison.getId() ).thenReturn( "org.apache.enforcer:m1:jar:1.0-SNAPSHOT" ); when( wrongParentVerison.getDependencies() ).thenReturn( Collections.<Dependency>emptyList() ); MavenProject mp2 = createProjectChild2( wrongParentVerison ); MavenProject mp3 = createProjectChild2( mp1 ); List<MavenProject> theList = Arrays.asList( mp1, mp2, mp3 ); setupSortedProjects( theList ); rule.execute( helper ); }
@Override public void execute( EnforcerRuleHelper helper ) throws EnforcerRuleException { logger = helper.getLog(); MavenSession session; try { session = (MavenSession) helper.evaluate( "${session}" ); } catch ( ExpressionEvaluationException eee ) { throw new EnforcerRuleException( "Unable to retrieve the MavenSession: ", eee ); } List<MavenProject> sortedProjects = session.getProjectDependencyGraph().getSortedProjects(); if ( sortedProjects != null && !sortedProjects.isEmpty() ) { checkReactor( sortedProjects ); checkParentsInReactor( sortedProjects ); checkMissingParentsInReactor( sortedProjects ); checkParentsPartOfTheReactor( sortedProjects ); if ( !isIgnoreModuleDependencies() ) { checkDependenciesWithinReactor( sortedProjects ); } } }
ReactorModuleConvergence extends AbstractNonCacheableEnforcerRule { @Override public void execute( EnforcerRuleHelper helper ) throws EnforcerRuleException { logger = helper.getLog(); MavenSession session; try { session = (MavenSession) helper.evaluate( "${session}" ); } catch ( ExpressionEvaluationException eee ) { throw new EnforcerRuleException( "Unable to retrieve the MavenSession: ", eee ); } List<MavenProject> sortedProjects = session.getProjectDependencyGraph().getSortedProjects(); if ( sortedProjects != null && !sortedProjects.isEmpty() ) { checkReactor( sortedProjects ); checkParentsInReactor( sortedProjects ); checkMissingParentsInReactor( sortedProjects ); checkParentsPartOfTheReactor( sortedProjects ); if ( !isIgnoreModuleDependencies() ) { checkDependenciesWithinReactor( sortedProjects ); } } } }
ReactorModuleConvergence extends AbstractNonCacheableEnforcerRule { @Override public void execute( EnforcerRuleHelper helper ) throws EnforcerRuleException { logger = helper.getLog(); MavenSession session; try { session = (MavenSession) helper.evaluate( "${session}" ); } catch ( ExpressionEvaluationException eee ) { throw new EnforcerRuleException( "Unable to retrieve the MavenSession: ", eee ); } List<MavenProject> sortedProjects = session.getProjectDependencyGraph().getSortedProjects(); if ( sortedProjects != null && !sortedProjects.isEmpty() ) { checkReactor( sortedProjects ); checkParentsInReactor( sortedProjects ); checkMissingParentsInReactor( sortedProjects ); checkParentsPartOfTheReactor( sortedProjects ); if ( !isIgnoreModuleDependencies() ) { checkDependenciesWithinReactor( sortedProjects ); } } }  }
ReactorModuleConvergence extends AbstractNonCacheableEnforcerRule { @Override public void execute( EnforcerRuleHelper helper ) throws EnforcerRuleException { logger = helper.getLog(); MavenSession session; try { session = (MavenSession) helper.evaluate( "${session}" ); } catch ( ExpressionEvaluationException eee ) { throw new EnforcerRuleException( "Unable to retrieve the MavenSession: ", eee ); } List<MavenProject> sortedProjects = session.getProjectDependencyGraph().getSortedProjects(); if ( sortedProjects != null && !sortedProjects.isEmpty() ) { checkReactor( sortedProjects ); checkParentsInReactor( sortedProjects ); checkMissingParentsInReactor( sortedProjects ); checkParentsPartOfTheReactor( sortedProjects ); if ( !isIgnoreModuleDependencies() ) { checkDependenciesWithinReactor( sortedProjects ); } } }  @Override void execute( EnforcerRuleHelper helper ); boolean isIgnoreModuleDependencies(); void setIgnoreModuleDependencies( boolean ignoreModuleDependencies ); }
ReactorModuleConvergence extends AbstractNonCacheableEnforcerRule { @Override public void execute( EnforcerRuleHelper helper ) throws EnforcerRuleException { logger = helper.getLog(); MavenSession session; try { session = (MavenSession) helper.evaluate( "${session}" ); } catch ( ExpressionEvaluationException eee ) { throw new EnforcerRuleException( "Unable to retrieve the MavenSession: ", eee ); } List<MavenProject> sortedProjects = session.getProjectDependencyGraph().getSortedProjects(); if ( sortedProjects != null && !sortedProjects.isEmpty() ) { checkReactor( sortedProjects ); checkParentsInReactor( sortedProjects ); checkMissingParentsInReactor( sortedProjects ); checkParentsPartOfTheReactor( sortedProjects ); if ( !isIgnoreModuleDependencies() ) { checkDependenciesWithinReactor( sortedProjects ); } } }  @Override void execute( EnforcerRuleHelper helper ); boolean isIgnoreModuleDependencies(); void setIgnoreModuleDependencies( boolean ignoreModuleDependencies );  }