Search in sources :

Example 46 with Build

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

the class ArtifactEndpointTest method shouldGetBuildsThatDependsOnArtifact.

@Test
public void shouldGetBuildsThatDependsOnArtifact() throws RemoteResourceException {
    ArtifactClient client = new ArtifactClient(RestClientConfiguration.asUser());
    RemoteCollection<Build> builds = client.getDependantBuilds(artifactRest3.getId());
    assertThat(builds).hasSize(2);
}
Also used : Build(org.jboss.pnc.dto.Build) ArtifactClient(org.jboss.pnc.client.ArtifactClient) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 47 with Build

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

the class BuildConfigurationEndpointTest method testGetAllWithLatest.

@Test
@InSequence(10)
public void testGetAllWithLatest() throws RemoteResourceException {
    BuildConfigurationClient client = new BuildConfigurationClient(RestClientConfiguration.asAnonymous());
    RemoteCollection<BuildConfigurationWithLatestBuild> bcsWithLatest = client.getAllWithLatestBuild();
    BuildsFilterParameters filter = new BuildsFilterParameters();
    filter.setLatest(true);
    // from DatabaseDataInitializer
    assertThat(bcsWithLatest).hasSize(5);
    for (BuildConfigurationWithLatestBuild bc : bcsWithLatest.getAll()) {
        List<Build> associatedBuilds = new ArrayList<>(client.getBuilds(bc.getId(), filter).getAll());
        if (bc.getLatestBuild() != null) {
            assertThat(associatedBuilds).isNotEmpty();
            assertThat(bc.getLatestBuild().getId()).isEqualTo(associatedBuilds.get(0).getId());
        }
    }
}
Also used : Build(org.jboss.pnc.dto.Build) BuildConfigurationWithLatestBuild(org.jboss.pnc.dto.BuildConfigurationWithLatestBuild) ArrayList(java.util.ArrayList) BuildConfigurationWithLatestBuild(org.jboss.pnc.dto.BuildConfigurationWithLatestBuild) BuildConfigurationClient(org.jboss.pnc.client.BuildConfigurationClient) BuildsFilterParameters(org.jboss.pnc.rest.api.parameters.BuildsFilterParameters) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test) InSequence(org.jboss.arquillian.junit.InSequence)

Example 48 with Build

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

the class BuildEndpointTest method shouldFilterByNotExistingBuildConfigurationName.

@Test
public void shouldFilterByNotExistingBuildConfigurationName() throws Exception {
    BuildClient client = new BuildClient(RestClientConfiguration.asAnonymous());
    String buildConfigName = "SomeRandomName";
    BuildsFilterParameters filter = new BuildsFilterParameters();
    filter.setBuildConfigName(buildConfigName);
    List<String> buildConfigNames = client.getAll(filter, null).getAll().stream().map(Build::getBuildConfigRevision).map(BuildConfigurationRevisionRef::getName).collect(Collectors.toList());
    assertThat(buildConfigNames).isEmpty();
}
Also used : Build(org.jboss.pnc.dto.Build) BuildClient(org.jboss.pnc.client.BuildClient) BuildsFilterParameters(org.jboss.pnc.rest.api.parameters.BuildsFilterParameters) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 49 with Build

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

the class BuildEndpointTest method prepareData.

@BeforeClass
public static void prepareData() throws Exception {
    BuildClient bc = new BuildClient(RestClientConfiguration.asAnonymous());
    Iterator<Build> it = bc.getAll(null, null).iterator();
    buildId = it.next().getId();
    build2Id = it.next().getId();
    build3Id = it.next().getId();
}
Also used : Build(org.jboss.pnc.dto.Build) BuildClient(org.jboss.pnc.client.BuildClient) BeforeClass(org.junit.BeforeClass)

Example 50 with Build

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

the class BuildEndpointTest method shouldUpdateBuild.

@Test
@InSequence(20)
public void shouldUpdateBuild() throws ClientException {
    // given
    BuildClient client = new BuildClient(RestClientConfiguration.asSystem());
    Build original = client.getSpecific(buildId);
    Build toUpdate = original.toBuilder().status(BuildStatus.SYSTEM_ERROR).build();
    assertThat(toUpdate.getStatus()).isNotEqualTo(original.getStatus());
    // when
    client.update(buildId, toUpdate);
    Build updated = client.getSpecific(buildId);
    assertThat(updated.getId()).isEqualTo(buildId);
    assertThat(updated).isEqualToIgnoringGivenFields(original, "status", "lastUpdateTime");
    assertThat(updated.getStatus()).isNotEqualTo(original.getStatus());
    assertThat(updated.getStatus()).isEqualTo(toUpdate.getStatus());
}
Also used : Build(org.jboss.pnc.dto.Build) BuildClient(org.jboss.pnc.client.BuildClient) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test) InSequence(org.jboss.arquillian.junit.InSequence)

Aggregations

Build (org.jboss.pnc.dto.Build)71 Test (org.junit.Test)52 ContainerTest (org.jboss.pnc.test.category.ContainerTest)35 BuildClient (org.jboss.pnc.client.BuildClient)20 BuildRecord (org.jboss.pnc.model.BuildRecord)18 BuildTask (org.jboss.pnc.spi.coordinator.BuildTask)16 BuildStatus (org.jboss.pnc.enums.BuildStatus)15 GroupBuild (org.jboss.pnc.dto.GroupBuild)14 BuildPageInfo (org.jboss.pnc.facade.providers.api.BuildPageInfo)14 ArrayList (java.util.ArrayList)12 BuildConfiguration (org.jboss.pnc.dto.BuildConfiguration)11 HashSet (java.util.HashSet)10 List (java.util.List)10 Set (java.util.Set)10 Logger (org.slf4j.Logger)10 LoggerFactory (org.slf4j.LoggerFactory)10 Date (java.util.Date)9 Page (org.jboss.pnc.dto.response.Page)9 BuildMapper (org.jboss.pnc.mapper.api.BuildMapper)9 BuildConfigurationAudited (org.jboss.pnc.model.BuildConfigurationAudited)9