Search in sources :

Example 1 with BuildParameters

use of org.jboss.pnc.rest.api.parameters.BuildParameters in project pnc by project-ncl.

the class BuildParametersValidatorTest method testBuildParametersValidation.

@Test
@Parameterized.Parameters
public void testBuildParametersValidation() {
    BuildParameters buildParameters = new BuildParameters();
    buildParameters.setTemporaryBuild(temporary);
    buildParameters.setAlignmentPreference(alignmentPreference);
    Set<ConstraintViolation<BuildParameters>> violations = validator.validate(buildParameters);
    Assert.assertEquals(isValid, violations.isEmpty());
}
Also used : GroupBuildParameters(org.jboss.pnc.rest.api.parameters.GroupBuildParameters) BuildParameters(org.jboss.pnc.rest.api.parameters.BuildParameters) ConstraintViolation(javax.validation.ConstraintViolation) Test(org.junit.Test)

Example 2 with BuildParameters

use of org.jboss.pnc.rest.api.parameters.BuildParameters in project pnc by project-ncl.

the class WebSocketClientTest method testBuildListener.

@Test
public void testBuildListener() 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();
    AtomicInteger notificationCounter = new AtomicInteger(0);
    // when
    ListenerUnsubscriber unsubscriber = wsClient.onBuildChangedNotification((notification -> {
        notificationCounter.incrementAndGet();
        assertThat(notification).isNotNull();
        assertThat(notification.getBuild()).isNotNull();
    }), withBuildConfiguration(bc.getId()));
    buildConfigurationClient.trigger(bc.getId(), new BuildParameters());
    // then
    Thread.sleep(1000);
    unsubscriber.run();
    wsClient.disconnect().get();
    assertThat(notificationCounter).hasValueGreaterThanOrEqualTo(2);
}
Also used : BuildChangedNotificationPredicates.withBuildConfiguration(org.jboss.pnc.restclient.websocket.predicates.BuildChangedNotificationPredicates.withBuildConfiguration) BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) NOTIFICATION_PATH(org.jboss.pnc.integration.setup.RestClientConfiguration.NOTIFICATION_PATH) Handlers(io.undertow.Handlers) GroupBuildParameters(org.jboss.pnc.rest.api.parameters.GroupBuildParameters) AdvancedGroupConfigurationClient(org.jboss.pnc.restclient.AdvancedGroupConfigurationClient) Arquillian(org.jboss.arquillian.junit.Arquillian) GroupBuildClient(org.jboss.pnc.client.GroupBuildClient) GroupConfiguration(org.jboss.pnc.dto.GroupConfiguration) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) LoggerFactory(org.slf4j.LoggerFactory) BuildParameters(org.jboss.pnc.rest.api.parameters.BuildParameters) Undertow(io.undertow.Undertow) BuildConfigurationClient(org.jboss.pnc.client.BuildConfigurationClient) ListenerUnsubscriber(org.jboss.pnc.restclient.websocket.ListenerUnsubscriber) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) GroupBuild(org.jboss.pnc.dto.GroupBuild) Deployments(org.jboss.pnc.integration.setup.Deployments) Method(java.lang.reflect.Method) EnterpriseArchive(org.jboss.shrinkwrap.api.spec.EnterpriseArchive) GroupBuildChangedNotificationPredicates.withGConfigId(org.jboss.pnc.restclient.websocket.predicates.GroupBuildChangedNotificationPredicates.withGConfigId) AbstractReceiveListener(io.undertow.websockets.core.AbstractReceiveListener) Category(org.junit.experimental.categories.Category) BuildChangedNotificationPredicates.withBuildCompleted(org.jboss.pnc.restclient.websocket.predicates.BuildChangedNotificationPredicates.withBuildCompleted) Assertions.fail(org.assertj.core.api.Assertions.fail) WebSocketHttpExchange(io.undertow.websockets.spi.WebSocketHttpExchange) AdvancedBuildConfigurationClient(org.jboss.pnc.restclient.AdvancedBuildConfigurationClient) RunWith(org.junit.runner.RunWith) CompletableFuture(java.util.concurrent.CompletableFuture) WebSocketConnectionCallback(io.undertow.websockets.WebSocketConnectionCallback) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) ContainerTest(org.jboss.pnc.test.category.ContainerTest) ResponseUtils(org.jboss.pnc.integration.utils.ResponseUtils) ClientException(org.jboss.pnc.client.ClientException) BufferedBinaryMessage(io.undertow.websockets.core.BufferedBinaryMessage) BuildChangedNotification(org.jboss.pnc.dto.notification.BuildChangedNotification) WebSocketClient(org.jboss.pnc.restclient.websocket.WebSocketClient) GroupBuildChangedNotification(org.jboss.pnc.dto.notification.GroupBuildChangedNotification) Logger(org.slf4j.Logger) VertxWebSocketClient(org.jboss.pnc.restclient.websocket.VertxWebSocketClient) GroupBuildChangedNotificationPredicates.withGBuildCompleted(org.jboss.pnc.restclient.websocket.predicates.GroupBuildChangedNotificationPredicates.withGBuildCompleted) Test(org.junit.Test) IOException(java.io.IOException) RestClientConfiguration(org.jboss.pnc.integration.setup.RestClientConfiguration) BuildChangedNotificationPredicates.withBuildConfiguration(org.jboss.pnc.restclient.websocket.predicates.BuildChangedNotificationPredicates.withBuildConfiguration) RemoteResourceNotFoundException(org.jboss.pnc.client.RemoteResourceNotFoundException) TimeUnit(java.util.concurrent.TimeUnit) Build(org.jboss.pnc.dto.Build) BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) Deployment(org.jboss.arquillian.container.test.api.Deployment) WebSocketChannel(io.undertow.websockets.core.WebSocketChannel) GroupBuildRequest(org.jboss.pnc.dto.requests.GroupBuildRequest) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) 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) ListenerUnsubscriber(org.jboss.pnc.restclient.websocket.ListenerUnsubscriber) VertxWebSocketClient(org.jboss.pnc.restclient.websocket.VertxWebSocketClient) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 3 with BuildParameters

