use of org.jboss.pnc.dto.SCMRepository in project pnc by project-ncl.
the class RemoteBuildTest method getOrCreateBuildConfiguration.
private BuildConfiguration getOrCreateBuildConfiguration(String buildConfigurationName, String buildScript, String scmRevision, Map<String, String> genericParameters, String projectId, String repositoryConfigurationId, String buildEnvironmentId) throws RemoteResourceException {
RemoteCollection<BuildConfiguration> existing = buildConfigurationRestClient.getAll(Optional.empty(), Optional.of("name==" + buildConfigurationName));
Iterator<BuildConfiguration> it = existing.iterator();
if (!it.hasNext()) {
ProjectRef project = ProjectRef.refBuilder().id(projectId).build();
SCMRepository repository = SCMRepository.builder().id(repositoryConfigurationId).build();
Environment environment = Environment.builder().id(buildEnvironmentId).build();
BuildConfiguration buildConfiguration = BuildConfiguration.builder().name(buildConfigurationName).project(project).scmRepository(repository).scmRevision(scmRevision).environment(environment).buildScript(buildScript).parameters(genericParameters).build();
BuildConfiguration created = buildConfigurationRestClient.createNew(buildConfiguration);
return created;
} else {
return it.next();
}
}
use of org.jboss.pnc.dto.SCMRepository in project pnc by project-ncl.
the class BuildConfigurationEndpointTest method prepareData.
@SuppressWarnings("unchecked")
@BeforeClass
public static void prepareData() throws Exception {
BuildConfigurationClient bcc = new BuildConfigurationClient(RestClientConfiguration.asAnonymous());
Iterator<BuildConfiguration> it = bcc.getAll().iterator();
configurationId = it.next().getId();
configuration2Id = it.next().getId();
configuration3Id = it.next().getId();
configuration4Id = it.next().getId();
ProductClient pdc = new ProductClient(RestClientConfiguration.asAnonymous());
productId = pdc.getAll().iterator().next().getId();
EnvironmentClient ec = new EnvironmentClient(RestClientConfiguration.asAnonymous());
environmentId = ec.getAll().iterator().next().getId();
ProjectClient pjc = new ProjectClient(RestClientConfiguration.asAnonymous());
projectId = pjc.getAll().iterator().next().getId();
SCMRepositoryClient scmrc = new SCMRepositoryClient(RestClientConfiguration.asAnonymous());
final Iterator<SCMRepository> scmrIt = scmrc.getAll(null, null).iterator();
repositoryConfigurationId = scmrIt.next().getId();
repositoryConfiguration2Id = scmrIt.next().getId();
}
use of org.jboss.pnc.dto.SCMRepository in project pnc by project-ncl.
the class SCMRepositoryEndpointTest method shouldFailOnCreatingNewWithConflictingInternalUrl.
@Test
public void shouldFailOnCreatingNewWithConflictingInternalUrl() {
SCMRepository repository = SCMRepository.builder().internalUrl(// from DatabaseDataInitializer.class
"ssh://git@github.com:22/project-ncl/pnc.git").preBuildSyncEnabled(false).build();
CreateAndSyncSCMRequest request = CreateAndSyncSCMRequest.builder().scmUrl(repository.getInternalUrl()).preBuildSyncEnabled(repository.getPreBuildSyncEnabled()).build();
assertThatThrownBy(() -> repositoryClient.createNew(request)).hasCauseInstanceOf(ClientErrorException.class).has(new Condition<Throwable>((e -> ((ClientErrorException) e.getCause()).getResponse().getStatus() == 409), "Has Cause with conflicted status code 409"));
}
use of org.jboss.pnc.dto.SCMRepository in project pnc by project-ncl.
the class SCMRepositoryEndpointTest method shouldFailToCreateNewWithInvalidUrl.
@Test
public void shouldFailToCreateNewWithInvalidUrl() {
SCMRepository repository = SCMRepository.builder().internalUrl(// from DatabaseDataInitializer
"I will totally fail!!").preBuildSyncEnabled(false).build();
CreateAndSyncSCMRequest request = CreateAndSyncSCMRequest.builder().scmUrl(repository.getInternalUrl()).preBuildSyncEnabled(repository.getPreBuildSyncEnabled()).build();
assertThatThrownBy(() -> repositoryClient.createNew(request)).hasCauseInstanceOf(BadRequestException.class);
}
use of org.jboss.pnc.dto.SCMRepository in project pnc by project-ncl.
the class SCMRepositoryEndpointTest method shouldNotAllowUpdatingInternalUrl.
@Test
public void shouldNotAllowUpdatingInternalUrl() throws ClientException {
// then
final String validInternalUrl = "http://git@github.com:22/project-ncl/pnc22.git";
SCMRepository scmRepository = repositoryClient.getAll(null, null).iterator().next();
SCMRepository toUpdate = scmRepository.toBuilder().internalUrl(validInternalUrl).build();
// when/then
assertThatThrownBy(() -> repositoryClient.update(toUpdate.getId(), toUpdate)).hasCauseInstanceOf(BadRequestException.class);
}
Aggregations