use of org.jboss.pnc.dto.Build in project pnc by project-ncl.
the class BuildEndpointTest method shouldGetByStatusAndLog.
@Test
public void shouldGetByStatusAndLog() throws RemoteResourceException {
BuildClient client = new BuildClient(RestClientConfiguration.asAnonymous());
RemoteCollection<Build> builds = client.getAllByStatusAndLogContaining(BuildStatus.SUCCESS, "fox");
assertThat(builds.size()).isGreaterThan(0);
Build build = builds.iterator().next();
logger.info("Found build:" + build.toString());
}
use of org.jboss.pnc.dto.Build in project pnc by project-ncl.
the class BuildEndpointTest method shouldFilterByUsername.
@Test
public void shouldFilterByUsername() throws Exception {
BuildClient bc = new BuildClient(RestClientConfiguration.asAnonymous());
String username = "demo-user";
String rsql = "user.username==" + username;
List<String> userNames = bc.getAll(null, null, Optional.empty(), Optional.of(rsql)).getAll().stream().map(Build::getUser).map(User::getUsername).collect(Collectors.toList());
// from DatabaseDataInitializer
assertThat(userNames).hasSize(2);
assertThat(userNames).containsOnly(username);
}
use of org.jboss.pnc.dto.Build in project pnc by project-ncl.
the class BuildEndpointTest method shouldGetSpecificBuild.
@Test
@InSequence(10)
public void shouldGetSpecificBuild() throws ClientException {
BuildClient client = new BuildClient(RestClientConfiguration.asAnonymous());
Build dto = client.getSpecific(buildId);
// from DatabaseDataInitializer
assertThat(dto.getId()).isEqualTo(buildId);
// from DatabaseDataInitializer
assertThat(dto.getStatus()).isEqualTo(BuildStatus.SUCCESS);
assertThat(dto.getBuildConfigRevision()).isNotNull();
assertThat(dto.getBuildConfigRevision().getName()).isNotNull();
}
use of org.jboss.pnc.dto.Build in project pnc by project-ncl.
the class BuildEndpointTest method shouldFilterByBuildConfigurationNameLike.
@Test
public void shouldFilterByBuildConfigurationNameLike() throws Exception {
BuildClient client = new BuildClient(RestClientConfiguration.asAnonymous());
String buildConfigName = DatabaseDataInitializer.PNC_PROJECT_BUILD_CFG_ID;
BuildsFilterParameters filter = new BuildsFilterParameters();
filter.setBuildConfigName("*" + buildConfigName.substring(1, buildConfigName.length() - 2) + "*");
List<String> buildConfigNames = client.getAll(filter, null).getAll().stream().map(Build::getBuildConfigRevision).map(BuildConfigurationRevisionRef::getName).collect(Collectors.toList());
// from DatabaseDataInitializer
assertThat(buildConfigNames).hasSize(2);
assertThat(buildConfigNames).containsOnly(buildConfigName);
}
use of org.jboss.pnc.dto.Build in project pnc by project-ncl.
the class BuildPushTest method shouldPushBuild.
@Test
public void shouldPushBuild() throws ClientException {
BuildClient client = new BuildClient(RestClientConfiguration.asUser());
Build build = client.getSpecific(buildId);
// first push accepted
BuildPushParameters parameters = BuildPushParameters.builder().reimport(false).tagPrefix("test-tag").build();
BuildPushResult result = client.push(build.getId(), parameters);
String buildPushResultId = result.getId();
assertThat(result).isNotNull();
assertThat(result.getStatus()).isEqualTo(BuildPushStatus.ACCEPTED);
// second push rejected because already in process
assertThatThrownBy(() -> client.push(build.getId(), parameters)).hasCauseInstanceOf(ClientErrorException.class);
// should reject completion with invalid result id
assertThatThrownBy(() -> client.completePush(buildId, returnSuccessfulResult(buildId, "1111"))).hasCauseInstanceOf(ClientErrorException.class);
// successful complete of first push
client.completePush(buildId, returnSuccessfulResult(buildId, buildPushResultId));
// get result from db
BuildPushResult successPushResult = client.getPushResult(buildId);
assertThat(successPushResult.getStatus()).isEqualTo(BuildPushStatus.SUCCESS);
assertThat(successPushResult.getLogContext()).isEqualTo(buildPushResultId);
// next push should accept again
BuildPushResult result2 = client.push(build.getId(), parameters);
assertThat(result2).isNotNull();
assertThat(result2.getStatus()).isEqualTo(BuildPushStatus.ACCEPTED);
}
Aggregations