Search in sources :

Example 21 with ConfigElementImplementationRegistry

use of com.thoughtworks.go.config.registry.ConfigElementImplementationRegistry in project gocd by gocd.

the class FullConfigSaveNormalFlowTest method setup.

@Before
public void setup() throws Exception {
    configForEdit = new BasicCruiseConfig();
    updateConfigCommand = new FullConfigUpdateCommand(configForEdit, "md5");
    loader = mock(MagicalGoConfigXmlLoader.class);
    writer = mock(MagicalGoConfigXmlWriter.class);
    document = mock(Document.class);
    fileWriter = mock(GoConfigFileWriter.class);
    serverVersion = mock(ServerVersion.class);
    timeProvider = mock(TimeProvider.class);
    configRepository = mock(ConfigRepository.class);
    cachedGoPartials = mock(CachedGoPartials.class);
    configElementImplementationRegistry = mock(ConfigElementImplementationRegistry.class);
    partials = new ArrayList<>();
    flow = new FullConfigSaveNormalFlow(loader, writer, configElementImplementationRegistry, serverVersion, timeProvider, configRepository, cachedGoPartials, fileWriter);
}
Also used : ServerVersion(com.thoughtworks.go.server.util.ServerVersion) TimeProvider(com.thoughtworks.go.util.TimeProvider) ConfigRepository(com.thoughtworks.go.service.ConfigRepository) Document(org.jdom2.Document) FullConfigUpdateCommand(com.thoughtworks.go.config.update.FullConfigUpdateCommand) ConfigElementImplementationRegistry(com.thoughtworks.go.config.registry.ConfigElementImplementationRegistry) Before(org.junit.Before)

Example 22 with ConfigElementImplementationRegistry

use of com.thoughtworks.go.config.registry.ConfigElementImplementationRegistry in project gocd by gocd.

the class GoFileConfigDataSourceTest method setup.

@Before
public void setup() throws Exception {
    systemEnvironment = new SystemEnvironment();
    systemEnvironment.setProperty(SystemEnvironment.OPTIMIZE_FULL_CONFIG_SAVE.propertyName(), "false");
    configHelper = new GoConfigFileHelper();
    configHelper.onSetUp();
    configRepository = new ConfigRepository(systemEnvironment);
    configRepository.initialize();
    timeProvider = mock(TimeProvider.class);
    fullConfigSaveMergeFlow = mock(FullConfigSaveMergeFlow.class);
    fullConfigSaveNormalFlow = mock(FullConfigSaveNormalFlow.class);
    when(timeProvider.currentTime()).thenReturn(new Date());
    ServerVersion serverVersion = new ServerVersion();
    ConfigElementImplementationRegistry registry = ConfigElementImplementationRegistryMother.withNoPlugins();
    ServerHealthService serverHealthService = new ServerHealthService();
    cachedGoPartials = new CachedGoPartials(serverHealthService);
    dataSource = new GoFileConfigDataSource(new GoConfigMigration(new GoConfigMigration.UpgradeFailedHandler() {

        public void handle(Exception e) {
            throw new RuntimeException(e);
        }
    }, configRepository, new TimeProvider(), configCache, registry), configRepository, systemEnvironment, timeProvider, configCache, serverVersion, registry, mock(ServerHealthService.class), cachedGoPartials, fullConfigSaveMergeFlow, fullConfigSaveNormalFlow);
    dataSource.upgradeIfNecessary();
    CachedGoConfig cachedGoConfig = new CachedGoConfig(serverHealthService, dataSource, mock(CachedGoPartials.class), null, null);
    cachedGoConfig.loadConfigIfNull();
    goConfigDao = new GoConfigDao(cachedGoConfig);
    configHelper.load();
    configHelper.usingCruiseConfigDao(goConfigDao);
    GoConfigWatchList configWatchList = new GoConfigWatchList(cachedGoConfig, mock(GoConfigService.class));
    ConfigElementImplementationRegistry configElementImplementationRegistry = new ConfigElementImplementationRegistry(new NoPluginsInstalled());
    GoConfigPluginService configPluginService = new GoConfigPluginService(mock(ConfigRepoExtension.class), new ConfigCache(), configElementImplementationRegistry, cachedGoConfig);
    repoConfig = new ConfigRepoConfig(new GitMaterialConfig("url"), "plugin");
    configHelper.addConfigRepo(repoConfig);
    SecurityContext context = SecurityContextHolder.getContext();
    context.setAuthentication(new UsernamePasswordAuthenticationToken(new User("loser_boozer", "pass", true, true, true, true, new GrantedAuthority[] {}), null));
}
Also used : ServerVersion(com.thoughtworks.go.server.util.ServerVersion) User(org.springframework.security.userdetails.User) ConfigRepository(com.thoughtworks.go.service.ConfigRepository) UsernamePasswordAuthenticationToken(org.springframework.security.providers.UsernamePasswordAuthenticationToken) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) ServerHealthService(com.thoughtworks.go.serverhealth.ServerHealthService) NoPluginsInstalled(com.thoughtworks.go.config.registry.NoPluginsInstalled) ConfigRepoConfig(com.thoughtworks.go.config.remote.ConfigRepoConfig) ConfigFileHasChangedException(com.thoughtworks.go.config.exceptions.ConfigFileHasChangedException) GitAPIException(org.eclipse.jgit.api.errors.GitAPIException) GoConfigInvalidException(com.thoughtworks.go.config.exceptions.GoConfigInvalidException) ExpectedException(org.junit.rules.ExpectedException) ConfigMergeException(com.thoughtworks.go.config.exceptions.ConfigMergeException) IOException(java.io.IOException) GoConfigService(com.thoughtworks.go.server.service.GoConfigService) ConfigElementImplementationRegistry(com.thoughtworks.go.config.registry.ConfigElementImplementationRegistry) SecurityContext(org.springframework.security.context.SecurityContext) ConfigRepoExtension(com.thoughtworks.go.plugin.access.configrepo.ConfigRepoExtension) Before(org.junit.Before)

