mirror of https://github.com/apache/maven.git
Updated unit test to test for contents of two containers.
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@721109 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
33962fbf54
commit
d9d59f09cf
|
@ -73,6 +73,8 @@ public final class ArtifactModelContainerFactory
|
|||
|
||||
private String scope;
|
||||
|
||||
private String classifier;
|
||||
|
||||
private List<ModelProperty> properties;
|
||||
|
||||
private static String findBaseUriFrom( List<ModelProperty> modelProperties )
|
||||
|
@ -112,6 +114,10 @@ public final class ArtifactModelContainerFactory
|
|||
{
|
||||
this.scope = mp.getResolvedValue();
|
||||
}
|
||||
else if ( classifier == null && mp.getUri().equals( uri + "/classifier" ) )
|
||||
{
|
||||
this.classifier = mp.getResolvedValue();
|
||||
}
|
||||
else if ( type == null && mp.getUri().equals( ProjectUri.Dependencies.Dependency.type )
|
||||
|| mp.getUri().equals(ProjectUri.DependencyManagement.Dependencies.Dependency.type)
|
||||
|| mp.getUri().equals(ProjectUri.Build.PluginManagement.Plugins.Plugin.Dependencies.Dependency.type)
|
||||
|
@ -159,6 +165,11 @@ public final class ArtifactModelContainerFactory
|
|||
type = "jar";
|
||||
}
|
||||
|
||||
if ( classifier == null )
|
||||
{
|
||||
classifier = "";
|
||||
}
|
||||
|
||||
if ( scope == null || scope.equals("provided"))
|
||||
{
|
||||
scope = "compile";
|
||||
|
@ -178,7 +189,8 @@ public final class ArtifactModelContainerFactory
|
|||
}
|
||||
|
||||
ArtifactModelContainer c = (ArtifactModelContainer) modelContainer;
|
||||
if ( c.groupId.equals( groupId ) && c.artifactId.equals( artifactId ) && c.type.equals( type ) )
|
||||
if ( c.groupId.equals( groupId ) && c.artifactId.equals( artifactId ) && c.type.equals( type )
|
||||
&& c.classifier.equals( classifier ))
|
||||
{
|
||||
if ( c.version.equals( version ) )
|
||||
{
|
||||
|
|
|
@ -53,8 +53,15 @@ public class EnforcerPomTest
|
|||
DefaultModelDataSource source = new DefaultModelDataSource();
|
||||
source.init(domainModel.getModelProperties(), Arrays.asList(new ArtifactModelContainerFactory(), new IdModelContainerFactory()));
|
||||
List<ModelContainer> containers = source.queryFor(ProjectUri.Dependencies.Dependency.xUri);
|
||||
assertTrue(containers.size() == 1 );
|
||||
assertTrue(contains(ProjectUri.Dependencies.Dependency.version, "v1", containers.get(0)));
|
||||
assertTrue(containers.size() == 2 );
|
||||
|
||||
ModelContainer mc0 = containers.get(0);
|
||||
assertTrue(contains(ProjectUri.Dependencies.Dependency.version, "v1", mc0));
|
||||
assertFalse(contains(ProjectUri.Dependencies.Dependency.classifier, "tests", mc0));
|
||||
|
||||
ModelContainer mc1 = containers.get(1);
|
||||
assertTrue(contains(ProjectUri.Dependencies.Dependency.version, "v1", mc1));
|
||||
assertTrue(contains(ProjectUri.Dependencies.Dependency.classifier, "tests", mc1));
|
||||
}
|
||||
|
||||
private boolean contains(String name, String value, ModelContainer modelContainer) {
|
||||
|
|
Loading…
Reference in New Issue