mirror of https://github.com/apache/archiva.git
[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
This commit is contained in:
parent
6ff9147139
commit
201306c679
|
@ -437,6 +437,33 @@ public abstract class AbstractMetadataRepositoryTest
|
||||||
assertFalse( testFacet.toProperties().containsKey( "deleteKey" ) );
|
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()
|
public void testUpdateArtifactMetadataWithExistingFacetsFacetPropertyWasRemoved()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
|
@ -449,8 +476,10 @@ public abstract class AbstractMetadataRepositoryTest
|
||||||
metadata.addFacet( facet );
|
metadata.addFacet( facet );
|
||||||
repository.updateArtifact( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, metadata );
|
repository.updateArtifact( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, metadata );
|
||||||
|
|
||||||
metadata = repository.getArtifacts( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT,
|
Collection<ArtifactMetadata> artifacts = repository.getArtifacts( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT,
|
||||||
TEST_PROJECT_VERSION ).iterator().next();
|
TEST_PROJECT_VERSION );
|
||||||
|
assertEquals( 1, artifacts.size() );
|
||||||
|
metadata = artifacts.iterator().next();
|
||||||
assertEquals( Collections.singleton( TEST_FACET_ID ), metadata.getFacetIds() );
|
assertEquals( Collections.singleton( TEST_FACET_ID ), metadata.getFacetIds() );
|
||||||
|
|
||||||
TestMetadataFacet testFacet = (TestMetadataFacet) metadata.getFacet( TEST_FACET_ID );
|
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 );
|
repository.updateArtifact( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, metadata );
|
||||||
|
|
||||||
metadata = repository.getArtifacts( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT,
|
artifacts = repository.getArtifacts( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION );
|
||||||
TEST_PROJECT_VERSION ).iterator().next();
|
assertEquals( 1, artifacts.size() );
|
||||||
|
metadata = artifacts.iterator().next();
|
||||||
assertEquals( Collections.singleton( TEST_FACET_ID ), metadata.getFacetIds() );
|
assertEquals( Collections.singleton( TEST_FACET_ID ), metadata.getFacetIds() );
|
||||||
testFacet = (TestMetadataFacet) metadata.getFacet( TEST_FACET_ID );
|
testFacet = (TestMetadataFacet) metadata.getFacet( TEST_FACET_ID );
|
||||||
assertFalse( testFacet.toProperties().containsKey( "deleteKey" ) );
|
assertFalse( testFacet.toProperties().containsKey( "deleteKey" ) );
|
||||||
|
@ -523,14 +553,12 @@ public abstract class AbstractMetadataRepositoryTest
|
||||||
|
|
||||||
public void testGetMetadataFacetWhenEmpty()
|
public void testGetMetadataFacetWhenEmpty()
|
||||||
throws Exception
|
throws Exception
|
||||||
|
|
||||||
{
|
{
|
||||||
assertNull( repository.getMetadataFacet( TEST_REPO_ID, TEST_FACET_ID, TEST_NAME ) );
|
assertNull( repository.getMetadataFacet( TEST_REPO_ID, TEST_FACET_ID, TEST_NAME ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGetMetadataFacetWhenUnknownName()
|
public void testGetMetadataFacetWhenUnknownName()
|
||||||
throws Exception
|
throws Exception
|
||||||
|
|
||||||
{
|
{
|
||||||
repository.addMetadataFacet( TEST_REPO_ID, new TestMetadataFacet( TEST_VALUE ) );
|
repository.addMetadataFacet( TEST_REPO_ID, new TestMetadataFacet( TEST_VALUE ) );
|
||||||
|
|
||||||
|
@ -539,7 +567,6 @@ public abstract class AbstractMetadataRepositoryTest
|
||||||
|
|
||||||
public void testGetMetadataFacetWhenDefaultValue()
|
public void testGetMetadataFacetWhenDefaultValue()
|
||||||
throws Exception
|
throws Exception
|
||||||
|
|
||||||
{
|
{
|
||||||
repository.addMetadataFacet( TEST_REPO_ID, new TestMetadataFacet( null ) );
|
repository.addMetadataFacet( TEST_REPO_ID, new TestMetadataFacet( null ) );
|
||||||
|
|
||||||
|
@ -550,14 +577,12 @@ public abstract class AbstractMetadataRepositoryTest
|
||||||
|
|
||||||
public void testGetMetadataFacetWhenUnknownFacetId()
|
public void testGetMetadataFacetWhenUnknownFacetId()
|
||||||
throws Exception
|
throws Exception
|
||||||
|
|
||||||
{
|
{
|
||||||
assertNull( repository.getMetadataFacet( TEST_REPO_ID, UNKNOWN, TEST_NAME ) );
|
assertNull( repository.getMetadataFacet( TEST_REPO_ID, UNKNOWN, TEST_NAME ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGetMetadataFacets()
|
public void testGetMetadataFacets()
|
||||||
throws Exception
|
throws Exception
|
||||||
|
|
||||||
{
|
{
|
||||||
repository.addMetadataFacet( TEST_REPO_ID, new TestMetadataFacet( TEST_VALUE ) );
|
repository.addMetadataFacet( TEST_REPO_ID, new TestMetadataFacet( TEST_VALUE ) );
|
||||||
|
|
||||||
|
@ -590,7 +615,6 @@ public abstract class AbstractMetadataRepositoryTest
|
||||||
|
|
||||||
public void testRemoveFacetsWhenEmpty()
|
public void testRemoveFacetsWhenEmpty()
|
||||||
throws Exception
|
throws Exception
|
||||||
|
|
||||||
{
|
{
|
||||||
List<String> facets = repository.getMetadataFacets( TEST_REPO_ID, TEST_FACET_ID );
|
List<String> facets = repository.getMetadataFacets( TEST_REPO_ID, TEST_FACET_ID );
|
||||||
assertTrue( facets.isEmpty() );
|
assertTrue( facets.isEmpty() );
|
||||||
|
@ -603,7 +627,6 @@ public abstract class AbstractMetadataRepositoryTest
|
||||||
|
|
||||||
public void testRemoveFacetsWhenUnknown()
|
public void testRemoveFacetsWhenUnknown()
|
||||||
throws Exception
|
throws Exception
|
||||||
|
|
||||||
{
|
{
|
||||||
// testing no exception
|
// testing no exception
|
||||||
repository.removeMetadataFacets( TEST_REPO_ID, UNKNOWN );
|
repository.removeMetadataFacets( TEST_REPO_ID, UNKNOWN );
|
||||||
|
@ -611,7 +634,6 @@ public abstract class AbstractMetadataRepositoryTest
|
||||||
|
|
||||||
public void testRemoveFacetWhenUnknown()
|
public void testRemoveFacetWhenUnknown()
|
||||||
throws Exception
|
throws Exception
|
||||||
|
|
||||||
{
|
{
|
||||||
// testing no exception
|
// testing no exception
|
||||||
repository.removeMetadataFacet( TEST_REPO_ID, UNKNOWN, TEST_NAME );
|
repository.removeMetadataFacet( TEST_REPO_ID, UNKNOWN, TEST_NAME );
|
||||||
|
@ -619,7 +641,6 @@ public abstract class AbstractMetadataRepositoryTest
|
||||||
|
|
||||||
public void testRemoveFacet()
|
public void testRemoveFacet()
|
||||||
throws Exception
|
throws Exception
|
||||||
|
|
||||||
{
|
{
|
||||||
TestMetadataFacet metadataFacet = new TestMetadataFacet( TEST_VALUE );
|
TestMetadataFacet metadataFacet = new TestMetadataFacet( TEST_VALUE );
|
||||||
repository.addMetadataFacet( TEST_REPO_ID, metadataFacet );
|
repository.addMetadataFacet( TEST_REPO_ID, metadataFacet );
|
||||||
|
@ -637,7 +658,6 @@ public abstract class AbstractMetadataRepositoryTest
|
||||||
|
|
||||||
public void testRemoveFacetWhenEmpty()
|
public void testRemoveFacetWhenEmpty()
|
||||||
throws Exception
|
throws Exception
|
||||||
|
|
||||||
{
|
{
|
||||||
List<String> facets = repository.getMetadataFacets( TEST_REPO_ID, TEST_FACET_ID );
|
List<String> facets = repository.getMetadataFacets( TEST_REPO_ID, TEST_FACET_ID );
|
||||||
assertTrue( facets.isEmpty() );
|
assertTrue( facets.isEmpty() );
|
||||||
|
|
|
@ -640,7 +640,10 @@ public class JcrMetadataRepository
|
||||||
artifacts = new ArrayList<ArtifactMetadata>();
|
artifacts = new ArrayList<ArtifactMetadata>();
|
||||||
for ( Node n : JcrUtils.getNodes( result ) )
|
for ( Node n : JcrUtils.getNodes( result ) )
|
||||||
{
|
{
|
||||||
artifacts.add( getArtifactFromNode( repositoryId, n ) );
|
if ( n.isNodeType( ARTIFACT_NODE_TYPE ) )
|
||||||
|
{
|
||||||
|
artifacts.add( getArtifactFromNode( repositoryId, n ) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch ( RepositoryException e )
|
catch ( RepositoryException e )
|
||||||
|
@ -984,7 +987,10 @@ public class JcrMetadataRepository
|
||||||
|
|
||||||
for ( Node n : JcrUtils.getChildNodes( node ) )
|
for ( Node n : JcrUtils.getChildNodes( node ) )
|
||||||
{
|
{
|
||||||
artifacts.add( getArtifactFromNode( repositoryId, n ) );
|
if ( n.isNodeType( ARTIFACT_NODE_TYPE ) )
|
||||||
|
{
|
||||||
|
artifacts.add( getArtifactFromNode( repositoryId, n ) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue