From 5fa4ceb731b5440b7d7439c2d924f299dc109384 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Thu, 10 Apr 2014 16:36:21 +1000 Subject: more diamond --- .../repository/DefaultMetadataResolver.java | 16 ++++----- .../repository/AbstractMetadataRepositoryTest.java | 38 +++++++++++----------- 2 files changed, 27 insertions(+), 27 deletions(-) (limited to 'archiva-modules/metadata/metadata-repository-api') diff --git a/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/DefaultMetadataResolver.java b/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/DefaultMetadataResolver.java index 5c921d68b..06b4bb532 100644 --- a/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/DefaultMetadataResolver.java +++ b/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/DefaultMetadataResolver.java @@ -213,7 +213,7 @@ public class DefaultMetadataResolver } session.markDirty(); - namespaces = new ArrayList( namespaces ); + namespaces = new ArrayList<>( namespaces ); namespaces.addAll( storageNamespaces ); } @@ -240,7 +240,7 @@ public class DefaultMetadataResolver namespaces = metadataRepository.getNamespaces( repoId, namespace ); namespacesCache.put( cacheKey, namespaces ); } - Collection exclusions = new ArrayList( namespaces ); + Collection exclusions = new ArrayList<>( namespaces ); exclusions.addAll( metadataRepository.getProjects( repoId, namespace ) ); Collection storageNamespaces = repositoryStorage.listNamespaces( repoId, namespace, new ExcludesFilter( exclusions ) ); @@ -265,7 +265,7 @@ public class DefaultMetadataResolver } session.markDirty(); - namespaces = new ArrayList( namespaces ); + namespaces = new ArrayList<>( namespaces ); namespaces.addAll( storageNamespaces ); } return namespaces; @@ -283,7 +283,7 @@ public class DefaultMetadataResolver { MetadataRepository metadataRepository = session.getRepository(); Collection projects = metadataRepository.getProjects( repoId, namespace ); - Collection exclusions = new ArrayList( projects ); + Collection exclusions = new ArrayList<>( projects ); String cacheKey = repoId + "-" + namespace; Collection namespaces = namespacesCache.get( cacheKey ); @@ -319,7 +319,7 @@ public class DefaultMetadataResolver } session.markDirty(); - projects = new ArrayList( projects ); + projects = new ArrayList<>( projects ); projects.addAll( storageProjects ); } return projects; @@ -387,7 +387,7 @@ public class DefaultMetadataResolver } session.markDirty(); - projectVersions = new ArrayList( projectVersions ); + projectVersions = new ArrayList<>( projectVersions ); projectVersions.addAll( storageProjectVersions ); } return projectVersions; @@ -433,7 +433,7 @@ public class DefaultMetadataResolver } session.markDirty(); - artifacts = new ArrayList( artifacts ); + artifacts = new ArrayList<>( artifacts ); artifacts.addAll( storageArtifacts ); } return artifacts; @@ -450,7 +450,7 @@ public class DefaultMetadataResolver private Collection createArtifactIdList( Collection artifacts ) { - Collection artifactIds = new ArrayList(); + Collection artifactIds = new ArrayList<>(); for ( ArtifactMetadata artifact : artifacts ) { artifactIds.add( artifact.getId() ); 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 27eef207b..5f7f8c0a2 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 @@ -204,7 +204,7 @@ public abstract class AbstractMetadataRepositoryTest public void testGetArtifactOnly() throws Exception { - assertThat( new ArrayList( + assertThat( new ArrayList<>( repository.getArtifacts( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION ) ) ).isNotNull().isEmpty(); assertThat( @@ -508,19 +508,19 @@ public abstract class AbstractMetadataRepositoryTest Collection artifacts = repository.getArtifacts( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION ); - assertEquals( Collections.singletonList( artifactMetadata ), new ArrayList( artifacts ) ); + assertEquals( Collections.singletonList( artifactMetadata ), new ArrayList<>( artifacts ) ); artifacts = repository.getArtifacts( TEST_REPO_ID ); - assertEquals( Collections.singletonList( artifactMetadata ), new ArrayList( artifacts ) ); + assertEquals( Collections.singletonList( artifactMetadata ), new ArrayList<>( artifacts ) ); artifacts = repository.getArtifactsByChecksum( TEST_REPO_ID, TEST_SHA1 ); - assertEquals( Collections.singletonList( artifactMetadata ), new ArrayList( artifacts ) ); + assertEquals( Collections.singletonList( artifactMetadata ), new ArrayList<>( artifacts ) ); artifacts = repository.getArtifactsByChecksum( TEST_REPO_ID, TEST_MD5 ); - assertEquals( Collections.singletonList( artifactMetadata ), new ArrayList( artifacts ) ); + assertEquals( Collections.singletonList( artifactMetadata ), new ArrayList<>( artifacts ) ); artifacts = repository.getArtifactsByDateRange( TEST_REPO_ID, null, null ); - assertEquals( Collections.singletonList( artifactMetadata ), new ArrayList( artifacts ) ); + assertEquals( Collections.singletonList( artifactMetadata ), new ArrayList<>( artifacts ) ); } @Test @@ -812,7 +812,7 @@ public abstract class AbstractMetadataRepositoryTest Collection artifacts = repository.getArtifacts( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION ); - ArrayList actual = new ArrayList( artifacts ); + ArrayList actual = new ArrayList<>( artifacts ); Collections.sort( actual, new Comparator() { public int compare( ArtifactMetadata o1, ArtifactMetadata o2 ) @@ -1028,13 +1028,13 @@ public abstract class AbstractMetadataRepositoryTest // test it restricts to the appropriate repository assertEquals( Collections.singletonList( artifact ), - new ArrayList( repository.getArtifactsByChecksum( TEST_REPO_ID, TEST_SHA1 ) ) ); - assertEquals( Collections.singletonList( secondArtifact ), new ArrayList( + new ArrayList<>( repository.getArtifactsByChecksum( TEST_REPO_ID, TEST_SHA1 ) ) ); + assertEquals( Collections.singletonList( secondArtifact ), new ArrayList<>( repository.getArtifactsByChecksum( OTHER_REPO_ID, TEST_SHA1 ) ) ); assertEquals( Collections.singletonList( artifact ), - new ArrayList( repository.getArtifactsByChecksum( TEST_REPO_ID, TEST_MD5 ) ) ); + new ArrayList<>( repository.getArtifactsByChecksum( TEST_REPO_ID, TEST_MD5 ) ) ); assertEquals( Collections.singletonList( secondArtifact ), - new ArrayList( repository.getArtifactsByChecksum( OTHER_REPO_ID, TEST_MD5 ) ) ); + new ArrayList<>( repository.getArtifactsByChecksum( OTHER_REPO_ID, TEST_MD5 ) ) ); } @Test @@ -1121,7 +1121,7 @@ public abstract class AbstractMetadataRepositoryTest repository.save(); assertEquals( Collections.singletonList( artifact ), - new ArrayList( repository.getArtifactsByChecksum( TEST_REPO_ID, TEST_MD5 ) ) ); + new ArrayList<>( repository.getArtifactsByChecksum( TEST_REPO_ID, TEST_MD5 ) ) ); } @Test @@ -1133,7 +1133,7 @@ public abstract class AbstractMetadataRepositoryTest repository.save(); assertEquals( Collections.singletonList( artifact ), - new ArrayList( repository.getArtifactsByChecksum( TEST_REPO_ID, TEST_SHA1 ) ) ); + new ArrayList<>( repository.getArtifactsByChecksum( TEST_REPO_ID, TEST_SHA1 ) ) ); } @Test @@ -1147,9 +1147,9 @@ public abstract class AbstractMetadataRepositoryTest repository.save(); assertEquals( Collections.singletonList( artifact ), - new ArrayList( repository.getArtifactsByChecksum( TEST_REPO_ID, TEST_SHA1 ) ) ); + new ArrayList<>( repository.getArtifactsByChecksum( TEST_REPO_ID, TEST_SHA1 ) ) ); assertEquals( Collections.singletonList( artifact ), - new ArrayList( repository.getArtifactsByChecksum( TEST_REPO_ID, TEST_MD5 ) ) ); + new ArrayList<>( repository.getArtifactsByChecksum( TEST_REPO_ID, TEST_MD5 ) ) ); } @Test @@ -1166,11 +1166,11 @@ public abstract class AbstractMetadataRepositoryTest repository.save(); List artifacts = - new ArrayList( repository.getArtifactsByChecksum( TEST_REPO_ID, TEST_SHA1 ) ); + new ArrayList<>( repository.getArtifactsByChecksum( TEST_REPO_ID, TEST_SHA1 ) ); Collections.sort( artifacts, new ArtifactMetadataComparator() ); assertEquals( Arrays.asList( artifact2, artifact1 ), artifacts ); - artifacts = new ArrayList( repository.getArtifactsByChecksum( TEST_REPO_ID, TEST_MD5 ) ); + artifacts = new ArrayList<>( repository.getArtifactsByChecksum( TEST_REPO_ID, TEST_MD5 ) ); Collections.sort( artifacts, new ArtifactMetadataComparator() ); assertEquals( Arrays.asList( artifact2, artifact1 ), artifacts ); } @@ -1215,7 +1215,7 @@ public abstract class AbstractMetadataRepositoryTest Collections.sort( expected, new ArtifactMetadataComparator() ); List actual = - new ArrayList( repository.getArtifactsByDateRange( TEST_REPO_ID, null, null ) ); + new ArrayList<>( repository.getArtifactsByDateRange( TEST_REPO_ID, null, null ) ); Collections.sort( actual, new ArtifactMetadataComparator() ); assertEquals( expected, actual ); @@ -1276,7 +1276,7 @@ public abstract class AbstractMetadataRepositoryTest Collection artifacts = repository.getArtifacts( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION ); - assertEquals( Collections.singletonList( artifact ), new ArrayList( artifacts ) ); + assertEquals( Collections.singletonList( artifact ), new ArrayList<>( artifacts ) ); repository.removeArtifact( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact.getId() ); -- cgit v1.2.3