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.Collections;
30 import java.util.Date;
31 import java.util.List;
33 public class TestMetadataRepository
34 extends AbstractMetadataRepository
36 private static final String TEST_REPO = "test-repo";
38 private static final String TEST_NAMESPACE = "org.apache.archiva";
40 private List<ArtifactMetadata> artifacts = new ArrayList<>();
42 private List<String> versions = new ArrayList<>();
44 public TestMetadataRepository()
46 Date whenGatheredDate = new Date( 123456789 );
47 ZonedDateTime whenGathered = ZonedDateTime.ofInstant(whenGatheredDate.toInstant(), ZoneId.systemDefault());
49 addArtifact( "artifact-one", "1.0", whenGathered );
50 addArtifact( "artifact-one", "1.1", whenGathered );
51 addArtifact( "artifact-one", "2.0", whenGathered );
52 addArtifact( "artifact-two", "1.0.1", whenGathered );
53 addArtifact( "artifact-two", "1.0.2", whenGathered );
54 addArtifact( "artifact-two", "1.0.3-SNAPSHOT", whenGathered );
55 addArtifact( "artifact-three", "2.0-SNAPSHOT", whenGathered );
56 addArtifact( "artifact-four", "1.1-beta-2", whenGathered );
59 private void addArtifact( String projectId, String projectVersion, ZonedDateTime whenGathered )
61 ArtifactMetadata artifact = new ArtifactMetadata();
62 artifact.setFileLastModified( System.currentTimeMillis() );
63 artifact.setNamespace( TEST_NAMESPACE );
64 artifact.setProjectVersion( projectVersion );
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 );
76 public List<String> getProjectVersions( RepositorySession session, String repoId, String namespace, String projectId )
82 public List<String> getMetadataFacets( RepositorySession session, String repodId, String facetId )
84 return Collections.emptyList();
88 public void removeMetadataFacet( RepositorySession session, String repoId, String facetId, String name )
90 //To change body of implemented methods use File | Settings | File Templates.
94 public List<ArtifactMetadata> getArtifactsByDateRange(RepositorySession session, String repoId, ZonedDateTime startTime, ZonedDateTime endTime )
101 public List<ArtifactMetadata> getArtifacts( RepositorySession session, String repoId, String namespace, String projectId,
102 String projectVersion )
108 public List<ArtifactMetadata> getArtifacts( RepositorySession session, String repositoryId )