org.apache.maven.enforcer.rule.api.EnforcerRuleException Java Examples

The following examples show how to use org.apache.maven.enforcer.rule.api.EnforcerRuleException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LinkageCheckerRuleTest.java    From cloud-opensource-java with Apache License 2.0 6 votes vote down vote up
@Test
public void testValidatePhase() {
  when(mockProject.getArtifact())
      .thenReturn(
          new org.apache.maven.artifact.DefaultArtifact(
              "com.google.cloud",
              "foo-tests",
              "0.0.1",
              "compile",
              "jar",
              null,
              new DefaultArtifactHandler()));

  when(mockMojoExecution.getLifecyclePhase()).thenReturn("validate");
  try {
    rule.execute(mockRuleHelper);
    fail("The rule should throw EnforcerRuleException when running in validate phase");
  } catch (EnforcerRuleException ex) {
    assertEquals(
        "To run the check on the compiled class files, the linkage checker enforcer rule should"
            + " be bound to the 'verify' phase. Current phase: validate",
        ex.getMessage());
  }
}
 
Example #2
Source File: LinkageCheckerRule.java    From cloud-opensource-java with Apache License 2.0 6 votes vote down vote up
/** Builds a class path for {@code bomProject}. */
private ClassPathResult findBomClasspath(
    MavenProject bomProject, RepositorySystemSession repositorySystemSession)
    throws EnforcerRuleException {

  ArtifactTypeRegistry artifactTypeRegistry = repositorySystemSession.getArtifactTypeRegistry();
  ImmutableList<Artifact> artifacts =
      bomProject.getDependencyManagement().getDependencies().stream()
          .map(dependency -> RepositoryUtils.toDependency(dependency, artifactTypeRegistry))
          .map(Dependency::getArtifact)
          .filter(artifact -> !Bom.shouldSkipBomMember(artifact))
          .collect(toImmutableList());

  ClassPathResult result = classPathBuilder.resolve(artifacts);
  ImmutableList<UnresolvableArtifactProblem> artifactProblems = result.getArtifactProblems();
  if (!artifactProblems.isEmpty()) {
    throw new EnforcerRuleException("Failed to collect dependency: " + artifactProblems);
  }
  return result;
}
 
Example #3
Source File: EnforceBytecodeVersion.java    From extra-enforcer-rules with Apache License 2.0 6 votes vote down vote up
@Override
protected void handleArtifacts( Set<Artifact> artifacts )
    throws EnforcerRuleException
{
    computeParameters();

    // look for banned dependencies
    Set<Artifact> foundExcludes = checkDependencies( filterArtifacts( artifacts ), getLog() );

    // if any are found, fail the check but list all of them
    if ( foundExcludes != null && !foundExcludes.isEmpty() )
    {
        StringBuilder buf = new StringBuilder();
        if ( message != null )
        {
            buf.append( message + "\n" );
        }
        for ( Artifact artifact : foundExcludes )
        {
            buf.append( getErrorMessage( artifact ) );
        }
        message = buf.toString() + "Use 'mvn dependency:tree' to locate the source of the banned dependencies.";

        throw new EnforcerRuleException( message );
    }
}
 
Example #4
Source File: LinkageCheckerRuleTest.java    From cloud-opensource-java with Apache License 2.0 6 votes vote down vote up
@Test
public void testExecute_shouldPassGoodProject_sessionProperties()
    throws EnforcerRuleException, RepositoryException, DependencyResolutionException {
  setupMockDependencyResolution("com.google.guava:guava:27.0.1-jre");

  rule.execute(mockRuleHelper);

  ArgumentCaptor<DependencyResolutionRequest> argumentCaptor =
      ArgumentCaptor.forClass(DependencyResolutionRequest.class);
  verify(mockProjectDependenciesResolver).resolve(argumentCaptor.capture());
  Map<String, String> propertiesUsedInSession =
      argumentCaptor.getValue().getRepositorySession().getSystemProperties();
  Truth.assertWithMessage(
          "RepositorySystemSession should have variables such as os.detected.classifier")
      .that(propertiesUsedInSession)
      .containsAtLeastEntriesIn(OsProperties.detectOsProperties());
  // There was a problem in resolving profiles because original properties were missing (#817)
  Truth.assertWithMessage("RepositorySystemSession should have original properties")
      .that(propertiesUsedInSession)
      .containsAtLeastEntriesIn(repositorySystemSession.getSystemProperties());
}
 
