use of org.jboss.pnc.spi.coordinator.BuildTask in project pnc by project-ncl.
the class DatastoreAdapterTest method shouldStoreRepourResult.
@Test
public void shouldStoreRepourResult() throws DatastoreException {
// given
DatastoreMock datastore = new DatastoreMock();
DatastoreAdapter datastoreAdapter = new DatastoreAdapter(datastore);
RepourResult repourResult = RepourResultMock.mock();
// when
BuildConfiguration buildConfiguration = BuildConfiguration.Builder.newBuilder().name("Configuration.").build();
BuildConfigurationAudited buildConfigurationAudited = BuildConfigurationAudited.Builder.newBuilder().buildConfiguration(buildConfiguration).build();
BuildTask buildTask = mockBuildTask();
BuildExecutionConfiguration buildExecutionConfiguration = mock(BuildExecutionConfiguration.class);
BuildResult buildResult = new BuildResult(CompletionStatus.SUCCESS, Optional.empty(), "", Optional.of(buildExecutionConfiguration), Optional.of(BuildDriverResultMock.mockResult(BuildStatus.SUCCESS)), Optional.of(RepositoryManagerResultMock.mockResult()), Optional.of(EnvironmentDriverResultMock.mock()), Optional.of(repourResult));
datastoreAdapter.storeResult(buildTask, buildResult);
// then
List<BuildRecord> buildRecords = datastore.getBuildRecords();
Assert.assertEquals(1, buildRecords.size());
BuildRecord buildRecord = buildRecords.get(0);
Assert.assertEquals(buildRecord.getStatus(), BuildStatus.SUCCESS);
Assert.assertEquals(repourResult.getExecutionRootName(), buildRecord.getExecutionRootName());
Assert.assertEquals(repourResult.getExecutionRootVersion(), buildRecord.getExecutionRootVersion());
Assert.assertEquals(repourResult.getLog(), buildRecord.getRepourLog());
}
use of org.jboss.pnc.spi.coordinator.BuildTask in project pnc by project-ncl.
the class StatusUpdatesTest method BuildTaskCallbacksShouldBeCalled.
@Test
@InSequence(30)
public void BuildTaskCallbacksShouldBeCalled() throws DatastoreException, CoreException {
User user = User.Builder.newBuilder().id(3).username("test-user-3").build();
Set<BuildTask> buildTasks = initializeBuildTaskSet(configurationBuilder, user, (buildConfigSetRecord) -> {
}).getBuildTasks();
Set<String> tasksIds = buildTasks.stream().map((BuildTask::getId)).collect(Collectors.toSet());
Set<String> receivedUpdatesForId = new HashSet<>();
Consumer<BuildStatusChangedEvent> statusChangeEventConsumer = (statusChangedEvent) -> {
receivedUpdatesForId.add(statusChangedEvent.getBuild().getId());
};
tasksIds.forEach((id) -> buildStatusNotifications.subscribe(new BuildCallBack(id, statusChangeEventConsumer)));
buildTasks.forEach((bt) -> buildCoordinator.updateBuildTaskStatus(bt, BuildCoordinationStatus.DONE));
System.out.println("Received updates: " + receivedUpdatesForId);
tasksIds.forEach((id) -> Assert.assertTrue("Did not receive update for task " + id, receivedUpdatesForId.contains(id)));
}
use of org.jboss.pnc.spi.coordinator.BuildTask in project pnc by project-ncl.
the class ReadDependenciesTest method createDependenciesTestCase.
@Test
public void createDependenciesTestCase() throws DatastoreException {
BuildConfigurationSet buildConfigurationSet = configurationBuilder.buildConfigurationSet(1);
User user = User.Builder.newBuilder().id(1).username("test-user").build();
BuildSetTask buildSetTask = null;
try {
buildSetTask = createBuildSetTask(buildConfigurationSet, user);
} catch (CoreException e) {
Assert.fail(e.getMessage());
}
Assert.assertEquals("Missing build tasks in set.", 5, buildSetTask.getBuildTasks().size());
BuildTask buildTask2 = buildSetTask.getBuildTasks().stream().filter(task -> task.getBuildConfigurationAudited().getId().equals(2)).findFirst().get();
Assert.assertEquals("Wrong number of dependencies.", 2, buildTask2.getDependencies().size());
}
use of org.jboss.pnc.spi.coordinator.BuildTask in project pnc by project-ncl.
the class SingleProjectBuildTest method buildWithAdvancedOptionsTest.
@Test
public void buildWithAdvancedOptionsTest() throws Exception {
// given
BuildOptions originalBuildOptions = new BuildOptions(true, true, true, true, RebuildMode.FORCE, AlignmentPreference.PREFER_PERSISTENT);
DatastoreMock datastoreMock = new DatastoreMock();
TestProjectConfigurationBuilder configurationBuilder = new TestProjectConfigurationBuilder(datastoreMock);
List<BuildStatusChangedEvent> receivedStatuses = new CopyOnWriteArrayList<>();
// when
BuildCoordinator coordinator = buildCoordinatorFactory.createBuildCoordinator(datastoreMock).coordinator;
BuildTask buildTask = buildProject(configurationBuilder.build(1, "c1-java"), coordinator, receivedStatuses::add, originalBuildOptions);
// then
List<BuildRecord> buildRecords = datastoreMock.getBuildRecords();
Assert.assertEquals("Wrong datastore results count.", 1, buildRecords.size());
Assert.assertEquals(originalBuildOptions, buildTask.getBuildOptions());
}
use of org.jboss.pnc.spi.coordinator.BuildTask in project pnc by project-ncl.
the class SingleProjectBuildTest method buildWithBasicOptionsTest.
@Test
public void buildWithBasicOptionsTest() throws Exception {
// given
DatastoreMock datastoreMock = new DatastoreMock();
TestProjectConfigurationBuilder configurationBuilder = new TestProjectConfigurationBuilder(datastoreMock);
List<BuildStatusChangedEvent> receivedStatuses = new CopyOnWriteArrayList<>();
// when
BuildCoordinator coordinator = buildCoordinatorFactory.createBuildCoordinator(datastoreMock).coordinator;
BuildTask buildTask = buildProject(configurationBuilder.build(1, "c1-java"), coordinator, receivedStatuses::add);
// then
List<BuildRecord> buildRecords = datastoreMock.getBuildRecords();
Assert.assertEquals("Wrong datastore results count.", 1, buildRecords.size());
Assert.assertEquals(new BuildOptions(), buildTask.getBuildOptions());
}
Aggregations