Search in sources :

Example 1 with Repository

use of org.jboss.pnc.spi.datastore.repositories.api.Repository in project pnc by project-ncl.

the class ArtifactProviderTest method testStore.

@Test
public void testStore() {
    TargetRepository repo = TargetRepository.refBuilder().identifier("repo-id").repositoryPath("/repo/path").repositoryType(RepositoryType.MAVEN).build();
    final String identifier = "foo:bar:0.0.1";
    Artifact artifact = Artifact.builder().identifier(identifier).artifactQuality(ArtifactQuality.NEW).buildCategory(BuildCategory.STANDARD).build();
    Artifact stored = provider.store(artifact);
    assertThat(stored.getIdentifier()).isEqualTo(identifier);
    assertThat(stored.getId()).isNotNull();
    Mockito.verify(repository).save(ArgumentMatchers.argThat(a -> identifier.equals(a.getIdentifier())));
}
Also used : TargetRepository(org.jboss.pnc.dto.TargetRepository) TargetRepository(org.jboss.pnc.dto.TargetRepository) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) ArgumentMatchers(org.mockito.ArgumentMatchers) SortInfo(org.jboss.pnc.spi.datastore.repositories.api.SortInfo) Predicate(org.jboss.pnc.spi.datastore.repositories.api.Predicate) Mock(org.mockito.Mock) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) RunWith(org.junit.runner.RunWith) ArtifactQuality(org.jboss.pnc.enums.ArtifactQuality) ArtifactRevision(org.jboss.pnc.dto.ArtifactRevision) ArtifactRepository(org.jboss.pnc.spi.datastore.repositories.ArtifactRepository) Repository(org.jboss.pnc.spi.datastore.repositories.api.Repository) ArrayList(java.util.ArrayList) BuildRecordRepository(org.jboss.pnc.spi.datastore.repositories.BuildRecordRepository) RepositoryType(org.jboss.pnc.enums.RepositoryType) UserService(org.jboss.pnc.facade.util.UserService) DTOValidationException(org.jboss.pnc.facade.validation.DTOValidationException) Spy(org.mockito.Spy) Assert.fail(org.junit.Assert.fail) User(org.jboss.pnc.model.User) Before(org.junit.Before) InjectMocks(org.mockito.InjectMocks) ArtifactAudited(org.jboss.pnc.model.ArtifactAudited) Iterator(java.util.Iterator) ArtifactAuditedRepository(org.jboss.pnc.spi.datastore.repositories.ArtifactAuditedRepository) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) Artifact(org.jboss.pnc.dto.Artifact) Page(org.jboss.pnc.dto.response.Page) IdRev(org.jboss.pnc.model.IdRev) Mockito(org.mockito.Mockito) List(java.util.List) Condition(org.assertj.core.api.Condition) BuildCategory(org.jboss.pnc.enums.BuildCategory) MockitoJUnitRunner(org.mockito.junit.MockitoJUnitRunner) Assert.assertEquals(org.junit.Assert.assertEquals) TargetRepositoryRepository(org.jboss.pnc.spi.datastore.repositories.TargetRepositoryRepository) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Mockito.mock(org.mockito.Mockito.mock) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Artifact(org.jboss.pnc.dto.Artifact) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 Condition (org.assertj.core.api.Condition)1 Artifact (org.jboss.pnc.dto.Artifact)1 ArtifactRevision (org.jboss.pnc.dto.ArtifactRevision)1 TargetRepository (org.jboss.pnc.dto.TargetRepository)1 Page (org.jboss.pnc.dto.response.Page)1 ArtifactQuality (org.jboss.pnc.enums.ArtifactQuality)1 BuildCategory (org.jboss.pnc.enums.BuildCategory)1 RepositoryType (org.jboss.pnc.enums.RepositoryType)1 UserService (org.jboss.pnc.facade.util.UserService)1 DTOValidationException (org.jboss.pnc.facade.validation.DTOValidationException)1 ArtifactAudited (org.jboss.pnc.model.ArtifactAudited)1 IdRev (org.jboss.pnc.model.IdRev)1 User (org.jboss.pnc.model.User)1 ArtifactAuditedRepository (org.jboss.pnc.spi.datastore.repositories.ArtifactAuditedRepository)1 ArtifactRepository (org.jboss.pnc.spi.datastore.repositories.ArtifactRepository)1 BuildRecordRepository (org.jboss.pnc.spi.datastore.repositories.BuildRecordRepository)1