@Test public void testNoActiveProfilesInProjectAndNoProfilesExpectedToBeActivated() throws EnforcerRuleException { when( project.getActiveProfiles() ).thenReturn( Collections.<Profile> emptyList() ); rule.execute( helper ); assertTrue( true ); }
@Override public void execute( EnforcerRuleHelper theHelper ) throws EnforcerRuleException { List<String> missingProfiles = new ArrayList<>(); try { MavenProject project = (MavenProject) theHelper.evaluate( "${project}" ); if ( StringUtils.isNotEmpty( profiles ) ) { String[] profs = profiles.split( "," ); for ( String profile : profs ) { if ( !isProfileActive( project, profile ) ) { missingProfiles.add( profile ); } } boolean fail = false; if ( !missingProfiles.isEmpty() ) { if ( all || missingProfiles.size() == profs.length ) { fail = true; } } if ( fail ) { String message = getMessage(); StringBuilder buf = new StringBuilder(); if ( message != null ) { buf.append( message + System.lineSeparator() ); } for ( String profile : missingProfiles ) { buf.append( "Profile \"" + profile + "\" is not activated." + System.lineSeparator() ); } throw new EnforcerRuleException( buf.toString() ); } } } catch ( ExpressionEvaluationException e ) { throw new EnforcerRuleException( "Unable to retrieve the project.", e ); } }
RequireActiveProfile extends AbstractNonCacheableEnforcerRule { @Override public void execute( EnforcerRuleHelper theHelper ) throws EnforcerRuleException { List<String> missingProfiles = new ArrayList<>(); try { MavenProject project = (MavenProject) theHelper.evaluate( "${project}" ); if ( StringUtils.isNotEmpty( profiles ) ) { String[] profs = profiles.split( "," ); for ( String profile : profs ) { if ( !isProfileActive( project, profile ) ) { missingProfiles.add( profile ); } } boolean fail = false; if ( !missingProfiles.isEmpty() ) { if ( all || missingProfiles.size() == profs.length ) { fail = true; } } if ( fail ) { String message = getMessage(); StringBuilder buf = new StringBuilder(); if ( message != null ) { buf.append( message + System.lineSeparator() ); } for ( String profile : missingProfiles ) { buf.append( "Profile \"" + profile + "\" is not activated." + System.lineSeparator() ); } throw new EnforcerRuleException( buf.toString() ); } } } catch ( ExpressionEvaluationException e ) { throw new EnforcerRuleException( "Unable to retrieve the project.", e ); } } }
RequireActiveProfile extends AbstractNonCacheableEnforcerRule { @Override public void execute( EnforcerRuleHelper theHelper ) throws EnforcerRuleException { List<String> missingProfiles = new ArrayList<>(); try { MavenProject project = (MavenProject) theHelper.evaluate( "${project}" ); if ( StringUtils.isNotEmpty( profiles ) ) { String[] profs = profiles.split( "," ); for ( String profile : profs ) { if ( !isProfileActive( project, profile ) ) { missingProfiles.add( profile ); } } boolean fail = false; if ( !missingProfiles.isEmpty() ) { if ( all || missingProfiles.size() == profs.length ) { fail = true; } } if ( fail ) { String message = getMessage(); StringBuilder buf = new StringBuilder(); if ( message != null ) { buf.append( message + System.lineSeparator() ); } for ( String profile : missingProfiles ) { buf.append( "Profile \"" + profile + "\" is not activated." + System.lineSeparator() ); } throw new EnforcerRuleException( buf.toString() ); } } } catch ( ExpressionEvaluationException e ) { throw new EnforcerRuleException( "Unable to retrieve the project.", e ); } }  }
RequireActiveProfile extends AbstractNonCacheableEnforcerRule { @Override public void execute( EnforcerRuleHelper theHelper ) throws EnforcerRuleException { List<String> missingProfiles = new ArrayList<>(); try { MavenProject project = (MavenProject) theHelper.evaluate( "${project}" ); if ( StringUtils.isNotEmpty( profiles ) ) { String[] profs = profiles.split( "," ); for ( String profile : profs ) { if ( !isProfileActive( project, profile ) ) { missingProfiles.add( profile ); } } boolean fail = false; if ( !missingProfiles.isEmpty() ) { if ( all || missingProfiles.size() == profs.length ) { fail = true; } } if ( fail ) { String message = getMessage(); StringBuilder buf = new StringBuilder(); if ( message != null ) { buf.append( message + System.lineSeparator() ); } for ( String profile : missingProfiles ) { buf.append( "Profile \"" + profile + "\" is not activated." + System.lineSeparator() ); } throw new EnforcerRuleException( buf.toString() ); } } } catch ( ExpressionEvaluationException e ) { throw new EnforcerRuleException( "Unable to retrieve the project.", e ); } }  final String getProfiles(); final void setProfiles( String profiles ); final boolean isAll(); final void setAll( boolean all ); @Override void execute( EnforcerRuleHelper theHelper ); }
RequireActiveProfile extends AbstractNonCacheableEnforcerRule { @Override public void execute( EnforcerRuleHelper theHelper ) throws EnforcerRuleException { List<String> missingProfiles = new ArrayList<>(); try { MavenProject project = (MavenProject) theHelper.evaluate( "${project}" ); if ( StringUtils.isNotEmpty( profiles ) ) { String[] profs = profiles.split( "," ); for ( String profile : profs ) { if ( !isProfileActive( project, profile ) ) { missingProfiles.add( profile ); } } boolean fail = false; if ( !missingProfiles.isEmpty() ) { if ( all || missingProfiles.size() == profs.length ) { fail = true; } } if ( fail ) { String message = getMessage(); StringBuilder buf = new StringBuilder(); if ( message != null ) { buf.append( message + System.lineSeparator() ); } for ( String profile : missingProfiles ) { buf.append( "Profile \"" + profile + "\" is not activated." + System.lineSeparator() ); } throw new EnforcerRuleException( buf.toString() ); } } } catch ( ExpressionEvaluationException e ) { throw new EnforcerRuleException( "Unable to retrieve the project.", e ); } }  final String getProfiles(); final void setProfiles( String profiles ); final boolean isAll(); final void setAll( boolean all ); @Override void execute( EnforcerRuleHelper theHelper );  }