Search in sources :

Example 11 with Build

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());
}
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 12 with Build

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);
}
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 13 with Build

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

Example 14 with Build

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);
}
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 15 with Build

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);
}
Also used : Build(org.jboss.pnc.dto.Build) BuildClient(org.jboss.pnc.client.BuildClient) BuildPushParameters(org.jboss.pnc.dto.requests.BuildPushParameters) BuildPushResult(org.jboss.pnc.dto.BuildPushResult) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

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