@Test public void testRepositoryWithMultipleClassifiedArtifacts() { ArtifactTypeMappingService artifactTypeMappingService = new ArtifactTypeMappingService(); ArtifactRepository repo = new ArtifactRepository( createArtifacts( new String[] { "myartifact", "myartifact", "myartifact" }, null, null, new String[] { "class1", "class2", "class3" } ), MAIN_ARTIFACT_ID, artifactTypeMappingService ); assertNull( repo.getUniqueArtifact( DEFAULT_GROUPID, "myartifact", "jar" ) ); assertNotNull( repo.getUniqueArtifact( DEFAULT_GROUPID, "myartifact", "jar", "class1" ) ); assertNotNull( repo.getUniqueArtifact( DEFAULT_GROUPID, "myartifact", "jar", "class2" ) ); assertNotNull( repo.getUniqueArtifact( DEFAULT_GROUPID, "myartifact", "jar", "class3" ) ); assertNull( repo.getUniqueArtifact( DEFAULT_GROUPID, "myartifact", "jar", "wrong" ) ); }
public Artifact getUniqueArtifact( String groupId, String artifactId, String type, String classifier ) { final Set<Artifact> candidates = getArtifacts( groupId, artifactId, type ); if ( candidates.size() == 0 ) { return null; } else if ( candidates.size() == 1 && classifier == null ) { return candidates.iterator().next(); } else if ( classifier != null ) { for ( Artifact a : candidates ) { if ( a.getClassifier() == null && classifier.equals( mainArtifactId ) ) { return a; } else if ( classifier.equals( a.getClassifier() ) ) { return a; } } } return null; }
ArtifactRepository { public Artifact getUniqueArtifact( String groupId, String artifactId, String type, String classifier ) { final Set<Artifact> candidates = getArtifacts( groupId, artifactId, type ); if ( candidates.size() == 0 ) { return null; } else if ( candidates.size() == 1 && classifier == null ) { return candidates.iterator().next(); } else if ( classifier != null ) { for ( Artifact a : candidates ) { if ( a.getClassifier() == null && classifier.equals( mainArtifactId ) ) { return a; } else if ( classifier.equals( a.getClassifier() ) ) { return a; } } } return null; } }
ArtifactRepository { public Artifact getUniqueArtifact( String groupId, String artifactId, String type, String classifier ) { final Set<Artifact> candidates = getArtifacts( groupId, artifactId, type ); if ( candidates.size() == 0 ) { return null; } else if ( candidates.size() == 1 && classifier == null ) { return candidates.iterator().next(); } else if ( classifier != null ) { for ( Artifact a : candidates ) { if ( a.getClassifier() == null && classifier.equals( mainArtifactId ) ) { return a; } else if ( classifier.equals( a.getClassifier() ) ) { return a; } } } return null; } ArtifactRepository( Set<Artifact> artifacts, String mainArtifactId,
                               ArtifactTypeMappingService artifactTypeMappingService ); }
ArtifactRepository { public Artifact getUniqueArtifact( String groupId, String artifactId, String type, String classifier ) { final Set<Artifact> candidates = getArtifacts( groupId, artifactId, type ); if ( candidates.size() == 0 ) { return null; } else if ( candidates.size() == 1 && classifier == null ) { return candidates.iterator().next(); } else if ( classifier != null ) { for ( Artifact a : candidates ) { if ( a.getClassifier() == null && classifier.equals( mainArtifactId ) ) { return a; } else if ( classifier.equals( a.getClassifier() ) ) { return a; } } } return null; } ArtifactRepository( Set<Artifact> artifacts, String mainArtifactId,
                               ArtifactTypeMappingService artifactTypeMappingService ); Artifact getUniqueArtifact( String groupId, String artifactId, String type, String classifier ); Artifact getUniqueArtifact( String groupId, String artifactId, String type ); Set<Artifact> getArtifacts( String groupId, String artifactId, String type ); }
ArtifactRepository { public Artifact getUniqueArtifact( String groupId, String artifactId, String type, String classifier ) { final Set<Artifact> candidates = getArtifacts( groupId, artifactId, type ); if ( candidates.size() == 0 ) { return null; } else if ( candidates.size() == 1 && classifier == null ) { return candidates.iterator().next(); } else if ( classifier != null ) { for ( Artifact a : candidates ) { if ( a.getClassifier() == null && classifier.equals( mainArtifactId ) ) { return a; } else if ( classifier.equals( a.getClassifier() ) ) { return a; } } } return null; } ArtifactRepository( Set<Artifact> artifacts, String mainArtifactId,
                               ArtifactTypeMappingService artifactTypeMappingService ); Artifact getUniqueArtifact( String groupId, String artifactId, String type, String classifier ); Artifact getUniqueArtifact( String groupId, String artifactId, String type ); Set<Artifact> getArtifacts( String groupId, String artifactId, String type );  }