use of org.jboss.pnc.model.BuildConfiguration in project pnc by project-ncl.
the class BuildConfigurationRepositoryImplTest method shouldNotCreateBuildConfigurationWithDuplicatedName.
@Test
public void shouldNotCreateBuildConfigurationWithDuplicatedName() {
String name = randomAlphabetic(10);
repository.save(producers.createValidBuildConfiguration(name));
BuildConfiguration duplicatedConfiguration = producers.createValidBuildConfiguration(name);
assertThrows(() -> repository.save(duplicatedConfiguration), org.hibernate.exception.ConstraintViolationException.class);
}
use of org.jboss.pnc.model.BuildConfiguration in project pnc by project-ncl.
the class BuildConfigurationSetRepositoryTest method shouldSaveBCSetWithBCs.
@Test
public void shouldSaveBCSetWithBCs() {
// given
BuildConfigurationFactory buildConfigurationFactory = new BuildConfigurationFactory();
BuildConfiguration buildConfiguration1 = buildConfigurationFactory.createDetached("One");
BuildConfiguration buildConfiguration2 = buildConfigurationFactory.createDetached("Two");
BuildConfiguration buildConfiguration3 = buildConfigurationFactory.createDetached("Three");
BuildConfigurationSet buildConfigurationSet = BuildConfigurationSet.Builder.newBuilder().name("Build Group").buildConfiguration(buildConfiguration1).build();
// when
BuildConfigurationSet buildConfigurationSetSaved = buildConfigurationSetRepository.save(buildConfigurationSet);
// then
List<BuildConfiguration> buildConfigurationsLoaded = buildConfigurationRepository.queryWithPredicates(withBuildConfigurationSetId(buildConfigurationSetSaved.getId()), isNotArchived());
assertThat(buildConfigurationsLoaded).isNotEmpty();
assertThat(buildConfigurationsLoaded.size()).isEqualTo(1);
assertThat(buildConfiguration1.getDefaultAlignmentParams().contains("-DdependencySource=REST"));
assertThat(buildConfiguration2.getDefaultAlignmentParams().contains("-DdependencySource=REST"));
assertThat(buildConfiguration3.getDefaultAlignmentParams().contains("-DdependencySource=REST"));
}
use of org.jboss.pnc.model.BuildConfiguration in project pnc by project-ncl.
the class BuildRecordRepositoryTest method initBuildRecordBuilder.
private BuildRecord.Builder initBuildRecordBuilder(String id) {
if (user == null) {
List<User> users = userRepository.queryWithPredicates(UserPredicates.withUserName("demo-user"));
if (users.size() > 0) {
user = users.get(0);
}
if (user == null) {
this.user = userRepository.save(User.Builder.newBuilder().username("demo-user").firstName("Demo First Name").lastName("Demo Last Name").email("demo-user@pnc.com").build());
}
}
BuildConfiguration buildConfiguration = producers.createValidBuildConfiguration("buildRecordTest-" + id);
BuildConfiguration saved = buildConfigurationRepository.save(buildConfiguration);
BuildConfigurationAudited buildConfigurationAudited = buildConfigurationAuditedRepository.findAllByIdOrderByRevDesc(saved.getId()).get(0);
return BuildRecord.Builder.newBuilder().id(id).buildConfigurationAudited(buildConfigurationAudited).submitTime(new Date()).user(user).status(BuildStatus.SUCCESS);
}
use of org.jboss.pnc.model.BuildConfiguration in project pnc by project-ncl.
the class BuildConfigurationAuditedRepositoryImpl method searchIdRevForBuildConfigurationName.
@Override
public List<IdRev> searchIdRevForBuildConfigurationName(String buildConfigurationName) {
buildConfigurationName = buildConfigurationName.replaceAll("\\*", "%");
List<Object[]> result = AuditReaderFactory.get(entityManager).createQuery().forRevisionsOfEntity(BuildConfiguration.class, false, false).add(AuditEntity.property("name").like(buildConfigurationName)).addOrder(AuditEntity.revisionNumber().desc()).getResultList();
return result.stream().map(o -> {
BuildConfiguration buildConfiguration = (BuildConfiguration) o[0];
DefaultRevisionEntity revisionEntity = (DefaultRevisionEntity) o[1];
return new IdRev(buildConfiguration.getId(), revisionEntity.getId());
}).collect(Collectors.toList());
}
use of org.jboss.pnc.model.BuildConfiguration in project pnc by project-ncl.
the class BuildConfigurationAuditedRepositoryImpl method searchIdRevForBuildConfigurationNameOrProjectName.
@Override
public List<IdRev> searchIdRevForBuildConfigurationNameOrProjectName(List<Project> projectsMatchingName, String name) {
AuditDisjunction disjunction = AuditEntity.disjunction();
projectsMatchingName.forEach(project -> disjunction.add(AuditEntity.relatedId("project").eq(project.getId())));
disjunction.add(AuditEntity.property("name").like(name));
List<Object[]> result = AuditReaderFactory.get(entityManager).createQuery().forRevisionsOfEntity(BuildConfiguration.class, false, false).add(disjunction).addOrder(AuditEntity.revisionNumber().desc()).getResultList();
return result.stream().map(o -> {
BuildConfiguration buildConfiguration = (BuildConfiguration) o[0];
DefaultRevisionEntity revisionEntity = (DefaultRevisionEntity) o[1];
return new IdRev(buildConfiguration.getId(), revisionEntity.getId());
}).collect(Collectors.toList());
}
Aggregations