Example #5
Source File: LinkageCheckerRuleTest.java    From cloud-opensource-java with Apache License 2.0 6 votes vote down vote up
@Test
public void testExecute_shouldFailForBadProject() throws RepositoryException {
  try {
    // This artifact is known to contain classes missing dependencies
    setupMockDependencyResolution("com.google.appengine:appengine-api-1.0-sdk:1.9.64");
    rule.execute(mockRuleHelper);
    Assert.fail(
        "The rule should raise an EnforcerRuleException for artifacts missing dependencies");
  } catch (EnforcerRuleException ex) {
    // pass
    ArgumentCaptor<String> errorMessageCaptor = ArgumentCaptor.forClass(String.class);
    verify(mockLog, times(2)).error(errorMessageCaptor.capture());

    List<String> errorMessages = errorMessageCaptor.getAllValues();
    Truth.assertThat(errorMessages.get(0)).startsWith("Linkage Checker rule found 112 errors.");
    Truth.assertThat(errorMessages.get(1))
        .startsWith(
            "Problematic artifacts in the dependency tree:\n"
                + "com.google.appengine:appengine-api-1.0-sdk:1.9.64 is at:\n"
                + "  a:b:jar:0.1 / com.google.appengine:appengine-api-1.0-sdk:1.9.64 (compile)");
    assertEquals("Failed while checking class path. See above error report.", ex.getMessage());
  }
}
 
Example #6
Source File: LinkageCheckerRuleTest.java    From cloud-opensource-java with Apache License 2.0 6 votes vote down vote up
@Test
public void testExecute_shouldFailForBadProject_reachableErrors() throws RepositoryException {
  try {
    // This pair of artifacts contains linkage errors on grpc-core's use of Verify. Because
    // grpc-core is included in entry point jars, the errors are reachable.
    setupMockDependencyResolution(
        "com.google.api-client:google-api-client:1.27.0", "io.grpc:grpc-core:1.17.1");
    rule.setReportOnlyReachable(true);
    rule.execute(mockRuleHelper);
    Assert.fail(
        "The rule should raise an EnforcerRuleException for artifacts with reachable errors");
  } catch (EnforcerRuleException ex) {
    // pass
    verify(mockLog)
        .error(ArgumentMatchers.startsWith("Linkage Checker rule found 1 reachable error."));
    assertEquals(
        "Failed while checking class path. See above error report.", ex.getMessage());
  }
}
 
Example #7
Source File: RequirePropertyDivergesTest.java    From extra-enforcer-rules with Apache License 2.0 6 votes vote down vote up
/**
 * Test of execute method, of class RequirePropertyDiverges.
 */
@Test
public void testExecuteInParentWithConfigurationInPluginManagement() throws EnforcerRuleException
{
    RequirePropertyDiverges mockInstance = createMockRule();
    final MavenProject project = createMavenProject( "company", "company-parent-pom" );
    final Build build = new Build();
    // create pluginManagement
    final Plugin pluginInManagement = newPlugin( "org.apache.maven.plugins", "maven-enforcer-plugin", "1.0");
    final Xpp3Dom configuration = createPluginConfiguration();
    pluginInManagement.setConfiguration( configuration );
    final PluginManagement pluginManagement = new PluginManagement();
    pluginManagement.addPlugin( pluginInManagement );
    build.setPluginManagement( pluginManagement );
    // create plugins
    final Plugin pluginInPlugins = newPlugin( "org.apache.maven.plugins", "maven-enforcer-plugin", "1.0");
    build.addPlugin( pluginInPlugins );
    // add build
    project.getOriginalModel().setBuild( build );
    //project.getOriginalModel().setBuild( build );
    setUpHelper( project, "parentValue" );
    mockInstance.execute( helper );
}
 
Example #8
Source File: AbstractRequireRoles.java    From extra-enforcer-rules with Apache License 2.0 6 votes vote down vote up
private void checkValidRoles( final Set<String> requiredRolesSet, final Set<String> rolesFromProject )
    throws EnforcerRuleException
{
    final Set<String> copyOfRolesFromProject = new LinkedHashSet<String>(rolesFromProject); 
    final Set<String> allowedRoles = getRolesFromString( validRoles );
    if ( !allowedRoles.contains( "*" ) )
    {
        allowedRoles.addAll( requiredRolesSet );

        // results in invalid roles
        copyOfRolesFromProject.removeAll( allowedRoles );
        if ( copyOfRolesFromProject.size() > 0 )
        {
            final String message = String.format( "Found invalid %s role(s) '%s'", getRoleName(), copyOfRolesFromProject );
            throw new EnforcerRuleException( message );
        }
    }
}
 
