1 package org.apache.archiva.metadata.repository.memory;
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
22 import org.apache.archiva.metadata.model.ArtifactMetadata;
23 import org.apache.archiva.metadata.model.MetadataFacet;
24 import org.apache.archiva.metadata.model.ProjectMetadata;
25 import org.apache.archiva.metadata.model.ProjectVersionMetadata;
26 import org.apache.archiva.metadata.model.ProjectVersionReference;
27 import org.apache.archiva.metadata.repository.MetadataRepository;
29 import java.util.ArrayList;
30 import java.util.Collection;
31 import java.util.Collections;
32 import java.util.Date;
33 import java.util.List;
35 public class TestMetadataRepository
36 implements MetadataRepository
38 private static final String TEST_REPO = "test-repo";
40 private static final String TEST_NAMESPACE = "org.apache.archiva";
42 private List<ArtifactMetadata> artifacts = new ArrayList<ArtifactMetadata>();
44 private List<String> versions = new ArrayList<String>();
46 public TestMetadataRepository()
48 Date whenGathered = new Date( 123456789 );
50 addArtifact( "artifact-one", "1.0", whenGathered );
51 addArtifact( "artifact-one", "1.1", whenGathered );
52 addArtifact( "artifact-one", "2.0", whenGathered );
53 addArtifact( "artifact-two", "1.0.1", whenGathered );
54 addArtifact( "artifact-two", "1.0.2", whenGathered );
55 addArtifact( "artifact-two", "1.0.3-SNAPSHOT", whenGathered );
56 addArtifact( "artifact-three", "2.0-SNAPSHOT", whenGathered );
57 addArtifact( "artifact-four", "1.1-beta-2", whenGathered );
60 private void addArtifact( String projectId, String projectVersion, Date whenGathered )
62 ArtifactMetadata artifact = new ArtifactMetadata();
63 artifact.setFileLastModified( System.currentTimeMillis() );
64 artifact.setNamespace( TEST_NAMESPACE );
65 artifact.setProjectVersion( projectVersion );
66 artifact.setVersion( projectVersion );
67 artifact.setId( projectId + "-" + projectVersion + ".jar" );
68 artifact.setProject( projectId );
69 artifact.setRepositoryId( TEST_REPO );
70 artifact.setWhenGathered( whenGathered );
71 artifacts.add( artifact );
73 versions.add( projectVersion );
76 public ProjectMetadata getProject( String repoId, String namespace, String projectId )
78 throw new UnsupportedOperationException();
81 public ProjectVersionMetadata getProjectVersion( String repoId, String namespace, String projectId,
82 String projectVersion )
84 throw new UnsupportedOperationException();
87 public Collection<String> getArtifactVersions( String repoId, String namespace, String projectId,
88 String projectVersion )
90 throw new UnsupportedOperationException();
93 public Collection<ProjectVersionReference> getProjectReferences( String repoId, String namespace, String projectId,
94 String projectVersion )
96 throw new UnsupportedOperationException();
99 public Collection<String> getRootNamespaces( String repoId )
101 throw new UnsupportedOperationException();
104 public Collection<String> getNamespaces( String repoId, String namespace )
106 throw new UnsupportedOperationException();
109 public Collection<String> getProjects( String repoId, String namespace )
111 throw new UnsupportedOperationException();
114 public Collection<String> getProjectVersions( String repoId, String namespace, String projectId )
119 public void updateProject( String repoId, ProjectMetadata project )
121 throw new UnsupportedOperationException();
124 public void updateArtifact( String repoId, String namespace, String projectId, String projectVersion,
125 ArtifactMetadata artifactMeta )
127 throw new UnsupportedOperationException();
130 public void updateProjectVersion( String repoId, String namespace, String projectId,
131 ProjectVersionMetadata versionMetadata )
133 throw new UnsupportedOperationException();
136 public void updateProjectReference( String repoId, String namespace, String projectId, String projectVersion,
137 ProjectVersionReference reference )
139 throw new UnsupportedOperationException();
142 public void updateNamespace( String repoId, String namespace )
144 throw new UnsupportedOperationException();
147 public List<String> getMetadataFacets( String repodId, String facetId )
149 return Collections.emptyList();
152 public MetadataFacet getMetadataFacet( String repositoryId, String facetId, String name )
154 throw new UnsupportedOperationException();
157 public void addMetadataFacet( String repositoryId, MetadataFacet metadataFacet )
159 throw new UnsupportedOperationException();
162 public void removeMetadataFacets( String repositoryId, String facetId )
164 throw new UnsupportedOperationException();
167 public void removeMetadataFacet( String repoId, String facetId, String name )
169 //To change body of implemented methods use File | Settings | File Templates.
172 public List<ArtifactMetadata> getArtifactsByDateRange( String repoId, Date startTime, Date endTime )
177 public Collection<String> getRepositories()
179 return Collections.singletonList( TEST_REPO );
182 public List<ArtifactMetadata> getArtifactsByChecksum( String repoId, String checksum )
184 return null; //To change body of implemented methods use File | Settings | File Templates.
187 public void deleteArtifact( String repositoryId, String namespace, String project, String version, String id )
189 //To change body of implemented methods use File | Settings | File Templates.
192 public void deleteRepository( String repoId )
194 //To change body of implemented methods use File | Settings | File Templates.
197 public Collection<ArtifactMetadata> getArtifacts( String repoId, String namespace, String projectId,
198 String projectVersion )