Search in sources :

Example 6 with ValidationError

use of org.apache.archiva.repository.validation.ValidationError in project archiva by apache.

the class ManagedRepositoryHandlerTest method validateRepositoryIfExisting.

@Test
void validateRepositoryIfExisting() throws IOException, RepositoryException {
    final String id = "test-repo-11";
    try {
        ManagedRepositoryHandler repoHandler = createHandler();
        EditableManagedRepository repository = createRepository(id, "n-" + id);
        repoHandler.put(repository);
        CheckedResult<ManagedRepository, Map<String, List<ValidationError>>> result = repoHandler.validateRepository(repository);
        assertNotNull(result);
        assertEquals(1, result.getResult().size());
    } finally {
        removeRepositoryFromConfig(id);
    }
}
Also used : ManagedRepository(org.apache.archiva.repository.ManagedRepository) EditableManagedRepository(org.apache.archiva.repository.EditableManagedRepository) EditableManagedRepository(org.apache.archiva.repository.EditableManagedRepository) ValidationError(org.apache.archiva.repository.validation.ValidationError) Map(java.util.Map) Test(org.junit.jupiter.api.Test)

Example 7 with ValidationError

use of org.apache.archiva.repository.validation.ValidationError in project archiva by apache.

the class RepositoryGroupHandlerTest method validateRepositoryForUpdate.

@Test
void validateRepositoryForUpdate() throws IOException, RepositoryException {
    final String id = "test-group-12";
    try {
        RepositoryGroupHandler groupHandler = createHandler();
        EditableRepositoryGroup repositoryGroup = createRepository(id, "n-" + id);
        repositoryGroup.setMergedIndexTTL(5);
        groupHandler.put(repositoryGroup);
        CheckedResult<RepositoryGroup, Map<String, List<ValidationError>>> result = groupHandler.validateRepositoryForUpdate(repositoryGroup);
        assertNotNull(result);
        assertEquals(0, 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 ValidationError

use of org.apache.archiva.repository.validation.ValidationError in project archiva by apache.

the class RepositoryGroupHandlerTest method putWithCheck_invalid.

@Test
void putWithCheck_invalid() throws RepositoryException {
    final String id = "test-group-07";
    final String name = "n-" + id;
    try {
        RepositoryGroupHandler groupHandler = createHandler();
        BasicRepositoryGroupValidator checker = new BasicRepositoryGroupValidator(configurationHandler);
        RepositoryGroupConfiguration configuration = new RepositoryGroupConfiguration();
        configuration.setId("");
        configuration.setName(name);
        ArrayList<String> repos = new ArrayList<>();
        repos.add("internal");
        configuration.setRepositories(repos);
        CheckedResult<RepositoryGroup, Map<String, List<ValidationError>>> result = groupHandler.putWithCheck(configuration, checker);
        assertNull(groupHandler.get(id));
        assertNotNull(result.getResult());
        assertNotNull(result.getResult().get("id"));
        assertEquals(1, result.getResult().get("id").size());
        assertEquals(ISEMPTY, result.getResult().get("id").get(0).getType());
        assertFalse(hasGroupInConfig(id));
        assertFalse(hasGroupInConfig(""));
    } 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) ValidationError(org.apache.archiva.repository.validation.ValidationError) Map(java.util.Map) Test(org.junit.jupiter.api.Test)

Example 9 with ValidationError

use of org.apache.archiva.repository.validation.ValidationError in project archiva by apache.

the class ManagedRepositoryHandlerTest method validateRepositoryForUpdate.

@Test
void validateRepositoryForUpdate() throws IOException, RepositoryException {
    final String id = "test-repo-12";
    try {
        ManagedRepositoryHandler repoHandler = createHandler();
        EditableManagedRepository repository = createRepository(id, "n-" + id);
        repoHandler.put(repository);
        CheckedResult<ManagedRepository, Map<String, List<ValidationError>>> result = repoHandler.validateRepositoryForUpdate(repository);
        assertNotNull(result);
        assertEquals(0, result.getResult().size());
    } finally {
        removeRepositoryFromConfig(id);
    }
}
Also used : ManagedRepository(org.apache.archiva.repository.ManagedRepository) EditableManagedRepository(org.apache.archiva.repository.EditableManagedRepository) EditableManagedRepository(org.apache.archiva.repository.EditableManagedRepository) ValidationError(org.apache.archiva.repository.validation.ValidationError) Map(java.util.Map) Test(org.junit.jupiter.api.Test)

Example 10 with ValidationError

use of org.apache.archiva.repository.validation.ValidationError in project archiva by apache.

the class RemoteRepositoryHandlerTest method validateRepositoryForUpdate.

@Test
void validateRepositoryForUpdate() throws IOException, RepositoryException {
    final String id = "test-repo-12";
    try {
        RemoteRepositoryHandler repoHandler = createHandler();
        EditableRemoteRepository repository = createRepository(id, "n-" + id);
        repoHandler.put(repository);
        CheckedResult<RemoteRepository, Map<String, List<ValidationError>>> result = repoHandler.validateRepositoryForUpdate(repository);
        assertNotNull(result);
        assertEquals(0, result.getResult().size());
    } finally {
        removeRepositoryFromConfig(id);
    }
}
Also used : RemoteRepository(org.apache.archiva.repository.RemoteRepository) EditableRemoteRepository(org.apache.archiva.repository.EditableRemoteRepository) ValidationError(org.apache.archiva.repository.validation.ValidationError) Map(java.util.Map) EditableRemoteRepository(org.apache.archiva.repository.EditableRemoteRepository) Test(org.junit.jupiter.api.Test)

Aggregations

Map (java.util.Map)14 ValidationError (org.apache.archiva.repository.validation.ValidationError)14 Test (org.junit.jupiter.api.Test)12 EditableRepositoryGroup (org.apache.archiva.repository.EditableRepositoryGroup)6 EditableManagedRepository (org.apache.archiva.repository.EditableManagedRepository)4 EditableRemoteRepository (org.apache.archiva.repository.EditableRemoteRepository)4 ManagedRepository (org.apache.archiva.repository.ManagedRepository)4 RemoteRepository (org.apache.archiva.repository.RemoteRepository)4 RepositoryGroup (org.apache.archiva.repository.RepositoryGroup)4 RepositoryGroupConfiguration (org.apache.archiva.configuration.model.RepositoryGroupConfiguration)3 RepositoryException (org.apache.archiva.repository.RepositoryException)2 RepositoryGroup (org.apache.archiva.rest.api.v2.model.RepositoryGroup)2 ArchivaRestServiceException (org.apache.archiva.rest.api.v2.svc.ArchivaRestServiceException)2 ArrayList (java.util.ArrayList)1 ManagedRepositoryConfiguration (org.apache.archiva.configuration.model.ManagedRepositoryConfiguration)1 RemoteRepositoryConfiguration (org.apache.archiva.configuration.model.RemoteRepositoryConfiguration)1