aboutsummaryrefslogtreecommitdiffstats
path: root/archiva-modules/metadata/metadata-repository-api
diff options
context:
space:
mode:
authorOlivier Lamy <olamy@apache.org>2014-03-26 12:16:02 +0000
committerOlivier Lamy <olamy@apache.org>2014-03-26 12:16:02 +0000
commitacc72428047d54ba43f802d457afb4f5d10f9c88 (patch)
tree3f6ecac23c8122f989ea695136fb845fdb4d21c1 /archiva-modules/metadata/metadata-repository-api
parent24a6d8419c45178a9d2d8ca959f8fd120bcadfd5 (diff)
downloadarchiva-acc72428047d54ba43f802d457afb4f5d10f9c88.tar.gz
archiva-acc72428047d54ba43f802d457afb4f5d10f9c88.zip
add unit test for method getProjectReferences
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1581807 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-modules/metadata/metadata-repository-api')
-rw-r--r--archiva-modules/metadata/metadata-repository-api/src/test/java/org/apache/archiva/metadata/repository/AbstractMetadataRepositoryTest.java56
1 files changed, 54 insertions, 2 deletions
diff --git a/archiva-modules/metadata/metadata-repository-api/src/test/java/org/apache/archiva/metadata/repository/AbstractMetadataRepositoryTest.java b/archiva-modules/metadata/metadata-repository-api/src/test/java/org/apache/archiva/metadata/repository/AbstractMetadataRepositoryTest.java
index 14bf3b7cc..27eef207b 100644
--- a/archiva-modules/metadata/metadata-repository-api/src/test/java/org/apache/archiva/metadata/repository/AbstractMetadataRepositoryTest.java
+++ b/archiva-modules/metadata/metadata-repository-api/src/test/java/org/apache/archiva/metadata/repository/AbstractMetadataRepositoryTest.java
@@ -31,6 +31,7 @@ import org.apache.archiva.metadata.model.MetadataFacetFactory;
import org.apache.archiva.metadata.model.Organization;
import org.apache.archiva.metadata.model.ProjectMetadata;
import org.apache.archiva.metadata.model.ProjectVersionMetadata;
+import org.apache.archiva.metadata.model.ProjectVersionReference;
import org.apache.archiva.metadata.model.Scm;
import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
import org.assertj.core.util.Sets;
@@ -56,8 +57,8 @@ import java.util.TimeZone;
import static org.assertj.core.api.Assertions.assertThat;
-@RunWith(ArchivaSpringJUnit4ClassRunner.class)
-@ContextConfiguration(locations = { "classpath*:/META-INF/spring-context.xml", "classpath*:/spring-context.xml" })
+@RunWith( ArchivaSpringJUnit4ClassRunner.class )
+@ContextConfiguration( locations = { "classpath*:/META-INF/spring-context.xml", "classpath*:/spring-context.xml" } )
public abstract class AbstractMetadataRepositoryTest
extends TestCase
{
@@ -1368,6 +1369,57 @@ public abstract class AbstractMetadataRepositoryTest
}
+ @Test
+ public void testgetProjectReferences()
+ throws Exception
+ {
+ ProjectVersionMetadata metadata = new ProjectVersionMetadata();
+ metadata.setId( TEST_PROJECT_VERSION );
+
+ metadata.setName( "project name" );
+ metadata.setDescription( "project description" );
+ metadata.setUrl( "the url" );
+
+ Dependency d = new Dependency();
+ d.setArtifactId( "artifactId" );
+ d.setClassifier( "classifier" );
+ d.setGroupId( "groupId" );
+ d.setScope( "scope" );
+ d.setSystemPath( "system path" );
+ d.setType( "type" );
+ d.setVersion( "version" );
+ d.setOptional( true );
+ metadata.addDependency( d );
+
+ d = new Dependency();
+ d.setArtifactId( "artifactId1" );
+ d.setClassifier( "classifier" );
+ d.setGroupId( "groupId" );
+ d.setScope( "scope" );
+ d.setSystemPath( "system path" );
+ d.setType( "type" );
+ d.setVersion( "version1" );
+ d.setOptional( true );
+ metadata.addDependency( d );
+
+ repository.updateProjectVersion( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, metadata );
+
+ repository.save();
+
+ metadata = repository.getProjectVersion( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION );
+
+ Collection<ProjectVersionReference> references =
+ repository.getProjectReferences( TEST_REPO_ID, d.getGroupId(), d.getArtifactId(), d.getVersion() );
+
+ log.info( "references: {}", references );
+
+ assertThat( references ).isNotNull().hasSize( 1 ).contains(
+ new ProjectVersionReference( ProjectVersionReference.ReferenceType.DEPENDENCY, TEST_PROJECT, TEST_NAMESPACE,
+ TEST_PROJECT_VERSION ) );
+
+ }
+
+
private static ProjectMetadata createProject()
{
return createProject( TEST_NAMESPACE );