Search in sources :

Example 1 with MockVcsOperationProgressProvider

use of jetbrains.buildServer.vcs.MockVcsOperationProgressProvider in project teamcity-git by JetBrains.

the class GitSupportBuilder method build.

@NotNull
public GitVcsSupport build() {
    if (myPluginConfigBuilder == null && myServerPaths == null && myPluginConfig == null)
        throw new IllegalStateException("Plugin config or server paths should be set");
    if (myPluginConfig == null)
        myPluginConfig = myPluginConfigBuilder != null ? myPluginConfigBuilder.build() : new PluginConfigImpl(myServerPaths);
    if (myTransportFactory == null)
        myTransportFactory = new TransportFactoryImpl(myPluginConfig, myVcsRootSSHKeyManager);
    Mockery context = new Mockery();
    if (myFetchCommand == null) {
        if (myBeforeFetchHook == null) {
            myFetchCommand = new FetchCommandImpl(myPluginConfig, myTransportFactory, new FetcherProperties(myPluginConfig), myVcsRootSSHKeyManager);
        } else {
            final FetchCommand originalCommand = new FetchCommandImpl(myPluginConfig, myTransportFactory, new FetcherProperties(myPluginConfig), myVcsRootSSHKeyManager);
            myFetchCommand = (db, fetchURI, settings) -> {
                myBeforeFetchHook.run();
                originalCommand.fetch(db, fetchURI, settings);
            };
        }
    }
    MirrorManager mirrorManager = new MirrorManagerImpl(myPluginConfig, new HashCalculatorImpl(), new RemoteRepositoryUrlInvestigatorImpl());
    myRepositoryManager = new RepositoryManagerImpl(myPluginConfig, mirrorManager);
    final ResetCacheRegister resetCacheManager;
    if (myResetCacheManager == null) {
        context.setImposteriser(ClassImposteriser.INSTANCE);
        resetCacheManager = context.mock(ResetCacheRegister.class);
        context.checking(new Expectations() {

            {
                allowing(resetCacheManager).registerHandler(with(any(ResetCacheHandler.class)));
            }
        });
    } else {
        resetCacheManager = myResetCacheManager;
    }
    RevisionsCache revisionsCache = new RevisionsCache(myPluginConfig);
    myMapFullPath = new GitMapFullPath(myPluginConfig, revisionsCache);
    final GitRepoOperationsImpl gitRepoOperations = new GitRepoOperationsImpl(myPluginConfig, myTransportFactory, myVcsRootSSHKeyManager, myFetchCommand);
    myCommitLoader = new CommitLoaderImpl(myRepositoryManager, gitRepoOperations, myMapFullPath, myPluginConfig);
    GitResetCacheHandler resetCacheHandler = new GitResetCacheHandler(myRepositoryManager, new GcErrors());
    ResetRevisionsCacheHandler resetRevisionsCacheHandler = new ResetRevisionsCacheHandler(revisionsCache);
    TokenRefresher tokenRefresher = new TokenRefresher() {

        @Nullable
        @Override
        public OAuthToken getRefreshableToken(@NotNull String vcsRootExtId, @NotNull String tokenFullId) {
            return null;
        }

        @Nullable
        @Override
        public OAuthToken getRefreshableToken(@NotNull SProject project, @NotNull String tokenFullId) {
            return null;
        }
    };
    GitVcsSupport git = new GitVcsSupport(gitRepoOperations, myPluginConfig, resetCacheManager, myTransportFactory, myRepositoryManager, myMapFullPath, myCommitLoader, myVcsRootSSHKeyManager, new MockVcsOperationProgressProvider(), resetCacheHandler, resetRevisionsCacheHandler, tokenRefresher, myTestConnectionSupport);
    git.addExtensions(myExtensions);
    git.setExtensionHolder(myExtensionHolder);
    return git;
}
Also used : TokenRefresher(jetbrains.buildServer.serverSide.oauth.TokenRefresher) GitRepoOperationsImpl(jetbrains.buildServer.buildTriggers.vcs.git.command.impl.GitRepoOperationsImpl) SProject(jetbrains.buildServer.serverSide.SProject) Mockery(org.jmock.Mockery) NotNull(org.jetbrains.annotations.NotNull) Expectations(org.jmock.Expectations) MockVcsOperationProgressProvider(jetbrains.buildServer.vcs.MockVcsOperationProgressProvider) ResetCacheHandler(jetbrains.buildServer.util.cache.ResetCacheHandler) ResetCacheRegister(jetbrains.buildServer.util.cache.ResetCacheRegister) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

GitRepoOperationsImpl (jetbrains.buildServer.buildTriggers.vcs.git.command.impl.GitRepoOperationsImpl)1 SProject (jetbrains.buildServer.serverSide.SProject)1 TokenRefresher (jetbrains.buildServer.serverSide.oauth.TokenRefresher)1 ResetCacheHandler (jetbrains.buildServer.util.cache.ResetCacheHandler)1 ResetCacheRegister (jetbrains.buildServer.util.cache.ResetCacheRegister)1 MockVcsOperationProgressProvider (jetbrains.buildServer.vcs.MockVcsOperationProgressProvider)1 NotNull (org.jetbrains.annotations.NotNull)1 Expectations (org.jmock.Expectations)1 Mockery (org.jmock.Mockery)1