use of org.jboss.pnc.model.BuildConfigurationAudited in project pnc by project-ncl.
the class DefaultBuildCoordinatorTest method testBuildBuildConfigurationSetWithAudited.
@Test
public void testBuildBuildConfigurationSetWithAudited() throws BuildConflictException, CoreException, DatastoreException {
BuildConfigurationAudited bca = mockDatastoreWithBCAudited(BC_1, 5);
BuildConfigurationAudited bcaDep = mockDatastoreWithBCAudited(BC_2, 2);
BuildConfigurationAudited bca3 = mockDatastoreWithBCAudited(BC_3, 9);
BuildConfigurationAudited reqBCA = toBuildConfigurationAudited(BC_1, 4);
reqBCA.setName("build-config-changed");
when(datastore.getBuildConfigurations(BCS)).thenReturn(BCS.getBuildConfigurations());
Map<Integer, BuildConfigurationAudited> overrides = Collections.singletonMap(1, reqBCA);
BuildSetTask buildSetTask = coordinator.build(BCS, overrides, USER, BUILD_OPTIONS);
assertEquals(2, buildSetTask.getBuildTasks().size());
BuildTask buildTask = buildSetTask.getBuildTask(reqBCA);
assertNotNull(buildTask);
assertNull(buildSetTask.getBuildTask(bca));
// Dependencies outside group are not build
assertNull(buildSetTask.getBuildTask(bcaDep));
assertNotNull(buildSetTask.getBuildTask(bca3));
assertEquals(4, buildTask.getBuildConfigurationAudited().getRev().intValue());
assertEquals("build-config-changed", buildTask.getBuildConfigurationAudited().getName());
assertSame(BUILD_OPTIONS, buildSetTask.getBuildOptions());
}
use of org.jboss.pnc.model.BuildConfigurationAudited in project pnc by project-ncl.
the class DefaultBuildCoordinatorTest method mockDatastoreWithBCAudited.
private BuildConfigurationAudited mockDatastoreWithBCAudited(BuildConfiguration bc, int rev) {
BuildConfigurationAudited bca = toBuildConfigurationAudited(bc, rev);
when(datastore.getLatestBuildConfigurationAudited(bc.getId())).thenReturn(bca);
when(datastore.getLatestBuildConfigurationAuditedLoadBCDependencies(bc.getId())).thenReturn(bca);
return bca;
}
use of org.jboss.pnc.model.BuildConfigurationAudited in project pnc by project-ncl.
the class DefaultBuildCoordinatorTest method testBuildBuildConfigurationAudited.
@Test
public void testBuildBuildConfigurationAudited() throws BuildConflictException, CoreException {
assertTrue("Test assumes that we build with dependencies", BUILD_OPTIONS.isBuildDependencies());
BuildConfigurationAudited bca = mockDatastoreWithBCAudited(BC_1, 5);
BuildConfigurationAudited bcaDep = mockDatastoreWithBCAudited(BC_2, 2);
BuildConfigurationAudited reqBCA = toBuildConfigurationAudited(BC_1, 4);
reqBCA.setName("build-config-changed");
BuildSetTask buildSetTask = coordinator.build(reqBCA, USER, BUILD_OPTIONS);
assertEquals(2, buildSetTask.getBuildTasks().size());
BuildTask buildTask = buildSetTask.getBuildTask(reqBCA);
assertNotNull(buildTask);
assertNotNull(buildSetTask.getBuildTask(bcaDep));
assertNull(buildSetTask.getBuildTask(bca));
assertEquals(4, buildTask.getBuildConfigurationAudited().getRev().intValue());
assertEquals("build-config-changed", buildTask.getBuildConfigurationAudited().getName());
assertSame(BUILD_OPTIONS, buildSetTask.getBuildOptions());
}
use of org.jboss.pnc.model.BuildConfigurationAudited in project pnc by project-ncl.
the class DefaultBuildCoordinatorTest method testBuildBuildConfiguration.
@Test
public void testBuildBuildConfiguration() throws BuildConflictException, CoreException {
assertTrue("Test assumes that we build with dependencies", BUILD_OPTIONS.isBuildDependencies());
BuildConfigurationAudited bca = mockDatastoreWithBCAudited(BC_1, 5);
BuildConfigurationAudited bcaDep = mockDatastoreWithBCAudited(BC_2, 2);
BuildSetTask buildSetTask = coordinator.build(BC_1, USER, BUILD_OPTIONS);
assertEquals(2, buildSetTask.getBuildTasks().size());
assertNotNull(buildSetTask.getBuildTask(bca));
assertNotNull(buildSetTask.getBuildTask(bcaDep));
assertSame(BUILD_OPTIONS, buildSetTask.getBuildOptions());
}
use of org.jboss.pnc.model.BuildConfigurationAudited in project pnc by project-ncl.
the class DefaultBuildCoordinatorTest method shouldCreateNoRebuildRequiredRecords.
@Test
public void shouldCreateNoRebuildRequiredRecords() throws CoreException, TimeoutException, InterruptedException {
when(datastore.requiresRebuild(any(BuildConfigurationAudited.class), any(Boolean.class), any(Boolean.class), nullable(AlignmentPreference.class), anySet())).thenReturn(false);
BuildConfigurationAudited bca1 = new BuildConfigurationAudited();
IdRev idRev1 = new IdRev(BC_1.getId(), BC_1.getId() * 1000 + 1);
bca1.setIdRev(idRev1);
bca1.setId(idRev1.getId());
bca1.setRev(idRev1.getRev());
bca1.setProject(PROJECT);
when(datastore.getLatestBuildConfigurationAuditedLoadBCDependencies(BC_1.getId())).thenReturn(bca1);
BuildConfigurationAudited bca3 = new BuildConfigurationAudited();
IdRev idRev3 = new IdRev(BC_3.getId(), BC_3.getId() * 1000 + 1);
bca3.setIdRev(idRev3);
bca3.setId(idRev3.getId());
bca3.setRev(idRev3.getRev());
bca3.setProject(PROJECT);
when(datastore.getLatestBuildConfigurationAuditedLoadBCDependencies(BC_3.getId())).thenReturn(bca3);
Set<BuildConfiguration> buildConfigs = new HashSet<>();
buildConfigs.add(BC_1);
buildConfigs.add(BC_3);
when(datastore.getBuildConfigurations(any())).thenReturn(buildConfigs);
Set<BuildRecord> storedRecords = new HashSet<>();
when(datastore.storeRecordForNoRebuild(any())).thenAnswer(new SaveRecordForNoRebuildAnswer(storedRecords));
BuildSetTask bsTask = coordinator.build(BCS, USER, BUILD_OPTIONS);
coordinator.start();
assertThat(bsTask.getBuildConfigSetRecord().get().getStatus()).isEqualTo(BuildStatus.NO_REBUILD_REQUIRED);
Wait.forCondition(() -> storedRecords.size() == 2, 3, ChronoUnit.SECONDS);
assertThat(storedRecords.size()).isEqualTo(2);
}
Aggregations