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