Example #9
Source File: RequirePropertyDiverges.java    From extra-enforcer-rules with Apache License 2.0 6 votes vote down vote up
/**
 * Checks the value of the project against the one given in the defining ancestor project.
 *
 * @param project
 * @param parent
 * @param helper
 * @param propValue
 * @throws EnforcerRuleException
 */
void checkAgainstParentValue( final MavenProject project, final MavenProject parent, EnforcerRuleHelper helper,
        Object propValue ) throws EnforcerRuleException
{
    final StringBuilder parentHierarchy = new StringBuilder( "project." );
    MavenProject needle = project;
    while ( !needle.equals( parent ) )
    {
        parentHierarchy.append( "parent." );
        needle = needle.getParent();
    }
    final String propertyNameInParent = property.replace( "project.", parentHierarchy.toString() );
    Object parentValue = getPropertyValue( helper, propertyNameInParent );
    if ( propValue.equals( parentValue ) )
    {
        final String errorMessage = createResultingErrorMessage( String.format(
                "Property '%s' evaluates to '%s'. This does match '%s' from parent %s",
                property, propValue, parentValue, parent ) );
        throw new EnforcerRuleException( errorMessage );
    }
}
 
Example #10
Source File: LinkageCheckerRuleTest.java    From cloud-opensource-java with Apache License 2.0 6 votes vote down vote up
@Test
public void testArtifactTransferError()
    throws RepositoryException, DependencyResolutionException {
  DependencyNode graph = createResolvedDependencyGraph("org.apache.maven:maven-core:jar:3.5.2");
  DependencyResolutionResult resolutionResult = mock(DependencyResolutionResult.class);
  when(resolutionResult.getDependencyGraph()).thenReturn(graph);
  DependencyResolutionException exception =
      createDummyResolutionException(
          new DefaultArtifact("aopalliance:aopalliance:1.0"), resolutionResult);
  when(mockProjectDependenciesResolver.resolve(any())).thenThrow(exception);

  try {
    rule.execute(mockRuleHelper);
    fail("The rule should throw EnforcerRuleException upon dependency resolution exception");
  } catch (EnforcerRuleException expected) {
    verify(mockLog)
        .warn(
            "aopalliance:aopalliance:jar:1.0 was not resolved. "
                + "Dependency path: a:b:jar:0.1 > "
                + "org.apache.maven:maven-core:jar:3.5.2 (compile) > "
                + "com.google.inject:guice:jar:no_aop:4.0 (compile) > "
                + "aopalliance:aopalliance:jar:1.0 (compile)");
  }
}
 
Example #11
Source File: EnforceBytecodeVersion.java    From extra-enforcer-rules with Apache License 2.0 6 votes vote down vote up
protected Set<Artifact> checkDependencies( Set<Artifact> dependencies, Log log )
    throws EnforcerRuleException
{
    long beforeCheck = System.currentTimeMillis();
    Set<Artifact> problematic = new LinkedHashSet<Artifact>();
    for ( Iterator<Artifact> it = dependencies.iterator(); it.hasNext(); )
    {
        Artifact artifact = it.next();
        getLog().debug( "Analyzing artifact " + artifact );
        String problem = isBadArtifact( artifact );
        if ( problem != null )
        {
            getLog().info( problem );
            problematic.add( artifact );
        }
    }
    getLog().debug( "Bytecode version analysis took " + ( System.currentTimeMillis() - beforeCheck ) + " ms" );
    return problematic;
}
 
Example #12
Source File: LinkageCheckerRuleTest.java    From cloud-opensource-java with Apache License 2.0 6 votes vote down vote up
@Test
public void testExecute_shouldSkipBadBomWithNonPomPackaging() throws EnforcerRuleException {
  rule.setDependencySection(DependencySection.DEPENDENCY_MANAGEMENT);
  setupMockDependencyManagementSection(
      "com.google.api-client:google-api-client:1.27.0", "io.grpc:grpc-core:1.17.1");
  when(mockProject.getArtifact())
      .thenReturn(
          new org.apache.maven.artifact.DefaultArtifact(
              "com.google.cloud",
              "linkage-checker-rule-test-bom",
              "0.0.1",
              "compile",
              "jar", // BOM should have pom here
              null,
              new DefaultArtifactHandler()));
  rule.execute(mockRuleHelper);
}
 
