Search in sources :

Example 71 with BuildRecord

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);
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Build(org.jboss.pnc.dto.Build) BuildRecord(org.jboss.pnc.model.BuildRecord) SortInfo(org.jboss.pnc.spi.datastore.repositories.api.SortInfo)

Example 72 with BuildRecord

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);
}
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 73 with BuildRecord

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

Example 74 with BuildRecord

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);
}
Also used : ProductMilestone(org.jboss.pnc.model.ProductMilestone) ArrayList(java.util.ArrayList) BuildRecord(org.jboss.pnc.model.BuildRecord) Before(org.junit.Before)

Example 75 with BuildRecord

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

Aggregations

BuildRecord (org.jboss.pnc.model.BuildRecord)92 Test (org.junit.Test)50 Base32LongID (org.jboss.pnc.model.Base32LongID)19 Build (org.jboss.pnc.dto.Build)15 BuildTask (org.jboss.pnc.spi.coordinator.BuildTask)15 ContainerTest (org.jboss.pnc.test.category.ContainerTest)14 HashSet (java.util.HashSet)13 Artifact (org.jboss.pnc.model.Artifact)13 BuildConfiguration (org.jboss.pnc.model.BuildConfiguration)13 SortInfo (org.jboss.pnc.spi.datastore.repositories.api.SortInfo)13 Date (java.util.Date)12 List (java.util.List)12 BuildConfigSetRecord (org.jboss.pnc.model.BuildConfigSetRecord)12 BuildConfigurationAudited (org.jboss.pnc.model.BuildConfigurationAudited)12 DatastoreMock (org.jboss.pnc.mock.datastore.DatastoreMock)11 PageInfo (org.jboss.pnc.spi.datastore.repositories.api.PageInfo)11 Logger (org.slf4j.Logger)11 LoggerFactory (org.slf4j.LoggerFactory)11 Inject (javax.inject.Inject)10 BuildStatus (org.jboss.pnc.enums.BuildStatus)10