use of org.jboss.pnc.rest.api.parameters.BuildParameters in project pnc by project-ncl.

the class BuildTest method getBuildParameters.

private BuildParameters getBuildParameters(boolean temporary, boolean force) {
    BuildParameters buildParameters = new BuildParameters();
    buildParameters.setTemporaryBuild(temporary);
    buildParameters.setBuildDependencies(true);
    if (force)
        buildParameters.setRebuildMode(RebuildMode.FORCE);
    return buildParameters;
}
Also used : GroupBuildParameters(org.jboss.pnc.rest.api.parameters.GroupBuildParameters) BuildParameters(org.jboss.pnc.rest.api.parameters.BuildParameters)

Example 4 with BuildParameters

use of org.jboss.pnc.rest.api.parameters.BuildParameters in project pnc by project-ncl.

the class RemoteBuildTest method runMultipleBuilds.

@Test
public void runMultipleBuilds() throws Exception {
    String bcID = prepareBuildConfiguration("test-build-execution");
    BuildParameters buildOptions = new BuildParameters();
    buildOptions.setBuildDependencies(false);
    buildOptions.setRebuildMode(RebuildMode.FORCE);
    for (int i = 0; i < 20; i++) {
        CompletableFuture<Build> executeBuild = buildConfigurationRestClient.executeBuild(bcID, buildOptions);
        Build build = executeBuild.get(1, TimeUnit.MINUTES);
        assertThat(build.getStatus().completedSuccessfully()).isTrue();
    }
}
Also used : BuildParameters(org.jboss.pnc.rest.api.parameters.BuildParameters) Build(org.jboss.pnc.dto.Build) DebugTest(org.jboss.pnc.test.category.DebugTest) Test(org.junit.Test)

Example 5 with BuildParameters

use of org.jboss.pnc.rest.api.parameters.BuildParameters in project pnc by project-ncl.

the class WebSocketClientTest method testRestBuildFallback.

