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