Search in sources :

Example 11 with Artifact

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

the class ArtifactProviderTest method testUpdate.

@Test
public void testUpdate() {
    fillRepository(artifacts);
    Artifact toUpdate = Artifact.builder().id(artifact1.getId().toString()).artifactQuality(// Modified field
    ArtifactQuality.BLACKLISTED).buildCategory(BuildCategory.STANDARD).identifier(artifact1.getIdentifier()).md5(artifact1.getMd5()).sha1(artifact1.getSha1()).sha256(artifact1.getSha256()).build();
    // assert that original is
    assertThat(artifact1.getArtifactQuality()).isNotEqualTo(ArtifactQuality.BLACKLISTED);
    // different
    Artifact updated = provider.update(Integer.toString(artifact1.getId()), toUpdate);
    assertThat(updated.getId()).isEqualTo(artifact1.getId().toString());
    // modified
    assertThat(updated.getArtifactQuality()).isEqualTo(ArtifactQuality.BLACKLISTED);
    assertThat(updated.getIdentifier()).isEqualTo(artifact1.getIdentifier());
    assertThat(updated.getSha256()).isEqualTo(artifact1.getSha256());
}
Also used : Artifact(org.jboss.pnc.dto.Artifact) Test(org.junit.Test)

Example 12 with Artifact

use of org.jboss.pnc.dto.Artifact 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 13 with Artifact

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

Example 14 with Artifact

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

the class BuildEndpointTest method shouldModifyBuiltArtifactQualityLevels.

@Test
public void shouldModifyBuiltArtifactQualityLevels() throws RemoteResourceException {
    BuildClient client = new BuildClient(RestClientConfiguration.asSystem());
    String buildRecordId = build3Id;
    String REASON = "This artifact has become old enough";
    ArtifactClient artifactClient = new ArtifactClient(RestClientConfiguration.asSystem());
    Artifact newArtifact = artifactClient.create(Artifact.builder().artifactQuality(ArtifactQuality.NEW).buildCategory(BuildCategory.STANDARD).filename("builtArtifactInsertNew.jar").identifier("integration-test:built-artifact-new:jar:1.0").targetRepository(artifactClient.getSpecific("100").getTargetRepository()).md5("insert-md5-22").sha1("insert-22").sha256("insert-22").size(10L).build());
    client.setBuiltArtifacts(build3Id, Collections.singletonList(newArtifact.getId()));
    client.createBuiltArtifactsQualityLevelRevisions(buildRecordId, "BLACKListed", REASON);
    RemoteCollection<Artifact> artifacts = client.getBuiltArtifacts(buildRecordId);
    for (Artifact artifact : artifacts) {
        assertThat(artifact.getArtifactQuality()).isEqualTo(ArtifactQuality.BLACKLISTED);
        assertThat(artifact.getQualityLevelReason()).isEqualTo(REASON);
        assertThat(artifact.getModificationUser().getUsername()).isEqualTo("system");
    }
    Build withAttribute = client.getSpecific(buildRecordId);
    assertThat(withAttribute.getAttributes()).contains(entry(Attributes.BLACKLIST_REASON, REASON));
}
Also used : Build(org.jboss.pnc.dto.Build) BuildClient(org.jboss.pnc.client.BuildClient) ArtifactClient(org.jboss.pnc.client.ArtifactClient) Artifact(org.jboss.pnc.dto.Artifact) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 15 with Artifact

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

the class ProductMilestoneEndpointTest method testGetDeliveredArtifacts.

@Test
public void testGetDeliveredArtifacts() throws ClientException {
    ProductMilestoneClient client = new ProductMilestoneClient(RestClientConfiguration.asAnonymous());
    RemoteCollection<Artifact> all = client.getDeliveredArtifacts(milestoneId);
    assertThat(all).hasSize(3);
}
Also used : ProductMilestoneClient(org.jboss.pnc.client.ProductMilestoneClient) Artifact(org.jboss.pnc.dto.Artifact) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Aggregations

Artifact (org.jboss.pnc.dto.Artifact)31 Test (org.junit.Test)28 ContainerTest (org.jboss.pnc.test.category.ContainerTest)24 ArtifactClient (org.jboss.pnc.client.ArtifactClient)22 BuildClient (org.jboss.pnc.client.BuildClient)4 ArrayList (java.util.ArrayList)3 ArtifactRevision (org.jboss.pnc.dto.ArtifactRevision)3 List (java.util.List)2 TargetRepository (org.jboss.pnc.dto.TargetRepository)2 DTOValidationException (org.jboss.pnc.facade.validation.DTOValidationException)2 Before (org.junit.Before)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2 Iterator (java.util.Iterator)1 Collectors (java.util.stream.Collectors)1 ApplicationScoped (javax.enterprise.context.ApplicationScoped)1 Inject (javax.inject.Inject)1 BadRequestException (javax.ws.rs.BadRequestException)1 ClientErrorException (javax.ws.rs.ClientErrorException)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 Condition (org.assertj.core.api.Condition)1