1 package org.apache.archiva.webtest.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.repository.AbstractMetadataRepository;
24 import org.apache.archiva.metadata.repository.RepositorySession;
26 import java.time.ZoneId;
27 import java.time.ZonedDateTime;
28 import java.util.ArrayList;
29 import java.util.Collection;
30 import java.util.Collections;
31 import java.util.Date;
32 import java.util.List;
34 public class TestMetadataRepository
35 extends AbstractMetadataRepository
37 private static final String TEST_REPO = "test-repo";
39 private static final String TEST_NAMESPACE = "org.apache.archiva";
41 private List<ArtifactMetadata> artifacts = new ArrayList<>();
43 private List<String> versions = new ArrayList<>();
45 public TestMetadataRepository()
47 Date whenGatheredDate = new Date( 123456789 );
48 ZonedDateTime whenGathered = ZonedDateTime.ofInstant(whenGatheredDate.toInstant(), ZoneId.systemDefault());
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, ZonedDateTime 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 );
77 public Collection<String> getProjectVersions( RepositorySession session, String repoId, String namespace, String projectId )
83 public List<String> getMetadataFacets( RepositorySession session, String repodId, String facetId )
85 return Collections.emptyList();
89 public void removeMetadataFacet( RepositorySession session, String repoId, String facetId, String name )
91 //To change body of implemented methods use File | Settings | File Templates.
95 public List<ArtifactMetadata> getArtifactsByDateRange(RepositorySession session, String repoId, ZonedDateTime startTime, ZonedDateTime endTime )
102 public Collection<ArtifactMetadata> getArtifacts( RepositorySession session, String repoId, String namespace, String projectId,
103 String projectVersion )
109 public List<ArtifactMetadata> getArtifacts( RepositorySession session, String repositoryId )