@Test
public void testRestBuildFallback() throws Exception {
    // with
    WebSocketSessionHandler handler = new WebSocketSessionHandler();
    Undertow wsServer = withHandler(handler);
    wsServer.start();
    WebSocketClient wsClient = new VertxWebSocketClient();
    wsClient.connect("ws://localhost:8082" + NOTIFICATION_PATH).join();
    AdvancedBuildConfigurationClient buildConfigurationClient = new AdvancedBuildConfigurationClient(RestClientConfiguration.asUser());
    // test the actual fallbackSupplier (it's private -> reflection unfortunately)
    Method supplier = buildConfigurationClient.getClass().getDeclaredMethod("fallbackSupplier", String.class);
    supplier.setAccessible(true);
    // when
    BuildConfiguration bc = buildConfigurationClient.getAll().iterator().next();
    CompletableFuture<BuildChangedNotification> future = wsClient.catchBuildChangedNotification(() -> invokeMethod(supplier, Build.class, buildConfigurationClient, bc.getId()), withBuildConfiguration(bc.getId()), withBuildCompleted());
    buildConfigurationClient.trigger(bc.getId(), new BuildParameters());
    // make client reconnect and use REST fallback
    handler.closeSession();
    // then
    assertThat(future).succeedsWithin(1000, TimeUnit.MILLISECONDS);
    wsClient.close();
    wsServer.stop();
}
Also used : BuildChangedNotificationPredicates.withBuildConfiguration(org.jboss.pnc.restclient.websocket.predicates.BuildChangedNotificationPredicates.withBuildConfiguration) BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) AdvancedBuildConfigurationClient(org.jboss.pnc.restclient.AdvancedBuildConfigurationClient) GroupBuildParameters(org.jboss.pnc.rest.api.parameters.GroupBuildParameters) BuildParameters(org.jboss.pnc.rest.api.parameters.BuildParameters) GroupBuild(org.jboss.pnc.dto.GroupBuild) Build(org.jboss.pnc.dto.Build) Method(java.lang.reflect.Method) WebSocketClient(org.jboss.pnc.restclient.websocket.WebSocketClient) VertxWebSocketClient(org.jboss.pnc.restclient.websocket.VertxWebSocketClient) BuildChangedNotification(org.jboss.pnc.dto.notification.BuildChangedNotification) GroupBuildChangedNotification(org.jboss.pnc.dto.notification.GroupBuildChangedNotification) Undertow(io.undertow.Undertow) VertxWebSocketClient(org.jboss.pnc.restclient.websocket.VertxWebSocketClient) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Aggregations

BuildParameters (org.jboss.pnc.rest.api.parameters.BuildParameters)6 GroupBuildParameters (org.jboss.pnc.rest.api.parameters.GroupBuildParameters)5 Test (org.junit.Test)5 Build (org.jboss.pnc.dto.Build)3 BuildConfiguration (org.jboss.pnc.dto.BuildConfiguration)3 BuildChangedNotification (org.jboss.pnc.dto.notification.BuildChangedNotification)3 GroupBuildChangedNotification (org.jboss.pnc.dto.notification.GroupBuildChangedNotification)3 AdvancedBuildConfigurationClient (org.jboss.pnc.restclient.AdvancedBuildConfigurationClient)3 VertxWebSocketClient (org.jboss.pnc.restclient.websocket.VertxWebSocketClient)3 Undertow (io.undertow.Undertow)2 Method (java.lang.reflect.Method)2 BuildConfigurationClient (org.jboss.pnc.client.BuildConfigurationClient)2 GroupBuild (org.jboss.pnc.dto.GroupBuild)2 WebSocketClient (org.jboss.pnc.restclient.websocket.WebSocketClient)2 BuildChangedNotificationPredicates.withBuildConfiguration (org.jboss.pnc.restclient.websocket.predicates.BuildChangedNotificationPredicates.withBuildConfiguration)2 ContainerTest (org.jboss.pnc.test.category.ContainerTest)2 Handlers (io.undertow.Handlers)1 WebSocketConnectionCallback (io.undertow.websockets.WebSocketConnectionCallback)1 AbstractReceiveListener (io.undertow.websockets.core.AbstractReceiveListener)1 BufferedBinaryMessage (io.undertow.websockets.core.BufferedBinaryMessage)1