Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

TestMetadataRepository.java 4.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. package org.apache.archiva.web.webtest.memory;
  2. /*
  3. * Licensed to the Apache Software Foundation (ASF) under one
  4. * or more contributor license agreements. See the NOTICE file
  5. * distributed with this work for additional information
  6. * regarding copyright ownership. The ASF licenses this file
  7. * to you under the Apache License, Version 2.0 (the
  8. * "License"); you may not use this file except in compliance
  9. * with the License. You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. * Unless required by applicable law or agreed to in writing,
  13. * software distributed under the License is distributed on an
  14. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  15. * KIND, either express or implied. See the License for the
  16. * specific language governing permissions and limitations
  17. * under the License.
  18. */
  19. import org.apache.archiva.metadata.model.ArtifactMetadata;
  20. import org.apache.archiva.metadata.repository.AbstractMetadataRepository;
  21. import org.apache.archiva.metadata.repository.RepositorySession;
  22. import java.time.ZoneId;
  23. import java.time.ZonedDateTime;
  24. import java.util.ArrayList;
  25. import java.util.Collections;
  26. import java.util.Date;
  27. import java.util.List;
  28. public class TestMetadataRepository
  29. extends AbstractMetadataRepository
  30. {
  31. private static final String TEST_REPO = "test-repo";
  32. private static final String TEST_NAMESPACE = "org.apache.archiva";
  33. private List<ArtifactMetadata> artifacts = new ArrayList<>();
  34. private List<String> versions = new ArrayList<>();
  35. public TestMetadataRepository()
  36. {
  37. Date whenGatheredDate = new Date( 123456789 );
  38. ZonedDateTime whenGathered = ZonedDateTime.ofInstant(whenGatheredDate.toInstant(), ZoneId.systemDefault());
  39. addArtifact( "artifact-one", "1.0", whenGathered );
  40. addArtifact( "artifact-one", "1.1", whenGathered );
  41. addArtifact( "artifact-one", "2.0", whenGathered );
  42. addArtifact( "artifact-two", "1.0.1", whenGathered );
  43. addArtifact( "artifact-two", "1.0.2", whenGathered );
  44. addArtifact( "artifact-two", "1.0.3-SNAPSHOT", whenGathered );
  45. addArtifact( "artifact-three", "2.0-SNAPSHOT", whenGathered );
  46. addArtifact( "artifact-four", "1.1-beta-2", whenGathered );
  47. }
  48. private void addArtifact( String projectId, String projectVersion, ZonedDateTime whenGathered )
  49. {
  50. ArtifactMetadata artifact = new ArtifactMetadata();
  51. artifact.setFileLastModified( System.currentTimeMillis() );
  52. artifact.setNamespace( TEST_NAMESPACE );
  53. artifact.setProjectVersion( projectVersion );
  54. artifact.setVersion( projectVersion );
  55. artifact.setId( projectId + "-" + projectVersion + ".jar" );
  56. artifact.setProject( projectId );
  57. artifact.setRepositoryId( TEST_REPO );
  58. artifact.setWhenGathered( whenGathered );
  59. artifacts.add( artifact );
  60. versions.add( projectVersion );
  61. }
  62. @Override
  63. public List<String> getProjectVersions( RepositorySession session, String repoId, String namespace, String projectId )
  64. {
  65. return versions;
  66. }
  67. @Override
  68. public List<String> getMetadataFacets( RepositorySession session, String repodId, String facetId )
  69. {
  70. return Collections.emptyList();
  71. }
  72. @Override
  73. public void removeMetadataFacet( RepositorySession session, String repoId, String facetId, String name )
  74. {
  75. //To change body of implemented methods use File | Settings | File Templates.
  76. }
  77. @Override
  78. public List<ArtifactMetadata> getArtifactsByDateRange(RepositorySession session, String repoId, ZonedDateTime startTime, ZonedDateTime endTime )
  79. {
  80. return artifacts;
  81. }
  82. @Override
  83. public List<ArtifactMetadata> getArtifacts( RepositorySession session, String repoId, String namespace, String projectId,
  84. String projectVersion )
  85. {
  86. return artifacts;
  87. }
  88. @Override
  89. public List<ArtifactMetadata> getArtifacts( RepositorySession session, String repositoryId )
  90. {
  91. return artifacts;
  92. }
  93. }