Example #13
Source File: LinkageCheckerRuleTest.java    From cloud-opensource-java with Apache License 2.0 6 votes vote down vote up
@Test
public void testExecute_shouldFilterExclusionRule()
    throws RepositoryException, URISyntaxException {
  try {
    // This artifact is known to contain classes missing dependencies
    setupMockDependencyResolution("com.google.appengine:appengine-api-1.0-sdk:1.9.64");
    String exclusionFileLocation =
        Paths.get(ClassLoader.getSystemResource("appengine-exclusion.xml").toURI())
            .toAbsolutePath()
            .toString();
    rule.setExclusionFile(exclusionFileLocation);
    rule.execute(mockRuleHelper);
    Assert.fail(
        "The rule should raise an EnforcerRuleException for artifacts missing dependencies");
  } catch (EnforcerRuleException ex) {
    // pass.
    // The number of errors was 112 in testExecute_shouldFailForBadProjectWithBundlePackaging
    verify(mockLog).error(ArgumentMatchers.startsWith("Linkage Checker rule found 93 errors."));
    assertEquals("Failed while checking class path. See above error report.", ex.getMessage());
  }
}
 
Example #14
Source File: LinkageCheckerRuleTest.java    From cloud-opensource-java with Apache License 2.0 6 votes vote down vote up
@Test
public void testExecute_shouldExcludeTestScope() throws EnforcerRuleException {
  org.apache.maven.model.Dependency dependency = new org.apache.maven.model.Dependency();
  Artifact artifact = new DefaultArtifact("junit:junit:3.8.2");
  dependency.setArtifactId(artifact.getArtifactId());
  dependency.setGroupId(artifact.getGroupId());
  dependency.setVersion(artifact.getVersion());
  dependency.setClassifier(artifact.getClassifier());
  dependency.setScope("test");

  when(mockDependencyResolutionResult.getDependencyGraph()).thenReturn(
      new DefaultDependencyNode(dummyArtifactWithFile)
  );
  when(mockProject.getDependencies())
      .thenReturn(ImmutableList.of(dependency));

  rule.execute(mockRuleHelper);
}
 
Example #15
Source File: RequirePropertyDivergesTest.java    From extra-enforcer-rules with Apache License 2.0 6 votes vote down vote up
/**
 * Test of execute method, of class RequirePropertyDiverges.
 */
@Test
public void testExecuteInParentWithConfigurationInExecution() throws EnforcerRuleException
{
    RequirePropertyDiverges mockInstance = createMockRule();
    final MavenProject project = createMavenProject( "company", "company-parent-pom" );
    final Build build = new Build();
    build.setPluginManagement( new PluginManagement() );
    final Plugin plugin = newPlugin( "org.apache.maven.plugins", "maven-enforcer-plugin", "1.0" );
    final Xpp3Dom configuration = createPluginConfiguration();
    PluginExecution pluginExecution = new PluginExecution();
    pluginExecution.setConfiguration( configuration );
    plugin.addExecution( pluginExecution );
    build.addPlugin( plugin );
    project.getOriginalModel().setBuild( build );
    setUpHelper(project, "parentValue");
    mockInstance.execute( helper );
}
 
Example #16
Source File: AbstractRequireRoles.java    From extra-enforcer-rules with Apache License 2.0 5 votes vote down vote up
/**
 * Extracted for easier testability.
 *
 * @param helper
 * @return the MavenProject enforcer is running on.
 *
 * @throws EnforcerRuleException
 */
MavenProject getMavenProject( EnforcerRuleHelper helper ) throws EnforcerRuleException
{
    try
    {
        return ( MavenProject ) helper.evaluate( "${project}" );
    }
    catch ( ExpressionEvaluationException eee )
    {
        throw new EnforcerRuleException( "Unable to get project.", eee );
    }
}
 
Example #17
Source File: RequireEncodingTest.java    From extra-enforcer-rules with Apache License 2.0 5 votes vote down vote up
@Test
public void failUTF8() throws Exception {
  
  when(helper.evaluate("${basedir}")).thenReturn(new File("src/test/resources").getAbsolutePath());
  when(helper.evaluate("${project.build.sourceEncoding}")).thenReturn("UTF-8");
  when(helper.getLog()).thenReturn(mock(Log.class));
  
  rule.setIncludes("ascii.txt");

  exception.expect(EnforcerRuleException.class);
  rule.execute(helper);
}
 
