use of org.jboss.pnc.model.BuildRecord in project pnc by project-ncl.
the class BuildProviderImplTest method testBuildIterator.
public void testBuildIterator() {
SortInfo sortInfo = mock(SortInfo.class);
Predicate<BuildRecord> predicate = mock(Predicate.class);
mockRepository(sortInfo, predicate);
BuildProviderImpl.BuildIterator bit;
List<Integer> ret;
bit = provider.new BuildIterator(1, 10, 1, sortInfo, predicate);
ret = new ArrayList<>();
while (bit.hasNext()) {
Build next = bit.next();
System.out.println("next: " + next);
ret.add(Integer.valueOf(next.getId()));
}
assertEquals(Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10), ret);
bit = provider.new BuildIterator(1, 10, 10, sortInfo, predicate);
ret = new ArrayList<>();
while (bit.hasNext()) {
ret.add(Integer.valueOf(bit.next().getId()));
}
assertEquals(Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10), ret);
bit = provider.new BuildIterator(1, 10, 100, sortInfo, predicate);
ret = new ArrayList<>();
while (bit.hasNext()) {
ret.add(Integer.valueOf(bit.next().getId()));
}
assertEquals(Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10), ret);
bit = provider.new BuildIterator(7, 12, 100, sortInfo, predicate);
ret = new ArrayList<>();
while (bit.hasNext()) {
ret.add(Integer.valueOf(bit.next().getId()));
}
assertEquals(Arrays.asList(7, 8, 9, 10, 11, 12), ret);
}
use of org.jboss.pnc.model.BuildRecord in project pnc by project-ncl.
the class RepositoryManagerDriver method collectRepoManagerResult.
@Override
public RepositoryManagerResult collectRepoManagerResult(String id) throws RepositoryManagerException {
Base32LongID buildId = new Base32LongID(id);
BuildRecord br = buildRecordRepository.findByIdFetchProperties(buildId);
if (br == null) {
return null;
}
BuildConfigurationAudited bc = br.getBuildConfigurationAudited();
String buildContentId = br.getBuildContentId();
BuildType buildType = bc.getBuildType();
boolean tempBuild = br.isTemporaryBuild();
Indy indy = init(null);
String buildPromotionTarget = tempBuild ? TEMP_BUILD_PROMOTION_TARGET : BUILD_PROMOTION_TARGET;
String packageType = getIndyPackageTypeKey(buildType.getRepoType());
BuildCategory buildCategory = getBuildCategory(bc.getGenericParameters());
ArtifactFilter artifactFilter = new ArtifactFilterImpl(ignoredPathPatternsPromotion, ignoredPathPatternsData, ignoredRepoPatterns);
IndyRepositorySession session = new IndyRepositorySession(indy, indy, buildContentId, packageType, null, artifactFilter, buildPromotionTarget, buildCategory, tempBuild);
return session.extractBuildArtifacts(false);
}
use of org.jboss.pnc.model.BuildRecord in project pnc by project-ncl.
the class BuildPusherRejectionsTest method shouldRejectWithBlacklistedArtifacts.
@Test
public void shouldRejectWithBlacklistedArtifacts() throws ProcessException {
// given
BuildRecord record = new BuildRecord();
record.setStatus(buildStatus);
record.setExecutionRootName("FOO");
BuildRecord savedBuildRecord = buildRecordRepository.save(record);
Artifact artifact = Artifact.builder().build();
artifact.setArtifactQuality(artifactQuality);
artifact.setBuildRecord(savedBuildRecord);
when(globalModuleGroup.getPncUrl()).thenReturn("http://localhost/");
when(artifactRepository.queryWithPredicates(any())).thenReturn(Collections.singletonList(artifact));
when(buildRecordRepository.getAnyLatestSuccessfulBuildRecordWithRevision(any(IdRev.class), any(Boolean.class))).thenReturn(null);
// then
thrown.expect(expected);
// when
BuildPushParameters buildPushParameters = BuildPushParameters.builder().build();
brewPusher.pushBuild(BuildMapper.idMapper.toDto(savedBuildRecord.getId()), buildPushParameters);
}
use of org.jboss.pnc.model.BuildRecord in project pnc by project-ncl.
the class ProductMilestoneProviderTest method setup.
@Before
public void setup() {
when(userService.currentUserToken()).thenReturn("eyUserToken");
when(bpmModuleConfig.isNewBpmForced()).thenReturn(true);
ProductMilestoneFactory.getInstance().setIdSupplier(() -> entityId.getAndIncrement());
List<ProductMilestone> productMilestones = new ArrayList<>();
mock.setPerformedBuilds(new HashSet<BuildRecord>(Arrays.asList(new BuildRecord())));
productMilestones.add(mock);
productMilestones.add(mockSecond);
productMilestones.add(ProductMilestoneFactory.getInstance().prepareNewProductMilestone("1.3", "1.3.2.GA"));
productMilestones.add(ProductMilestoneFactory.getInstance().prepareNewProductMilestone("5.5", "5.5.5.CR1"));
fillRepository(productMilestones);
}
use of org.jboss.pnc.model.BuildRecord in project pnc by project-ncl.
the class RSQLPredicateProducerTest method testCriteriaPredicateEmbeded.
@Test
public void testCriteriaPredicateEmbeded() {
org.jboss.pnc.spi.datastore.repositories.api.Predicate<BuildRecord> criteriaPredicate = producer.getCriteriaPredicate(BuildRecord.class, "environment.name==fooEnv");
CriteriaBuilder cb = mock(CriteriaBuilder.class);
Root<BuildRecord> root = mock(Root.class);
Join<BuildRecord, BuildEnvironment> join = mock(Join.class);
SingularAttributePath<String> namePath = mock(SingularAttributePath.class);
when(root.join(BuildRecord_.buildEnvironment)).thenReturn(join);
when(join.get(BuildEnvironment_.name)).thenReturn(namePath);
Mockito.doReturn(String.class).when(namePath).getJavaType();
SingularAttribute pathAttribute = mock(SingularAttribute.class);
java.lang.reflect.Member javaMember = mock(java.lang.reflect.Member.class);
Mockito.doReturn(BuildEnvironment.class).when(javaMember).getDeclaringClass();
Mockito.doReturn(javaMember).when(pathAttribute).getJavaMember();
Mockito.doReturn("name").when(pathAttribute).getName();
Mockito.doReturn(pathAttribute).when(namePath).getAttribute();
criteriaPredicate.apply(root, null, cb);
Mockito.verify(cb).equal(namePath, "fooEnv");
}
Aggregations