Search in sources :

Example 1 with BuildsFilterParameters

use of org.jboss.pnc.rest.api.parameters.BuildsFilterParameters in project pnc by project-ncl.

the class BuildTest method shouldTriggerBuildWithADependencyAndFinishWithoutProblems.

@Test
public void shouldTriggerBuildWithADependencyAndFinishWithoutProblems() throws ClientException {
    // given - A BC with a dependency on pnc-1.0.0.DR1
    BuildConfiguration buildConfigurationParent = buildConfigurationClient.getAll(Optional.empty(), Optional.of("name==dependency-analysis-1.3")).iterator().next();
    // Update dependency
    BuildConfiguration buildConfigurationChild = buildConfigurationClient.getAll(Optional.empty(), Optional.of("name==pnc-1.0.0.DR1")).iterator().next();
    BuildConfiguration updatedBuildConfigurationChild = buildConfigurationChild.toBuilder().description(buildConfigurationChild.getDescription() + ".").build();
    buildConfigurationClient.update(buildConfigurationChild.getId(), updatedBuildConfigurationChild);
    // The update of the description should not have changed the lastModificationDate
    assertThat(buildConfigurationChild.getModificationTime()).isEqualTo(updatedBuildConfigurationChild.getModificationTime());
    // when
    Build build = buildConfigurationClient.trigger(buildConfigurationParent.getId(), getBuildParameters(false, true));
    BuildsFilterParameters parameters = new BuildsFilterParameters();
    parameters.setRunning(true);
    RemoteCollection<Build> childBuildCol = buildConfigurationClient.getBuilds(buildConfigurationChild.getId(), parameters);
    Build childBuild = childBuildCol.getAll().iterator().next();
    // then
    assertThat(childBuildCol.size()).isEqualTo(1);
    assertThat(buildConfigurationParent.getDependencies().size()).isEqualTo(1);
    assertThat(build).isNotNull().extracting("id").isNotNull().isNotEqualTo("");
    EnumSet<BuildStatus> isIn = EnumSet.of(BuildStatus.SUCCESS);
    ResponseUtils.waitSynchronouslyFor(() -> buildToFinish(build.getId(), isIn, null), 15, TimeUnit.SECONDS);
    ResponseUtils.waitSynchronouslyFor(() -> buildToFinish(childBuild.getId(), isIn, null), 15, TimeUnit.SECONDS);
}
Also used : BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) GroupBuild(org.jboss.pnc.dto.GroupBuild) Build(org.jboss.pnc.dto.Build) BuildStatus(org.jboss.pnc.enums.BuildStatus) BuildsFilterParameters(org.jboss.pnc.rest.api.parameters.BuildsFilterParameters) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 2 with BuildsFilterParameters

use of org.jboss.pnc.rest.api.parameters.BuildsFilterParameters in project pnc by project-ncl.

the class BuildEndpointTest method shouldFilterByBuildConfigurationName.

@Test
public void shouldFilterByBuildConfigurationName() throws Exception {
    BuildClient client = new BuildClient(RestClientConfiguration.asAnonymous());
    String buildConfigName = DatabaseDataInitializer.PNC_PROJECT_BUILD_CFG_ID;
    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());
    // 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 3 with BuildsFilterParameters

use of org.jboss.pnc.rest.api.parameters.BuildsFilterParameters in project pnc by project-ncl.

the class BuildEndpointTest method shouldFilterByBuildConfigurationNameAndUserId.

