should return null if no facets found

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1581639 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2014-03-26 02:41:06 +00:00
parent 509e72be48
commit 122145013e
3 changed files with 16 additions and 7 deletions

View File

@ -743,14 +743,14 @@ public abstract class AbstractMetadataRepositoryTest
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() ); assertThat( facets ).isNotNull().isEmpty();
assertNull( repository.getMetadataFacet( TEST_REPO_ID, TEST_FACET_ID, TEST_NAME ) ); assertThat( repository.getMetadataFacet( TEST_REPO_ID, TEST_FACET_ID, TEST_NAME ) ).isNull();
repository.removeMetadataFacet( TEST_REPO_ID, TEST_FACET_ID, TEST_NAME ); repository.removeMetadataFacet( TEST_REPO_ID, TEST_FACET_ID, TEST_NAME );
facets = repository.getMetadataFacets( TEST_REPO_ID, TEST_FACET_ID ); facets = repository.getMetadataFacets( TEST_REPO_ID, TEST_FACET_ID );
assertTrue( facets.isEmpty() ); assertThat( facets ).isNotNull().isEmpty();
assertNull( repository.getMetadataFacet( TEST_REPO_ID, TEST_FACET_ID, TEST_NAME ) ); assertThat( repository.getMetadataFacet( TEST_REPO_ID, TEST_FACET_ID, TEST_NAME ) ).isNull();
} }
@Test @Test

View File

@ -1300,7 +1300,8 @@ public class CassandraMetadataRepository
addInsertion( dependencyMutator, keyDependency, cfDependency, "version", dependency.getVersion() ); addInsertion( dependencyMutator, keyDependency, cfDependency, "version", dependency.getVersion() );
} dependencyMutator.execute(); }
dependencyMutator.execute();
} }
protected void removeDependencies( String projectVersionMetadataKey ) protected void removeDependencies( String projectVersionMetadataKey )
@ -1334,7 +1335,8 @@ public class CassandraMetadataRepository
for ( Row<String, String, String> row : result.get() ) for ( Row<String, String, String> row : result.get() )
{ {
ColumnFamilyResult<String, String> columnFamilyResult = this.dependencyTemplate.queryColumns( row.getKey() ); ColumnFamilyResult<String, String> columnFamilyResult =
this.dependencyTemplate.queryColumns( row.getKey() );
Dependency dependency = new Dependency(); Dependency dependency = new Dependency();
dependency.setClassifier( columnFamilyResult.getString( "classifier" ) ); dependency.setClassifier( columnFamilyResult.getString( "classifier" ) );
@ -1595,7 +1597,12 @@ public class CassandraMetadataRepository
.execute(); .execute();
MetadataFacet metadataFacet = metadataFacetFactory.createMetadataFacet( repositoryId, name ); MetadataFacet metadataFacet = metadataFacetFactory.createMetadataFacet( repositoryId, name );
Map<String, String> map = new HashMap<String, String>( result.get().getCount() ); int size = result.get().getCount();
if ( size < 1 )
{
return null;
}
Map<String, String> map = new HashMap<String, String>( size );
for ( Row<String, String, String> row : result.get() ) for ( Row<String, String, String> row : result.get() )
{ {
ColumnSlice<String, String> columnSlice = row.getColumnSlice(); ColumnSlice<String, String> columnSlice = row.getColumnSlice();

View File

@ -80,8 +80,10 @@ public class CassandraMetadataRepositoryTest
{ {
cassandraArchivaManager.getCluster().truncate( cassandraArchivaManager.getKeyspace().getKeyspaceName(), cassandraArchivaManager.getCluster().truncate( cassandraArchivaManager.getKeyspace().getKeyspaceName(),
cassandraArchivaManager.getProjectFamilyName() ); cassandraArchivaManager.getProjectFamilyName() );
cassandraArchivaManager.getCluster().truncate( cassandraArchivaManager.getKeyspace().getKeyspaceName(), cassandraArchivaManager.getCluster().truncate( cassandraArchivaManager.getKeyspace().getKeyspaceName(),
cassandraArchivaManager.getNamespaceFamilyName() ); cassandraArchivaManager.getNamespaceFamilyName() );
cassandraArchivaManager.getCluster().truncate( cassandraArchivaManager.getKeyspace().getKeyspaceName(), cassandraArchivaManager.getCluster().truncate( cassandraArchivaManager.getKeyspace().getKeyspaceName(),
cassandraArchivaManager.getRepositoryFamilyName() ); cassandraArchivaManager.getRepositoryFamilyName() );