use of org.jboss.pnc.dto.response.MilestoneInfo in project pnc by project-ncl.
the class ProductMilestoneProviderImpl method getMilestonesOfArtifact.
@Override
public Page<MilestoneInfo> getMilestonesOfArtifact(String artifactId, int pageIndex, int pageSize) {
CriteriaBuilder cb = em.getCriteriaBuilder();
Optional<Integer> builtIn = getMilestoneIdByBuildRecord(cb, artifactId);
List<Integer> dependencyOf = getDependentMilestoneIds(cb, artifactId);
Set<Integer> milestoneIds = new HashSet<>(dependencyOf);
builtIn.ifPresent(milestoneIds::add);
// some builds are not in a milestone and so it gives us null
milestoneIds.remove(null);
if (milestoneIds.isEmpty()) {
return new Page<>();
}
CriteriaQuery<Tuple> query = milestoneInfoQuery(cb, milestoneIds);
int offset = pageIndex * pageSize;
List<MilestoneInfo> milestones = em.createQuery(query).setMaxResults(pageSize).setFirstResult(offset).getResultList().stream().map(m -> mapTupleToMilestoneInfo(m, builtIn)).collect(Collectors.toList());
return new Page<>(pageIndex, pageSize, milestoneIds.size(), milestones);
}
use of org.jboss.pnc.dto.response.MilestoneInfo in project pnc by project-ncl.
the class ArtifactEndpointTest method shouldGetMilestonesInfo.
@Test
public void shouldGetMilestonesInfo() throws RemoteResourceException {
ArtifactClient client = new ArtifactClient(RestClientConfiguration.asAnonymous());
RemoteCollection<MilestoneInfo> milestonesInfo = client.getMilestonesInfo(artifactRest3.getId());
assertThat(milestonesInfo).hasSize(1).first().extracting(MilestoneInfo::isBuilt).isEqualTo(false);
RemoteCollection<MilestoneInfo> milestonesInfo2 = client.getMilestonesInfo(artifactRest1.getId());
ObjectAssert<MilestoneInfo> milestone = assertThat(milestonesInfo2).hasSize(1).first();
milestone.extracting(MilestoneInfo::isBuilt).isEqualTo(true);
milestone.extracting(MilestoneInfo::getProductName).isEqualTo("Project Newcastle Demo Product");
milestone.extracting(MilestoneInfo::getMilestoneVersion).isEqualTo("1.0.0.Build1");
}
Aggregations