Search in sources :

Example 76 with BuildConfiguration

use of org.jboss.pnc.dto.BuildConfiguration in project pnc by project-ncl.

the class SecondLevelCacheStoreTest method prepareData.

/**
 * At first we need to create testing data and commit it.
 */
@Test
@InSequence(-2)
public void prepareData() throws Exception {
    EnvironmentClient client = new EnvironmentClient(RestClientConfiguration.asAnonymous());
    environmentId = client.getAll().iterator().next().getId();
    SCMRepositoryClient scmrc = new SCMRepositoryClient(RestClientConfiguration.asAnonymous());
    final Iterator<SCMRepository> scmrIt = scmrc.getAll(null, null).iterator();
    repositoryConfigurationBCId = scmrIt.next().getId();
    repositoryConfigurationDepBCId = scmrIt.next().getId();
    Project projectBC = createProjectAndValidateResults("https://github.com/project-ncl/dependency-analysis", null, "Dependency Analysis New", "Dependency Analysis - Analise project dependencies.");
    Project projectDepBC = createProjectAndValidateResults("https://github.com/project-ncl/pnc", null, "Project Newcastle Demo Project 1 New", "Example Project for Newcastle Demo");
    projectBCId = projectBC.getId();
    projectDepBCId = projectDepBC.getId();
    BuildConfiguration dependencyBC = createBuildConfigurationAndValidateResults(projectDepBCId, environmentId, repositoryConfigurationDepBCId, "pnc-1.0.0.DR1-new", UUID.randomUUID().toString());
    BuildConfiguration buildConfiguration = createBuildConfigurationAndValidateResults(projectBCId, environmentId, repositoryConfigurationBCId, "dependency-analysis-master-new", UUID.randomUUID().toString());
    dependencyBCId = dependencyBC.getId();
    buildConfigurationId = buildConfiguration.getId();
}
Also used : BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) SCMRepositoryClient(org.jboss.pnc.client.SCMRepositoryClient) Project(org.jboss.pnc.dto.Project) EnvironmentClient(org.jboss.pnc.client.EnvironmentClient) SCMRepository(org.jboss.pnc.dto.SCMRepository) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test) InSequence(org.jboss.arquillian.junit.InSequence)

Example 77 with BuildConfiguration

use of org.jboss.pnc.dto.BuildConfiguration in project pnc by project-ncl.

the class SecondLevelCacheStoreTest method verifyPresenceOfRequiredData.

/**
 * Secondly we need to verify it.
 */
@Test
@InSequence(-1)
public void verifyPresenceOfRequiredData() throws Exception {
    BuildConfiguration savedBuildConfiguration = buildConfigurationClient.getSpecific(buildConfigurationId);
    assertThat(savedBuildConfiguration).isNotNull();
    BuildConfiguration savedDependencyBuildConfiguration = buildConfigurationClient.getSpecific(dependencyBCId);
    assertThat(savedDependencyBuildConfiguration).isNotNull();
    assertThat(savedBuildConfiguration.getDependencies().containsKey(dependencyBCId));
}
Also used : BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test) InSequence(org.jboss.arquillian.junit.InSequence)

Example 78 with BuildConfiguration

use of org.jboss.pnc.dto.BuildConfiguration in project pnc by project-ncl.

the class SecondLevelCacheStoreTest method bogusUpdateBC.

/**
 * Finally, we update it.
 */
@Test
@InSequence(1)
public void bogusUpdateBC() throws Exception {
    BuildConfiguration originalBuildConfiguration = buildConfigurationClient.getSpecific(buildConfigurationId);
    BuildConfiguration.Builder bcBuilder = originalBuildConfiguration.toBuilder();
    bcBuilder.buildScript("mvn clean install");
    BuildConfiguration updatedBC = bcBuilder.build();
    buildConfigurationClient.update(updatedBC.getId(), updatedBC);
}
Also used : BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test) InSequence(org.jboss.arquillian.junit.InSequence)

Example 79 with BuildConfiguration

use of org.jboss.pnc.dto.BuildConfiguration in project pnc by project-ncl.

the class SCMRepositoryEndpointTest method testGetBuildConfigurationForARepository.

@Test
public void testGetBuildConfigurationForARepository() throws ClientException {
    BuildConfigurationClient buildConfigurationClient = new BuildConfigurationClient(RestClientConfiguration.asUser());
    SCMRepository scmRepository = repositoryClient.getAll(null, null).iterator().next();
    Iterator<BuildConfiguration> allConfigsIterator = buildConfigurationClient.getAll().iterator();
    BuildConfiguration buildConfiguration1 = allConfigsIterator.next().toBuilder().scmRepository(scmRepository).build();
    BuildConfiguration buildConfiguration2 = allConfigsIterator.next().toBuilder().scmRepository(scmRepository).build();
    buildConfigurationClient.update(buildConfiguration1.getId(), buildConfiguration1);
    buildConfigurationClient.update(buildConfiguration2.getId(), buildConfiguration2);
    RemoteCollection<BuildConfiguration> buildConfigs = repositoryClient.getBuildConfigs(scmRepository.getId());
    assertThat(buildConfigs).usingElementComparatorIgnoringFields("modificationTime", "creationUser", "modificationUser").contains(buildConfiguration1, buildConfiguration2).allSatisfy((bc -> scmRepository.equals(bc.getScmRepository())));
}
Also used : BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) Arquillian(org.jboss.arquillian.junit.Arquillian) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) RunWith(org.junit.runner.RunWith) LoggerFactory(org.slf4j.LoggerFactory) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) ClientErrorException(javax.ws.rs.ClientErrorException) RemoteCollection(org.jboss.pnc.client.RemoteCollection) CreateAndSyncSCMRequest(org.jboss.pnc.dto.requests.CreateAndSyncSCMRequest) ContainerTest(org.jboss.pnc.test.category.ContainerTest) ClientException(org.jboss.pnc.client.ClientException) RepositoryCreationResponse(org.jboss.pnc.dto.response.RepositoryCreationResponse) BuildConfigurationClient(org.jboss.pnc.client.BuildConfigurationClient) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) BadRequestException(javax.ws.rs.BadRequestException) Deployments(org.jboss.pnc.integration.setup.Deployments) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) EnterpriseArchive(org.jboss.shrinkwrap.api.spec.EnterpriseArchive) Test(org.junit.Test) Category(org.junit.experimental.categories.Category) RestClientConfiguration(org.jboss.pnc.integration.setup.RestClientConfiguration) SCMRepositoryClient(org.jboss.pnc.client.SCMRepositoryClient) BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) SCMRepository(org.jboss.pnc.dto.SCMRepository) Ignore(org.junit.Ignore) Deployment(org.jboss.arquillian.container.test.api.Deployment) Condition(org.assertj.core.api.Condition) RemoteResourceException(org.jboss.pnc.client.RemoteResourceException) BuildConfigurationClient(org.jboss.pnc.client.BuildConfigurationClient) SCMRepository(org.jboss.pnc.dto.SCMRepository) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 80 with BuildConfiguration

use of org.jboss.pnc.dto.BuildConfiguration 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

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