Search in sources :

Example 1 with BuildConfigurationRepositoryMock

use of org.jboss.pnc.mock.repository.BuildConfigurationRepositoryMock in project pnc by project-ncl.

the class AbstractDependentBuildTest method initialize.

@Before
@SuppressWarnings("unchecked")
public void initialize() throws DatastoreException, ConfigurationParseException {
    MockitoAnnotations.initMocks(this);
    builtTasks = new ArrayList<>();
    user = new User();
    user.setId(375939);
    user.setUsername("username");
    Configuration config = mock(Configuration.class);
    SystemConfig systemConfig = mock(SystemConfig.class);
    when(systemConfig.getCoordinatorThreadPoolSize()).thenReturn(1);
    when(systemConfig.getCoordinatorMaxConcurrentBuilds()).thenReturn(1);
    when(systemConfig.getTemporaryBuildsLifeSpan()).thenReturn(1);
    when(config.getModuleConfig(any())).thenReturn(systemConfig);
    buildQueue = new BuildQueue(config.getModuleConfig(new PncConfigProvider<>(SystemConfig.class)));
    if (buildConfigurationRepository == null) {
        buildConfigurationRepository = new BuildConfigurationRepositoryMock();
    }
    buildRecordRepository = new BuildRecordRepositoryMock();
    buildConfigurationAuditedRepository = new BuildConfigurationAuditedRepositoryMock();
    TargetRepositoryRepository targetRepositoryRepository = new TargetRepositoryRepositoryMock();
    DefaultDatastore datastore = new DefaultDatastore(new ArtifactRepositoryMock(), buildRecordRepository, buildConfigurationRepository, buildConfigurationAuditedRepository, new BuildConfigSetRecordRepositoryMock(), new UserRepositoryMock(), targetRepositoryRepository);
    DatastoreAdapter datastoreAdapter = new DatastoreAdapter(datastore);
    if (buildSchedulerFactory == null) {
        buildSchedulerFactory = new MockBuildSchedulerFactory();
    }
    coordinator = new DefaultBuildCoordinator(datastoreAdapter, mock(Event.class), mock(Event.class), buildSchedulerFactory, buildQueue, systemConfig, mock(GroupBuildMapper.class), mock(BuildMapper.class));
    buildQueue.initSemaphore();
    coordinator.start();
}
Also used : BuildQueue(org.jboss.pnc.coordinator.builder.BuildQueue) SystemConfig(org.jboss.pnc.common.json.moduleconfig.SystemConfig) User(org.jboss.pnc.model.User) BuildConfigSetRecordRepositoryMock(org.jboss.pnc.mock.repository.BuildConfigSetRecordRepositoryMock) BuildConfiguration(org.jboss.pnc.model.BuildConfiguration) BuildExecutionConfiguration(org.jboss.pnc.spi.executor.BuildExecutionConfiguration) RepositoryConfiguration(org.jboss.pnc.model.RepositoryConfiguration) Configuration(org.jboss.pnc.common.Configuration) BuildRecordRepositoryMock(org.jboss.pnc.mock.repository.BuildRecordRepositoryMock) TargetRepositoryRepositoryMock(org.jboss.pnc.mock.repository.TargetRepositoryRepositoryMock) BuildConfigurationRepositoryMock(org.jboss.pnc.mock.repository.BuildConfigurationRepositoryMock) BuildConfigurationAuditedRepositoryMock(org.jboss.pnc.mock.repository.BuildConfigurationAuditedRepositoryMock) TargetRepositoryRepository(org.jboss.pnc.spi.datastore.repositories.TargetRepositoryRepository) DatastoreAdapter(org.jboss.pnc.coordinator.builder.datastore.DatastoreAdapter) DefaultBuildCoordinator(org.jboss.pnc.coordinator.builder.DefaultBuildCoordinator) DefaultDatastore(org.jboss.pnc.datastore.DefaultDatastore) ArtifactRepositoryMock(org.jboss.pnc.mock.repository.ArtifactRepositoryMock) UserRepositoryMock(org.jboss.pnc.mock.repository.UserRepositoryMock) Before(org.junit.Before)

Example 2 with BuildConfigurationRepositoryMock

use of org.jboss.pnc.mock.repository.BuildConfigurationRepositoryMock in project pnc by project-ncl.

the class OutsideGroupDependentConfigsTest method initialize.

@Before
public void initialize() throws DatastoreException, ConfigurationParseException {
    config1 = buildConfig("1");
    configA = buildConfig("A", config1);
    configB = buildConfig("B", configA);
    BuildConfiguration configC = buildConfig("C");
    configSet = configSet(configA, configB, configC);
    buildConfigurationRepository = spy(new BuildConfigurationRepositoryMock());
    when(buildConfigurationRepository.queryWithPredicates(any())).thenReturn(new ArrayList<>(configSet.getBuildConfigurations()));
    super.initialize();
    saveConfig(config1);
    configSet.getBuildConfigurations().forEach(this::saveConfig);
    insertNewBuildRecords(config1, configA, configB, configC);
    makeResult(configA).dependOn(config1);
}
Also used : BuildConfiguration(org.jboss.pnc.model.BuildConfiguration) BuildConfigurationRepositoryMock(org.jboss.pnc.mock.repository.BuildConfigurationRepositoryMock) Before(org.junit.Before)

Aggregations

BuildConfigurationRepositoryMock (org.jboss.pnc.mock.repository.BuildConfigurationRepositoryMock)2 BuildConfiguration (org.jboss.pnc.model.BuildConfiguration)2 Before (org.junit.Before)2 Configuration (org.jboss.pnc.common.Configuration)1 SystemConfig (org.jboss.pnc.common.json.moduleconfig.SystemConfig)1 BuildQueue (org.jboss.pnc.coordinator.builder.BuildQueue)1 DefaultBuildCoordinator (org.jboss.pnc.coordinator.builder.DefaultBuildCoordinator)1 DatastoreAdapter (org.jboss.pnc.coordinator.builder.datastore.DatastoreAdapter)1 DefaultDatastore (org.jboss.pnc.datastore.DefaultDatastore)1 ArtifactRepositoryMock (org.jboss.pnc.mock.repository.ArtifactRepositoryMock)1 BuildConfigSetRecordRepositoryMock (org.jboss.pnc.mock.repository.BuildConfigSetRecordRepositoryMock)1 BuildConfigurationAuditedRepositoryMock (org.jboss.pnc.mock.repository.BuildConfigurationAuditedRepositoryMock)1 BuildRecordRepositoryMock (org.jboss.pnc.mock.repository.BuildRecordRepositoryMock)1 TargetRepositoryRepositoryMock (org.jboss.pnc.mock.repository.TargetRepositoryRepositoryMock)1 UserRepositoryMock (org.jboss.pnc.mock.repository.UserRepositoryMock)1 RepositoryConfiguration (org.jboss.pnc.model.RepositoryConfiguration)1 User (org.jboss.pnc.model.User)1 TargetRepositoryRepository (org.jboss.pnc.spi.datastore.repositories.TargetRepositoryRepository)1 BuildExecutionConfiguration (org.jboss.pnc.spi.executor.BuildExecutionConfiguration)1