Search in sources :

Example 1 with PartialConfigUpdateCommand

use of com.thoughtworks.go.config.update.PartialConfigUpdateCommand in project gocd by gocd.

the class PartialConfigServiceTest method setUp.

@BeforeEach
void setUp() {
    ConfigRepoService configRepoService = mock(ConfigRepoService.class);
    serverHealthService = mock(ServerHealthService.class);
    GoConfigPluginService configPluginService = mock(GoConfigPluginService.class);
    partialConfigHelper = mock(PartialConfigHelper.class);
    plugin = mock(PartialConfigProvider.class);
    when(configPluginService.partialConfigProviderFor(any(ConfigRepoConfig.class))).thenReturn(plugin);
    cruiseConfig = new BasicCruiseConfig();
    configRepoConfig = ConfigRepoConfig.createConfigRepoConfig(git("url"), "plugin", "id");
    cruiseConfig.setConfigRepos(new ConfigReposConfig(configRepoConfig));
    CachedGoConfig cachedGoConfig = mock(CachedGoConfig.class);
    when(cachedGoConfig.currentConfig()).thenReturn(cruiseConfig);
    configWatchList = new GoConfigWatchList(cachedGoConfig, mock(GoConfigService.class));
    goConfigService = mock(GoConfigService.class);
    repoConfigDataSource = new GoConfigRepoConfigDataSource(configWatchList, configPluginService, serverHealthService, configRepoService, goConfigService);
    cachedGoPartials = new CachedGoPartials(serverHealthService);
    serverHealthService = mock(ServerHealthService.class);
    updateCommand = null;
    service = new PartialConfigService(repoConfigDataSource, configWatchList, goConfigService, cachedGoPartials, serverHealthService, partialConfigHelper) {

        @Override
        protected PartialConfigUpdateCommand buildUpdateCommand(PartialConfig partial, String fingerprint) {
            if (null == updateCommand) {
                return super.buildUpdateCommand(partial, fingerprint);
            }
            return updateCommand;
        }
    };
    when(configRepoService.findByFingerprint(anyString())).thenReturn(configRepoConfig);
}
Also used : ConfigRepoConfig(com.thoughtworks.go.config.remote.ConfigRepoConfig) PartialConfig(com.thoughtworks.go.config.remote.PartialConfig) GoConfigService(com.thoughtworks.go.server.service.GoConfigService) ConfigReposConfig(com.thoughtworks.go.config.remote.ConfigReposConfig) ServerHealthService(com.thoughtworks.go.serverhealth.ServerHealthService) ConfigRepoService(com.thoughtworks.go.server.service.ConfigRepoService) PartialConfigUpdateCommand(com.thoughtworks.go.config.update.PartialConfigUpdateCommand) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 2 with PartialConfigUpdateCommand

use of com.thoughtworks.go.config.update.PartialConfigUpdateCommand in project gocd by gocd.

the class PartialConfigService method merge.

public CruiseConfig merge(PartialConfig partialConfig, String fingerprint, CruiseConfig cruiseConfig) {
    PartialConfigUpdateCommand command = buildUpdateCommand(partialConfig, fingerprint);
    command.update(cruiseConfig);
    return cruiseConfig;
}
Also used : PartialConfigUpdateCommand(com.thoughtworks.go.config.update.PartialConfigUpdateCommand)

Aggregations

PartialConfigUpdateCommand (com.thoughtworks.go.config.update.PartialConfigUpdateCommand)2 ConfigRepoConfig (com.thoughtworks.go.config.remote.ConfigRepoConfig)1 ConfigReposConfig (com.thoughtworks.go.config.remote.ConfigReposConfig)1 PartialConfig (com.thoughtworks.go.config.remote.PartialConfig)1 ConfigRepoService (com.thoughtworks.go.server.service.ConfigRepoService)1 GoConfigService (com.thoughtworks.go.server.service.GoConfigService)1 ServerHealthService (com.thoughtworks.go.serverhealth.ServerHealthService)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1