Search in sources :

Example 6 with RepositoryGroup

use of org.apache.archiva.repository.RepositoryGroup in project archiva by apache.

the class RepositoryGroupHandlerTest method validateRepository.

@Test
void validateRepository() throws IOException {
    RepositoryGroupHandler groupHandler = createHandler();
    final String id = "test-group-10";
    EditableRepositoryGroup repositoryGroup = createRepository(id, "n-" + id);
    repositoryGroup.setMergedIndexTTL(5);
    CheckedResult<RepositoryGroup, Map<String, List<ValidationError>>> result = groupHandler.validateRepository(repositoryGroup);
    assertNotNull(result);
    assertEquals(0, result.getResult().size());
    repositoryGroup = createRepository(id, "n-test-group-10###");
    result = groupHandler.validateRepository(repositoryGroup);
    assertNotNull(result);
    assertEquals(2, result.getResult().size());
    assertNotNull(result.getResult().get("merged_index_ttl"));
    assertNotNull(result.getResult().get("name"));
}
Also used : EditableRepositoryGroup(org.apache.archiva.repository.EditableRepositoryGroup) RepositoryGroup(org.apache.archiva.repository.RepositoryGroup) ValidationError(org.apache.archiva.repository.validation.ValidationError) EditableRepositoryGroup(org.apache.archiva.repository.EditableRepositoryGroup) Map(java.util.Map) Test(org.junit.jupiter.api.Test)

Example 7 with RepositoryGroup

use of org.apache.archiva.repository.RepositoryGroup in project archiva by apache.

the class RepositoryGroupHandlerTest method validateRepositoryIfExisting.

@Test
void validateRepositoryIfExisting() throws IOException, RepositoryException {
    final String id = "test-group-11";
    try {
        RepositoryGroupHandler groupHandler = createHandler();
        EditableRepositoryGroup repositoryGroup = createRepository(id, "n-" + id);
        repositoryGroup.setMergedIndexTTL(5);
        groupHandler.put(repositoryGroup);
        CheckedResult<RepositoryGroup, Map<String, List<ValidationError>>> result = groupHandler.validateRepository(repositoryGroup);
        assertNotNull(result);
        assertEquals(1, result.getResult().size());
    } finally {
        removeGroupFromConfig(id);
    }
}
Also used : EditableRepositoryGroup(org.apache.archiva.repository.EditableRepositoryGroup) RepositoryGroup(org.apache.archiva.repository.RepositoryGroup) ValidationError(org.apache.archiva.repository.validation.ValidationError) EditableRepositoryGroup(org.apache.archiva.repository.EditableRepositoryGroup) Map(java.util.Map) Test(org.junit.jupiter.api.Test)

Example 8 with RepositoryGroup

use of org.apache.archiva.repository.RepositoryGroup in project archiva by apache.

the class RepositoryGroupHandlerTest method activateRepository.

@Test
void activateRepository() throws RepositoryException {
    String id = "test-group-02";
    RepositoryGroupHandler groupHandler = createHandler();
    RepositoryGroup repo = groupHandler.newInstance(RepositoryType.MAVEN, id);
    groupHandler.activateRepository(repo);
    verify(mergedRemoteIndexesScheduler).schedule(eq(repo), any());
    assertEquals(RepositoryState.INITIALIZED, repo.getLastState());
    assertFalse(hasGroupInConfig(id));
}
Also used : EditableRepositoryGroup(org.apache.archiva.repository.EditableRepositoryGroup) RepositoryGroup(org.apache.archiva.repository.RepositoryGroup) Test(org.junit.jupiter.api.Test)

Example 9 with RepositoryGroup

use of org.apache.archiva.repository.RepositoryGroup in project archiva by apache.

the class RepositoryGroupHandlerTest method putWithConfiguration.

@Test
void putWithConfiguration() throws RepositoryException {
    String id = "test-group-05";
    try {
        RepositoryGroupHandler groupHandler = createHandler();
        RepositoryGroupConfiguration configuration = new RepositoryGroupConfiguration();
        configuration.setId(id);
        configuration.setName("n-" + id);
        ArrayList<String> repos = new ArrayList<>();
        repos.add("internal");
        configuration.setRepositories(repos);
        groupHandler.put(configuration);
        RepositoryGroup repo = groupHandler.get(id);
        assertNotNull(repo);
        assertEquals(id, repo.getId());
        assertEquals("n-" + id, repo.getName());
        assertNotNull(repo.getRepositories());
        assertEquals(1, repo.getRepositories().size());
        assertEquals("internal", repo.getRepositories().get(0).getId());
        assertTrue(hasGroupInConfig(id));
    } finally {
        removeGroupFromConfig(id);
    }
}
Also used : RepositoryGroupConfiguration(org.apache.archiva.configuration.model.RepositoryGroupConfiguration) EditableRepositoryGroup(org.apache.archiva.repository.EditableRepositoryGroup) RepositoryGroup(org.apache.archiva.repository.RepositoryGroup) ArrayList(java.util.ArrayList) Test(org.junit.jupiter.api.Test)

Example 10 with RepositoryGroup

use of org.apache.archiva.repository.RepositoryGroup in project archiva by apache.

the class BasicRepositoryGroupValidatorTest method apply.

@Test
void apply() throws IOException {
    BasicRepositoryGroupValidator validator = new BasicRepositoryGroupValidator(configurationHandler);
    EditableRepositoryGroup group = createGroup("test", "test");
    group.setMergedIndexTTL(360);
    ValidationResponse<RepositoryGroup> result = validator.apply(group);
    assertNotNull(result);
    assertTrue(result.isValid());
}
Also used : EditableRepositoryGroup(org.apache.archiva.repository.EditableRepositoryGroup) RepositoryGroup(org.apache.archiva.repository.RepositoryGroup) EditableRepositoryGroup(org.apache.archiva.repository.EditableRepositoryGroup) Test(org.junit.jupiter.api.Test)

Aggregations

RepositoryGroup (org.apache.archiva.repository.RepositoryGroup)25 EditableRepositoryGroup (org.apache.archiva.repository.EditableRepositoryGroup)23 Test (org.junit.jupiter.api.Test)15 RepositoryGroupConfiguration (org.apache.archiva.configuration.model.RepositoryGroupConfiguration)8 Map (java.util.Map)6 ArrayList (java.util.ArrayList)5 RepositoryException (org.apache.archiva.repository.RepositoryException)5 ValidationError (org.apache.archiva.repository.validation.ValidationError)5 IOException (java.io.IOException)4 RepositoryType (org.apache.archiva.repository.RepositoryType)4 Path (java.nio.file.Path)3 RegistryException (org.apache.archiva.components.registry.RegistryException)3 Configuration (org.apache.archiva.configuration.model.Configuration)3 ManagedRepositoryConfiguration (org.apache.archiva.configuration.model.ManagedRepositoryConfiguration)3 IndeterminateConfigurationException (org.apache.archiva.configuration.provider.IndeterminateConfigurationException)3 ManagedRepository (org.apache.archiva.repository.ManagedRepository)3 List (java.util.List)2 ReentrantReadWriteLock (java.util.concurrent.locks.ReentrantReadWriteLock)2 Inject (javax.inject.Inject)2 Named (javax.inject.Named)2