Search in sources :

Example 16 with Base32LongID

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()));
}
Also used : Base32LongID(org.jboss.pnc.model.Base32LongID) Build(org.jboss.pnc.dto.Build) BuildRecord(org.jboss.pnc.model.BuildRecord) Test(org.junit.Test)

Example 17 with Base32LongID

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);
}
Also used : PageInfo(org.jboss.pnc.spi.datastore.repositories.api.PageInfo) BuildPageInfo(org.jboss.pnc.facade.providers.api.BuildPageInfo) Base32LongID(org.jboss.pnc.model.Base32LongID) User(org.jboss.pnc.model.User) SortInfo(org.jboss.pnc.spi.datastore.repositories.api.SortInfo) BuildConfigSetRecord(org.jboss.pnc.model.BuildConfigSetRecord) Before(org.junit.Before)

Example 18 with Base32LongID

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());
}
Also used : Base32LongID(org.jboss.pnc.model.Base32LongID) Build(org.jboss.pnc.dto.Build) BuildPageInfo(org.jboss.pnc.facade.providers.api.BuildPageInfo)

Example 19 with Base32LongID

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);
}
Also used : BuildConfigurationAudited(org.jboss.pnc.model.BuildConfigurationAudited) Base32LongID(org.jboss.pnc.model.Base32LongID) BuildCategory(org.jboss.pnc.enums.BuildCategory) Indy(org.commonjava.indy.client.core.Indy) BuildType(org.jboss.pnc.enums.BuildType) BuildRecord(org.jboss.pnc.model.BuildRecord)

Example 20 with Base32LongID

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);
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) Base32LongID(org.jboss.pnc.model.Base32LongID) BuildRecord(org.jboss.pnc.model.BuildRecord) SingularAttribute(javax.persistence.metamodel.SingularAttribute) Test(org.junit.Test)

Aggregations

Base32LongID (org.jboss.pnc.model.Base32LongID)26 BuildRecord (org.jboss.pnc.model.BuildRecord)18 Test (org.junit.Test)7 Build (org.jboss.pnc.dto.Build)6 BuildConfigurationAudited (org.jboss.pnc.model.BuildConfigurationAudited)6 Date (java.util.Date)5 BuildPageInfo (org.jboss.pnc.facade.providers.api.BuildPageInfo)5 IdRev (org.jboss.pnc.model.IdRev)5 BuildTask (org.jboss.pnc.spi.coordinator.BuildTask)5 List (java.util.List)4 Map (java.util.Map)4 Set (java.util.Set)4 BuildConfigSetRecord (org.jboss.pnc.model.BuildConfigSetRecord)4 Collectors (java.util.stream.Collectors)3 Stateless (javax.ejb.Stateless)3 Inject (javax.inject.Inject)3 BuildConfiguration (org.jboss.pnc.model.BuildConfiguration)3 BuildConfigurationAuditedRepository (org.jboss.pnc.spi.datastore.repositories.BuildConfigurationAuditedRepository)3 BuildRecordRepository (org.jboss.pnc.spi.datastore.repositories.BuildRecordRepository)3 Logger (org.slf4j.Logger)3