Example #18
Source File: RequirePropertyDiverges.java    From extra-enforcer-rules with Apache License 2.0 5 votes vote down vote up
/**
 * Checks that the property is not null or empty string
 *
 * @param propValue value of the property from the project.
 * @throws EnforcerRuleException
 */
void checkPropValueNotBlank( Object propValue ) throws EnforcerRuleException
{

    if ( propValue == null || StringUtils.isBlank( propValue.toString() ) )
    {
        throw new EnforcerRuleException( String.format(
                "Property '%s' is required for this build and not defined in hierarchy at all.", property ) );
    }
}
 
Example #19
Source File: AbstractRequireRoles.java    From extra-enforcer-rules with Apache License 2.0 5 votes vote down vote up
private void checkRequiredRoles( final Set<String> requiredRolesSet, final Set<String> rolesFromProject )
    throws EnforcerRuleException
{
    final Set<String> copyOfRequiredRolesSet = new LinkedHashSet<String>( requiredRolesSet );
    copyOfRequiredRolesSet.removeAll( rolesFromProject );
    if ( copyOfRequiredRolesSet.size() > 0 )
    {
        final String message =
            String.format( "Found no %s representing role(s) '%s'", getRoleName(), copyOfRequiredRolesSet );
        throw new EnforcerRuleException( message );
    }
}
 
Example #20
Source File: AbstractRequireRoles.java    From extra-enforcer-rules with Apache License 2.0 5 votes vote down vote up
/**
 * Execute the rule.
 * 
 * @param helper the helper
 * @throws EnforcerRuleException the enforcer rule exception
 */
public void execute( EnforcerRuleHelper helper )
    throws EnforcerRuleException
{
    MavenProject mavenProject = getMavenProject( helper );

    // Trying to prevent side-effects with unmodifiable sets (already got burned)
    final Set<String> requiredRolesSet = Collections.unmodifiableSet( getRolesFromString( requiredRoles ) );
    final Set<String> rolesFromProject = Collections.unmodifiableSet(getRolesFromProject( mavenProject ));

    checkRequiredRoles( requiredRolesSet, rolesFromProject );
    checkValidRoles( requiredRolesSet, rolesFromProject );
}
 
Example #21
Source File: LinkageCheckerRule.java    From cloud-opensource-java with Apache License 2.0 5 votes vote down vote up
private static ClassPathResult buildClassPathResult(DependencyResolutionResult result)
    throws EnforcerRuleException {
  // The root node must have the project's JAR file
  DependencyNode root = result.getDependencyGraph();
  File rootFile = root.getArtifact().getFile();
  if (rootFile == null) {
    throw new EnforcerRuleException("The root project artifact is not associated with a file.");
  }

  List<Dependency> unresolvedDependencies = result.getUnresolvedDependencies();
  Set<Artifact> unresolvedArtifacts =
      unresolvedDependencies.stream().map(Dependency::getArtifact).collect(toImmutableSet());

  DependencyGraph dependencyGraph = DependencyGraph.from(root);
  ImmutableListMultimap.Builder<ClassPathEntry, DependencyPath> builder =
      ImmutableListMultimap.builder();
  ImmutableList.Builder<UnresolvableArtifactProblem> problems = ImmutableList.builder();
  for (DependencyPath path : dependencyGraph.list()) {
    Artifact artifact = path.getLeaf();

    if (unresolvedArtifacts.contains(artifact)) {
      problems.add(new UnresolvableArtifactProblem(artifact));
    } else {
      builder.put(new ClassPathEntry(artifact), path);
    }
  }
  return new ClassPathResult(builder.build(), problems.build());
}
 
Example #22
Source File: RequirePropertyDivergesTest.java    From extra-enforcer-rules with Apache License 2.0 5 votes vote down vote up
/**
 * Test of execute method, of class RequirePropertyDiverges.
 */
@Test
public void testExecuteInChild() throws EnforcerRuleException
{
    RequirePropertyDiverges mockInstance = createMockRule();
    final MavenProject project = createMavenProject( "company", "child" );
    final MavenProject parent = createParentProject();
    project.setParent( parent );
    setUpHelper( project, "childValue" );
    mockInstance.execute( helper );
}
 
