mirror of
https://github.com/apache/archiva.git
synced 2025-02-23 11:04:56 +00:00
all tests passed with cassandra implementation: does not mean everyhting is really working but a good step :-)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1581699 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
3c0c99a9f2
commit
1754cb76e0
@ -837,10 +837,10 @@ public void testGetArtifactVersions()
|
||||
repository.updateArtifact( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact1 );
|
||||
repository.updateArtifact( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact2 );
|
||||
|
||||
List<String> versions = new ArrayList<String>(
|
||||
repository.getArtifactVersions( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION ) );
|
||||
Collections.sort( versions );
|
||||
assertEquals( Arrays.asList( version1, version2 ), versions );
|
||||
Collection<String> versions =
|
||||
repository.getArtifactVersions( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION );
|
||||
|
||||
assertThat( versions ).isNotNull().isNotEmpty().contains( version1, version2 );
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -1235,8 +1235,8 @@ public void testDeleteArtifact()
|
||||
|
||||
repository.updateArtifact( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact );
|
||||
|
||||
assertEquals( Collections.singletonList( artifact ), new ArrayList<ArtifactMetadata>(
|
||||
repository.getArtifacts( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION ) ) );
|
||||
assertThat( repository.getArtifacts( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT,
|
||||
TEST_PROJECT_VERSION ) ).containsExactly( artifact );
|
||||
|
||||
repository.updateArtifact( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION_2_0, artifact );
|
||||
|
||||
|
@ -853,8 +853,13 @@ public void updateProjectVersion( String repositoryId, String namespaceId, Strin
|
||||
projectVersionMetadataModel.setLicenses( versionMetadata.getLicenses() );
|
||||
|
||||
// we don't test of repository and namespace really exist !
|
||||
String key = new ProjectVersionMetadataModel.KeyBuilder().withRepository( repositoryId ).withNamespace(
|
||||
namespaceId ).withProjectId( projectId ).withId( versionMetadata.getId() ).build();
|
||||
String key = new ProjectVersionMetadataModel.KeyBuilder() //
|
||||
.withRepository( repositoryId ) //
|
||||
.withNamespace( namespaceId ) //
|
||||
.withProjectId( projectId ) //
|
||||
.withProjectVersion( versionMetadata.getVersion() ) //
|
||||
.withVersion( versionMetadata.getId() ) //
|
||||
.build();
|
||||
|
||||
// FIXME nested objects to store!!!
|
||||
if ( creation )
|
||||
@ -1435,10 +1440,25 @@ public void updateArtifact( String repositoryId, String namespaceId, String proj
|
||||
.withRepository( repositoryId ) //
|
||||
.withNamespace( namespace ) //
|
||||
.withProjectId( projectId ) //
|
||||
.withId( artifactMeta.getId() ) //
|
||||
.withProjectVersion( projectVersion ) //
|
||||
.withVersion( artifactMeta.getId() ) //
|
||||
.build();
|
||||
|
||||
exists = this.projectVersionMetadataModelTemplate.isColumnsExist( key );
|
||||
Keyspace keyspace = cassandraArchivaManager.getKeyspace();
|
||||
StringSerializer ss = StringSerializer.get();
|
||||
|
||||
QueryResult<OrderedRows<String, String, String>> result = HFactory //
|
||||
.createRangeSlicesQuery( keyspace, ss, ss, ss ) //
|
||||
.setColumnFamily( cassandraArchivaManager.getProjectVersionMetadataFamilyName() ) //
|
||||
.setColumnNames( "version" ) //
|
||||
.addEqualsExpression( "repositoryName", repositoryId ) //
|
||||
.addEqualsExpression( "namespaceId", namespaceId ) //
|
||||
.addEqualsExpression( "projectId", projectId ) //
|
||||
.addEqualsExpression( "projectVersion", projectVersion ) //
|
||||
.addEqualsExpression( "version", artifactMeta.getVersion() ) //
|
||||
.execute();
|
||||
|
||||
exists = result.get().getCount() > 0;
|
||||
|
||||
if ( !exists )
|
||||
{
|
||||
@ -1892,9 +1912,13 @@ public void removeArtifact( final String repositoryId, final String namespace, f
|
||||
|
||||
this.artifactMetadataTemplate.deleteRow( key );
|
||||
|
||||
key =
|
||||
new ProjectVersionMetadataModel.KeyBuilder().withId( version ).withRepository( repositoryId ).withNamespace(
|
||||
namespace ).withProjectId( project ).build();
|
||||
key = new ProjectVersionMetadataModel.KeyBuilder() //
|
||||
.withRepository( repositoryId ) //
|
||||
.withNamespace( namespace ) //
|
||||
.withProjectId( project ) //
|
||||
.withProjectVersion( version ) //
|
||||
.withVersion( id ) //
|
||||
.build();
|
||||
|
||||
this.projectVersionMetadataModelTemplate.deleteRow( key );
|
||||
}
|
||||
|
@ -248,7 +248,6 @@ public String toString()
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static class KeyBuilder
|
||||
{
|
||||
|
||||
@ -258,11 +257,13 @@ public static class KeyBuilder
|
||||
|
||||
private String projectId;
|
||||
|
||||
private String id;
|
||||
private String projectVersion;
|
||||
|
||||
private String version;
|
||||
|
||||
public KeyBuilder()
|
||||
{
|
||||
|
||||
// no op
|
||||
}
|
||||
|
||||
public KeyBuilder withNamespace( Namespace namespace )
|
||||
@ -284,28 +285,29 @@ public KeyBuilder withRepository( String repositoryId )
|
||||
return this;
|
||||
}
|
||||
|
||||
public KeyBuilder withRepository( Repository repository )
|
||||
{
|
||||
this.repositoryName = repository.getName();
|
||||
return this;
|
||||
}
|
||||
|
||||
public KeyBuilder withProjectId( String projectId )
|
||||
{
|
||||
this.projectId = projectId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public KeyBuilder withId( String id )
|
||||
public KeyBuilder withProjectVersion( String projectVersion )
|
||||
{
|
||||
this.id = id;
|
||||
this.projectVersion = projectVersion;
|
||||
return this;
|
||||
}
|
||||
|
||||
public KeyBuilder withVersion( String version )
|
||||
{
|
||||
this.version = version;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String build()
|
||||
{
|
||||
// FIXME add some controls
|
||||
return CassandraUtils.generateKey( this.repositoryName, this.namespace, this.projectId, this.id );
|
||||
return CassandraUtils.generateKey( this.repositoryName, this.namespace, this.projectId, this.projectVersion,
|
||||
this.version );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user