Search in sources :

Example 31 with BuildClient

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

the class BuildEndpointTest method shouldSetDependentArtifacts.

@Test
public void shouldSetDependentArtifacts() throws RemoteResourceException {
    BuildClient client = new BuildClient(RestClientConfiguration.asSystem());
    String buildRecordId = buildId;
    RemoteCollection<Artifact> artifacts = client.getDependencyArtifacts(buildRecordId);
    Set<Integer> artifactIds = artifactIds(artifacts);
    assertThat(artifactIds).contains(104, 105);
    client.setDependentArtifacts(buildRecordId, Collections.singletonList("102"));
    RemoteCollection<Artifact> newDependencyArtifacts = client.getDependencyArtifacts(buildRecordId);
    Set<Integer> updatedArtifactIds = artifactIds(newDependencyArtifacts);
    assertThat(updatedArtifactIds).contains(102);
}
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 32 with BuildClient

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

the class BuildEndpointTest method shouldGetAndRemoveAttribute.

@Test
public void shouldGetAndRemoveAttribute() throws ClientException {
    // given
    BuildClient client = new BuildClient(RestClientConfiguration.asUser());
    Build original = client.getSpecific(buildId);
    final String key = "TEST_ATTRIBUTE";
    final String value = "test value";
    assertThat(original.getAttributes()).doesNotContainKey(key);
    // when
    client.addAttribute(buildId, key, value);
    // then
    Build withAttribute = client.getSpecific(buildId);
    assertThat(withAttribute.getAttributes()).contains(entry(key, value));
    // and when
    client.removeAttribute(buildId, key);
    // then
    Build withRemovedAttribute = client.getSpecific(buildId);
    assertThat(withRemovedAttribute.getAttributes()).doesNotContainKey(key);
}
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 33 with BuildClient

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

the class BuildEndpointTest method shouldNotApplyUnknownQualityLevel.

@Test
public void shouldNotApplyUnknownQualityLevel() throws RemoteResourceException {
    BuildClient client = new BuildClient(RestClientConfiguration.asUser());
    String REASON = "This artifact will be marked as WHITELISTED";
    assertThatThrownBy(() -> client.createBuiltArtifactsQualityLevelRevisions(buildId, "WHITELISTED", REASON)).hasCauseInstanceOf(BadRequestException.class);
}
Also used : BuildClient(org.jboss.pnc.client.BuildClient) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 34 with BuildClient

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

the class BuildEndpointTest method shouldFilterResults.

@Test
public void shouldFilterResults() throws Exception {
    BuildClient bc = new BuildClient(RestClientConfiguration.asAnonymous());
    String rsql = "id==" + buildId;
    List<String> filtered = bc.getAll(null, null, Optional.empty(), Optional.of(rsql)).getAll().stream().map(BuildRef::getId).collect(Collectors.toList());
    assertThat(filtered).containsExactly(buildId);
}
Also used : BuildClient(org.jboss.pnc.client.BuildClient) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 35 with BuildClient

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

the class BuildPushTest 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();
}
Also used : Build(org.jboss.pnc.dto.Build) BuildClient(org.jboss.pnc.client.BuildClient) BeforeClass(org.junit.BeforeClass)

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