Search in sources :

Example 1 with TargetRepository

use of org.jboss.pnc.dto.TargetRepository 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)

Example 2 with TargetRepository

use of org.jboss.pnc.dto.TargetRepository in project bacon by project-ncl.

the class OfflineManifestGeneratorTest method mockBuildsAndArtifacts.

private void mockBuildsAndArtifacts() {
    TargetRepository repository = TargetRepository.refBuilder().identifier("repo1").repositoryType(RepositoryType.MAVEN).build();
    builds = new HashMap<>();
    artifacts = new HashSet<>();
    for (int i = 1; i <= 5; i++) {
        String buildName = "build" + i;
        List<Artifact> builtArtifacts = new ArrayList<>();
        for (int j = 1; j <= i * 2; j++) {
            builtArtifacts.add(Artifact.builder().targetRepository(repository).identifier("org:built:jar:" + i + "." + j).filename("built-" + i + "." + j + ".jar").sha256("built_" + i + "_" + j).build());
        }
        List<Artifact> dependencies = new ArrayList<>();
        for (int k = 1; k <= i * 3; k++) {
            dependencies.add(Artifact.builder().targetRepository(repository).identifier("org:dependency:jar:" + i + "." + k).filename("dependency-" + i + "." + k + ".jar").sha256("dependency_" + i + "_" + k).build());
        }
        PncBuild build = new PncBuild();
        build.setId(buildName);
        build.setName(buildName);
        build.addBuiltArtifacts(builtArtifacts);
        build.addDependencyArtifacts(dependencies);
        builds.put(buildName, build);
        artifacts.addAll(builtArtifacts);
        artifacts.addAll(dependencies);
    }
}
Also used : TargetRepository(org.jboss.pnc.dto.TargetRepository) ArrayList(java.util.ArrayList) PncBuild(org.jboss.pnc.bacon.pig.impl.pnc.PncBuild) Artifact(org.jboss.pnc.dto.Artifact)

Aggregations

ArrayList (java.util.ArrayList)2 Artifact (org.jboss.pnc.dto.Artifact)2 TargetRepository (org.jboss.pnc.dto.TargetRepository)2 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 PncBuild (org.jboss.pnc.bacon.pig.impl.pnc.PncBuild)1 ArtifactRevision (org.jboss.pnc.dto.ArtifactRevision)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