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
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 );
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 )
.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 )
{
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 );
}
}
-
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 )
return this;
}
- public KeyBuilder withRepository( Repository repository )
+ public KeyBuilder withProjectId( String projectId )
{
- this.repositoryName = repository.getName();
+ this.projectId = projectId;
return this;
}
- public KeyBuilder withProjectId( String projectId )
+ public KeyBuilder withProjectVersion( String projectVersion )
{
- this.projectId = projectId;
+ this.projectVersion = projectVersion;
return this;
}
- public KeyBuilder withId( String id )
+ public KeyBuilder withVersion( String version )
{
- this.id = id;
+ 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 );
}
}
}