gt:         assertThat( plugin.getVersion(), nullValue() );
context: /*
   * Copyright (c) 2010 Red Hat, Inc.
   * 
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU General Public License as published
   * by the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   * 
   * This program is distributed in the hope that it will be useful, but
   * WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   * GNU General Public License for more details.
   * 
   * You should have received a copy of the GNU General Public License
   * along with this program.  If not, see 
   * <http://www.gnu.org/licenses>.
   */
  
  package com.redhat.rcm.version.mgr;
  
  import static com.redhat.rcm.version.testutil.PluginMatcher.mavenPlugin;
  import static com.redhat.rcm.version.testutil.PluginMatcher.plugin;
  import static com.redhat.rcm.version.testutil.TestProjectFixture.dumpModel;
  import static com.redhat.rcm.version.testutil.TestProjectFixture.getResourceFile;
  import static com.redhat.rcm.version.testutil.TestProjectFixture.loadModel;
  import static com.redhat.rcm.version.testutil.TestProjectFixture.loadModels;
  import static com.redhat.rcm.version.testutil.TestProjectFixture.loadProjectKey;
  import static com.redhat.rcm.version.testutil.TestProjectFixture.newVersionManagerSession;
  import static org.apache.commons.io.FileUtils.copyFile;
  import static org.apache.commons.lang.StringUtils.join;
  import static org.hamcrest.Matchers.equalTo;
  import static org.hamcrest.Matchers.hasItem;
  import static org.hamcrest.Matchers.is;
  import static org.hamcrest.Matchers.not;
  import static org.hamcrest.Matchers.notNullValue;
  import static org.hamcrest.Matchers.nullValue;
  import static org.junit.Assert.assertThat;
  import static org.junit.Assert.fail;
  
  import java.io.File;
  import java.io.IOException;
  import java.util.Collections;
  import java.util.List;
  import java.util.Map;
  import java.util.Set;
  
  import org.apache.maven.mae.project.ProjectToolsException;
  import org.apache.maven.mae.project.key.FullProjectKey;
  import org.apache.maven.model.Build;
  import org.apache.maven.model.Model;
  import org.apache.maven.model.Parent;
  import org.apache.maven.model.Plugin;
  import org.apache.maven.model.PluginContainer;
  import org.apache.maven.model.PluginExecution;
  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.project.MavenProject;
  import org.junit.After;
  import org.junit.Before;
  import org.junit.BeforeClass;
  import org.junit.Test;
  
  import com.redhat.rcm.version.fixture.LoggingFixture;
  import com.redhat.rcm.version.mgr.mod.ToolchainModder;
  import com.redhat.rcm.version.mgr.session.SessionBuilder;
  import com.redhat.rcm.version.mgr.session.VersionManagerSession;
  import com.redhat.rcm.version.model.Project;
  import com.redhat.rcm.version.testutil.PluginMatcher;
  
  public class ToolchainManagementTest
      extends AbstractVersionManagerTest
  {
  
      private static final String TOOLCHAIN_TEST_POMS = "toolchain/";
  
      private static final String TOOLCHAIN_PATH = TOOLCHAIN_TEST_POMS + "toolchain-1.0.pom";
  
      private static final String EMPTY_TOOLCHAIN_PATH = TOOLCHAIN_TEST_POMS + "toolchain-empty-1.0.pom";
  
      private static final String REPORTS_TOOLCHAIN_PATH = TOOLCHAIN_TEST_POMS + "toolchain-reportPlugins-1.0.pom";
  
      private static final String ADDITIONS_TOOLCHAIN_PATH = TOOLCHAIN_TEST_POMS + "toolchain-addedPlugins-1.0.pom";
  
      private static FullProjectKey toolchainKey;
  
      @BeforeClass
      public static void enableLogging()
      {
          LoggingFixture.setupLogging();
      }
  
      @Before
      public void setup()
          throws Throwable
      {
          setupDirs();
          setupVersionManager();
      }
  
      @After
      public void teardown()
      {
          LoggingFixture.flushLogging();
      }
  
      @Test
      public void relocatePlugin()
          throws Throwable
      {
          final String path = "relocate-plugin.pom";
          final Model original = loadModel( TOOLCHAIN_TEST_POMS + path );
  
          final String toolchainPath = EMPTY_TOOLCHAIN_PATH;
          final Model toolchainModel = loadModel( toolchainPath );
          final MavenProject toolchainProject = new MavenProject( toolchainModel );
          toolchainProject.setOriginalModel( toolchainModel );
  
          assertBuildPlugins( original, 1, plugin( "org.codehaus.mojo", "rat-maven-plugin" ) );
          assertPluginManagementPlugins( original, -1 );
  
          final Project project = new Project( original );
          final SessionBuilder builder =
              new SessionBuilder( workspace, reports ).withCoordinateRelocation( "org.codehaus.mojo:rat-maven-plugin",
                                                                                 "org.apache.rat:apache-rat-plugin:0.8" );
  
          final VersionManagerSession session = builder.build();
          session.setToolchain( new File( toolchainPath ), toolchainProject );
  
          final boolean changed = new ToolchainModder().inject( project, session );
  
          dumpModel( project.getModel() );
  
          assertThat( changed, equalTo( true ) );
          assertNoErrors( session );
  
          assertBuildPlugins( project.getModel(), 1, plugin( "org.apache.rat", "apache-rat-plugin" ) );
          assertPluginManagementPlugins( project.getModel(), -1 );
      }
  
      @Test
      public void relocateManagedPlugin()
          throws Throwable
      {
          final String path = "relocate-managed-plugin.pom";
          final Model original = loadModel( TOOLCHAIN_TEST_POMS + path );
  
          final String toolchainPath = EMPTY_TOOLCHAIN_PATH;
          final Model toolchainModel = loadModel( toolchainPath );
          final MavenProject toolchainProject = new MavenProject( toolchainModel );
          toolchainProject.setOriginalModel( toolchainModel );
  
          assertBuildPlugins( original, -1 );
          assertPluginManagementPlugins( original, 1, plugin( "org.codehaus.mojo", "rat-maven-plugin" ) );
  
          final Project project = new Project( original );
          final SessionBuilder builder =
              new SessionBuilder( workspace, reports ).withCoordinateRelocation( "org.codehaus.mojo:rat-maven-plugin",
                                                                                 "org.apache.rat:apache-rat-plugin:0.8" );
  
          final VersionManagerSession session = builder.build();
          session.setToolchain( new File( toolchainPath ), toolchainProject );
  
          final boolean changed = new ToolchainModder().inject( project, session );
  
          dumpModel( project.getModel() );
  
          assertThat( changed, equalTo( true ) );
          assertNoErrors( session );
  
          assertBuildPlugins( project.getModel(), -1 );
          assertPluginManagementPlugins( project.getModel(), 1, plugin( "org.apache.rat", "apache-rat-plugin" ) );
      }
  
      @Test
      public void relocateReportPlugin()
          throws Throwable
      {
          final String path = "relocate-report-plugin.pom";
          final Model original = loadModel( TOOLCHAIN_TEST_POMS + path );
  
          final String toolchainPath = EMPTY_TOOLCHAIN_PATH;
          final Model toolchainModel = loadModel( toolchainPath );
          final MavenProject toolchainProject = new MavenProject( toolchainModel );
          toolchainProject.setOriginalModel( toolchainModel );
  
          assertReportPlugins( original, 1, plugin( "org.codehaus.mojo", "rat-maven-plugin" ) );
  
          final Project project = new Project( original );
          final SessionBuilder builder =
              new SessionBuilder( workspace, reports ).withCoordinateRelocation( "org.codehaus.mojo:rat-maven-plugin",
                                                                                 "org.apache.rat:apache-rat-plugin:0.8" );
  
          final VersionManagerSession session = builder.build();
          session.setToolchain( new File( toolchainPath ), toolchainProject );
  
          final boolean changed = new ToolchainModder().inject( project, session );
  
          dumpModel( project.getModel() );
  
          assertThat( changed, equalTo( true ) );
          assertNoErrors( session );
  
          assertReportPlugins( project.getModel(), 1, plugin( "org.apache.rat", "apache-rat-plugin" ) );
      }
  
      @Test
      public void adjustReportPluginWithoutVersion_InheritFromToolchain()
          throws Throwable
      {
          final String toolchainPath = REPORTS_TOOLCHAIN_PATH;
          final String path = "child-reportPlugin-noVersion-1.0.pom";
  
          final Model original = loadModel( TOOLCHAIN_TEST_POMS + path );
  
          assertReportPlugins( original, 1, mavenPlugin( "maven-checkstyle-plugin" ).version( null ) );
          assertPluginManagementPlugins( original, -1 );
  
          final Project project = adjustSingle( "Adjust report plugin version in POM that inherits from toolchain", path, toolchainPath );
  
          assertReportPlugins( project.getModel(), 1, mavenPlugin( "maven-checkstyle-plugin" ).version( "2.6" ) );
          assertPluginManagementPlugins( project.getModel(), -1 );
      }
  
      @Test
      public void adjustReportPluginWithWrongVersion_InheritFromToolchain()
          throws Throwable
      {
          final String toolchainPath = REPORTS_TOOLCHAIN_PATH;
          final String path = "child-reportPlugin-wrongVersion-1.0.pom";
  
          final Model original = loadModel( TOOLCHAIN_TEST_POMS + path );
  
          assertReportPlugins( original, 1, mavenPlugin( "maven-checkstyle-plugin" ).version( "2.2" ) );
          assertPluginManagementPlugins( original, -1 );
  
          final Project project = adjustSingle( "Adjust report plugin version in POM that inherits from toolchain", path, toolchainPath );
  
          assertReportPlugins( project.getModel(), 1, mavenPlugin( "maven-checkstyle-plugin" ).version( "2.6" ) );
          assertPluginManagementPlugins( project.getModel(), -1 );
      }
  
      @Test
      public void adjustReportPluginWithoutVersion_NotInheritFromToolchain()
          throws Throwable
      {
          final String toolchainPath = REPORTS_TOOLCHAIN_PATH;
          final String path = "external-withParent-reportPlugin-noVersion-1.0.pom";
  
          final Model original = loadModel( TOOLCHAIN_TEST_POMS + path );
  
          assertReportPlugins( original, 1, mavenPlugin( "maven-checkstyle-plugin" ).version( null ) );
          assertPluginManagementPlugins( original, -1 );
  
          final Project project = adjustSingle( "Adjust report plugin version in POM not inherited from toolchain", path, toolchainPath );
  
          assertReportPlugins( project.getModel(), 1, mavenPlugin( "maven-checkstyle-plugin" ).version( "2.6" ) );
          assertPluginManagementPlugins( project.getModel(), -1 );
  
          // NOTE: PluginManagement MUST be injected into the highest level possible!
          // Since all non-toolchain parent POMs MUST be built for the repository to be
          // complete, we can inject it there.
          // assertPluginManagementPlugins( project.getModel(), 1, mavenPlugin( "maven-checkstyle-plugin" ).version( "2.6"
          // ) );
      }
  
      @Test
      public void adjustReportPluginWithWrongVersion_NotInheritFromToolchain()
          throws Throwable
      {
          final String toolchainPath = REPORTS_TOOLCHAIN_PATH;
          final String path = "external-withParent-reportPlugin-wrongVersion-1.0.pom";
  
          final Model original = loadModel( TOOLCHAIN_TEST_POMS + path );
  
          assertReportPlugins( original, 1, mavenPlugin( "maven-checkstyle-plugin" ).version( "2.2" ) );
          assertPluginManagementPlugins( original, -1 );
  
          final Project project = adjustSingle( "Adjust report plugin version in POM not inherited from toolchain", path, toolchainPath );
  
          assertReportPlugins( project.getModel(), 1, mavenPlugin( "maven-checkstyle-plugin" ).version( "2.6" ) );
          assertPluginManagementPlugins( project.getModel(), -1 );
  
          // NOTE: PluginManagement MUST be injected into the highest level possible!
          // Since all non-toolchain parent POMs MUST be built for the repository to be
          // complete, we can inject it there.
          // assertPluginManagementPlugins( project.getModel(), 1, mavenPlugin( "maven-checkstyle-plugin" ).version( "2.6"
          // ) );
      }
  
      @Test
      public void removeBuildPlugin()
          throws Throwable
      {
          final String toolchainPath = EMPTY_TOOLCHAIN_PATH;
          final String path = "external-withParent-removePlugin-1.0.pom";
  
          final Model original = loadModel( TOOLCHAIN_TEST_POMS + path );
  
          assertBuildPlugins( original, 1, mavenPlugin( "maven-checkstyle-plugin" ) );
          assertPluginManagementPlugins( original, -1 );
  
          final Project project =
              adjustSingle( "Remove banned plugin from the build section in a POM", path, toolchainPath,
                            Collections.singletonList( "org.apache.maven.plugins:maven-checkstyle-plugin" ) );
  
          assertBuildPlugins( project.getModel(), -1 );
          assertPluginManagementPlugins( project.getModel(), -1 );
      }
  
      @Test
      public void removePluginManagementPlugin()
          throws Throwable
      {
          final String toolchainPath = EMPTY_TOOLCHAIN_PATH;
          final String path = "external-withParent-removeManagedPlugin-1.0.pom";
  
          final Model original = loadModel( TOOLCHAIN_TEST_POMS + path );
  
          assertPluginManagementPlugins( original, 1, mavenPlugin( "maven-checkstyle-plugin" ) );
          assertBuildPlugins( original, -1 );
  
          final Project project =
              adjustSingle( "Remove banned plugin from the pluginManagement section in a POM", path, toolchainPath,
                            Collections.singletonList( "org.apache.maven.plugins:maven-checkstyle-plugin" ) );
  
          assertBuildPlugins( project.getModel(), -1 );
          assertPluginManagementPlugins( project.getModel(), -1 );
      }
  
      @Test
      public void removeReportPlugin()
          throws Throwable
      {
          final String toolchainPath = EMPTY_TOOLCHAIN_PATH;
          final String path = "external-withParent-removeReportPlugin-1.0.pom";
  
          final Model original = loadModel( TOOLCHAIN_TEST_POMS + path );
  
          assertReportPlugins( original, 1, mavenPlugin( "maven-checkstyle-plugin" ) );
          assertPluginManagementPlugins( original, -1 );
  
          final Project project =
              adjustSingle( "Remove banned plugin from the reporting section in a POM", path, toolchainPath,
                            Collections.singletonList( "org.apache.maven.plugins:maven-checkstyle-plugin" ) );
  
          assertReportPlugins( project.getModel(), -1 );
          assertPluginManagementPlugins( project.getModel(), -1 );
      }
  
      // Everything in the system should have a toolchain ancestor...
      // If the POM doesn't have a parent, it has the toolchain injected as its parent
      // If it does have a parent, the above rule ensures that parent is descended from the toolchain.
      //
      // Because of this, any new plugin executions can be specified ONLY in the toolchain POM.
      // @Test
      // public void addPluginExecutionInChildNotInheritingFromToolchain()
      // throws Throwable
      // {
      // String toolchainPath = ADDITIONS_TOOLCHAIN_PATH;
      // String path = "external-withParent-noPlugins-1.0.pom";
      //
      // Model original = loadModel( TOOLCHAIN_TEST_POMS + path );
      //
      // assertBuildPlugins( original, -1 );
      // assertPluginManagementPlugins( original, -1 );
      //
      // Project project =
      // adjustSingle( "Inject single plugin execution into POM not inheriting from "
      // + "toolchain that doesn't already have it", path, toolchainPath );
      //
      // assertBuildPlugins( project.getModel(), 1, mavenPlugin( "maven-source-plugin" ).version( null ) );
      //
      // assertPluginManagementPlugins( project.getModel(),
      // 1,
      // mavenPlugin( "maven-source-plugin" ).version( "2.1.2" ).execution( "create-source-jar" ) );
      // }
  
      @Test
      public void addPluginExecutionToExistingExecutionsInChildNotInheritingFromToolchain()
          throws Throwable
      {
          final String toolchainPath = ADDITIONS_TOOLCHAIN_PATH;
          final String path = "external-withParent-existingPluginExecution-1.0.pom";
  
          final Model original = loadModel( TOOLCHAIN_TEST_POMS + path );
  
          assertBuildPlugins( original, 1, mavenPlugin( "maven-source-plugin" ).version( "2.1.2" )
                                                                               .execution( "other-source-jar" ) );
  
          assertPluginManagementPlugins( original, -1 );
  
          final Project project =
              adjustSingle( "Inject plugin execution into POM not inheriting from " + "toolchain that already has another execution of the plugin",
                            path, toolchainPath );
  
          assertBuildPlugins( project.getModel(), 1, mavenPlugin( "maven-source-plugin" ).version( null )
                                                                                         .execution( "other-source-jar" ) );
  
          assertPluginManagementPlugins( project.getModel(), -1 );
  
          // NOTE: PluginManagement MUST be injected into the highest level possible!
          // Since all non-toolchain parent POMs MUST be built for the repository to be
          // complete, we can inject it there.
          // assertPluginManagementPlugins( project.getModel(),
          // 1,
          // mavenPlugin( "maven-source-plugin" ).version( "2.1.2" ).execution( "create-source-jar" ) );
      }
  
      @Test
      public void doNothingToCollidingPluginExecutionInChildNotInheritingFromToolchain()
          throws Throwable
      {
          final String toolchainPath = ADDITIONS_TOOLCHAIN_PATH;
          final String path = "external-withParent-collidingPluginExecution-1.0.pom";
  
          final Model original = loadModel( TOOLCHAIN_TEST_POMS + path );
  
          assertBuildPlugins( original, 1, mavenPlugin( "maven-source-plugin" ).version( "2.1.2" )
                                                                               .execution( "create-source-jar" ) );
  
          assertPluginManagementPlugins( original, -1 );
  
          final Project project =
              adjustSingle( "Leave existing plugin execution in POM not inheriting from " + "toolchain when it collides with the injected one", path,
                            toolchainPath );
  
          assertBuildPlugins( project.getModel(), 1, mavenPlugin( "maven-source-plugin" ).version( null )
                                                                                         .execution( "create-source-jar" ) );
  
          assertPluginManagementPlugins( project.getModel(), -1 );
  
          // NOTE: PluginManagement MUST be injected into the highest level possible!
          // Since all non-toolchain parent POMs MUST be built for the repository to be
          // complete, we can inject it there.
          // assertPluginManagementPlugins( project.getModel(), 1, mavenPlugin( "maven-source-plugin" ).version( "2.1.2" )
          // );
      }
  
      @Test
      public void adjustInheritedToolchainParentVersion()
          throws Throwable
      {
          final String path = "child-wrongParentVersion-1.0.pom";
  
          final Model original = loadModel( TOOLCHAIN_TEST_POMS + path );
          final Model toolchain = loadModel( TOOLCHAIN_PATH );
  
          assertParent( original, null, null, toolchain.getVersion(), false );
  
          final Project project = adjustSingle( "Adjust parent version in POM inherited from toolchain", path );
  
          assertParent( project.getModel(), null, null, toolchain.getVersion(), true );
      }
  
      @Test
      public void injectToolchainAsParent()
          throws Throwable
      {
          final String path = "external-noParent-1.0.pom";
  
          final Model original = loadModel( TOOLCHAIN_TEST_POMS + path );
          final Model toolchain = loadModel( TOOLCHAIN_PATH );
  
          assertThat( original.getParent(), nullValue() );
  
          final Project project = adjustSingle( "Inject toolchain as parent in POM without a pre-existing parent", path );
  
          assertThat( project.getModel(), notNullValue() );
          assertParent( project.getModel(), null, null, toolchain.getVersion(), true );
      }
  
      @Test
      public void doNotInjectToolchainWhenPomHasExternalParent()
          throws Throwable
      {
          final String path = "external-withParent-1.0.pom";
  
          final Model original = loadModel( TOOLCHAIN_TEST_POMS + path );
          final Model toolchain = loadModel( TOOLCHAIN_PATH );
  
          assertParent( original, toolchain.getGroupId(), toolchain.getArtifactId(), toolchain.getVersion(), false );
  
          adjustNone( "Inject toolchain as parent in POM without a pre-existing parent", path, TOOLCHAIN_PATH, null );
  
          // NOTE: PluginManagement MUST be injected into the highest level possible!
          // Since all non-toolchain parent POMs MUST be built for the repository to be
          // complete, we can inject it there.
          // adjustSingle( "Inject toolchain as parent in POM without a pre-existing parent", path );
          //
          // assertThat( project.getModel(), notNullValue() );
          // assertParent( project.getModel(), toolchain.getGroupId(), toolchain.getArtifactId(), toolchain.getVersion(),
          // false );
      }
  
      @Test
      public void adjustNonManagedPluginForInheritedToolchain()
          throws Throwable
      {
          final Project project = adjustSingle( "Adjust single non-managed plugin in POM inherited from toolchain", "child-nonManaged-1.0.pom" );
  
          final Model changed = project.getModel();
  
          final Build build = changed.getBuild();
          assertThat( build, notNullValue() );
  
          final List<Plugin> plugins = build.getPlugins();
          assertThat( plugins, notNullValue() );
          assertThat( plugins.size(), equalTo( 1 ) );
  
          final Plugin plugin = plugins.get( 0 );
          assertThat( plugin.getArtifactId(), equalTo( "maven-compiler-plugin" ) );
          assertThat( plugin.getVersion(), nullValue() );
      }
  
      @Test
      public void adjustManagedPluginForInheritedToolchain()
          throws Throwable
      {
          final Project project = adjustSingle( "Adjust managed plugin in POM inherited from toolchain", "child-managed-1.0.pom" );
  
          final Model changed = project.getModel();
  
          final Build build = changed.getBuild();
          assertThat( build, notNullValue() );
  
          final PluginManagement pm = build.getPluginManagement();
          assertThat( pm, notNullValue() );
  
          final List<Plugin> plugins = pm.getPlugins();
          assertThat( plugins, notNullValue() );
          assertThat( plugins.size(), equalTo( 1 ) );
  
          final Plugin plugin = plugins.get( 0 );
          assertThat( plugin.getArtifactId(), equalTo( "maven-compiler-plugin" ) );
          assertThat( plugin.getVersion(), nullValue() );
      }
  
      @Test
      public void adjustNonManagedPluginForNonInheritedToolchain()
          throws Throwable
      {
          final Project project =
              adjustSingle( "Adjust non-managed plugin in POM NOT inheriting from toolchain", "external-withParent-nonManaged-1.0.pom" );
  
          final Model changed = project.getModel();
          System.out.println( "Verifying POM: " + project.getPom() );
          LoggingFixture.flushLogging();
  
          final Build build = changed.getBuild();
          assertThat( build, notNullValue() );
  
          final List<Plugin> plugins = build.getPlugins();
          assertThat( plugins, notNullValue() );
          assertThat( plugins.size(), equalTo( 1 ) );
  
          final Plugin plugin = plugins.get( 0 );
          assertThat( plugin.getArtifactId(), equalTo( "maven-compiler-plugin" ) );
          assertThat( plugin.getVersion(), nullValue() );
  
          // NOTE: PluginManagement MUST be injected into the highest level possible!
          // Since all non-toolchain parent POMs MUST be built for the repository to be
          // complete, we can inject it there.
          // PluginManagement pm = build.getPluginManagement();
          // assertThat( pm, notNullValue() );
          //
          // Map<String, Plugin> pluginMap = pm.getPluginsAsMap();
          // assertThat( pluginMap, notNullValue() );
          //
          // plugin = pluginMap.get( "org.apache.maven.plugins:maven-compiler-plugin" );
          // assertThat( plugin.getVersion(), equalTo( "2.0" ) );
      }
  
      @Test
      public void adjustNonManagedPluginForInjectedToolchainParent()
          throws Throwable
      {
          final Project project =
              adjustSingle( "Adjust single non-managed plugin in POM to be inherited from toolchain", "external-noParent-nonManaged-1.0.pom" );
  
          final Model changed = project.getModel();
  
          final Parent parent = changed.getParent();
          assertThat( parent, notNullValue() );
  
          final FullProjectKey tk = getToolchainKey();
          assertThat( parent.getGroupId(), equalTo( tk.getGroupId() ) );
          assertThat( parent.getArtifactId(), equalTo( tk.getArtifactId() ) );
          assertThat( parent.getVersion(), equalTo( tk.getVersion() ) );
  
          final Build build = changed.getBuild();
          assertThat( build, notNullValue() );
  
          final List<Plugin> plugins = build.getPlugins();
          assertThat( plugins, notNullValue() );
          assertThat( plugins.size(), equalTo( 1 ) );
  
          final Plugin plugin = plugins.get( 0 );
          assertThat( plugin.getArtifactId(), equalTo( "maven-compiler-plugin" ) );
          assertThat( plugin.getVersion(), nullValue() );
      }
  
      @Test
      public void removeVersionForEmptyNonManagedPluginForInheritedToolchain()
          throws Throwable
      {
          final Project project =
              adjustSingle( "Adjust single non-managed plugin in POM inherited from toolchain", "child-nonManaged-emptyPlugin-1.0.pom" );
  
          final Model changed = project.getModel();
  
          final Build build = changed.getBuild();
          assertThat( build, notNullValue() );
  
          final List<Plugin> plugins = build.getPlugins();
          assertThat( plugins, notNullValue() );
          assertThat( plugins.size(), equalTo( 1 ) );
  
          final Plugin plugin = plugins.get( 0 );
          assertThat( plugin, notNullValue() );
  