Search in sources :

Example 81 with BuildConfiguration

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();
}
Also used : BuildChangedNotificationPredicates.withBuildConfiguration(org.jboss.pnc.restclient.websocket.predicates.BuildChangedNotificationPredicates.withBuildConfiguration) BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) GroupBuildParameters(org.jboss.pnc.rest.api.parameters.GroupBuildParameters) BuildParameters(org.jboss.pnc.rest.api.parameters.BuildParameters) WebSocketClient(org.jboss.pnc.restclient.websocket.WebSocketClient) VertxWebSocketClient(org.jboss.pnc.restclient.websocket.VertxWebSocketClient) BuildConfigurationClient(org.jboss.pnc.client.BuildConfigurationClient) AdvancedBuildConfigurationClient(org.jboss.pnc.restclient.AdvancedBuildConfigurationClient) BuildChangedNotification(org.jboss.pnc.dto.notification.BuildChangedNotification) GroupBuildChangedNotification(org.jboss.pnc.dto.notification.GroupBuildChangedNotification) VertxWebSocketClient(org.jboss.pnc.restclient.websocket.VertxWebSocketClient) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 82 with BuildConfiguration

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());
}
Also used : BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) Test(org.junit.Test)

Example 83 with BuildConfiguration

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());
}
Also used : BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) Test(org.junit.Test)

Example 84 with BuildConfiguration

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());
}
Also used : BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) Test(org.junit.Test)

Example 85 with BuildConfiguration

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
    }
}
Also used : BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) Test(org.junit.Test)

Aggregations

BuildConfiguration (org.jboss.pnc.dto.BuildConfiguration)90 Test (org.junit.Test)65 ContainerTest (org.jboss.pnc.test.category.ContainerTest)45 BuildConfigurationClient (org.jboss.pnc.client.BuildConfigurationClient)31 HashMap (java.util.HashMap)17 InSequence (org.jboss.arquillian.junit.InSequence)17 Build (org.jboss.pnc.dto.Build)13 GroupBuild (org.jboss.pnc.dto.GroupBuild)12 SCMRepository (org.jboss.pnc.dto.SCMRepository)10 Test (org.junit.jupiter.api.Test)10 BuildConfigurationRef (org.jboss.pnc.dto.BuildConfigurationRef)9 Instant (java.time.Instant)8 GroupConfiguration (org.jboss.pnc.dto.GroupConfiguration)7 BuildStatus (org.jboss.pnc.enums.BuildStatus)7 GroupConfigurationClient (org.jboss.pnc.client.GroupConfigurationClient)5 Logger (org.slf4j.Logger)5 LoggerFactory (org.slf4j.LoggerFactory)5 ArrayList (java.util.ArrayList)4 BuildConfigurationRevision (org.jboss.pnc.dto.BuildConfigurationRevision)4 HashSet (java.util.HashSet)3