Search in sources :

Example 6 with DatastoreMock

use of org.jboss.pnc.mock.datastore.DatastoreMock 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());
}
Also used : BuildConfiguration(org.jboss.pnc.model.BuildConfiguration) BuildConfigurationAudited(org.jboss.pnc.model.BuildConfigurationAudited) BuildResult(org.jboss.pnc.spi.BuildResult) BuildTask(org.jboss.pnc.spi.coordinator.BuildTask) BuildExecutionConfiguration(org.jboss.pnc.spi.executor.BuildExecutionConfiguration) DatastoreMock(org.jboss.pnc.mock.datastore.DatastoreMock) DatastoreAdapter(org.jboss.pnc.coordinator.builder.datastore.DatastoreAdapter) RepourResult(org.jboss.pnc.spi.repour.RepourResult) BuildRecord(org.jboss.pnc.model.BuildRecord) Test(org.junit.Test)

Example 7 with DatastoreMock

use of org.jboss.pnc.mock.datastore.DatastoreMock in project pnc by project-ncl.

the class DatastoreAdapterTest method shouldStoreRepositoryManagerSuccessResult.

@Test
public void shouldStoreRepositoryManagerSuccessResult() throws DatastoreException {
    // given
    DatastoreMock datastore = new DatastoreMock();
    DatastoreAdapter datastoreAdapter = new DatastoreAdapter(datastore);
    BuildStatus buildStatus = BuildStatus.SUCCESS;
    CompletionStatus completionStatus = CompletionStatus.SUCCESS;
    // when
    storeResult(datastoreAdapter, buildStatus, completionStatus);
    // then
    List<BuildRecord> buildRecords = datastore.getBuildRecords();
    Assert.assertEquals(1, buildRecords.size());
    BuildRecord buildRecord = buildRecords.get(0);
    Assert.assertEquals(buildRecord.getStatus(), BuildStatus.SUCCESS);
    Assert.assertTrue(buildRecord.getBuildLog().contains(BUILD_LOG));
    Assert.assertTrue(buildRecord.getBuildLog().contains(REPOSITORY_MANAGER_LOG));
}
Also used : CompletionStatus(org.jboss.pnc.spi.coordinator.CompletionStatus) DatastoreMock(org.jboss.pnc.mock.datastore.DatastoreMock) BuildStatus(org.jboss.pnc.enums.BuildStatus) DatastoreAdapter(org.jboss.pnc.coordinator.builder.datastore.DatastoreAdapter) BuildRecord(org.jboss.pnc.model.BuildRecord) Test(org.junit.Test)

Example 8 with DatastoreMock

use of org.jboss.pnc.mock.datastore.DatastoreMock 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());
}
Also used : BuildCoordinator(org.jboss.pnc.spi.coordinator.BuildCoordinator) BuildTask(org.jboss.pnc.spi.coordinator.BuildTask) BuildOptions(org.jboss.pnc.spi.BuildOptions) TestProjectConfigurationBuilder(org.jboss.pnc.mock.model.builders.TestProjectConfigurationBuilder) BuildStatusChangedEvent(org.jboss.pnc.spi.events.BuildStatusChangedEvent) DatastoreMock(org.jboss.pnc.mock.datastore.DatastoreMock) BuildRecord(org.jboss.pnc.model.BuildRecord) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) Test(org.junit.Test)

Example 9 with DatastoreMock

use of org.jboss.pnc.mock.datastore.DatastoreMock in project pnc by project-ncl.

the class SingleProjectBuildTest method buildSingleProjectTestCase.

