Search in sources :

Example 51 with Build

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

the class BuildEndpointTest method shouldGetAndRemoveAttribute.

@Test
public void shouldGetAndRemoveAttribute() throws ClientException {
    // given
    BuildClient client = new BuildClient(RestClientConfiguration.asUser());
    Build original = client.getSpecific(buildId);
    final String key = "TEST_ATTRIBUTE";
    final String value = "test value";
    assertThat(original.getAttributes()).doesNotContainKey(key);
    // when
    client.addAttribute(buildId, key, value);
    // then
    Build withAttribute = client.getSpecific(buildId);
    assertThat(withAttribute.getAttributes()).contains(entry(key, value));
    // and when
    client.removeAttribute(buildId, key);
    // then
    Build withRemovedAttribute = client.getSpecific(buildId);
    assertThat(withRemovedAttribute.getAttributes()).doesNotContainKey(key);
}
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)

Example 52 with Build

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

the class BuildPushTest 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();
}
Also used : Build(org.jboss.pnc.dto.Build) BuildClient(org.jboss.pnc.client.BuildClient) BeforeClass(org.junit.BeforeClass)

Example 53 with Build

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

the class BuildPushTest method shouldRefuseToPushNoRebuildRequiredStatusBuild.

@Test
public void shouldRefuseToPushNoRebuildRequiredStatusBuild() throws ClientException {
    BuildClient client = new BuildClient(RestClientConfiguration.asSystem());
    Build build = client.getSpecific(build2Id);
    Build noRebuildStatus = build.toBuilder().status(BuildStatus.NO_REBUILD_REQUIRED).build();
    client.update(build2Id, noRebuildStatus);
    BuildPushParameters parameters = BuildPushParameters.builder().reimport(false).tagPrefix("test-tag").build();
    assertThatThrownBy(() -> client.push(build2Id, parameters)).hasCauseInstanceOf(ForbiddenException.class);
}
Also used : Build(org.jboss.pnc.dto.Build) BuildClient(org.jboss.pnc.client.BuildClient) BuildPushParameters(org.jboss.pnc.dto.requests.BuildPushParameters) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 54 with Build

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

the class RemoteBuildTest method runMultipleBuilds.

@Test
public void runMultipleBuilds() throws Exception {
    String bcID = prepareBuildConfiguration("test-build-execution");
    BuildParameters buildOptions = new BuildParameters();
    buildOptions.setBuildDependencies(false);
    buildOptions.setRebuildMode(RebuildMode.FORCE);
    for (int i = 0; i < 20; i++) {
        CompletableFuture<Build> executeBuild = buildConfigurationRestClient.executeBuild(bcID, buildOptions);
        Build build = executeBuild.get(1, TimeUnit.MINUTES);
        assertThat(build.getStatus().completedSuccessfully()).isTrue();
    }
}
Also used : BuildParameters(org.jboss.pnc.rest.api.parameters.BuildParameters) Build(org.jboss.pnc.dto.Build) DebugTest(org.jboss.pnc.test.category.DebugTest) Test(org.junit.Test)

Example 55 with Build

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

the class UserEndpointTest method testGetAllBuilds.

@Test
public void testGetAllBuilds() throws ClientException {
    UserClient client = new UserClient(RestClientConfiguration.asUser());
    BuildClient buildClient = new BuildClient(RestClientConfiguration.asAnonymous());
    BuildsFilterParameters params = new BuildsFilterParameters();
    params.setLatest(false);
    params.setRunning(false);
    RemoteCollection<Build> remoteBuilds = buildClient.getAllByStatusAndLogContaining(BuildStatus.SUCCESS, "fox");
    User user = remoteBuilds.iterator().next().getUser();
    RemoteCollection<Build> builds = client.getBuilds(user.getId(), params);
    assertThat(builds).isNotNull();
    assertThat(builds.size()).isGreaterThanOrEqualTo(1);
}
Also used : UserClient(org.jboss.pnc.client.UserClient) User(org.jboss.pnc.dto.User) Build(org.jboss.pnc.dto.Build) BuildClient(org.jboss.pnc.client.BuildClient) BuildsFilterParameters(org.jboss.pnc.rest.api.parameters.BuildsFilterParameters) Test(org.junit.Test) ContainerTest(org.jboss.pnc.test.category.ContainerTest)

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