use of org.jboss.pnc.dto.response.ArtifactInfo in project pnc by project-ncl.
the class ArtifactEndpointTest method testGetAllArtifactsFilteredByIdentifier.
@Test
public void testGetAllArtifactsFilteredByIdentifier() throws RemoteResourceException {
ArtifactClient client = new ArtifactClient(RestClientConfiguration.asAnonymous());
RemoteCollection<ArtifactInfo> result;
result = client.getAllFiltered("*demo:*:jar:*", null, null);
assertThat(result).allSatisfy(a -> assertThat(a.getIdentifier().contains("demo:") && a.getIdentifier().contains(":jar:")));
result = client.getAllFiltered("demo:built-artifact11:pom:*", null, null);
// from DatabaseDataInitializer
assertThat(result).hasSize(1);
result = client.getAllFiltered("demo:built-artifact22:jar:1.0", null, null);
// from DatabaseDataInitializer
assertThat(result).hasSize(1);
}
use of org.jboss.pnc.dto.response.ArtifactInfo in project pnc by project-ncl.
the class ArtifactEndpointTest method testGetAllArtifactsFilteredByQualitiesList.
@Test
public void testGetAllArtifactsFilteredByQualitiesList() throws RemoteResourceException {
ArtifactClient client = new ArtifactClient(RestClientConfiguration.asAnonymous());
RemoteCollection<ArtifactInfo> result;
result = client.getAllFiltered(null, new HashSet<>(Arrays.asList(ArtifactQuality.NEW)), null);
assertThat(result).allSatisfy(a -> assertThat(a.getArtifactQuality().equals(ArtifactQuality.NEW)));
result = client.getAllFiltered(null, new HashSet<>(Arrays.asList(ArtifactQuality.VERIFIED, ArtifactQuality.DELETED)), null);
// from DatabaseDataInitializer
assertThat(result).hasSize(2);
}
use of org.jboss.pnc.dto.response.ArtifactInfo in project pnc by project-ncl.
the class ArtifactEndpointTest method testGetAllArtifactsFilteredByBuildCategories.
@Test
public void testGetAllArtifactsFilteredByBuildCategories() throws RemoteResourceException {
ArtifactClient client = new ArtifactClient(RestClientConfiguration.asAnonymous());
RemoteCollection<ArtifactInfo> result;
result = client.getAllFiltered(null, null, null, new HashSet<>(Arrays.asList(BuildCategory.STANDARD)));
assertThat(result).allSatisfy(a -> assertThat(a.getBuildCategory().equals(BuildCategory.STANDARD)));
result = client.getAllFiltered(null, null, null, new HashSet<>(Arrays.asList(BuildCategory.SERVICE)));
// from DatabaseDataInitializer
assertThat(result).hasSize(2);
}
use of org.jboss.pnc.dto.response.ArtifactInfo in project pnc by project-ncl.
the class ArtifactEndpointTest method testGetAllArtifactsFilteredByRepoType.
@Test
public void testGetAllArtifactsFilteredByRepoType() throws RemoteResourceException {
ArtifactClient client = new ArtifactClient(RestClientConfiguration.asAnonymous());
RemoteCollection<ArtifactInfo> result;
RepositoryType type = RepositoryType.NPM;
result = client.getAllFiltered(null, null, type);
// from DatabaseDataInitializer
assertThat(result).hasSize(2).allSatisfy(a -> assertThat(a.getRepositoryType().equals(type)));
}
use of org.jboss.pnc.dto.response.ArtifactInfo in project pnc by project-ncl.
the class ArtifactProviderImpl method getAllFiltered.
@Override
public Page<ArtifactInfo> getAllFiltered(int pageIndex, int pageSize, Optional<String> identifierPattern, Set<ArtifactQuality> qualities, Optional<RepositoryType> repoType, Set<BuildCategory> buildCategories) {
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Tuple> query = artifactInfoQuery(cb, identifierPattern, qualities, repoType, buildCategories);
int offset = pageIndex * pageSize;
List<ArtifactInfo> artifacts = em.createQuery(query).setMaxResults(pageSize).setFirstResult(offset).getResultList().stream().map(this::mapTupleToArtifactInfo).collect(Collectors.toList());
Predicate<Artifact>[] predicates = getPredicates(identifierPattern, qualities, repoType, buildCategories);
int totalHits = repository.count(predicates);
int totalPages = (totalHits + pageSize - 1) / pageSize;
return new Page<>(pageIndex, pageSize, totalPages, totalHits, artifacts);
}
Aggregations