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();
}
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));
}
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);
}
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())));
}
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();
}
Aggregations