Search in sources :

Example 26 with BuildClient

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

the class BuildEndpointTest method shouldFailToGetSshCredentialsForUserThatDidntTrigger.

@Test
public void shouldFailToGetSshCredentialsForUserThatDidntTrigger() {
    BuildClient client = new BuildClient(RestClientConfiguration.getConfiguration(Credentials.USER2));
    // 403
    assertThatThrownBy(() -> client.getSshCredentials(buildId)).hasCauseInstanceOf(ForbiddenException.class);
// means
// not
// authorized
}
Also used : BuildClient(org.jboss.pnc.client.BuildClient) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 27 with BuildClient

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

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

the class BuildEndpointTest method prepareData.

@BeforeClass
public static void prepareData() throws Exception {
    BuildClient bc = new BuildClient(RestClientConfiguration.asAnonymous());
    Iterator<Build> it = bc.getAll(null, null).iterator();
    buildId = it.next().getId();
    build2Id = it.next().getId();
    build3Id = it.next().getId();
}
Also used : Build(org.jboss.pnc.dto.Build) BuildClient(org.jboss.pnc.client.BuildClient) BeforeClass(org.junit.BeforeClass)

Example 29 with BuildClient

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

the class BuildEndpointTest method shouldSetBuiltArtifacts.

@Test
public void shouldSetBuiltArtifacts() throws RemoteResourceException {
    BuildClient client = new BuildClient(RestClientConfiguration.asSystem());
    String buildRecordId = buildId;
    RemoteCollection<Artifact> artifacts = client.getBuiltArtifacts(buildRecordId);
    Set<Integer> artifactIds = artifactIds(artifacts);
    assertThat(artifactIds).containsExactlyInAnyOrder(100, 101);
    client.setBuiltArtifacts(buildRecordId, Collections.singletonList("104"));
    RemoteCollection<Artifact> newBuiltArtifacts = client.getBuiltArtifacts(buildRecordId);
    Set<Integer> updatedArtifactIds = artifactIds(newBuiltArtifacts);
    assertThat(updatedArtifactIds).containsExactlyInAnyOrder(104);
}
Also used : BuildClient(org.jboss.pnc.client.BuildClient) Artifact(org.jboss.pnc.dto.Artifact) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 30 with BuildClient

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

the class BuildEndpointTest method shouldUpdateBuild.

@Test
@InSequence(20)
public void shouldUpdateBuild() throws ClientException {
    // given
    BuildClient client = new BuildClient(RestClientConfiguration.asSystem());
    Build original = client.getSpecific(buildId);
    Build toUpdate = original.toBuilder().status(BuildStatus.SYSTEM_ERROR).build();
    assertThat(toUpdate.getStatus()).isNotEqualTo(original.getStatus());
    // when
    client.update(buildId, toUpdate);
    Build updated = client.getSpecific(buildId);
    assertThat(updated.getId()).isEqualTo(buildId);
    assertThat(updated).isEqualToIgnoringGivenFields(original, "status", "lastUpdateTime");
    assertThat(updated.getStatus()).isNotEqualTo(original.getStatus());
    assertThat(updated.getStatus()).isEqualTo(toUpdate.getStatus());
}
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)

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