@Test
public void shouldFilterByBuildConfigurationNameAndUserId() throws Exception {
    BuildClient client = new BuildClient(RestClientConfiguration.asAnonymous());
    String buildConfigName = DatabaseDataInitializer.PNC_PROJECT_BUILD_CFG_ID;
    String username = "pnc-admin";
    String rsql = "user.username==" + username;
    BuildsFilterParameters filter = new BuildsFilterParameters();
    filter.setBuildConfigName(buildConfigName);
    List<Build> builds = new ArrayList<>(client.getAll(filter, null, Optional.empty(), Optional.of(rsql)).getAll());
    assertThat(builds).hasSize(2);
    assertThat(builds.stream().map(Build::getBuildConfigRevision).map(BuildConfigurationRevisionRef::getName).allMatch(name -> name.equals(buildConfigName)));
    assertThat(builds.stream().map(Build::getUser).map(User::getUsername).allMatch(name -> name.equals(username)));
}
Also used : Arquillian(org.jboss.arquillian.junit.Arquillian) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) LoggerFactory(org.slf4j.LoggerFactory) User(org.jboss.pnc.dto.User) BadRequestException(javax.ws.rs.BadRequestException) BuildConfigurationRevision(org.jboss.pnc.dto.BuildConfigurationRevision) Deployments(org.jboss.pnc.integration.setup.Deployments) ClientBase(org.jboss.pnc.client.ClientBase) BuildRef(org.jboss.pnc.dto.BuildRef) EnterpriseArchive(org.jboss.shrinkwrap.api.spec.EnterpriseArchive) BASE_REST_PATH(org.jboss.pnc.integration.setup.RestClientConfiguration.BASE_REST_PATH) Set(java.util.Set) MAX_PAGE_SIZE(org.jboss.pnc.rest.configuration.Constants.MAX_PAGE_SIZE) Category(org.junit.experimental.categories.Category) Instant(java.time.Instant) BuildStatus(org.jboss.pnc.enums.BuildStatus) Collectors(java.util.stream.Collectors) List(java.util.List) Response(javax.ws.rs.core.Response) ApacheHttpClient43EngineWithRetry(org.jboss.pnc.client.ApacheHttpClient43EngineWithRetry) ResteasyClient(org.jboss.resteasy.client.jaxrs.ResteasyClient) NotAuthorizedException(javax.ws.rs.NotAuthorizedException) Optional(java.util.Optional) RestAssured.given(io.restassured.RestAssured.given) BeforeClass(org.junit.BeforeClass) BuildClient(org.jboss.pnc.client.BuildClient) Credentials(org.jboss.pnc.integration.setup.Credentials) BuildPushParameters(org.jboss.pnc.dto.requests.BuildPushParameters) RunWith(org.junit.runner.RunWith) ArtifactQuality(org.jboss.pnc.enums.ArtifactQuality) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) RemoteCollection(org.jboss.pnc.client.RemoteCollection) ArrayList(java.util.ArrayList) ContainerTest(org.jboss.pnc.test.category.ContainerTest) HashSet(java.util.HashSet) ClientException(org.jboss.pnc.client.ClientException) Configuration(org.jboss.pnc.client.Configuration) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) Attributes(org.jboss.pnc.constants.Attributes) Status(javax.ws.rs.core.Response.Status) BuildsFilterParameters(org.jboss.pnc.rest.api.parameters.BuildsFilterParameters) Logger(org.slf4j.Logger) ForbiddenException(javax.ws.rs.ForbiddenException) Iterator(java.util.Iterator) IoUtils(org.jboss.pnc.common.util.IoUtils) DatabaseDataInitializer(org.jboss.pnc.demo.data.DatabaseDataInitializer) Test(org.junit.Test) IOException(java.io.IOException) InSequence(org.jboss.arquillian.junit.InSequence) Artifact(org.jboss.pnc.dto.Artifact) Field(java.lang.reflect.Field) RestClientConfiguration(org.jboss.pnc.integration.setup.RestClientConfiguration) Assertions.entry(org.assertj.core.api.Assertions.entry) Build(org.jboss.pnc.dto.Build) Deployment(org.jboss.arquillian.container.test.api.Deployment) ArtifactClient(org.jboss.pnc.client.ArtifactClient) RemoteResourceException(org.jboss.pnc.client.RemoteResourceException) BuildConfigurationRevisionRef(org.jboss.pnc.dto.BuildConfigurationRevisionRef) BuildCategory(org.jboss.pnc.enums.BuildCategory) Collections(java.util.Collections) InputStream(java.io.InputStream) User(org.jboss.pnc.dto.User) Build(org.jboss.pnc.dto.Build) BuildClient(org.jboss.pnc.client.BuildClient) BuildConfigurationRevisionRef(org.jboss.pnc.dto.BuildConfigurationRevisionRef) ArrayList(java.util.ArrayList) BuildsFilterParameters(org.jboss.pnc.rest.api.parameters.BuildsFilterParameters) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 4 with BuildsFilterParameters

use of org.jboss.pnc.rest.api.parameters.BuildsFilterParameters 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 5 with BuildsFilterParameters

use of org.jboss.pnc.rest.api.parameters.BuildsFilterParameters in project bacon by project-ncl.

the class AbstractBuildListCommand method getAll.

public Collection<Build> getAll(String sort, String query) throws RemoteResourceException {
    BuildsFilterParameters filter = new BuildsFilterParameters();
    filter.setLatest(latest);
    filter.setRunning(running);
    return getAll(filter, sort, query);
}
Also used : BuildsFilterParameters(org.jboss.pnc.rest.api.parameters.BuildsFilterParameters)

Aggregations

BuildsFilterParameters (org.jboss.pnc.rest.api.parameters.BuildsFilterParameters)14 Build (org.jboss.pnc.dto.Build)13 ContainerTest (org.jboss.pnc.test.category.ContainerTest)9 Test (org.junit.Test)9 BuildClient (org.jboss.pnc.client.BuildClient)7 ArrayList (java.util.ArrayList)3 ClientException (org.jboss.pnc.client.ClientException)3 GroupBuild (org.jboss.pnc.dto.GroupBuild)3 InSequence (org.jboss.arquillian.junit.InSequence)2 BuildConfigurationClient (org.jboss.pnc.client.BuildConfigurationClient)2 RemoteResourceException (org.jboss.pnc.client.RemoteResourceException)2 BuildStatus (org.jboss.pnc.enums.BuildStatus)2 RestAssured.given (io.restassured.RestAssured.given)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 Field (java.lang.reflect.Field)1 Instant (java.time.Instant)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1