Search in sources :

Example 21 with BuildClient

use of org.jboss.pnc.client.BuildClient in project pnc by project-ncl.

the class BuildEndpointTest method shouldFilterByBuildConfigurationNameAndInvalidUserId.

@Test
public void shouldFilterByBuildConfigurationNameAndInvalidUserId() throws Exception {
    BuildClient client = new BuildClient(RestClientConfiguration.asAnonymous());
    String buildConfigName = DatabaseDataInitializer.PNC_PROJECT_BUILD_CFG_ID;
    String username = "random-user-name";
    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).isEmpty();
}
Also used : Build(org.jboss.pnc.dto.Build) BuildClient(org.jboss.pnc.client.BuildClient) ArrayList(java.util.ArrayList) BuildsFilterParameters(org.jboss.pnc.rest.api.parameters.BuildsFilterParameters) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 22 with BuildClient

use of org.jboss.pnc.client.BuildClient in project pnc by project-ncl.

the class BuildEndpointTest method shouldGetBuilds.

@Test
@InSequence(10)
public void shouldGetBuilds() throws RemoteResourceException {
    BuildClient client = new BuildClient(RestClientConfiguration.asAnonymous());
    RemoteCollection<Build> all = client.getAll(null, null);
    assertThat(all).hasSize(4);
}
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 23 with BuildClient

use of org.jboss.pnc.client.BuildClient in project pnc by project-ncl.

the class BuildEndpointTest method shouldGetSCMArchiveLink.

@Test
public void shouldGetSCMArchiveLink() throws ClientException, ReflectiveOperationException {
    BuildClient client = new BuildClient(RestClientConfiguration.asAnonymous());
    // Disable redirects so we can test the actual response
    Field f = ClientBase.class.getDeclaredField("client");
    f.setAccessible(true);
    ResteasyClient reClient = (ResteasyClient) f.get(client);
    ApacheHttpClient43EngineWithRetry engine = (ApacheHttpClient43EngineWithRetry) reClient.httpEngine();
    engine.setFollowRedirects(false);
    Response internalScmArchiveLink = client.getInternalScmArchiveLink(buildId);
    assertThat(internalScmArchiveLink.getStatusInfo()).isEqualTo(Status.TEMPORARY_REDIRECT);
    assertThat(internalScmArchiveLink.getHeaderString("Location")).isNotEmpty();
}
Also used : Response(javax.ws.rs.core.Response) Field(java.lang.reflect.Field) ResteasyClient(org.jboss.resteasy.client.jaxrs.ResteasyClient) BuildClient(org.jboss.pnc.client.BuildClient) ApacheHttpClient43EngineWithRetry(org.jboss.pnc.client.ApacheHttpClient43EngineWithRetry) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 24 with BuildClient

use of org.jboss.pnc.client.BuildClient 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 25 with BuildClient

use of org.jboss.pnc.client.BuildClient in project pnc by project-ncl.

the class BuildEndpointTest method shouldGetAlignLogs.

@Test
public void shouldGetAlignLogs() throws ClientException, IOException {
    // when
    BuildClient client = new BuildClient(RestClientConfiguration.asAnonymous());
    Optional<InputStream> stream = client.getAlignLogs(buildId);
    // then
    assertThat(stream).isPresent();
    String log = IoUtils.readStreamAsString(stream.get());
    // from DatabaseDataInitializer
    assertThat(log).contains("alignment log");
}
Also used : InputStream(java.io.InputStream) BuildClient(org.jboss.pnc.client.BuildClient) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Aggregations

BuildClient (org.jboss.pnc.client.BuildClient)37 ContainerTest (org.jboss.pnc.test.category.ContainerTest)33 Test (org.junit.Test)33 Build (org.jboss.pnc.dto.Build)20 BuildsFilterParameters (org.jboss.pnc.rest.api.parameters.BuildsFilterParameters)7 InputStream (java.io.InputStream)5 Artifact (org.jboss.pnc.dto.Artifact)5 InSequence (org.jboss.arquillian.junit.InSequence)4 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 Response (javax.ws.rs.core.Response)3 ArtifactClient (org.jboss.pnc.client.ArtifactClient)3 BuildPushParameters (org.jboss.pnc.dto.requests.BuildPushParameters)3 Field (java.lang.reflect.Field)2 ApacheHttpClient43EngineWithRetry (org.jboss.pnc.client.ApacheHttpClient43EngineWithRetry)2 ClientException (org.jboss.pnc.client.ClientException)2 Configuration (org.jboss.pnc.client.Configuration)2 BuildConfigurationRevision (org.jboss.pnc.dto.BuildConfigurationRevision)2 BuildRef (org.jboss.pnc.dto.BuildRef)2 BeforeClass (org.junit.BeforeClass)2