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);
}
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();
}
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);
}
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();
}
}
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);
}
Aggregations