Search in sources :

Example 6 with EditableRepositoryGroup

use of org.apache.archiva.repository.EditableRepositoryGroup 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 7 with EditableRepositoryGroup

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

the class RepositoryGroupHandlerTest method has.

@Test
void has() throws IOException, RepositoryException {
    final String id = "test-group-13";
    try {
        RepositoryGroupHandler groupHandler = createHandler();
        EditableRepositoryGroup repositoryGroup = createRepository(id, "n-" + id);
        repositoryGroup.setMergedIndexTTL(5);
        assertFalse(groupHandler.hasRepository(id));
        groupHandler.put(repositoryGroup);
        assertTrue(groupHandler.hasRepository(id));
    } finally {
        removeGroupFromConfig(id);
    }
}
Also used : EditableRepositoryGroup(org.apache.archiva.repository.EditableRepositoryGroup) Test(org.junit.jupiter.api.Test)

Example 8 with EditableRepositoryGroup

use of org.apache.archiva.repository.EditableRepositoryGroup 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)

Example 9 with EditableRepositoryGroup

use of org.apache.archiva.repository.EditableRepositoryGroup 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 10 with EditableRepositoryGroup

use of org.apache.archiva.repository.EditableRepositoryGroup 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)

Aggregations

EditableRepositoryGroup (org.apache.archiva.repository.EditableRepositoryGroup)19 RepositoryGroup (org.apache.archiva.repository.RepositoryGroup)12 Test (org.junit.jupiter.api.Test)11 RepositoryException (org.apache.archiva.repository.RepositoryException)6 Map (java.util.Map)4 ValidationError (org.apache.archiva.repository.validation.ValidationError)3 EntityExistsException (org.apache.archiva.admin.model.EntityExistsException)2 RepositoryAdminException (org.apache.archiva.admin.model.RepositoryAdminException)2 Configuration (org.apache.archiva.configuration.model.Configuration)2 ManagedRepositoryConfiguration (org.apache.archiva.configuration.model.ManagedRepositoryConfiguration)2 RepositoryGroupConfiguration (org.apache.archiva.configuration.model.RepositoryGroupConfiguration)2 RepositoryType (org.apache.archiva.repository.RepositoryType)2 ArchivaRestServiceException (org.apache.archiva.rest.api.v2.svc.ArchivaRestServiceException)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 ReentrantReadWriteLock (java.util.concurrent.locks.ReentrantReadWriteLock)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1 Collectors (java.util.stream.Collectors)1