@Test
public void buildSingleProjectTestCase() throws Exception {
    // given
    DatastoreMock datastoreMock = new DatastoreMock();
    TestProjectConfigurationBuilder configurationBuilder = new TestProjectConfigurationBuilder(datastoreMock);
    List<BuildStatusChangedEvent> receivedStatuses = new CopyOnWriteArrayList<>();
    // when
    BuildCoordinator coordinator = buildCoordinatorFactory.createBuildCoordinator(datastoreMock).coordinator;
    buildProject(configurationBuilder.build(1, "c1-java"), coordinator, receivedStatuses::add);
    // expect
    List<BuildRecord> buildRecords = datastoreMock.getBuildRecords();
    Assert.assertEquals("Wrong datastore results count.", 1, buildRecords.size());
    BuildRecord buildRecord = buildRecords.get(0);
    String buildLog = buildRecord.getBuildLog();
    Assert.assertTrue("Invalid build log.", buildLog.contains(BuildDriverResultMock.BUILD_LOG));
    assertArtifactsPresent(buildRecord.getBuiltArtifacts());
    assertArtifactsPresent(buildRecord.getDependencies());
    Assert.assertNotNull(buildRecord.getSubmitTime());
    Assert.assertNotNull(buildRecord.getStartTime());
    Assert.assertNotNull(buildRecord.getEndTime());
    receivedStatuses.stream().filter(e -> e.getNewStatus().isFinal()).forEach(e -> Assert.assertNotNull("Final event " + e + " should have end build time.", e.getBuild().getEndTime()));
}
Also used : BuildCoordinator(org.jboss.pnc.spi.coordinator.BuildCoordinator) BuildOptions(org.jboss.pnc.spi.BuildOptions) Arquillian(org.jboss.arquillian.junit.Arquillian) BuildCoordinator(org.jboss.pnc.spi.coordinator.BuildCoordinator) RunWith(org.junit.runner.RunWith) AlignmentPreference(org.jboss.pnc.api.enums.AlignmentPreference) Test(org.junit.Test) BuildRecord(org.jboss.pnc.model.BuildRecord) RebuildMode(org.jboss.pnc.enums.RebuildMode) BuildTask(org.jboss.pnc.spi.coordinator.BuildTask) BuildDriverResultMock(org.jboss.pnc.mock.builddriver.BuildDriverResultMock) TestProjectConfigurationBuilder(org.jboss.pnc.mock.model.builders.TestProjectConfigurationBuilder) DatastoreMock(org.jboss.pnc.mock.datastore.DatastoreMock) Inject(javax.inject.Inject) List(java.util.List) Deployment(org.jboss.arquillian.container.test.api.Deployment) JavaArchive(org.jboss.shrinkwrap.api.spec.JavaArchive) BuildStatusChangedEvent(org.jboss.pnc.spi.events.BuildStatusChangedEvent) Assert(org.junit.Assert) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) TestProjectConfigurationBuilder(org.jboss.pnc.mock.model.builders.TestProjectConfigurationBuilder) BuildStatusChangedEvent(org.jboss.pnc.spi.events.BuildStatusChangedEvent) DatastoreMock(org.jboss.pnc.mock.datastore.DatastoreMock) BuildRecord(org.jboss.pnc.model.BuildRecord) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) Test(org.junit.Test)

Example 10 with DatastoreMock

use of org.jboss.pnc.mock.datastore.DatastoreMock 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());
}
Also used : BuildCoordinator(org.jboss.pnc.spi.coordinator.BuildCoordinator) BuildTask(org.jboss.pnc.spi.coordinator.BuildTask) BuildOptions(org.jboss.pnc.spi.BuildOptions) TestProjectConfigurationBuilder(org.jboss.pnc.mock.model.builders.TestProjectConfigurationBuilder) BuildStatusChangedEvent(org.jboss.pnc.spi.events.BuildStatusChangedEvent) DatastoreMock(org.jboss.pnc.mock.datastore.DatastoreMock) BuildRecord(org.jboss.pnc.model.BuildRecord) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) Test(org.junit.Test)

Aggregations

DatastoreMock (org.jboss.pnc.mock.datastore.DatastoreMock)10 BuildRecord (org.jboss.pnc.model.BuildRecord)10 Test (org.junit.Test)10 TestProjectConfigurationBuilder (org.jboss.pnc.mock.model.builders.TestProjectConfigurationBuilder)6 DatastoreAdapter (org.jboss.pnc.coordinator.builder.datastore.DatastoreAdapter)5 BuildCoordinator (org.jboss.pnc.spi.coordinator.BuildCoordinator)5 BuildTask (org.jboss.pnc.spi.coordinator.BuildTask)5 BuildStatusChangedEvent (org.jboss.pnc.spi.events.BuildStatusChangedEvent)5 BuildOptions (org.jboss.pnc.spi.BuildOptions)4 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)3 BuildStatus (org.jboss.pnc.enums.BuildStatus)3 List (java.util.List)2 Inject (javax.inject.Inject)2 Deployment (org.jboss.arquillian.container.test.api.Deployment)2 Arquillian (org.jboss.arquillian.junit.Arquillian)2 CompletionStatus (org.jboss.pnc.spi.coordinator.CompletionStatus)2 JavaArchive (org.jboss.shrinkwrap.api.spec.JavaArchive)2 Assert (org.junit.Assert)2 RunWith (org.junit.runner.RunWith)2 ArrayList (java.util.ArrayList)1