Search in sources :

Example 11 with RepositoryGroup

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

the class BasicRepositoryGroupValidatorTest method applyWithBadName.

@Test
void applyWithBadName() throws IOException {
    BasicRepositoryGroupValidator validator = new BasicRepositoryGroupValidator(configurationHandler);
    validator.setRepositoryRegistry(repositoryRegistry);
    EditableRepositoryGroup group = createGroup("test", "badtest\\name");
    group.setMergedIndexTTL(360);
    ValidationResponse<RepositoryGroup> result = validator.apply(group);
    assertFalse(result.isValid());
    assertEquals(1, result.getResult().size());
    assertEquals("invalid_chars", result.getResult().get("name").get(0).getType());
}
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)

Example 12 with RepositoryGroup

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

the class BasicRepositoryGroupValidatorTest method applyWithNullObject.

@Test
void applyWithNullObject() throws IOException {
    BasicRepositoryGroupValidator validator = new BasicRepositoryGroupValidator(configurationHandler);
    EditableRepositoryGroup group = createGroup("", "test");
    group.setMergedIndexTTL(0);
    ValidationResponse<RepositoryGroup> result = validator.apply(null);
    assertNotNull(result);
    assertFalse(result.isValid());
    assertTrue(result.getResult().containsKey("object"));
    assertEquals("repository_group", result.getResult().get("object").get(0).getCategory());
    assertEquals("isnull", result.getResult().get("object").get(0).getType());
    assertEquals("object", result.getResult().get("object").get(0).getAttribute());
}
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)

Example 13 with RepositoryGroup

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

the class BasicRepositoryGroupValidatorTest method applyWithEmptyId.

@Test
void applyWithEmptyId() throws IOException {
    BasicRepositoryGroupValidator validator = new BasicRepositoryGroupValidator(configurationHandler);
    EditableRepositoryGroup group = createGroup("", "test");
    group.setMergedIndexTTL(0);
    ValidationResponse<RepositoryGroup> result = validator.apply(group);
    assertNotNull(result);
    assertFalse(result.isValid());
    assertTrue(result.getResult().containsKey("id"));
    assertEquals("repository_group", result.getResult().get("id").get(0).getCategory());
    assertEquals("empty", result.getResult().get("id").get(0).getType());
    assertEquals("id", result.getResult().get("id").get(0).getAttribute());
}
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)

Example 14 with RepositoryGroup

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

the class BasicRepositoryGroupValidatorTest method applyWithBadTTL.

@Test
void applyWithBadTTL() throws IOException {
    BasicRepositoryGroupValidator validator = new BasicRepositoryGroupValidator(configurationHandler);
    EditableRepositoryGroup group = createGroup("test", "test");
    group.setMergedIndexTTL(0);
    ValidationResponse<RepositoryGroup> result = validator.apply(group);
    assertNotNull(result);
    assertFalse(result.isValid());
    assertTrue(result.getResult().containsKey("merged_index_ttl"));
    assertEquals("repository_group", result.getResult().get("merged_index_ttl").get(0).getCategory());
    assertEquals("min", result.getResult().get("merged_index_ttl").get(0).getType());
    assertEquals("merged_index_ttl", result.getResult().get("merged_index_ttl").get(0).getAttribute());
}
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)

Example 15 with RepositoryGroup

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

the class MavenRepositoryProviderTest method createRepositoryGroupWithCfg.

@Test
public void createRepositoryGroupWithCfg() throws RepositoryException {
    RepositoryGroupConfiguration cfg = new RepositoryGroupConfiguration();
    cfg.setId("group2");
    cfg.setName("Group 2");
    cfg.setCronExpression("0 0 03 ? * MON");
    cfg.setMergedIndexTtl(504);
    cfg.setMergedIndexPath(".index-abc");
    ArrayList<String> repos = new ArrayList<>();
    repos.add("test01");
    repos.add("test02");
    cfg.setRepositories(repos);
    RepositoryGroup grp = provider.createRepositoryGroup(cfg);
    assertEquals("group2", grp.getId());
    assertEquals("Group 2", grp.getName());
    assertEquals("0 0 03 ? * MON", grp.getSchedulingDefinition());
    IndexCreationFeature indexCreationFeature = grp.getFeature(IndexCreationFeature.class);
    try {
        assertEquals(new URI(".index-abc"), indexCreationFeature.getIndexPath());
    } catch (URISyntaxException e) {
        e.printStackTrace();
    }
    assertEquals(504, grp.getMergedIndexTTL());
    assertEquals(0, grp.getRepositories().size());
// assertTrue(grp.getRepositories().stream().anyMatch(r -> "test01".equals(r.getId())));
// assertTrue(grp.getRepositories().stream().anyMatch(r -> "test02".equals(r.getId())));
}
Also used : RepositoryGroupConfiguration(org.apache.archiva.configuration.model.RepositoryGroupConfiguration) IndexCreationFeature(org.apache.archiva.repository.features.IndexCreationFeature) EditableRepositoryGroup(org.apache.archiva.repository.EditableRepositoryGroup) RepositoryGroup(org.apache.archiva.repository.RepositoryGroup) ArrayList(java.util.ArrayList) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) Test(org.junit.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