use of org.jboss.pnc.rest.api.parameters.BuildsFilterParameters 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.rest.api.parameters.BuildsFilterParameters in project pnc by project-ncl.
the class BuildConfigurationEndpointTest method testGetAllWithLatest.
@Test
@InSequence(10)
public void testGetAllWithLatest() throws RemoteResourceException {
BuildConfigurationClient client = new BuildConfigurationClient(RestClientConfiguration.asAnonymous());
RemoteCollection<BuildConfigurationWithLatestBuild> bcsWithLatest = client.getAllWithLatestBuild();
BuildsFilterParameters filter = new BuildsFilterParameters();
filter.setLatest(true);
// from DatabaseDataInitializer
assertThat(bcsWithLatest).hasSize(5);
for (BuildConfigurationWithLatestBuild bc : bcsWithLatest.getAll()) {
List<Build> associatedBuilds = new ArrayList<>(client.getBuilds(bc.getId(), filter).getAll());
if (bc.getLatestBuild() != null) {
assertThat(associatedBuilds).isNotEmpty();
assertThat(bc.getLatestBuild().getId()).isEqualTo(associatedBuilds.get(0).getId());
}
}
}
use of org.jboss.pnc.rest.api.parameters.BuildsFilterParameters 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.rest.api.parameters.BuildsFilterParameters in project pnc by project-ncl.
the class UserEndpointTest method testGetAllBuilds.
@Test
public void testGetAllBuilds() throws ClientException {
UserClient client = new UserClient(RestClientConfiguration.asUser());
BuildClient buildClient = new BuildClient(RestClientConfiguration.asAnonymous());
BuildsFilterParameters params = new BuildsFilterParameters();
params.setLatest(false);
params.setRunning(false);
RemoteCollection<Build> remoteBuilds = buildClient.getAllByStatusAndLogContaining(BuildStatus.SUCCESS, "fox");
User user = remoteBuilds.iterator().next().getUser();
RemoteCollection<Build> builds = client.getBuilds(user.getId(), params);
assertThat(builds).isNotNull();
assertThat(builds.size()).isGreaterThanOrEqualTo(1);
}
Aggregations