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
}
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();
}
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();
}
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);
}
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());
}
Aggregations