Search in sources :

Example 11 with BuildsFilterParameters

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

the class BuildEndpointTest method shouldFilterByBuildConfigurationNameNotLike.

@Test
public void shouldFilterByBuildConfigurationNameNotLike() 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).doesNotContain(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 12 with BuildsFilterParameters

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

the class BuildConfigurationEndpointTest method testGetAllWithLatest.

@Test
@InSequence(10)
public void testGetAllWithLatest() throws RemoteResourceException {
    BuildConfigurationClient client = new BuildConfigurationClient(RestClientConfiguration.asAnonymous());
    RemoteCollection<BuildConfigurationWithLatestBuild> bcsWithLatest = client.getAllWithLatestBuild();
    BuildsFilterParameters filter = new BuildsFilterParameters();
    filter.setLatest(true);
    // from DatabaseDataInitializer
    assertThat(bcsWithLatest).hasSize(5);
    for (BuildConfigurationWithLatestBuild bc : bcsWithLatest.getAll()) {
        List<Build> associatedBuilds = new ArrayList<>(client.getBuilds(bc.getId(), filter).getAll());
        if (bc.getLatestBuild() != null) {
            assertThat(associatedBuilds).isNotEmpty();
            assertThat(bc.getLatestBuild().getId()).isEqualTo(associatedBuilds.get(0).getId());
        }
    }
}
Also used : Build(org.jboss.pnc.dto.Build) BuildConfigurationWithLatestBuild(org.jboss.pnc.dto.BuildConfigurationWithLatestBuild) ArrayList(java.util.ArrayList) BuildConfigurationWithLatestBuild(org.jboss.pnc.dto.BuildConfigurationWithLatestBuild) BuildConfigurationClient(org.jboss.pnc.client.BuildConfigurationClient) BuildsFilterParameters(org.jboss.pnc.rest.api.parameters.BuildsFilterParameters) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test) InSequence(org.jboss.arquillian.junit.InSequence)

Example 13 with BuildsFilterParameters

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

the class BuildEndpointTest method shouldFilterByNotExistingBuildConfigurationName.

@Test
public void shouldFilterByNotExistingBuildConfigurationName() throws Exception {
    BuildClient client = new BuildClient(RestClientConfiguration.asAnonymous());
    String buildConfigName = "SomeRandomName";
    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());
    assertThat(buildConfigNames).isEmpty();
}
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 14 with BuildsFilterParameters

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

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