use of org.jboss.pnc.dto.BuildConfiguration in project pnc by project-ncl.
the class WebSocketClientTest method testNotificationCatcher.
@Test
public void testNotificationCatcher() throws Exception {
// with
WebSocketClient wsClient = new VertxWebSocketClient();
wsClient.connect(PNC_SOCKET_URL).get();
BuildConfigurationClient buildConfigurationClient = new BuildConfigurationClient(RestClientConfiguration.asUser());
BuildConfiguration bc = buildConfigurationClient.getAll().iterator().next();
// when
CompletableFuture<BuildChangedNotification> future = wsClient.catchBuildChangedNotification(withBuildConfiguration(bc.getId()), withBuildCompleted());
buildConfigurationClient.trigger(bc.getId(), new BuildParameters());
// then
assertThat(future).succeedsWithin(500, TimeUnit.MILLISECONDS);
BuildChangedNotification bcn = future.get();
assertThat(bcn).isNotNull();
assertThat(bcn.getBuild()).isNotNull();
assertThat(bcn.getBuild().getBuildConfigRevision().getId()).isEqualTo(bc.getId());
assertThat(bcn.getBuild().getStatus().isFinal()).isTrue();
wsClient.disconnect();
}
use of org.jboss.pnc.dto.BuildConfiguration in project pnc by project-ncl.
the class RSQLPredicateProducerTest method testPredicateIsNull.
@Test
public void testPredicateIsNull() {
Predicate<BuildConfiguration> streamPredicate = producer.getStreamPredicate("name=ISNULL=true");
BuildConfiguration fooBarG = BuildConfiguration.builder().name("FooBar").buildType(BuildType.GRADLE).build();
BuildConfiguration nullName = BuildConfiguration.builder().name(null).buildType(BuildType.MVN).build();
List<BuildConfiguration> filtered = Arrays.asList(fooBarG, nullName).stream().filter(streamPredicate).collect(Collectors.toList());
assertEquals(1, filtered.size());
assertNull(filtered.get(0).getName());
assertEquals(BuildType.MVN, filtered.get(0).getBuildType());
}
use of org.jboss.pnc.dto.BuildConfiguration in project pnc by project-ncl.
the class RSQLPredicateProducerTest method testStreamPredicate.
@Test
public void testStreamPredicate() {
Predicate<BuildConfiguration> streamPredicate = producer.getStreamPredicate("name==\"FooBar\"");
BuildConfiguration fooBar = BuildConfiguration.builder().name("FooBar").build();
BuildConfiguration fooBaz = BuildConfiguration.builder().name("FooBaz").build();
List<BuildConfiguration> filtered = Arrays.asList(fooBar, fooBaz).stream().filter(streamPredicate).collect(Collectors.toList());
assertEquals(1, filtered.size());
assertEquals("FooBar", filtered.get(0).getName());
}
use of org.jboss.pnc.dto.BuildConfiguration in project pnc by project-ncl.
the class RSQLPredicateProducerTest method testPredicateLike.
@Test
public void testPredicateLike() {
Predicate<BuildConfiguration> streamPredicate = producer.getStreamPredicate("name=LIKE=\"%Bar\"");
BuildConfiguration fooBarG = BuildConfiguration.builder().name("FooBar").buildType(BuildType.GRADLE).build();
BuildConfiguration fooBarM = BuildConfiguration.builder().name("FooBar").buildType(BuildType.MVN).build();
BuildConfiguration fooBazG = BuildConfiguration.builder().name("FooBaz").buildType(BuildType.GRADLE).build();
List<BuildConfiguration> filtered = Arrays.asList(fooBarG, fooBarM, fooBazG).stream().filter(streamPredicate).collect(Collectors.toList());
assertEquals(2, filtered.size());
assertEquals("FooBar", filtered.get(0).getName());
assertEquals(BuildType.GRADLE, filtered.get(0).getBuildType());
assertEquals("FooBar", filtered.get(1).getName());
assertEquals(BuildType.MVN, filtered.get(1).getBuildType());
}
use of org.jboss.pnc.dto.BuildConfiguration in project pnc by project-ncl.
the class RSQLPredicateProducerTest method testStreamPredicateUnknownQuery.
@Test
public void testStreamPredicateUnknownQuery() {
Predicate<BuildConfiguration> streamPredicate = producer.getStreamPredicate("fieldThatDoesNotExists==\"FooBar\"");
BuildConfiguration fooBar = BuildConfiguration.builder().name("FooBar").build();
BuildConfiguration fooBaz = BuildConfiguration.builder().name("FooBaz").build();
try {
List<BuildConfiguration> filtered = Arrays.asList(fooBar, fooBaz).stream().filter(streamPredicate).collect(Collectors.toList());
fail("Exception expected");
} catch (RuntimeException ex) {
// ok
}
}
Aggregations