Example 23 with ConfigElementImplementationRegistry

use of com.thoughtworks.go.config.registry.ConfigElementImplementationRegistry in project gocd by gocd.

the class GoConfigMigrationTest method setUp.

@Before
public void setUp() throws IOException {
    configRepo = mock(ConfigRepository.class);
    TimeProvider timeProvider = mock(TimeProvider.class);
    when(timeProvider.currentTime()).thenReturn(new Date());
    ConfigElementImplementationRegistry registry = ConfigElementImplementationRegistryMother.withNoPlugins();
    goConfigMigration = new GoConfigMigration(configRepo, timeProvider, new ConfigCache(), registry);
}
Also used : TimeProvider(com.thoughtworks.go.util.TimeProvider) ConfigElementImplementationRegistry(com.thoughtworks.go.config.registry.ConfigElementImplementationRegistry) ConfigRepository(com.thoughtworks.go.service.ConfigRepository) Date(java.util.Date) Before(org.junit.Before)

Example 24 with ConfigElementImplementationRegistry

use of com.thoughtworks.go.config.registry.ConfigElementImplementationRegistry in project gocd by gocd.

the class PipelineSelectionsServiceTest method setup.

@Before
public void setup() throws Exception {
    new SystemEnvironment().setProperty(SystemEnvironment.ENFORCE_SERVER_IMMUTABILITY, "N");
    goConfigDao = mock(GoConfigDao.class);
    pipelineRepository = mock(PipelineRepository.class);
    pipelinePauseService = mock(PipelinePauseService.class);
    systemEnvironment = mock(SystemEnvironment.class);
    cruiseConfig = unchangedConfig();
    expectLoad(cruiseConfig);
    this.clock = mock(Clock.class);
    userDao = mock(UserDao.class);
    stub(systemEnvironment.optimizeFullConfigSave()).toReturn(false);
    ConfigElementImplementationRegistry registry = ConfigElementImplementationRegistryMother.withNoPlugins();
    goConfigService = mock(GoConfigService.class);
    pipelineSelectionsService = new PipelineSelectionsService(pipelineRepository, goConfigService, clock);
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) UserDao(com.thoughtworks.go.server.dao.UserDao) ConfigElementImplementationRegistry(com.thoughtworks.go.config.registry.ConfigElementImplementationRegistry) PipelineRepository(com.thoughtworks.go.server.persistence.PipelineRepository) Clock(com.thoughtworks.go.util.Clock) Before(org.junit.Before)

Aggregations

ConfigElementImplementationRegistry (com.thoughtworks.go.config.registry.ConfigElementImplementationRegistry)24 Test (org.junit.Test)13 ExecTask (com.thoughtworks.go.config.ExecTask)8 ConfigRepository (com.thoughtworks.go.service.ConfigRepository)7 Before (org.junit.Before)7 NoPluginsInstalled (com.thoughtworks.go.config.registry.NoPluginsInstalled)4 ServerVersion (com.thoughtworks.go.server.util.ServerVersion)4 TimeProvider (com.thoughtworks.go.util.TimeProvider)4 IOException (java.io.IOException)4 AntTask (com.thoughtworks.go.config.AntTask)3 PluggableTask (com.thoughtworks.go.config.pluggabletask.PluggableTask)3 PluginManager (com.thoughtworks.go.plugin.infra.PluginManager)3 ConfigCache (com.thoughtworks.go.config.ConfigCache)2 FetchTask (com.thoughtworks.go.config.FetchTask)2 MagicalGoConfigXmlLoader (com.thoughtworks.go.config.MagicalGoConfigXmlLoader)2 ConfigElementImplementationRegistrar (com.thoughtworks.go.config.registry.ConfigElementImplementationRegistrar)2 FullConfigUpdateCommand (com.thoughtworks.go.config.update.FullConfigUpdateCommand)2 UserDao (com.thoughtworks.go.server.dao.UserDao)2 PipelineRepository (com.thoughtworks.go.server.persistence.PipelineRepository)2 ServerHealthService (com.thoughtworks.go.serverhealth.ServerHealthService)2