use of org.jboss.pnc.dto.BuildConfigurationRevisionRef in project pnc by project-ncl.
the class BuildEndpointTest method shouldFilterByBuildConfigurationNameAndUserId.
@Test
public void shouldFilterByBuildConfigurationNameAndUserId() throws Exception {
BuildClient client = new BuildClient(RestClientConfiguration.asAnonymous());
String buildConfigName = DatabaseDataInitializer.PNC_PROJECT_BUILD_CFG_ID;
String username = "pnc-admin";
String rsql = "user.username==" + username;
BuildsFilterParameters filter = new BuildsFilterParameters();
filter.setBuildConfigName(buildConfigName);
List<Build> builds = new ArrayList<>(client.getAll(filter, null, Optional.empty(), Optional.of(rsql)).getAll());
assertThat(builds).hasSize(2);
assertThat(builds.stream().map(Build::getBuildConfigRevision).map(BuildConfigurationRevisionRef::getName).allMatch(name -> name.equals(buildConfigName)));
assertThat(builds.stream().map(Build::getUser).map(User::getUsername).allMatch(name -> name.equals(username)));
}
use of org.jboss.pnc.dto.BuildConfigurationRevisionRef in project pnc by project-ncl.
the class BuildBCRevisionFetcher method mapFromAuditedBuildConfig.
@BeforeMapping
public void mapFromAuditedBuildConfig(BuildRecord build, @MappingTarget Build.Builder dtoBuilder) {
Integer id = build.getBuildConfigurationId();
Integer revision = build.getBuildConfigurationRev();
// If somebody before us already set the BCA we don't need to query it from DB again
BuildConfigurationAudited bca = build.getBuildConfigurationAudited();
if (bca == null) {
bca = bcAuditedRepository.queryById(new IdRev(id, revision));
}
BuildConfigurationRevisionRef bcRevision = bcRevisionMapper.toRef(bca);
ProjectRef project = projectMapper.toRef(bca.getProject());
Environment environment = environmentMapper.toRef(bca.getBuildEnvironment());
SCMRepository scmRepository = scmRepositoryMapper.toRef(bca.getRepositoryConfiguration());
dtoBuilder.buildConfigRevision(bcRevision);
dtoBuilder.project(project);
dtoBuilder.environment(environment);
dtoBuilder.scmRepository(scmRepository);
}
use of org.jboss.pnc.dto.BuildConfigurationRevisionRef in project pnc by project-ncl.
the class BuildTriggererImpl method loadAuditedsFromDB.
private Map<Integer, BuildConfigurationAudited> loadAuditedsFromDB(BuildConfigurationSet buildConfigurationSet, List<BuildConfigurationRevisionRef> buildConfigurationAuditedRests) throws InvalidEntityException {
Map<Integer, BuildConfigurationAudited> buildConfigurationAuditedsMap = new HashMap<>();
Set<IdRev> buildConfigurationAuditedRevs = nullableStreamOf(buildConfigurationAuditedRests).map(bcrRef -> new IdRev(Integer.valueOf(bcrRef.getId()), bcrRef.getRev())).collect(Collectors.toSet());
if (!buildConfigurationAuditedRevs.isEmpty()) {
Map<IdRev, BuildConfigurationAudited> buildConfigurationsAuditedMap = buildConfigurationAuditedRepository.queryById(buildConfigurationAuditedRevs);
for (BuildConfigurationRevisionRef bc : buildConfigurationAuditedRests) {
BuildConfigurationAudited buildConfigurationAudited = buildConfigurationsAuditedMap.get(new IdRev(Integer.valueOf(bc.getId()), bc.getRev()));
Preconditions.checkArgument(buildConfigurationAudited != null, "Can't find Build Configuration with id=" + bc.getId() + ", rev=" + bc.getRev());
buildConfigurationAudited = hibernateLazyInitializer.initializeBuildConfigurationAuditedBeforeTriggeringIt(buildConfigurationAudited);
if (!buildConfigurationSet.getBuildConfigurations().contains(buildConfigurationAudited.getBuildConfiguration())) {
throw new InvalidEntityException("BuildConfigurationSet " + buildConfigurationSet + " doesn't contain this BuildConfigurationAudited entity " + buildConfigurationAudited);
}
buildConfigurationAuditedsMap.put(buildConfigurationAudited.getId(), buildConfigurationAudited);
}
}
return buildConfigurationAuditedsMap;
}
use of org.jboss.pnc.dto.BuildConfigurationRevisionRef in project pnc by project-ncl.
the class BuildTest method shouldTriggerGroupBuildWithBCInRevisionAndFinishWithoutProblems.
@Test
public void shouldTriggerGroupBuildWithBCInRevisionAndFinishWithoutProblems() throws ClientException {
// given
GroupConfiguration groupConfiguration = groupConfigurationClient.getAll().iterator().next();
assertThat(groupConfiguration.getBuildConfigs()).isNotEmpty();
List<BuildConfigurationRevisionRef> buildConfigurationRevisions = new ArrayList<>();
BuildConfigurationRevision buildConfigurationRevision = BuildConfigurationRevision.builder().id(groupConfiguration.getBuildConfigs().keySet().iterator().next()).rev(1).name(groupConfiguration.getName()).build();
buildConfigurationRevisions.add(buildConfigurationRevision);
GroupBuildRequest groupConfigWithAuditedBCsRest = GroupBuildRequest.builder().buildConfigurationRevisions(buildConfigurationRevisions).build();
GroupBuildParameters groupBuildParameters = new GroupBuildParameters();
groupBuildParameters.setRebuildMode(RebuildMode.FORCE);
// when
GroupBuild groupBuild = groupConfigurationClient.trigger(groupConfiguration.getId(), groupBuildParameters, groupConfigWithAuditedBCsRest);
// then
assertThat(groupBuild).isNotNull().extracting("id").isNotNull().isNotEqualTo("");
EnumSet<BuildStatus> isIn = EnumSet.of(BuildStatus.SUCCESS);
EnumSet<BuildStatus> isNotIn = EnumSet.of(BuildStatus.REJECTED);
ResponseUtils.waitSynchronouslyFor(() -> groupBuildToFinish(groupBuild.getId(), isIn, isNotIn), 15, TimeUnit.SECONDS);
}
use of org.jboss.pnc.dto.BuildConfigurationRevisionRef in project pnc by project-ncl.
the class BuildStatusChangedTest method getBuild.
private Build getBuild() {
ProjectRef projectRef = ProjectRef.refBuilder().id("1").name("A").description("desc").projectUrl("url1").issueTrackerUrl("url2").build();
SCMRepository scmRepository = SCMRepository.builder().id("1").internalUrl("url1").externalUrl("url2").preBuildSyncEnabled(true).build();
Environment buildEnvironment = Environment.builder().id("1").name("jdk8").description("desc").systemImageRepositoryUrl("url").systemImageId("11").systemImageType(SystemImageType.DOCKER_IMAGE).deprecated(true).build();
User user = User.builder().id("1").username("user").build();
BuildConfigurationRevisionRef buildConfigurationRevisionRef = BuildConfigurationRevisionRef.refBuilder().id("1").rev(1).name("name").buildScript("true").scmRevision("awqs21").build();
return Build.builder().project(projectRef).scmRepository(scmRepository).environment(buildEnvironment).user(user).buildConfigRevision(buildConfigurationRevisionRef).status(BuildStatus.BUILDING).buildContentId("build-42").temporaryBuild(true).build();
}
Aggregations