summaryrefslogtreecommitdiffstats
path: root/archiva-modules/metadata
diff options
context:
space:
mode:
authorBrett Porter <brett@apache.org>2010-12-29 23:23:28 +0000
committerBrett Porter <brett@apache.org>2010-12-29 23:23:28 +0000
commit201306c67923d61cd091e1892a8e0ad443e0e7e8 (patch)
tree22dcfac9b85da1b168316054e1b4337850239824 /archiva-modules/metadata
parent6ff91471395b21d91fd553faa6103e9adf55a92d (diff)
downloadarchiva-201306c67923d61cd091e1892a8e0ad443e0e7e8.tar.gz
archiva-201306c67923d61cd091e1892a8e0ad443e0e7e8.zip
[MRM-1327] prevent facets being returned as artifact versions
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1053767 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-modules/metadata')
-rw-r--r--archiva-modules/metadata/metadata-repository-api/src/test/java/org/apache/archiva/metadata/repository/AbstractMetadataRepositoryTest.java48
1 files changed, 34 insertions, 14 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 f9f13c1b4..e1348a2e2 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
@@ -437,6 +437,33 @@ public abstract class AbstractMetadataRepositoryTest
assertFalse( testFacet.toProperties().containsKey( "deleteKey" ) );
}
+ public void testGetArtifactsDoesntReturnProjectVersionMetadataFacets()
+ throws Exception
+ {
+ ProjectVersionMetadata versionMetadata = new ProjectVersionMetadata();
+ versionMetadata.setId( TEST_PROJECT_VERSION );
+
+ MetadataFacet facet = new TestMetadataFacet( TEST_FACET_ID, "baz" );
+ versionMetadata.addFacet( facet );
+ repository.updateProjectVersion( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, versionMetadata );
+
+ ArtifactMetadata artifactMetadata = createArtifact();
+ repository.updateArtifact( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifactMetadata );
+
+ Collection<ArtifactMetadata> artifacts = repository.getArtifacts( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT,
+ TEST_PROJECT_VERSION );
+ assertEquals( Collections.singletonList( artifactMetadata ), new ArrayList<ArtifactMetadata>( artifacts ) );
+
+ artifacts = repository.getArtifacts( TEST_REPO_ID );
+ assertEquals( Collections.singletonList( artifactMetadata ), new ArrayList<ArtifactMetadata>( artifacts ) );
+
+ artifacts = repository.getArtifactsByChecksum( TEST_REPO_ID, artifactMetadata.getSha1() );
+ assertEquals( Collections.singletonList( artifactMetadata ), new ArrayList<ArtifactMetadata>( artifacts ) );
+
+ artifacts = repository.getArtifactsByDateRange( TEST_REPO_ID, null, null );
+ assertEquals( Collections.singletonList( artifactMetadata ), new ArrayList<ArtifactMetadata>( artifacts ) );
+ }
+
public void testUpdateArtifactMetadataWithExistingFacetsFacetPropertyWasRemoved()
throws Exception
{
@@ -449,8 +476,10 @@ public abstract class AbstractMetadataRepositoryTest
metadata.addFacet( facet );
repository.updateArtifact( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, metadata );
- metadata = repository.getArtifacts( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT,
- TEST_PROJECT_VERSION ).iterator().next();
+ Collection<ArtifactMetadata> artifacts = repository.getArtifacts( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT,
+ TEST_PROJECT_VERSION );
+ assertEquals( 1, artifacts.size() );
+ metadata = artifacts.iterator().next();
assertEquals( Collections.singleton( TEST_FACET_ID ), metadata.getFacetIds() );
TestMetadataFacet testFacet = (TestMetadataFacet) metadata.getFacet( TEST_FACET_ID );
@@ -465,8 +494,9 @@ public abstract class AbstractMetadataRepositoryTest
repository.updateArtifact( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, metadata );
- metadata = repository.getArtifacts( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT,
- TEST_PROJECT_VERSION ).iterator().next();
+ artifacts = repository.getArtifacts( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION );
+ assertEquals( 1, artifacts.size() );
+ metadata = artifacts.iterator().next();
assertEquals( Collections.singleton( TEST_FACET_ID ), metadata.getFacetIds() );
testFacet = (TestMetadataFacet) metadata.getFacet( TEST_FACET_ID );
assertFalse( testFacet.toProperties().containsKey( "deleteKey" ) );
@@ -523,14 +553,12 @@ public abstract class AbstractMetadataRepositoryTest
public void testGetMetadataFacetWhenEmpty()
throws Exception
-
{
assertNull( repository.getMetadataFacet( TEST_REPO_ID, TEST_FACET_ID, TEST_NAME ) );
}
public void testGetMetadataFacetWhenUnknownName()
throws Exception
-
{
repository.addMetadataFacet( TEST_REPO_ID, new TestMetadataFacet( TEST_VALUE ) );
@@ -539,7 +567,6 @@ public abstract class AbstractMetadataRepositoryTest
public void testGetMetadataFacetWhenDefaultValue()
throws Exception
-
{
repository.addMetadataFacet( TEST_REPO_ID, new TestMetadataFacet( null ) );
@@ -550,14 +577,12 @@ public abstract class AbstractMetadataRepositoryTest
public void testGetMetadataFacetWhenUnknownFacetId()
throws Exception
-
{
assertNull( repository.getMetadataFacet( TEST_REPO_ID, UNKNOWN, TEST_NAME ) );
}
public void testGetMetadataFacets()
throws Exception
-
{
repository.addMetadataFacet( TEST_REPO_ID, new TestMetadataFacet( TEST_VALUE ) );
@@ -590,7 +615,6 @@ public abstract class AbstractMetadataRepositoryTest
public void testRemoveFacetsWhenEmpty()
throws Exception
-
{
List<String> facets = repository.getMetadataFacets( TEST_REPO_ID, TEST_FACET_ID );
assertTrue( facets.isEmpty() );
@@ -603,7 +627,6 @@ public abstract class AbstractMetadataRepositoryTest
public void testRemoveFacetsWhenUnknown()
throws Exception
-
{
// testing no exception
repository.removeMetadataFacets( TEST_REPO_ID, UNKNOWN );
@@ -611,7 +634,6 @@ public abstract class AbstractMetadataRepositoryTest
public void testRemoveFacetWhenUnknown()
throws Exception
-
{
// testing no exception
repository.removeMetadataFacet( TEST_REPO_ID, UNKNOWN, TEST_NAME );
@@ -619,7 +641,6 @@ public abstract class AbstractMetadataRepositoryTest
public void testRemoveFacet()
throws Exception
-
{
TestMetadataFacet metadataFacet = new TestMetadataFacet( TEST_VALUE );
repository.addMetadataFacet( TEST_REPO_ID, metadataFacet );
@@ -637,7 +658,6 @@ public abstract class AbstractMetadataRepositoryTest
public void testRemoveFacetWhenEmpty()
throws Exception
-
{
List<String> facets = repository.getMetadataFacets( TEST_REPO_ID, TEST_FACET_ID );
assertTrue( facets.isEmpty() );