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 java.util.ArrayList;
23 import java.util.Collection;
24 import java.util.Collections;
25 import java.util.Date;
26 import java.util.List;
28 import org.apache.archiva.metadata.model.ArtifactMetadata;
29 import org.apache.archiva.metadata.model.MetadataFacet;
30 import org.apache.archiva.metadata.model.ProjectMetadata;
31 import org.apache.archiva.metadata.model.ProjectVersionMetadata;
32 import org.apache.archiva.metadata.model.ProjectVersionReference;
33 import org.apache.archiva.metadata.repository.MetadataRepository;
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.setVersion( projectVersion );
66 artifact.setId( projectId + "-" + projectVersion + ".jar" );
67 artifact.setProject( projectId );
68 artifact.setRepositoryId( TEST_REPO );
69 artifact.setWhenGathered( whenGathered );
70 artifacts.add( artifact );
72 versions.add( projectVersion );
75 public ProjectMetadata getProject( String repoId, String namespace, String projectId )
77 throw new UnsupportedOperationException();
80 public ProjectVersionMetadata getProjectVersion( String repoId, String namespace, String projectId,
81 String projectVersion )
83 throw new UnsupportedOperationException();
86 public Collection<String> getArtifactVersions( String repoId, String namespace, String projectId,
87 String projectVersion )
89 throw new UnsupportedOperationException();
92 public Collection<ProjectVersionReference> getProjectReferences( String repoId, String namespace, String projectId,
93 String projectVersion )
95 throw new UnsupportedOperationException();
98 public Collection<String> getRootNamespaces( String repoId )
100 throw new UnsupportedOperationException();
103 public Collection<String> getNamespaces( String repoId, String namespace )
105 throw new UnsupportedOperationException();
108 public Collection<String> getProjects( String repoId, String namespace )
110 throw new UnsupportedOperationException();
113 public Collection<String> getProjectVersions( String repoId, String namespace, String projectId )
118 public void updateProject( String repoId, ProjectMetadata project )
120 throw new UnsupportedOperationException();
123 public void updateArtifact( String repoId, String namespace, String projectId, String projectVersion,
124 ArtifactMetadata artifactMeta )
126 throw new UnsupportedOperationException();
129 public void updateProjectVersion( String repoId, String namespace, String projectId,
130 ProjectVersionMetadata versionMetadata )
132 throw new UnsupportedOperationException();
135 public void updateProjectReference( String repoId, String namespace, String projectId, String projectVersion,
136 ProjectVersionReference reference )
138 throw new UnsupportedOperationException();
141 public void updateNamespace( String repoId, String namespace )
143 throw new UnsupportedOperationException();
146 public List<String> getMetadataFacets( String repodId, String facetId )
148 return Collections.emptyList();
151 public MetadataFacet getMetadataFacet( String repositoryId, String facetId, String name )
153 throw new UnsupportedOperationException();
156 public void addMetadataFacet( String repositoryId, MetadataFacet metadataFacet )
158 throw new UnsupportedOperationException();
161 public void removeMetadataFacets( String repositoryId, String facetId )
163 throw new UnsupportedOperationException();
166 public void removeMetadataFacet( String repoId, String facetId, String name )
168 //To change body of implemented methods use File | Settings | File Templates.
171 public List<ArtifactMetadata> getArtifactsByDateRange( String repoId, Date startTime, Date endTime )
176 public Collection<String> getRepositories()
178 return Collections.singletonList( TEST_REPO );
181 public List<ArtifactMetadata> getArtifactsByChecksum( String repoId, String checksum )
183 return null; //To change body of implemented methods use File | Settings | File Templates.
186 public void deleteArtifact( String repositoryId, String namespace, String project, String version, String id )
188 //To change body of implemented methods use File | Settings | File Templates.
191 public void deleteRepository( String repoId )
193 //To change body of implemented methods use File | Settings | File Templates.
196 public Collection<ArtifactMetadata> getArtifacts( String repoId, String namespace, String projectId,
197 String projectVersion )