Java Code Examples for org.sonatype.nexus.repository.Repository#init()

The following examples show how to use org.sonatype.nexus.repository.Repository#init() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AptApiRepositoryAdapterTest.java    From nexus-public with Eclipse Public License 1.0 6 votes vote down vote up
private static Repository createRepository(
    final Type type,
    final String distribution,
    final String keypair,
    final String passphrase,
    final Boolean flat) throws Exception
{
  Repository repository = new RepositoryImpl(mock(EventManager.class), type, new AptFormat());

  Configuration configuration = config("my-repo");
  Map<String, Object> apt = newHashMap();
  apt.put("distribution", distribution);
  apt.put("keypair", keypair);
  apt.put("passphrase", passphrase);
  apt.put("flat", flat);
  Map<String, Object> attributes = newHashMap();
  attributes.put("apt", apt);
  NestedAttributesMap aptNested = new NestedAttributesMap("apt", apt);
  when(configuration.attributes("apt")).thenReturn(aptNested);
  repository.init(configuration);
  return repository;
}
 
Example 2
Source File: RepositoryManagerImpl.java    From nexus-public with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Construct a new repository from configuration.
 */
private Repository newRepository(final Configuration configuration) throws Exception {
  String recipeName = configuration.getRecipeName();
  Recipe recipe = recipe(recipeName);
  log.debug("Using recipe: [{}] {}", recipeName, recipe);

  Repository repository = factory.create(recipe.getType(), recipe.getFormat());

  // attach mandatory facets
  repository.attach(configFacet.get());

  // apply recipe to repository
  recipe.apply(repository);

  // verify required facets
  repository.facet(ViewFacet.class);

  // ensure configuration sanity, once all facets are attached
  repository.validate(configuration);

  // initialize repository
  repository.init(configuration);

  return repository;
}
 
Example 3
Source File: MavenApiRepositoryAdapterTest.java    From nexus-public with Eclipse Public License 1.0 5 votes vote down vote up
private static Repository createRepository(
    final Type type,
    final LayoutPolicy layoutPolicy,
    final VersionPolicy versionPolicy) throws Exception
{
  Repository repository = new RepositoryImpl(Mockito.mock(EventManager.class), type, new Maven2Format());

  Configuration configuration = config("my-repo");
  NestedAttributesMap maven = new NestedAttributesMap("maven", newHashMap());
  maven.set("layoutPolicy", LayoutPolicy.STRICT.toString());
  maven.set("versionPolicy", VersionPolicy.MIXED.toString());
  when(configuration.attributes("maven")).thenReturn(maven);
  repository.init(configuration);
  return repository;
}
 
Example 4
Source File: SimpleApiRepositoryAdapterTest.java    From nexus-public with Eclipse Public License 1.0 5 votes vote down vote up
private static Repository createRepository(final Type type) throws Exception {
  Repository repository = new RepositoryImpl(mock(EventManager.class), type, new Format("test-format")
  {
  });
  repository.init(config("my-repo"));
  return repository;
}
 
Example 5
Source File: MavenApiRepositoryAdapterTest.java    From nexus-public with Eclipse Public License 1.0 4 votes vote down vote up
private static Repository createRepository(final Type type) throws Exception {
  Repository repository = new RepositoryImpl(Mockito.mock(EventManager.class), type, new Maven2Format());
  repository.init(config("my-repo"));
  return repository;
}