Search in sources :

Example 11 with BuildConfigurationClient

use of org.jboss.pnc.client.BuildConfigurationClient in project pnc by project-ncl.

the class BuildConfigurationEndpointTest method shouldCreateBuildConfigRevision.

@Test
public void shouldCreateBuildConfigRevision() throws ClientException {
    final String description = "Updated description.";
    final String updatedName = "thisisanupdatedname";
    final String buildScript = "mvn deploy # Updated script";
    BuildConfigurationClient client = new BuildConfigurationClient(RestClientConfiguration.asUser());
    BuildConfiguration bc = client.getSpecific(configurationId);
    Instant modTime = bc.getModificationTime();
    BuildConfiguration newBC1 = bc.toBuilder().name(updatedName).description(description).build();
    BuildConfiguration newBC2 = bc.toBuilder().buildScript(buildScript).build();
    BuildConfigurationRevision newRevision1 = client.createRevision(configurationId, newBC1);
    BuildConfigurationRevision newRevision2 = client.createRevision(configurationId, newBC2);
    assertNotEquals(modTime, newRevision1.getModificationTime());
    assertNotEquals(modTime, newRevision2.getModificationTime());
    assertEquals(updatedName, newRevision1.getName());
    assertEquals(bc.getBuildScript(), newRevision1.getBuildScript());
    assertEquals(bc.getEnvironment(), newRevision2.getEnvironment());
    assertEquals(buildScript, newRevision2.getBuildScript());
    assertThat(newRevision1.getRev()).isLessThan(newRevision2.getRev());
}
Also used : BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) Instant(java.time.Instant) BuildConfigurationRevision(org.jboss.pnc.dto.BuildConfigurationRevision) BuildConfigurationClient(org.jboss.pnc.client.BuildConfigurationClient) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 12 with BuildConfigurationClient

use of org.jboss.pnc.client.BuildConfigurationClient in project pnc by project-ncl.

the class BuildConfigurationEndpointTest method testGetAll.

@Test
@InSequence(10)
public void testGetAll() throws RemoteResourceException {
    BuildConfigurationClient client = new BuildConfigurationClient(RestClientConfiguration.asAnonymous());
    RemoteCollection<BuildConfiguration> all = client.getAll();
    // from DatabaseDataInitializer
    assertThat(all).hasSize(5);
}
Also used : BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) BuildConfigurationClient(org.jboss.pnc.client.BuildConfigurationClient) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test) InSequence(org.jboss.arquillian.junit.InSequence)

Example 13 with BuildConfigurationClient

use of org.jboss.pnc.client.BuildConfigurationClient in project pnc by project-ncl.

the class BuildConfigurationEndpointTest method shouldChangeRepositoryConfiguration.

@Test
@InSequence(61)
public void shouldChangeRepositoryConfiguration() throws ClientException {
    // given
    BuildConfigurationClient bcClient = new BuildConfigurationClient(RestClientConfiguration.asUser());
    SCMRepositoryClient scmClient = new SCMRepositoryClient(RestClientConfiguration.asAnonymous());
    BuildConfiguration buildConfiguration = bcClient.getSpecific(configuration4Id);
    // make sure this RC is not already set
    assertThat(buildConfiguration.getScmRepository().getId()).isNotEqualTo(repositoryConfiguration2Id);
    // when
    BuildConfiguration updateBC = BuildConfiguration.builder().id(buildConfiguration.getId()).name(buildConfiguration.getName()).buildScript(buildConfiguration.getBuildScript()).creationTime(buildConfiguration.getCreationTime()).modificationTime(buildConfiguration.getModificationTime()).project(buildConfiguration.getProject()).environment(buildConfiguration.getEnvironment()).parameters(buildConfiguration.getParameters()).scmRepository(scmClient.getSpecific(repositoryConfiguration2Id)).buildType(buildConfiguration.getBuildType()).build();
    bcClient.update(updateBC.getId(), updateBC);
    BuildConfiguration updatedBC = bcClient.getSpecific(updateBC.getId());
    // then
    assertThat(updateBC.getScmRepository().getId()).isEqualTo(repositoryConfiguration2Id);
}
Also used : BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) SCMRepositoryClient(org.jboss.pnc.client.SCMRepositoryClient) BuildConfigurationClient(org.jboss.pnc.client.BuildConfigurationClient) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test) InSequence(org.jboss.arquillian.junit.InSequence)

Example 14 with BuildConfigurationClient

use of org.jboss.pnc.client.BuildConfigurationClient in project pnc by project-ncl.

the class BuildConfigurationEndpointTest method shouldFailToCreateBuildConfigurationWhichDoesntMatchRegexp.

@Test
public void shouldFailToCreateBuildConfigurationWhichDoesntMatchRegexp() throws ClientException {
    BuildConfigurationClient client = new BuildConfigurationClient(RestClientConfiguration.asUser());
    BuildConfiguration bc = client.getSpecific(configurationId);
    BuildConfiguration invalidName = BuildConfiguration.builder().name(":").buildScript(bc.getBuildScript()).project(bc.getProject()).environment(bc.getEnvironment()).parameters(bc.getParameters()).scmRepository(bc.getScmRepository()).buildType(bc.getBuildType()).build();
    assertThatThrownBy(() -> client.createNew(invalidName)).hasCauseInstanceOf(BadRequestException.class);
}
Also used : BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) BuildConfigurationClient(org.jboss.pnc.client.BuildConfigurationClient) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 15 with BuildConfigurationClient

use of org.jboss.pnc.client.BuildConfigurationClient 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)

Aggregations

BuildConfigurationClient (org.jboss.pnc.client.BuildConfigurationClient)41 ContainerTest (org.jboss.pnc.test.category.ContainerTest)37 Test (org.junit.Test)37 BuildConfiguration (org.jboss.pnc.dto.BuildConfiguration)32 InSequence (org.jboss.arquillian.junit.InSequence)16 BuildConfigurationRevision (org.jboss.pnc.dto.BuildConfigurationRevision)6 GroupConfiguration (org.jboss.pnc.dto.GroupConfiguration)6 Instant (java.time.Instant)5 Build (org.jboss.pnc.dto.Build)5 BuildConfigurationRef (org.jboss.pnc.dto.BuildConfigurationRef)5 SCMRepositoryClient (org.jboss.pnc.client.SCMRepositoryClient)4 HashMap (java.util.HashMap)3 ClientErrorException (javax.ws.rs.ClientErrorException)3 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)3 Deployment (org.jboss.arquillian.container.test.api.Deployment)3 RunAsClient (org.jboss.arquillian.container.test.api.RunAsClient)3 Arquillian (org.jboss.arquillian.junit.Arquillian)3 ClientException (org.jboss.pnc.client.ClientException)3 GroupConfigurationClient (org.jboss.pnc.client.GroupConfigurationClient)3 BuildConfigurationPatchBuilder (org.jboss.pnc.client.patch.BuildConfigurationPatchBuilder)3