aboutsummaryrefslogtreecommitdiffstats
path: root/archiva-modules/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'archiva-modules/plugins')
-rw-r--r--archiva-modules/plugins/maven2-repository/pom.xml33
-rw-r--r--archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/dependency/tree/maven2/Maven3DependencyTreeBuilder.java15
-rw-r--r--archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/dependency/tree/maven2/TreeDependencyNodeVisitor.java74
-rw-r--r--archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/dependency/tree/maven2/DependencyTreeBuilderTest.java2
-rw-r--r--archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/dependency/tree/maven2/DependencyTreeBuilderTestMaven3.java338
5 files changed, 130 insertions, 332 deletions
diff --git a/archiva-modules/plugins/maven2-repository/pom.xml b/archiva-modules/plugins/maven2-repository/pom.xml
index 9409084a9..3046a3ecd 100644
--- a/archiva-modules/plugins/maven2-repository/pom.xml
+++ b/archiva-modules/plugins/maven2-repository/pom.xml
@@ -124,10 +124,28 @@
<artifactId>archiva-configuration</artifactId>
</dependency>
<dependency>
+ <groupId>org.apache.archiva</groupId>
+ <artifactId>archiva-maven2-model</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-provider-api</artifactId>
</dependency>
<dependency>
+ <groupId>net.sf.beanlib</groupId>
+ <artifactId>beanlib</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>cglib</groupId>
+ <artifactId>cglib</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>aopalliance</groupId>
+ <artifactId>aopalliance</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-http</artifactId>
<scope>provided</scope>
@@ -164,20 +182,11 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>net.sf.beanlib</groupId>
- <artifactId>beanlib</artifactId>
+ <groupId>org.easytesting</groupId>
+ <artifactId>fest-assert-core</artifactId>
<scope>test</scope>
- <exclusions>
- <exclusion>
- <groupId>cglib</groupId>
- <artifactId>cglib</artifactId>
- </exclusion>
- <exclusion>
- <groupId>aopalliance</groupId>
- <artifactId>aopalliance</artifactId>
- </exclusion>
- </exclusions>
</dependency>
+
</dependencies>
<build>
<plugins>
diff --git a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/dependency/tree/maven2/Maven3DependencyTreeBuilder.java b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/dependency/tree/maven2/Maven3DependencyTreeBuilder.java
index 023fe50ba..1e03b7dfb 100644
--- a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/dependency/tree/maven2/Maven3DependencyTreeBuilder.java
+++ b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/dependency/tree/maven2/Maven3DependencyTreeBuilder.java
@@ -30,6 +30,7 @@ import org.apache.archiva.admin.model.proxyconnector.ProxyConnectorAdmin;
import org.apache.archiva.admin.model.remote.RemoteRepositoryAdmin;
import org.apache.archiva.common.plexusbridge.PlexusSisuBridge;
import org.apache.archiva.common.plexusbridge.PlexusSisuBridgeException;
+import org.apache.archiva.maven2.model.TreeEntry;
import org.apache.archiva.metadata.repository.storage.RepositoryPathTranslator;
import org.apache.archiva.proxy.common.WagonFactory;
import org.apache.maven.artifact.Artifact;
@@ -67,6 +68,7 @@ import javax.inject.Inject;
import javax.inject.Named;
import java.io.File;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -120,8 +122,8 @@ public class Maven3DependencyTreeBuilder
builder = defaultModelBuilderFactory.newInstance();
}
- public void buildDependencyTree( List<String> repositoryIds, String groupId, String artifactId, String version,
- DependencyVisitor dependencyVisitor )
+ public List<TreeEntry> buildDependencyTree( List<String> repositoryIds, String groupId, String artifactId,
+ String version )
throws Exception
{
Artifact projectArtifact = factory.createProjectArtifact( groupId, artifactId, version );
@@ -139,7 +141,7 @@ public class Maven3DependencyTreeBuilder
if ( repository == null )
{
// metadata could not be resolved
- return;
+ return Collections.emptyList();
}
// MRM-1411
@@ -166,9 +168,14 @@ public class Maven3DependencyTreeBuilder
}
}
+ List<TreeEntry> treeEntries = new ArrayList<TreeEntry>();
+ TreeDependencyNodeVisitor treeDependencyNodeVisitor = new TreeDependencyNodeVisitor( treeEntries );
+
// FIXME take care of relative path
- resolve( repository.getLocation(), groupId, artifactId, version, dependencyVisitor );
+ resolve( repository.getLocation(), groupId, artifactId, version, treeDependencyNodeVisitor );
+ log.debug( "treeEntrie: {}", treeEntries );
+ return treeEntries;
}
diff --git a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/dependency/tree/maven2/TreeDependencyNodeVisitor.java b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/dependency/tree/maven2/TreeDependencyNodeVisitor.java
new file mode 100644
index 000000000..49edbe5b2
--- /dev/null
+++ b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/dependency/tree/maven2/TreeDependencyNodeVisitor.java
@@ -0,0 +1,74 @@
+package org.apache.archiva.dependency.tree.maven2;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import net.sf.beanlib.provider.replicator.BeanReplicator;
+import org.apache.archiva.maven2.model.Artifact;
+import org.apache.archiva.maven2.model.TreeEntry;
+import org.sonatype.aether.graph.DependencyNode;
+import org.sonatype.aether.graph.DependencyVisitor;
+
+import java.util.List;
+
+/**
+ * @author Olivier Lamy
+ * @since 1.4-M3
+ */
+public class TreeDependencyNodeVisitor
+ implements DependencyVisitor
+{
+
+ final List<TreeEntry> treeEntries;
+
+ private TreeEntry currentEntry;
+
+ private org.sonatype.aether.graph.DependencyNode firstDependencyNode;
+
+ public TreeDependencyNodeVisitor( List<TreeEntry> treeEntries )
+ {
+ this.treeEntries = treeEntries;
+ }
+
+
+ public boolean visitEnter( DependencyNode dependencyNode )
+ {
+ TreeEntry entry = new TreeEntry(
+ new BeanReplicator().replicateBean( dependencyNode.getDependency().getArtifact(), Artifact.class ) );
+ entry.getArtifact().setScope( dependencyNode.getDependency().getScope() );
+ entry.setParent( currentEntry );
+ currentEntry = entry;
+
+ if ( firstDependencyNode == null )
+ {
+ firstDependencyNode = dependencyNode;
+ treeEntries.add( currentEntry );
+ }
+ else
+ {
+ currentEntry.getParent().getChilds().add( currentEntry );
+ }
+ return true;
+ }
+
+ public boolean visitLeave( DependencyNode dependencyNode )
+ {
+ currentEntry = currentEntry.getParent();
+ return true;
+ }
+}
diff --git a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/dependency/tree/maven2/DependencyTreeBuilderTest.java b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/dependency/tree/maven2/DependencyTreeBuilderTest.java
index 8669f3c41..948dab0f6 100644
--- a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/dependency/tree/maven2/DependencyTreeBuilderTest.java
+++ b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/dependency/tree/maven2/DependencyTreeBuilderTest.java
@@ -23,6 +23,7 @@ import junit.framework.TestCase;
import org.apache.archiva.configuration.ArchivaConfiguration;
import org.apache.archiva.configuration.Configuration;
import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
+import org.apache.archiva.maven2.model.TreeEntry;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.versioning.VersionRange;
@@ -279,4 +280,5 @@ public class DependencyTreeBuilderTest
control.verify();
}
+
}
diff --git a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/dependency/tree/maven2/DependencyTreeBuilderTestMaven3.java b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/dependency/tree/maven2/DependencyTreeBuilderTestMaven3.java
index 8af4ca7ce..edb3ca793 100644
--- a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/dependency/tree/maven2/DependencyTreeBuilderTestMaven3.java
+++ b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/dependency/tree/maven2/DependencyTreeBuilderTestMaven3.java
@@ -24,27 +24,20 @@ import org.apache.archiva.common.plexusbridge.PlexusSisuBridge;
import org.apache.archiva.configuration.ArchivaConfiguration;
import org.apache.archiva.configuration.Configuration;
import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
+import org.apache.archiva.maven2.model.Artifact;
+import org.apache.archiva.maven2.model.TreeEntry;
import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
-import org.easymock.MockControl;
+import org.fest.assertions.api.Assertions;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.sonatype.aether.RepositorySystem;
-import org.sonatype.aether.artifact.Artifact;
-import org.sonatype.aether.graph.Dependency;
-import org.sonatype.aether.graph.DependencyNode;
-import org.sonatype.aether.graph.DependencyVisitor;
-import org.sonatype.aether.impl.internal.DefaultRepositorySystem;
-import org.sonatype.aether.util.artifact.DefaultArtifact;
-import org.sonatype.aether.util.graph.DefaultDependencyNode;
import org.springframework.test.context.ContextConfiguration;
import javax.inject.Inject;
import javax.inject.Named;
import java.io.File;
import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
+import java.util.List;
@RunWith( ArchivaSpringJUnit4ClassRunner.class )
@ContextConfiguration( locations = { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context.xml" } )
@@ -66,10 +59,6 @@ public class DependencyTreeBuilderTestMaven3
private static final String TEST_GROUP_ID = "org.apache.archiva";
- private DefaultRepositorySystem defaultRepositorySystem;
-
-
- final Map<String, DependencyNode> nodes = new HashMap<String, DependencyNode>();
@Inject
@Named( value = "archivaConfiguration#test" )
@@ -81,8 +70,6 @@ public class DependencyTreeBuilderTestMaven3
{
super.setUp();
- defaultRepositorySystem = (DefaultRepositorySystem) plexusSisuBridge.lookup( RepositorySystem.class );
-
Configuration configuration = new Configuration();
ManagedRepositoryConfiguration repoConfig = new ManagedRepositoryConfiguration();
repoConfig.setId( TEST_REPO_ID );
@@ -96,7 +83,7 @@ public class DependencyTreeBuilderTestMaven3
private Artifact createArtifact( String groupId, String artifactId, String version )
{
- return new DefaultArtifact( groupId, artifactId, "jar", version );
+ return new Artifact( groupId, artifactId, version );
}
private String getId( Artifact artifact )
@@ -109,321 +96,40 @@ public class DependencyTreeBuilderTestMaven3
throws Exception
{
- DependencyNode springContext = new DefaultDependencyNode(
- new Dependency( createArtifact( "org.springframework", "spring-context", "2.5.6" ), "compile" ) );
-
- //springContext.setPremanagedVersion( "2.5.5" );
-
- nodes.put( getId( springContext.getDependency().getArtifact() ), springContext );
-
- DependencyNode springTest = new DefaultDependencyNode(
- new Dependency( createArtifact( "org.springframework", "spring-test", "2.5.5" ), "test" ) );
-
- nodes.put( getId( springTest.getDependency().getArtifact() ), springTest );
-
- DependencyNode plexusUtils = new DefaultDependencyNode(
- new Dependency( createArtifact( "org.codehaus.plexus", "plexus-utils", "1.4.5" ), "compile" ) );
-
- //plexusUtils.setPremanagedVersion( "1.5.1" );
-
- nodes.put( getId( plexusUtils.getDependency().getArtifact() ), plexusUtils );
-
- DependencyNode slf4jLog4j12 = new DefaultDependencyNode(
- new Dependency( createArtifact( "org.slf4j", "slf4j-log4j12", "1.5.0" ), "runtime" ) );
-
- //slf4jLog4j12.setPremanagedScope( "test" );
-
- nodes.put( getId( slf4jLog4j12.getDependency().getArtifact() ), slf4jLog4j12 );
-
- DependencyNode plexusLog4j = new DefaultDependencyNode(
- new Dependency( createArtifact( "org.codehaus.plexus", "plexus-log4j-logging", "1.1-alpha-3" ), "test" ) );
-
- nodes.put( getId( plexusLog4j.getDependency().getArtifact() ), plexusLog4j );
-
- DependencyNode log4j =
- new DefaultDependencyNode( new Dependency( createArtifact( "log4j", "log4j", "1.2.14" ), "test" ) );
-
- nodes.put( getId( log4j.getDependency().getArtifact() ), log4j );
-
- DependencyNode mavenArtifact = new DefaultDependencyNode(
- new Dependency( createArtifact( "org.apache.maven", "maven-artifact", "2.0.8" ), "test" ) );
-
- nodes.put( getId( mavenArtifact.getDependency().getArtifact() ), mavenArtifact );
-
- DependencyNode mavenProject = new DefaultDependencyNode(
- new Dependency( createArtifact( "org.apache.maven", "maven-project", "2.0.8" ), "test" ) );
-
- nodes.put( getId( mavenProject.getDependency().getArtifact() ), mavenProject );
-
- DependencyNode mavenCore = new DefaultDependencyNode(
- new Dependency( createArtifact( "org.apache.maven", "maven-core", "2.0.8" ), "test" ) );
-
- nodes.put( getId( mavenCore.getDependency().getArtifact() ), mavenCore );
-
- DependencyNode mavenSettings = new DefaultDependencyNode(
- new Dependency( createArtifact( "org.apache.maven", "maven-settings", "2.0.8" ), "test" ) );
-
- nodes.put( getId( mavenSettings.getDependency().getArtifact() ), mavenSettings );
-
- DependencyNode mavenModel = new DefaultDependencyNode(
- new Dependency( createArtifact( "org.apache.maven", "maven-model", "2.0.8" ), "test" ) );
-
- nodes.put( getId( mavenModel.getDependency().getArtifact() ), mavenModel );
-
- DependencyNode plexusCommandLine = new DefaultDependencyNode(
- new Dependency( createArtifact( "org.codehaus.plexus", "plexus-command-line", "1.0-alpha-2" ), "test" ) );
-
- nodes.put( getId( plexusCommandLine.getDependency().getArtifact() ), plexusCommandLine );
-
- DependencyNode plexusRegistryCommons = new DefaultDependencyNode(
- new Dependency( createArtifact( "org.codehaus.plexus.registry", "plexus-registry-commons", "1.0-alpha-2" ),
- "test" ) );
-
- nodes.put( getId( plexusRegistryCommons.getDependency().getArtifact() ), plexusRegistryCommons );
-
- //plexusRegistryCommons.setPremanagedVersion( "1.0-alpha-3" );
-
- DependencyNode plexusRegistryApi = new DefaultDependencyNode(
- new Dependency( createArtifact( "org.codehaus.plexus.registry", "plexus-registry-api", "1.0-alpha-2" ),
- "test" ) );
-
- nodes.put( getId( plexusRegistryApi.getDependency().getArtifact() ), plexusRegistryApi );
-
- //plexusRegistryApi.setPremanagedVersion( "1.0-alpha-3" );
-
- DependencyNode plexusSpring = new DefaultDependencyNode(
- new Dependency( createArtifact( "org.codehaus.plexus", "plexus-spring", "1.2" ), "test" ) );
-
- nodes.put( getId( plexusSpring.getDependency().getArtifact() ), plexusSpring );
-
- plexusSpring.getChildren().add( springContext );
- plexusSpring.getChildren().add( springTest );
- plexusSpring.getChildren().add( plexusUtils );
- plexusSpring.getChildren().add( slf4jLog4j12 );
- plexusSpring.getChildren().add( plexusLog4j );
- plexusSpring.getChildren().add( log4j );
- plexusSpring.getChildren().add( mavenArtifact );
- plexusSpring.getChildren().add( mavenProject );
- plexusSpring.getChildren().add( mavenCore );
- plexusSpring.getChildren().add( mavenSettings );
- plexusSpring.getChildren().add( mavenModel );
- plexusSpring.getChildren().add( plexusCommandLine );
- plexusSpring.getChildren().add( plexusRegistryCommons );
- plexusSpring.getChildren().add( plexusRegistryApi );
-
- DependencyNode commonsLang = new DefaultDependencyNode(
- new Dependency( createArtifact( "commons-lang", "commons-lang", "2.2" ), "compile" ) );
-
- nodes.put( getId( commonsLang.getDependency().getArtifact() ), commonsLang );
-
- DependencyNode commonsIO = new DefaultDependencyNode(
- new Dependency( createArtifact( "commons-io", "commons-io", "1.4" ), "compile" ) );
-
- nodes.put( getId( commonsIO.getDependency().getArtifact() ), commonsIO );
-
- DependencyNode slf4j = new DefaultDependencyNode(
- new Dependency( createArtifact( "org.slf4j", "slf4j-api", "1.5.0" ), "compile" ) );
-
- nodes.put( getId( slf4j.getDependency().getArtifact() ), slf4j );
-
- DependencyNode plexusAPI = new DefaultDependencyNode(
- new Dependency( createArtifact( "org.codehaus.plexus", "plexus-component-api", "1.0-alpha-22" ),
- "compile" ) );
-
- nodes.put( getId( plexusAPI.getDependency().getArtifact() ), plexusAPI );
-
- DependencyNode xalan =
- new DefaultDependencyNode( new Dependency( createArtifact( "xalan", "xalan", "2.7.0" ), "compile" ) );
-
- nodes.put( getId( xalan.getDependency().getArtifact() ), xalan );
-
- DependencyNode dom4j =
- new TestDefaultDependencyNode( new Dependency( createArtifact( "dom4j", "dom4j", "1.6.1" ), "test" ) );
+ List<TreeEntry> treeEntries =
+ builder.buildDependencyTree( Collections.singletonList( TEST_REPO_ID ), TEST_GROUP_ID, TEST_ARTIFACT_ID,
+ TEST_VERSION );
- nodes.put( getId( dom4j.getDependency().getArtifact() ), dom4j );
-
- //dom4j.setFailedUpdateScope("compile");
-
- DependencyNode junit =
- new TestDefaultDependencyNode( new Dependency( createArtifact( "junit", "junit", "3.8.1" ), "test" ) );
-
- nodes.put( getId( junit.getDependency().getArtifact() ), junit );
-
- DependencyNode easymock = new TestDefaultDependencyNode(
- new Dependency( createArtifact( "easymock", "easymock", "1.2_Java1.3" ), "test" ) );
-
- nodes.put( getId( easymock.getDependency().getArtifact() ), easymock );
-
- DependencyNode easymockExt = new TestDefaultDependencyNode(
- new Dependency( createArtifact( "easymock", "easymockclassextension", "1.2" ), "test" ) );
-
- nodes.put( getId( easymockExt.getDependency().getArtifact() ), easymockExt );
-
- DependencyNode mainNode = new TestDefaultDependencyNode(
- new Dependency( createArtifact( TEST_GROUP_ID, TEST_ARTIFACT_ID, TEST_VERSION ), "" ) );
-
- nodes.put( getId( mainNode.getDependency().getArtifact() ), mainNode );
-
- mainNode.getChildren().add( commonsLang );
- mainNode.getChildren().add( commonsIO );
- mainNode.getChildren().add( slf4j );
- mainNode.getChildren().add( plexusAPI );
- mainNode.getChildren().add( plexusSpring );
- mainNode.getChildren().add( xalan );
- mainNode.getChildren().add( dom4j );
- mainNode.getChildren().add( junit );
- mainNode.getChildren().add( easymock );
- mainNode.getChildren().add( easymockExt );
-
- /*defaultRepositorySystem.setDependencyCollector( new DependencyCollector()
- {
-
- public CollectResult collectDependencies( RepositorySystemSession session, CollectRequest request )
- throws DependencyCollectionException
- {
- CollectResult collectResult = new CollectResult( request );
- collectResult.setRoot( new DefaultDependencyNode() );
- for ( Dependency dependency : request.getDependencies() )
- {
- DependencyNode node = nodes.get( getId( dependency.getArtifact() ) );
- if ( node != null )
- {
- collectResult.getRoot().getChildren().add( node );
- }
- }
- return collectResult;
- }
- } );
- */
-
- MockControl control = MockControl.createStrictControl( DependencyVisitor.class );
- DependencyVisitor visitor = (DependencyVisitor) control.getMock();
-
- control.expectAndReturn( visitor.visitEnter( mainNode ), true );
-
- control.expectAndReturn( visitor.visitEnter( commonsLang ), true );
- control.expectAndReturn( visitor.visitLeave( commonsLang ), true );
-
- control.expectAndReturn( visitor.visitEnter( commonsIO ), true );
- control.expectAndReturn( visitor.visitLeave( commonsIO ), true );
-
- control.expectAndReturn( visitor.visitEnter( slf4j ), true );
- control.expectAndReturn( visitor.visitLeave( slf4j ), true );
-
- control.expectAndReturn( visitor.visitEnter( plexusAPI ), true );
- control.expectAndReturn( visitor.visitLeave( plexusAPI ), true );
-
- control.expectAndReturn( visitor.visitEnter( plexusSpring ), true );
-
- control.expectAndReturn( visitor.visitEnter( springContext ), true );
- control.expectAndReturn( visitor.visitLeave( springContext ), true );
-
- control.expectAndReturn( visitor.visitEnter( springTest ), true );
- control.expectAndReturn( visitor.visitLeave( springTest ), true );
-
- control.expectAndReturn( visitor.visitEnter( plexusUtils ), true );
- control.expectAndReturn( visitor.visitLeave( plexusUtils ), true );
-
- control.expectAndReturn( visitor.visitEnter( slf4jLog4j12 ), true );
- control.expectAndReturn( visitor.visitLeave( slf4jLog4j12 ), true );
-
- control.expectAndReturn( visitor.visitEnter( plexusLog4j ), true );
- control.expectAndReturn( visitor.visitLeave( plexusLog4j ), true );
-
- control.expectAndReturn( visitor.visitEnter( log4j ), true );
- control.expectAndReturn( visitor.visitLeave( log4j ), true );
-
- control.expectAndReturn( visitor.visitEnter( mavenArtifact ), true );
- control.expectAndReturn( visitor.visitLeave( mavenArtifact ), true );
-
- control.expectAndReturn( visitor.visitEnter( mavenProject ), true );
- control.expectAndReturn( visitor.visitLeave( mavenProject ), true );
-
- control.expectAndReturn( visitor.visitEnter( mavenCore ), true );
- control.expectAndReturn( visitor.visitLeave( mavenCore ), true );
-
- control.expectAndReturn( visitor.visitEnter( mavenSettings ), true );
- control.expectAndReturn( visitor.visitLeave( mavenSettings ), true );
-
- control.expectAndReturn( visitor.visitEnter( mavenModel ), true );
- control.expectAndReturn( visitor.visitLeave( mavenModel ), true );
-
- control.expectAndReturn( visitor.visitEnter( plexusCommandLine ), true );
- control.expectAndReturn( visitor.visitLeave( plexusCommandLine ), true );
-
- control.expectAndReturn( visitor.visitEnter( plexusRegistryCommons ), true );
- control.expectAndReturn( visitor.visitLeave( plexusRegistryCommons ), true );
-
- control.expectAndReturn( visitor.visitEnter( plexusRegistryApi ), true );
- control.expectAndReturn( visitor.visitLeave( plexusRegistryApi ), true );
-
- control.expectAndReturn( visitor.visitLeave( plexusSpring ), true );
-
- control.expectAndReturn( visitor.visitEnter( xalan ), true );
- control.expectAndReturn( visitor.visitLeave( xalan ), true );
-
- control.expectAndReturn( visitor.visitEnter( dom4j ), true );
- control.expectAndReturn( visitor.visitLeave( dom4j ), true );
-
- control.expectAndReturn( visitor.visitEnter( junit ), true );
- control.expectAndReturn( visitor.visitLeave( junit ), true );
-
- control.expectAndReturn( visitor.visitEnter( easymock ), true );
- control.expectAndReturn( visitor.visitLeave( easymock ), true );
-
- control.expectAndReturn( visitor.visitEnter( easymockExt ), true );
- control.expectAndReturn( visitor.visitLeave( easymockExt ), true );
-
- control.expectAndReturn( visitor.visitLeave( mainNode ), true );
-
- control.replay();
-
- visitor = new DependencyVisitor()
- {
- public boolean visitEnter( DependencyNode dependencyNode )
- {
- return true;
- }
-
- public boolean visitLeave( DependencyNode dependencyNode )
- {
- return true;
- }
- };
-
- builder.buildDependencyTree( Collections.singletonList( TEST_REPO_ID ), TEST_GROUP_ID, TEST_ARTIFACT_ID,
- TEST_VERSION, visitor );
-
- control.verify();
+ Assertions.assertThat( treeEntries ).isNotNull().isNotEmpty().contains(
+ new TreeEntry( new Artifact( TEST_GROUP_ID, TEST_ARTIFACT_ID, TEST_VERSION, "", "" ) ) );
+ Assertions.assertThat( treeEntries.get( 0 ).getChilds() ).isNotNull().isNotEmpty().contains(
+ new TreeEntry( new Artifact( "commons-lang", "commons-lang", "2.2", "compile", "" ) ) );
}
- public static class TestDefaultDependencyNode
- extends DefaultDependencyNode
+
+ public static class TestTreeEntry
+ extends TreeEntry
{
+ Artifact a;
- private TestDefaultDependencyNode( Dependency dependency )
+ public TestTreeEntry( Artifact a )
{
- super( dependency );
+ this.a = a;
}
@Override
public int hashCode()
{
- return super.hashCode();
+ return this.a.hashCode();
}
@Override
public boolean equals( Object o )
{
- DependencyNode node = (DependencyNode) o;
- boolean equals = this.getDependency().getArtifact().getGroupId().equals(
- node.getDependency().getArtifact().getGroupId() ) &&
- this.getDependency().getArtifact().getArtifactId().equals(
- node.getDependency().getArtifact().getArtifactId() ) &&
- this.getDependency().getArtifact().getVersion().equals(
- node.getDependency().getArtifact().getVersion() );
- return equals;
+ Artifact artifact = ( (TreeEntry) o ).getArtifact();
+ return artifact.equals( this.a );
}
}
+
}