use of org.jboss.pnc.model.Base32LongID in project pnc by project-ncl.
the class BuildProviderImplTest method shouldThrowCorruptedDataExceptionTest.
@Test(expected = CorruptedDataException.class)
public void shouldThrowCorruptedDataExceptionTest() {
// given
mockBuildRecord(new Base32LongID(200000L), new Long[] {}, new Long[] {});
BuildRecord buildRecord = mockBuildRecord(new Base32LongID(200001L), new Long[] { 200000L, 220000L }, new Long[] {});
// when
Graph<Build> dependencyGraph = provider.getDependencyGraph(BuildMapper.idMapper.toDto(buildRecord.getId()));
}
use of org.jboss.pnc.model.Base32LongID in project pnc by project-ncl.
the class BuildProviderImplTest method prepareMock.
@Before
public void prepareMock() throws ReflectiveOperationException, IllegalArgumentException {
when(repository.queryWithPredicatesUsingCursor(any(PageInfo.class), any(SortInfo.class), any())).thenAnswer(new ListAnswer(repositoryList));
when(repository.findByIdFetchProperties(any())).thenAnswer(inv -> {
Base32LongID id = inv.getArgument(0);
return repositoryList.stream().filter(a -> id.equals(a.getId())).findFirst().orElse(null);
});
when(buildCoordinator.getSubmittedBuildTasks()).thenReturn(runningBuilds);
when(sortInfoProducer.getSortInfo(any(), any())).thenAnswer(i -> mock(SortInfo.class));
when(rsqlPredicateProducer.getSortInfo(any(), any())).thenAnswer(i -> mock(SortInfo.class));
user = mock(User.class);
when(user.getLoginToken()).thenReturn(USER_TOKEN);
when(userService.currentUser()).thenReturn(user);
BuildConfigSetRecord buildConfigSetRecord = BuildConfigSetRecord.Builder.newBuilder().id(1).temporaryBuild(false).build();
when(buildConfigSetRecordRepository.queryById(any())).thenReturn(buildConfigSetRecord);
}
use of org.jboss.pnc.model.Base32LongID in project pnc by project-ncl.
the class BuildProviderImplTest method testPage.
private void testPage(int idx, int size, Base32LongID... ids) {
BuildPageInfo pageInfo = new BuildPageInfo(idx, size, "", "", false, false, "");
Page<Build> builds = provider.getBuilds(pageInfo);
Iterator<Build> it = builds.getContent().iterator();
for (Base32LongID id : ids) {
assertEquals(BuildMapper.idMapper.toDto(id), it.next().getId());
}
assertFalse(it.hasNext());
}
use of org.jboss.pnc.model.Base32LongID 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.Base32LongID in project pnc by project-ncl.
the class RSQLPredicateProducerTest method testCriteriaPredicate.
@Test
public void testCriteriaPredicate() {
Base32LongID id = new Base32LongID(4L);
org.jboss.pnc.spi.datastore.repositories.api.Predicate<BuildRecord> criteriaPredicate = producer.getCriteriaPredicate(BuildRecord.class, "id==" + id.getId());
CriteriaBuilder cb = mock(CriteriaBuilder.class);
Root<BuildRecord> root = mock(Root.class);
SingularAttributePath<Base32LongID> idPath = mock(SingularAttributePath.class);
when(root.get(BuildRecord_.id)).thenReturn(idPath);
Mockito.doReturn(Base32LongID.class).when(idPath).getJavaType();
SingularAttribute pathAttribute = mock(SingularAttribute.class);
java.lang.reflect.Member javaMember = mock(java.lang.reflect.Member.class);
Mockito.doReturn(BuildRecord.class).when(javaMember).getDeclaringClass();
Mockito.doReturn(javaMember).when(pathAttribute).getJavaMember();
Mockito.doReturn("id").when(pathAttribute).getName();
Mockito.doReturn(pathAttribute).when(idPath).getAttribute();
criteriaPredicate.apply(root, null, cb);
Mockito.verify(cb).equal(idPath, id);
}
Aggregations