Example #23
Source File: RequirePropertyDivergesTest.java    From extra-enforcer-rules with Apache License 2.0 5 votes vote down vote up
/**
 * Test of execute method, of class RequirePropertyDiverges.
 */
@Test
public void testExecuteInParent() throws EnforcerRuleException
{
    RequirePropertyDiverges mockInstance = createMockRule();
    final MavenProject project = createParentProject();
    setUpHelper(project, "parentValue");
    mockInstance.execute(helper);
}
 
Example #24
Source File: RequirePropertyDivergesTest.java    From extra-enforcer-rules with Apache License 2.0 5 votes vote down vote up
/**
 * Test of execute method, of class RequirePropertyDiverges.
 */
@Test( expected = EnforcerRuleException.class )
public void testExecuteInChildShouldFail() throws EnforcerRuleException
{
    RequirePropertyDiverges mockInstance = createMockRule();
    final MavenProject project = createMavenProject( "company", "child" );
    final MavenProject parent = createParentProject();
    project.setParent( parent );
    setUpHelper( project, "parentValue" );
    mockInstance.execute( helper );
}
 
Example #25
Source File: RequirePropertyDivergesTest.java    From extra-enforcer-rules with Apache License 2.0 5 votes vote down vote up
/**
 * Test of checkPropValueNotBlank method, of class RequirePropertyDiverges.
 */
@Test( expected = EnforcerRuleException.class )
public void testCheckPropValueNotBlankNull() throws EnforcerRuleException
{
    instance.setProperty( "checkedProperty" );
    instance.checkPropValueNotBlank( null );
}
 
Example #26
Source File: RequirePropertyDivergesTest.java    From extra-enforcer-rules with Apache License 2.0 5 votes vote down vote up
@Test( expected = EnforcerRuleException.class )
public void testGetPropertyValueFail() throws ExpressionEvaluationException, EnforcerRuleException
{
    when( helper.evaluate( "${checkedProperty}" ) ).thenThrow( ExpressionEvaluationException.class );
    instance.setProperty( "checkedProperty" );
    instance.getPropertyValue( helper );
}
 
Example #27
Source File: RequirePropertyDivergesTest.java    From extra-enforcer-rules with Apache License 2.0 5 votes vote down vote up
void testCheckAgainstParentValue( final String parentGroupId, final String childGroupId ) throws ExpressionEvaluationException, EnforcerRuleException
{
    instance.setProperty( "project.groupId" );
    MavenProject parent = createMavenProject( parentGroupId, "parent-pom" );
    MavenProject project = createMavenProject( childGroupId, "child" );
    project.setParent( parent );
    when( helper.evaluate( "${project.parent.groupId}" ) ).thenReturn( parentGroupId );
    instance.checkAgainstParentValue( project, parent, helper, childGroupId );
}
 
Example #28
Source File: RequireRolesTest.java    From extra-enforcer-rules with Apache License 2.0 5 votes vote down vote up
@Test( expected = EnforcerRuleException.class )
public void shouldFailBecauseDeveloperWithRoleCodeMonkeyIsMissing() throws Exception
{
    addProjectHavingAnArchitectAsDeveloperAndABusinessEngineerAsContributorToHelper();
    newRequireDeveloperRoles( "codemonkey" /* required but not in project */, 
                              null ).execute( helper );
}
 
Example #29
Source File: RequireRolesTest.java    From extra-enforcer-rules with Apache License 2.0 5 votes vote down vote up
@Test( expected = EnforcerRuleException.class )
public void shouldFailBecauseContributorRoleBusinessEngineerIsInvalid() throws Exception
{
    addProjectHavingAnArchitectAsDeveloperAndABusinessEngineerAsContributorToHelper();
    newRequireContributorRoles( null /* no required roles needed */, 
                                "hacker" /* only valid role */).execute( helper );
}
 
Example #30
Source File: RequireRolesTest.java    From extra-enforcer-rules with Apache License 2.0 5 votes vote down vote up
@Test( expected = EnforcerRuleException.class )
public void shouldFailBecauseNoContributorRolesAtAllAreValid() throws Exception
{
    addProjectHavingAnArchitectAsDeveloperAndABusinessEngineerAsContributorToHelper();
    newRequireContributorRoles( null /* no required roles needed */, 
                                "" /*but no role is valid at all */).execute( helper );
}