001package org.eclipse.aether.internal.test.util; 002 003/* 004 * Licensed to the Apache Software Foundation (ASF) under one 005 * or more contributor license agreements. See the NOTICE file 006 * distributed with this work for additional information 007 * regarding copyright ownership. The ASF licenses this file 008 * to you under the Apache License, Version 2.0 (the 009 * "License"); you may not use this file except in compliance 010 * with the License. You may obtain a copy of the License at 011 * 012 * http://www.apache.org/licenses/LICENSE-2.0 013 * 014 * Unless required by applicable law or agreed to in writing, 015 * software distributed under the License is distributed on an 016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 017 * KIND, either express or implied. See the License for the 018 * specific language governing permissions and limitations 019 * under the License. 020 */ 021 022import java.util.List; 023 024import org.eclipse.aether.DefaultRepositorySystemSession; 025import org.eclipse.aether.RepositorySystemSession; 026import org.eclipse.aether.artifact.Artifact; 027import org.eclipse.aether.collection.DependencyCollectionContext; 028import org.eclipse.aether.collection.DependencyGraphTransformationContext; 029import org.eclipse.aether.collection.VersionFilter; 030import org.eclipse.aether.graph.Dependency; 031import org.eclipse.aether.resolution.VersionRangeResult; 032 033/** 034 * Utility methods to help unit testing. 035 */ 036public class TestUtils 037{ 038 039 private TestUtils() 040 { 041 // hide constructor 042 } 043 044 /** 045 * Creates a new repository session whose local repository manager is initialized with an instance of 046 * {@link TestLocalRepositoryManager}. 047 */ 048 public static DefaultRepositorySystemSession newSession() 049 { 050 DefaultRepositorySystemSession session = new DefaultRepositorySystemSession(); 051 session.setLocalRepositoryManager( new TestLocalRepositoryManager() ); 052 return session; 053 } 054 055 /** 056 * Creates a new dependency collection context. 057 */ 058 public static DependencyCollectionContext newCollectionContext( RepositorySystemSession session, 059 Dependency dependency, 060 List<Dependency> managedDependencies ) 061 { 062 return new TestDependencyCollectionContext( session, null, dependency, managedDependencies ); 063 } 064 065 /** 066 * Creates a new dependency collection context. 067 */ 068 public static DependencyCollectionContext newCollectionContext( RepositorySystemSession session, Artifact artifact, 069 Dependency dependency, 070 List<Dependency> managedDependencies ) 071 { 072 return new TestDependencyCollectionContext( session, artifact, dependency, managedDependencies ); 073 } 074 075 /** 076 * Creates a new dependency graph transformation context. 077 */ 078 public static DependencyGraphTransformationContext newTransformationContext( RepositorySystemSession session ) 079 { 080 return new TestDependencyGraphTransformationContext( session ); 081 } 082 083 /** 084 * Creates a new version filter context from the specified session and version range result. 085 */ 086 public static VersionFilter.VersionFilterContext newVersionFilterContext( RepositorySystemSession session, 087 VersionRangeResult rangeResult ) 088 { 089 return new TestVersionFilterContext( session, rangeResult ); 090 } 091 092}